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

Error parsing Java packages #34

Closed
jdubois opened this issue Mar 27, 2018 · 7 comments
Closed

Error parsing Java packages #34

jdubois opened this issue Mar 27, 2018 · 7 comments
Labels
area: bug 🐛 Something isn't working

Comments

@jdubois
Copy link
Member

jdubois commented Mar 27, 2018

I'm testing with prettier-java:0.0.2 with a specific patch for handling #31

I have lots of parsing errors, it looks like Java packages are not correctly parsed, here is one example:

[error] src/main/java/io/jhipster/demo/aop/logging/LoggingAspect.java: SyntaxError: ';' expected. (1:9)
[error] > 1 | package io.jhipster.demo.aop.logging;
[error]     |         ^
[error]   2 |
[error]   3 | import io.github.jhipster.config.JHipsterConstants;
[error]   4 |

In order to give you a full project, which might also have more issues, please have a look at the attached Zip file.: tmp.zip

This is a @jhipster application, made from the current master branch (which passes our test suite, so it should be quite good).

You need to run yarn prettier:format and it should format all .ts and .java files. It should be pretty comprehensive, so hopefully it will help you catch more issues.

@tvonhacht
Copy link

Something seems to be very different when releasing it instead of using it from within the project.

yarn prettier --write ../jhipster-example/**/*.java 2> errors

I get two errors from the parser for code that combines strings, but everything else it runs through like crazy... Will keep this open though for the great example :)

@tvonhacht tvonhacht added the area: bug 🐛 Something isn't working label Mar 28, 2018
@tvonhacht
Copy link

Please check version 0.0.4, if you remove all comments from the file it should parse! I tried that. For the status on the comments see: #32

@jdubois
Copy link
Member Author

jdubois commented Mar 28, 2018

Sorry but I upgraded to 0.0.4 and removed the comments, but still got the same error:

[error] src/main/java/io/jhipster/demo/aop/logging/LoggingAspect.java: SyntaxError: ';' expected. (1:9)
[error] > 1 | package io.jhipster.demo.aop.logging;
[error]     |         ^
[error]   2 |
[error]   3 | import io.github.jhipster.config.JHipsterConstants;
[error]   4 |

@tvonhacht tvonhacht reopened this Mar 28, 2018
@tvonhacht
Copy link

tvonhacht commented Mar 28, 2018

Can you checkout this project (prettier-java) and run 'yarn test' just to give me an idea if that works.
And after that can you run out of that project 'yarn prettier --write "../tmp/**/*.java"', imagining your tmp project is in the same workspace as prettier-java.

Can't test your project in total because I have not the correct node version, but I did this example project https://github.com/thorbenvh8/jhipster-prettier here, 'yarn prettier LoggingAspect.java' works for me, prints it into the console, add --write to in place replacement.

Can you check if that works, thanks for investing the time solving this with me :)

@jdubois
Copy link
Member Author

jdubois commented Mar 28, 2018

yarn test works, and indeed I have different errors:

[error] ../../tmp2/src/main/java/io/jhipster/demo/domain/User.java: Error: Sad sad panda, parsing errors detected in line: 222, column: 36!
[error] Expecting: one of these possible Token sequences:
[error]   1. [';']
[error]   2. [';']
[error] but found: '' +
[error]             ", firstName=''

So that's definitely an improvement!

@tvonhacht
Copy link

If you could create an issue with the minimal code that we need to reproduce that error?

And we still have to figure out why its not working when its standalone with comments in the other issue.

Im gonna close this issue! Thanks for helping

@j-f1
Copy link

j-f1 commented Mar 28, 2018

Can't test your project in total because I have not the correct node version

If you haven’t already, check out nvm @thorbenvh8.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: bug 🐛 Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants