-
Notifications
You must be signed in to change notification settings - Fork 174
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
No syntax exception raised in some cases for JDT #325
Comments
Hi! well spotted! Can you attach the test files? Thanks! |
Here they are. |
Great! Ok with a quick I get
The field declaration is strangely completely ignored... This is strange. I have to look in the jdt generator code. |
OK by opening the file I realize that there is no return type for the attribute which is a syntax error. If you add the type String to both files it works. I guess the big question is why there is no SyntaxError raised by JDT in this case ;-) |
Working on my side, no?
|
Parsing results in the following in my environment...
|
@jrfaller |
@tsantalis yes just what I realized. On top of that, neither the flag MALFORMED nor the flag RECOVERED seems to work in these cases. The only thing I get is that I have one "problem" in the problem list when casting the node to a CompilationUnit. I guess it could work better to detect syntax errors but I fear that it will report more than just syntax errors 😢 WDYT? |
@jrfaller Updating tree-sitter-parser resolved the problem. |
For commit analysis, which cannot be guaranteed to be syntactically valid and compilable, I think what JDT Parser is doing is fine. Instead of failing the whole file, it just skips the syntactically invalid sub-trees. |
That reminds me of something. |
We discovered that JDT ASTParser recommends a version to setup the parser, when it finds a parsing problem. We basically process the reported problems and re-parse the file with the recommended compatibility version. Here is our implementation in RefactoringMiner. |
Hi @tsantalis and thanks a lot for the tips. In the last commit I switched to |
@jrfaller The problem is with the compiler settings. (The same thing happened many years ago when If you put the latest Java version in the compiler settings, and parse a code using The best strategy is to start with a lower version compiler setting. If we get such a recommendation in the problems, we re-parse the file using the recommended version in the compiler settings. |
@tsantalis thanks a lot for the detailed explanation (and for pointing me the fix!) |
String literals seem to be ignored in some cases.
(tested with build 6584227)
The text was updated successfully, but these errors were encountered: