Repository navigation
Improve lambda method discovery Fixes: #477 - #478
Jinbo Wang (testforstephen) merged 6 commits into
Conversation
|
When parsing the AST for the lambda, we just passed a char array without the context Java model or project, that's why the binding information is not resolved correctly. Your workaround seems OK. Another way to fix this is to find the Java project that the current file belongs to and set the parser to use that project for binding resolver. |
|
Jinbo Wang (@testforstephen) WDYT about the latest change ? |
f008742 to
0d93da4
Compare
|
Jinbo Wang (@testforstephen) anything pending for approval and merge ? |
|
this PR is on the list for May sprint. |
Jinbo Wang (testforstephen)
left a comment
There was a problem hiding this comment.
When parsing the AST for the lambda, we just passed a char array without the context Java model or project, that's why the binding information is not resolved correctly.
A simpler fix is to use the parent Java project as the environment. This works for the case in issue #477.
IFile resource = (IFile) JDTUtils.findResource(JDTUtils.toURI(uri), ResourcesPlugin.getWorkspace().getRoot()::findFilesForLocationURI);
if (resource != null && JdtUtils.isJavaProject(resource.getProject())) {
parser.setProject(JavaCore.create(resource.getProject()));
} else {
parser.setEnvironment(new String[0], new String[0], null, true);
}- Use classfile and compilationunit resolution as the first method before fallback to old strategy. - Switch to using jdt.debug lambda helper which resolves lambda method signature with outer local variables.
0d93da4 to
a06f28b
Compare
This is a good suggestion, I change the code now. |
Jinbo Wang (testforstephen)
left a comment
There was a problem hiding this comment.
LGTM. Thanks for contribution.
The issue seems to be when resolving lambda method for reactive operators, the binding resolver is not the default binding resolvers which actually resolves the lambda method.
It seems. the AST construction effects which binding resolver is used at runtime in the node. Therefore switched to the using cache AST when available which seems to resolved the issue. Will do some more testing.