Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Can't printAST from stdin (Paths.get(fileName).parent must not be null) #528

Closed
jacquerie opened this issue Jul 16, 2019 · 1 comment · Fixed by #529
Closed

Can't printAST from stdin (Paths.get(fileName).parent must not be null) #528

jacquerie opened this issue Jul 16, 2019 · 1 comment · Fixed by #529
Labels
Milestone

Comments

@jacquerie
Copy link

The very example from the README (https://github.com/pinterest/ktlint#ast) does not appear to work with the latest ktlint installed through Homebrew:

$ ktlint --version
0.34.0

$ printf "fun main() {}" | ktlint --color printAST --stdin
Exception in thread "main" java.lang.IllegalStateException: Paths.get(fileName).parent must not be null
	at com.pinterest.ktlint.core.KtLint$userDataResolver$2.invoke(KtLint.kt:198)
	at com.pinterest.ktlint.core.KtLint$userDataResolver$2.invoke(KtLint.kt:41)
	at com.pinterest.ktlint.core.KtLint.lint(KtLint.kt:138)
	at com.pinterest.ktlint.internal.FileUtilsKt.lintFile(FileUtils.kt:51)
	at com.pinterest.ktlint.internal.FileUtilsKt.lintFile$default(FileUtils.kt:49)
	at com.pinterest.ktlint.internal.PrintASTSubCommand.printAST(PrintASTSubCommand.kt:69)
	at com.pinterest.ktlint.internal.PrintASTSubCommand.run(PrintASTSubCommand.kt:47)
	at com.pinterest.ktlint.Main.handleSubCommand(Main.kt:76)
	at com.pinterest.ktlint.Main.main(Main.kt:63)
@shashachu
Copy link
Contributor

@jacquerie Thanks for the report; this is indeed a regression in 0.34.0. We have one other possible regression (#526), so I'll put up a fix for this one, and assuming that one also needs a fix, we can push out a 0.34.1 sometime this week. In the meantime, printAST that takes in a filename is still working, so you can use that as a workaround.

@shashachu shashachu added the bug label Jul 16, 2019
shashachu added a commit to shashachu/ktlint that referenced this issue Jul 16, 2019
* Fixes pinterest#528
* Also properly pass through `--debug` flag from `printAST` command
* Small cleanup of unused variable
shashachu added a commit to shashachu/ktlint that referenced this issue Jul 16, 2019
* Fixes pinterest#528
* Also properly pass through `--debug` flag from `printAST` command
* Small cleanup of unused variable
shashachu added a commit that referenced this issue Jul 17, 2019
* Properly handle --stdin flag for printAST command

* Fixes #528
* Also properly pass through `--debug` flag from `printAST` command
* Small cleanup of unused variable

* move stdin to constant
@shashachu shashachu added this to the 0.34.1 milestone Jul 17, 2019
sowmyav24 pushed a commit to sowmyav24/ktlint that referenced this issue Jul 18, 2019
* Properly handle --stdin flag for printAST command

* Fixes pinterest#528
* Also properly pass through `--debug` flag from `printAST` command
* Small cleanup of unused variable

* move stdin to constant
orchestr7 pushed a commit to saveourtool/diktat that referenced this issue Jun 29, 2020
* Properly handle --stdin flag for printAST command

* Fixes pinterest/ktlint#528
* Also properly pass through `--debug` flag from `printAST` command
* Small cleanup of unused variable

* move stdin to constant
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants