-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Simplified usage of class AssociableToAST #3063
Conversation
Codecov Report
@@ Coverage Diff @@
## master #3063 +/- ##
===============================================
- Coverage 57.443% 57.415% -0.028%
- Complexity 2541 2555 +14
===============================================
Files 636 637 +1
Lines 33809 33853 +44
Branches 5841 5839 -2
===============================================
+ Hits 19421 19437 +16
- Misses 12307 12336 +29
+ Partials 2081 2080 -1
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
After the conversation with jlerbsc at #1940 (comment) that demonstrated the impact of this changes, decided to update this PR to reduce this impact. To reduce this impact a new AssociableToAst was created with a new name AssociatedWithAST and behavior exactly as described in the first comment. Also AssociableToAst has been marked as Deprecated for not complying with the expected documentation. |
It would be possible to have a clearer PR by deleting all unnecessary commits. |
...parser-core/src/main/java/com/github/javaparser/resolution/declarations/AssociableToAST.java
Outdated
Show resolved
Hide resolved
Given that the next version of JP will introduce a break in the API (this will be a major version certainly 4.0.0.), I send back my opinion, so that you can integrate this change directly into the existing interface. |
5eaa434
to
bbcf0cd
Compare
Did you complete your PR? |
Yes I did. Sorry I forgot to leave a comment. |
Thank you for this contribution. |
According to the documentation in AssociableToAST#toAst() all the Resolved declaration most be asociable to a AST.
Currently this doesn't happen, making it hard do access a node from a ResolvedDeclaration. To work around this we need to make some check that requires a lot of boilerplate like in the example below.
javaparser/javaparser-symbol-solver-core/src/main/java/com/github/javaparser/symbolsolver/javaparsermodel/contexts/CompilationUnitContext.java
Lines 353 to 366 in 1ce7d85
This PR suggest the remove of the type parameter of the class AssociableToAST and use a helper method to convert to the desired type.
To make it more clear lets take a look at the example mentioned above but this time in the new format:
Other example, previously we would have to do something like this:
Now we can do it by simple doing:
This also allows add room for more complex examples that were not possible with the previous format, like looking for specific declarations. We can do it now by simply: