diff options
author | Manoj Palat | 2014-02-03 16:59:46 +0000 |
---|---|---|
committer | ssankaran | 2014-02-03 16:59:46 +0000 |
commit | b399cc14c85cc6279d3fbdd38ff116c9655dc352 (patch) | |
tree | bf965b7c27fc5951669bee290f4f06aa938dd22d | |
parent | 9ecc2f6122d7f7a662b22f71e69ff3081609219c (diff) | |
download | eclipse.jdt.core-b399cc14c85cc6279d3fbdd38ff116c9655dc352.tar.gz eclipse.jdt.core-b399cc14c85cc6279d3fbdd38ff116c9655dc352.tar.xz eclipse.jdt.core-b399cc14c85cc6279d3fbdd38ff116c9655dc352.zip |
Fixed Bug 425743 - [1.8][api] CompilationUnit#findDeclaringNode(IBinding
binding) returns null for type inferred lambda parameter
-rw-r--r-- | org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverter18Test.java | 25 | ||||
-rw-r--r-- | org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ASTConverter.java | 1 |
2 files changed, 26 insertions, 0 deletions
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverter18Test.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverter18Test.java index 81132c2a52..d6f1f4d8f3 100644 --- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverter18Test.java +++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverter18Test.java @@ -3997,4 +3997,29 @@ public class ASTConverter18Test extends ConverterTestSetup { VariableDeclaration variableDeclaration = (VariableDeclaration) lambdaExpression.parameters().get(0); checkSourceRange(variableDeclaration, "int x", contents); } + /* + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=425743, [1.8][api] CompilationUnit#findDeclaringNode(IBinding binding) returns null for type inferred lambda parameter + */ + public void testBug425743() throws JavaModelException { + String contents = + "public class X{\n" + + " FI fi = (x2) -> x2;\n" + + "}\n" + + "interface FI {\n" + + " int foo(int n);\n" + + "}\n"; + this.workingCopy = getWorkingCopy("/Converter18/src/X.java", true/*resolve*/); + ASTNode node = buildAST(contents, this.workingCopy, true); + assertEquals("Not a compilation unit", ASTNode.COMPILATION_UNIT, node.getNodeType()); + CompilationUnit compilationUnit = (CompilationUnit) node; + node = getASTNode(compilationUnit, 0); + FieldDeclaration fi = ((TypeDeclaration) node).getFields()[0]; + VariableDeclarationFragment vdf = (VariableDeclarationFragment) fi.fragments().get(0); + LambdaExpression lambda = (LambdaExpression) vdf.getInitializer(); + VariableDeclaration param = (VariableDeclaration) lambda.parameters().get(0); + IBinding binding = param.getName().resolveBinding(); + ASTNode astNode = compilationUnit.findDeclaringNode(binding); + assertNotNull(astNode); + assertEquals("Not a variable declaration fragment", ASTNode.VARIABLE_DECLARATION_FRAGMENT, astNode.getNodeType()); + } } diff --git a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ASTConverter.java b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ASTConverter.java index f1692e6af6..888e5fd4e3 100644 --- a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ASTConverter.java +++ b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ASTConverter.java @@ -2230,6 +2230,7 @@ class ASTConverter { if (this.resolveBindings) { recordNodes(simpleName, argument); recordNodes(variableDeclarationFragment, argument); + variableDeclarationFragment.resolveBinding(); } variableDeclarationFragment.setName(simpleName); variableDeclarationFragment.setSourceRange(start, end - start + 1); |