Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

[core] Fix ast-dump CLI when reading from stdin #3896

Merged
merged 7 commits into from
Apr 21, 2022

Conversation

oowekyala
Copy link
Member

@oowekyala oowekyala commented Apr 3, 2022

Describe the PR

Bug was introduced in e64d485

This is the stacktrace

$ pmdrun ast-dump -i -f xml -l java    
-------------------------------------------------------------------------------
This command line utility is experimental. It might change at any time without
prior notice.
-------------------------------------------------------------------------------
Reading from stdin...
class X {}
Exception in thread "main" java.lang.NullPointerException
	at java.base/sun.nio.fs.UnixPath.normalizeAndCheck(UnixPath.java:75)
	at java.base/sun.nio.fs.UnixPath.<init>(UnixPath.java:69)
	at java.base/sun.nio.fs.UnixFileSystem.getPath(UnixFileSystem.java:279)
	at java.base/java.nio.file.Path.of(Path.java:147)
	at java.base/java.nio.file.Paths.get(Paths.java:69)
	at net.sourceforge.pmd.lang.AbstractParser.doParse(AbstractParser.java:46)
	at net.sourceforge.pmd.util.treeexport.TreeExportCli.run(TreeExportCli.java:178)
	at net.sourceforge.pmd.util.treeexport.TreeExportCli.main(TreeExportCli.java:86)

The rest of the PR adds tests for the tree export cli, and cleans up some related tests

41b03fe is standalone enough to be its own PR but I think it's a nice improvement and it is directly useful here.

Related issues

Ready?

  • Added unit tests for fixed bug/feature
  • Passing all unit tests
  • Complete build ./mvnw clean verify passes (checked automatically by github actions)
  • Added (in-code) documentation (if needed)

It builds a tree now, which allows building
valid trees more easily.

The syntax is lispish: balanced parentheses
create new nodes.
@pmd-test
Copy link

pmd-test commented Apr 6, 2022

1 Message
📖 Compared to master:
This changeset changes 0 violations,
introduces 0 new violations, 0 new errors and 0 new configuration errors,
removes 0 violations, 0 errors and 0 configuration errors.
Full report
Compared to master:
This changeset changes 0 violations,
introduces 0 new violations, 0 new errors and 0 new configuration errors,
removes 0 violations, 0 errors and 0 configuration errors.
Full report

Generated by 🚫 Danger

@oowekyala oowekyala marked this pull request as ready for review April 14, 2022 18:09
@oowekyala oowekyala added in:cli Affects the PMD Command Line Interface a:bug PMD crashes or fails to analyse a file. labels Apr 14, 2022
@adangel adangel added this to the 6.45.0 milestone Apr 21, 2022
return rootNode;
}

public static void setFileName(String fileName, Node rootNode) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll mark this as @InternalApi

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, whole AbstractParser is deprecated, but will add InternalApi anyway

Copy link
Member

@adangel adangel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

adangel added a commit that referenced this pull request Apr 21, 2022
adangel added a commit that referenced this pull request Apr 21, 2022
[core] Fix ast-dump CLI when reading from stdin #3896
@adangel adangel merged commit aa50b6f into pmd:master Apr 21, 2022
@oowekyala oowekyala deleted the fix-dump-cli branch April 21, 2022 15:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a:bug PMD crashes or fails to analyse a file. in:cli Affects the PMD Command Line Interface
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants