diff options
7 files changed, 177 insertions, 1 deletions
diff --git a/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/BuilderTests.java b/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/BuilderTests.java index f91a9e98ba..cb7bcbf602 100644 --- a/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/BuilderTests.java +++ b/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/BuilderTests.java @@ -1,10 +1,14 @@ /******************************************************************************* - * Copyright (c) 2000, 2012 IBM Corporation and others. + * Copyright (c) 2000, 2013 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * + * This is an implementation of an early-draft specification developed under the Java + * Community Process (JCP) and is made available for testing and evaluation purposes + * only. The code is not compatible with any specification of the JCP. + * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ @@ -517,6 +521,7 @@ public class BuilderTests extends TestCase { EfficiencyTests.class, ExecutionTests.class, IncrementalTests.class, + IncrementalTests18.class, MultiProjectTests.class, MultiSourceFolderAndOutputFolderTests.class, OutputFolderTests.class, diff --git a/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/IncrementalTests18.java b/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/IncrementalTests18.java new file mode 100644 index 0000000000..54b7464909 --- /dev/null +++ b/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/IncrementalTests18.java @@ -0,0 +1,124 @@ +/******************************************************************************* + * Copyright (c) 2013 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * This is an implementation of an early-draft specification developed under the Java + * Community Process (JCP) and is made available for testing and evaluation purposes + * only. The code is not compatible with any specification of the JCP. + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.jdt.core.tests.builder; + +import junit.framework.Test; + +import org.eclipse.core.runtime.IPath; +import org.eclipse.jdt.core.JavaModelException; +import org.eclipse.jdt.core.tests.util.Util; + +public class IncrementalTests18 extends BuilderTests { + + public IncrementalTests18(String name) { + super(name); + } + + public static Test suite() { + return buildTestSuite(IncrementalTests18.class); + } + + + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=423122, [1.8] Missing incremental build dependency from lambda expression to functional interface. + public void test423122() throws JavaModelException { + IPath projectPath = env.addProject("Project", "1.8"); + env.addExternalJars(projectPath, Util.getJavaClassLibs()); + + // remove old package fragment root so that names don't collide + env.removePackageFragmentRoot(projectPath, ""); + + IPath root = env.addPackageFragmentRoot(projectPath, "src"); + env.setOutputFolder(projectPath, "bin"); + + env.addClass(root, "p", "I", + "package p; \n"+ + "public interface I { void foo(); } \n" + ); + env.addClass(root, "p", "X", + "package p; \n"+ + "public class X { I i = () -> {}; } \n" + ); + + fullBuild(projectPath); + expectingNoProblems(); + + env.addClass(root, "p", "I", + "package p; \n"+ + "public interface I { } \n" + ); + incrementalBuild(projectPath); + expectingProblemsFor( + projectPath, + "Problem : The target type of this expression must be a functional interface [ resource : </Project/src/p/X.java> range : <35,40> category : <40> severity : <2>]" + ); + } + + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=423122, [1.8] Missing incremental build dependency from lambda expression to functional interface. + public void test423122a() throws JavaModelException { + IPath projectPath = env.addProject("Project", "1.8"); + env.addExternalJars(projectPath, Util.getJavaClassLibs()); + + // remove old package fragment root so that names don't collide + env.removePackageFragmentRoot(projectPath, ""); + + IPath root = env.addPackageFragmentRoot(projectPath, "src"); + env.setOutputFolder(projectPath, "bin"); + + env.addClass(root, "test1", "I", + "package test1;\n" + + "public interface I {\n" + + " int method(int a); // change argument type to Object\n" + + "}\n" + ); + env.addClass(root, "test1", "E", + "package test1;\n" + + "public class E {\n" + + " void take(I i) {\n" + + " }\n" + + "}\n" + ); + env.addClass(root, "test1", "Ref", + "package test1;\n" + + "public class Ref {\n" + + " void foo(E e) {\n" + + " e.take((x) -> x+2); // not recompiled when I#method changed\n" + + " }\n" + + "}\n" + ); + + fullBuild(projectPath); + expectingNoProblems(); + + env.addClass(root, "test1", "I", + "package test1;\n" + + "public interface I {\n" + + " int method(Object a); // change argument type to Object\n" + + "}\n" + ); + incrementalBuild(projectPath); + expectingProblemsFor( + projectPath, + "Problem : The operator + is undefined for the argument type(s) Object, int [ resource : </Project/src/test1/Ref.java> range : <76,79> category : <60> severity : <2>]" + ); + env.addClass(root, "test1", "I", + "package test1;\n" + + "public interface I {\n" + + " int method(int a); // change argument type back to int\n" + + "}\n" + ); + incrementalBuild(projectPath); + expectingNoProblems(); + } +} diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/RunAllJava8Tests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/RunAllJava8Tests.java index cac6c5a4ca..d109ee8698 100644 --- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/RunAllJava8Tests.java +++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/RunAllJava8Tests.java @@ -23,6 +23,7 @@ import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; +import org.eclipse.jdt.core.tests.builder.IncrementalTests18; import org.eclipse.jdt.core.tests.compiler.parser.ComplianceDiagnoseTest; import org.eclipse.jdt.core.tests.dom.ASTConverter15JLS8Test; import org.eclipse.jdt.core.tests.dom.ASTConverter17Test; @@ -54,6 +55,7 @@ public class RunAllJava8Tests extends TestCase { JavaSearchBugs8Tests.class, ResolveTests18.class, CompletionTests18.class, + IncrementalTests18.class, org.eclipse.jdt.compiler.apt.tests.AllTests.class, }; } diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/RunOnlyJava8Tests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/RunOnlyJava8Tests.java index 8b9bd93ad3..d4dbb03f54 100644 --- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/RunOnlyJava8Tests.java +++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/RunOnlyJava8Tests.java @@ -23,6 +23,7 @@ import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; +import org.eclipse.jdt.core.tests.builder.IncrementalTests18; import org.eclipse.jdt.core.tests.compiler.parser.CompletionParserTest18; import org.eclipse.jdt.core.tests.compiler.parser.ComplianceDiagnoseTest; import org.eclipse.jdt.core.tests.compiler.parser.LambdaExpressionSyntaxTest; @@ -98,6 +99,7 @@ public class RunOnlyJava8Tests extends TestCase { SelectionParserTest18.class, CompletionTests18.class, GenericsRegressionTest_1_8.class, + IncrementalTests18.class, }; } diff --git a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/CompletionEngine.java b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/CompletionEngine.java index 25e46a720c..f54e9edca3 100644 --- a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/CompletionEngine.java +++ b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/CompletionEngine.java @@ -1735,6 +1735,8 @@ public final class CompletionEngine completionOnMemberValueName(astNode, astNodeParent, scope, insideTypeAnnotation); } else if(astNode instanceof CompletionOnBranchStatementLabel) { completionOnBranchStatementLabel(astNode); + } else if (astNode instanceof CompletionOnReferenceExpressionName) { + completionOnReferenceExpressionName(astNode, scope); } else if(astNode instanceof CompletionOnMessageSendName) { completionOnMessageSendName(astNode, qualifiedBinding, scope); // Completion on Javadoc nodes @@ -2735,6 +2737,37 @@ public final class CompletionEngine } } + private void completionOnReferenceExpressionName(ASTNode astNode, Scope scope) { + if (!this.requestor.isIgnored(CompletionProposal.METHOD_REF)) { + CompletionOnReferenceExpressionName referenceExpression = (CompletionOnReferenceExpressionName) astNode; + + this.insideQualifiedReference = true; + this.completionToken = referenceExpression.selector; + + findMethods( + this.completionToken, + null, + null, + (ReferenceBinding)referenceExpression.lhs.resolvedType.capture(scope, referenceExpression.sourceEnd), + scope, + new ObjectVector(), + false, + false, + referenceExpression, + scope, + false, + false, + false, + null, + null, + null, + false, + null, + -1, + -1); + } + } + private void completionOnMessageSendName(ASTNode astNode, Binding qualifiedBinding, Scope scope) { if (!this.requestor.isIgnored(CompletionProposal.METHOD_REF)) { CompletionOnMessageSendName messageSend = (CompletionOnMessageSendName) astNode; diff --git a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionParser.java b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionParser.java index 81dc66d494..35dcb05e9f 100644 --- a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionParser.java +++ b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionParser.java @@ -4770,6 +4770,15 @@ protected boolean isInsideReturn(){ } return false; } +public ReferenceExpression newReferenceExpression() { + char[] selector = this.identifierStack[this.identifierPtr]; + if (selector != assistIdentifier()){ + return super.newReferenceExpression(); + } + ReferenceExpression referenceExpression = new CompletionOnReferenceExpressionName(); + this.assistNode = referenceExpression; + return referenceExpression; +} public CompilationUnitDeclaration parse(ICompilationUnit sourceUnit, CompilationResult compilationResult, int cursorLoc) { this.cursorLocation = cursorLoc; diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ReferenceBinding.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ReferenceBinding.java index e5200577ab..13e98f25f1 100644 --- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ReferenceBinding.java +++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ReferenceBinding.java @@ -1858,6 +1858,7 @@ public MethodBinding getSingleAbstractMethod(Scope scope, boolean replaceWildcar return this.singleAbstractMethod; } + scope.compilationUnitScope().recordQualifiedReference(this.compoundName); MethodBinding[] methods = null; try { methods = getInterfaceAbstractContracts(scope); |