From 66e8fc150e781abba38e9f9e922a5f5a6582d98b Mon Sep 17 00:00:00 2001 From: Sha Sha Chu Date: Tue, 16 Jul 2019 09:51:36 -0700 Subject: [PATCH] Properly handle --stdin flag for printAST command * Fixes https://github.com/pinterest/ktlint/issues/528 * Also properly pass through `--debug` flag from `printAST` command * Small cleanup of unused variable --- ktlint/src/main/kotlin/com/pinterest/ktlint/Main.kt | 2 -- .../com/pinterest/ktlint/internal/PrintASTSubCommand.kt | 4 ++-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/ktlint/src/main/kotlin/com/pinterest/ktlint/Main.kt b/ktlint/src/main/kotlin/com/pinterest/ktlint/Main.kt index ca425a2b62..f2772f41e3 100644 --- a/ktlint/src/main/kotlin/com/pinterest/ktlint/Main.kt +++ b/ktlint/src/main/kotlin/com/pinterest/ktlint/Main.kt @@ -241,8 +241,6 @@ class KtlintCommandLine { @Parameters(hidden = true) private var patterns = ArrayList() - private val workDir = File(".").canonicalPath - fun run() { if (apply || applyToProject) { applyToIDEA() diff --git a/ktlint/src/main/kotlin/com/pinterest/ktlint/internal/PrintASTSubCommand.kt b/ktlint/src/main/kotlin/com/pinterest/ktlint/internal/PrintASTSubCommand.kt index ab6e151eb4..94e3ed777f 100644 --- a/ktlint/src/main/kotlin/com/pinterest/ktlint/internal/PrintASTSubCommand.kt +++ b/ktlint/src/main/kotlin/com/pinterest/ktlint/internal/PrintASTSubCommand.kt @@ -66,7 +66,7 @@ internal class PrintASTSubCommand : Runnable { } try { - lintFile(fileName, fileContent, astRuleSet) + lintFile(fileName, fileContent, astRuleSet, debug = ktlintCommand.debug) } catch (e: Exception) { if (e is ParseException) { throw ParseException(e.line, e.col, "Not a valid Kotlin file (${e.message?.toLowerCase()})") @@ -77,6 +77,6 @@ internal class PrintASTSubCommand : Runnable { companion object { internal const val COMMAND_NAME = "printAST" - private const val STDIN_FILE = "" + private const val STDIN_FILE = "" } }