diff options
author | Stephan Herrmann | 2014-11-15 13:33:08 +0000 |
---|---|---|
committer | Stephan Herrmann | 2014-11-15 15:26:22 +0000 |
commit | e6a1a64e0a1233f2bc50a92db03a15239574d96f (patch) | |
tree | 885be55668773e162a61e98d4deec5e80cdd36a5 /org.eclipse.jdt.core.tests.model | |
parent | 426434604ec54a9ca9d426a5832e400d1c50c7d4 (diff) | |
download | org.eclipse.objectteams-e6a1a64e0a1233f2bc50a92db03a15239574d96f.tar.gz org.eclipse.objectteams-e6a1a64e0a1233f2bc50a92db03a15239574d96f.tar.xz org.eclipse.objectteams-e6a1a64e0a1233f2bc50a92db03a15239574d96f.zip |
Update jdt.core to I20141111-0830
Diffstat (limited to 'org.eclipse.jdt.core.tests.model')
7 files changed, 193 insertions, 2 deletions
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/RunOnly335CompilerTests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/RunOnly335CompilerTests.java index 3484594af..92ac3df2f 100644 --- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/RunOnly335CompilerTests.java +++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/RunOnly335CompilerTests.java @@ -23,6 +23,7 @@ import org.eclipse.jdt.core.tests.compiler.regression.GenericsRegressionTest_1_7 import org.eclipse.jdt.core.tests.compiler.regression.GenericsRegressionTest_1_8; import org.eclipse.jdt.core.tests.compiler.regression.LambdaExpressionsTest; import org.eclipse.jdt.core.tests.compiler.regression.LambdaRegressionTest; +import org.eclipse.jdt.core.tests.compiler.regression.LambdaShapeTests; import org.eclipse.jdt.core.tests.compiler.regression.NegativeLambdaExpressionsTest; import org.eclipse.jdt.core.tests.compiler.regression.NullTypeAnnotationTest; import org.eclipse.jdt.core.tests.compiler.regression.OverloadResolutionTest8; @@ -41,6 +42,7 @@ public class RunOnly335CompilerTests extends TestCase { LambdaRegressionTest.class, NegativeLambdaExpressionsTest.class, OverloadResolutionTest8.class, + LambdaShapeTests.class, NullTypeAnnotationTest.class, // tests type inference }; } 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 328889513..9f37664bb 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 @@ -41,6 +41,7 @@ import org.eclipse.jdt.core.tests.compiler.regression.JSR308SpecSnippetTests; import org.eclipse.jdt.core.tests.compiler.regression.JSR335ClassFileTest; import org.eclipse.jdt.core.tests.compiler.regression.LambdaExpressionsTest; import org.eclipse.jdt.core.tests.compiler.regression.LambdaRegressionTest; +import org.eclipse.jdt.core.tests.compiler.regression.LambdaShapeTests; import org.eclipse.jdt.core.tests.compiler.regression.MethodParametersAttributeTest; import org.eclipse.jdt.core.tests.compiler.regression.NegativeLambdaExpressionsTest; import org.eclipse.jdt.core.tests.compiler.regression.NegativeTypeAnnotationTest; @@ -78,6 +79,7 @@ public class RunOnlyJava8Tests extends TestCase { NegativeLambdaExpressionsTest.class, LambdaExpressionsTest.class, LambdaRegressionTest.class, + LambdaShapeTests.class, SerializableLambdaTest.class, OverloadResolutionTest8.class, JSR335ClassFileTest.class, 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 a441b3479..f3dfa7cbf 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 @@ -4316,7 +4316,7 @@ public void testBug425183a() throws JavaModelException { IJavaElement[] elements = this.workingCopy.codeSelect(start, length); assertElementsEqual( "Unexpected elements", - "naturalOrder() {key=LBug425183a~Comparator<>;.naturalOrder<T::Ljava/lang/Comparable<-TT;>;>()LComparator<TT;>;%<^{267#0};>} [in Comparator [in [Working copy] Bug425183a.java [in <default> [in src [in Converter18]]]]]", + "naturalOrder() {key=LBug425183a~Comparator<>;.naturalOrder<T::Ljava/lang/Comparable<-TT;>;>()LComparator<TT;>;%<^{291#0};>} [in Comparator [in [Working copy] Bug425183a.java [in <default> [in src [in Converter18]]]]]", elements, true ); diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompletionTests18.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompletionTests18.java index e6b1202eb..c9230adc3 100644 --- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompletionTests18.java +++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompletionTests18.java @@ -2266,4 +2266,71 @@ public void test447774() throws JavaModelException { "expectedTypesKeys=null\n" + "completion token location={STATEMENT_START}", requestor.getContext()); } +// https://bugs.eclipse.org/bugs/show_bug.cgi?id=449358, Content assist inside lambda broken in all methods except last +public void test449358() throws JavaModelException { + this.workingCopies = new ICompilationUnit[1]; + this.workingCopies[0] = getWorkingCopy( + "/Completion/src/X.java", + "import java.util.Optional;\n" + + "public class LambdaBug {\n" + + " private final String field = \"final field\";\n" + + " void localmethod1() {\n" + + " Optional.of(\"test\").map(s -> {\n" + + " String local;\n" + + " /*HERE*/localMeth\n" + + " return s;\n" + + " }).get();\n" + + " }\n" + + " void localmethod2() {\n" + + " Optional.of(\"test\").map(s -> {\n" + + " String local;\n" + + " // content assist works there\n" + + " return s;\n" + + " }).get();\n" + + " }\n" + + "}\n"); + + CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, true, true, false); + requestor.allowAllRequiredProposals(); + String str = this.workingCopies[0].getSource(); + String completeBehind = "/*HERE*/localMeth"; + int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); + this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); + assertResults("localmethod1[METHOD_REF]{localmethod1(), LLambdaBug;, ()V, null, null, localmethod1, null, [181, 190], 17}\n" + + "localmethod2[METHOD_REF]{localmethod2(), LLambdaBug;, ()V, null, null, localmethod2, null, [181, 190], 17}", requestor.getResults()); + +} +// https://bugs.eclipse.org/bugs/show_bug.cgi?id=449358, Content assist inside lambda broken in all methods except last +public void test449358a() throws JavaModelException { + this.workingCopies = new ICompilationUnit[1]; + this.workingCopies[0] = getWorkingCopy( + "/Completion/src/X.java", + "import java.util.Optional;\n" + + "public class LambdaBug {\n" + + " private final String field = \"final field\";\n" + + " void localmethod1() {\n" + + " Optional.of(\"test\").map(s -> {\n" + + " String local;\n" + + " return s;\n" + + " }).get();\n" + + " }\n" + + " void localmethod2() {\n" + + " Optional.of(\"test\").map(s -> {\n" + + " String local;\n" + + " /*HERE*/localMeth\n" + + " return s;\n" + + " }).get();\n" + + " }\n" + + "}\n"); + + CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, true, true, false); + requestor.allowAllRequiredProposals(); + String str = this.workingCopies[0].getSource(); + String completeBehind = "/*HERE*/localMeth"; + int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); + this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); + assertResults("localmethod1[METHOD_REF]{localmethod1(), LLambdaBug;, ()V, null, null, localmethod1, null, [282, 291], 17}\n" + + "localmethod2[METHOD_REF]{localmethod2(), LLambdaBug;, ()V, null, null, localmethod2, null, [282, 291], 17}", requestor.getResults()); + +} } diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/HierarchyOnWorkingCopiesTests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/HierarchyOnWorkingCopiesTests.java index d1331d4ce..9f64a81af 100644 --- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/HierarchyOnWorkingCopiesTests.java +++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/HierarchyOnWorkingCopiesTests.java @@ -25,6 +25,10 @@ import org.eclipse.jdt.core.JavaCore; public class HierarchyOnWorkingCopiesTests extends WorkingCopyTests { +static { +// TESTS_NAMES = new String [] { "test450442" }; +} + public HierarchyOnWorkingCopiesTests(String name) { super(name); } @@ -525,5 +529,65 @@ public void test442534() throws CoreException, IOException { this.deleteProject(project); } } +// https://bugs.eclipse.org/bugs/show_bug.cgi?id=450442, [1.8] NPE at HandleFactory.createElement on hover +public void test450442() throws CoreException, IOException { + + IJavaProject project = null; + try { + project = this.createJavaProject( + "Bug450442", + new String[] {"src"}, + new String[] {this.getExternalJCLPathString(), "lib"}, + "bin"); + project.setOption(JavaCore.COMPILER_COMPLIANCE, "1.8"); + project.setOption(JavaCore.COMPILER_SOURCE, "1.8"); + + this.createFile("Bug450442/src/Claxx.java", + "import java.util.function.Consumer;\n" + + "public class Claxx {\n" + + " void post(Runnable r) {\n" + + " r.run();\n" + + " }\n" + + " void absorb(Consumer<Claxx> c) throws Exception {\n" + + " c.accept(this);\n" + + " }\n" + + " \n" + + " static void execute() {\n" + + " System.out.println(\"exec!\");\n" + + " }\n" + + " static void executeGiven(Object o) {\n" + + " System.out.println(\"exec \" + o);\n" + + " }\n" + + " void executeObject() {\n" + + " System.out.println(\"exec \" + this);\n" + + " } \n" + + "}\n" + + "class ClaxxTest {\n" + + " Claxx claxx = new Claxx();\n" + + " \n" + + " void doInBackground() throws Exception {\n" + + " claxx.post(Claxx::execute); \n" + + " absorb(Claxx::executeGiven);\n" + + " post(this::executeObject);\n" + + " \n" + + " absorb(Claxx::executeObject);\n" + + " post(() -> execute());\n" + + " post(() -> executeGiven(this)); // not convertible\n" + + " post(() -> executeObject());\n" + + " }\n" + + "}\n"); + + ITypeHierarchy h = project.findType("Claxx").newSupertypeHierarchy(null); + assertHierarchyEquals( + "Focus: Claxx [in Claxx.java [in <default> [in src [in Bug450442]]]]\n" + + "Super types:\n" + + " Object [in Object.class [in java.lang [in "+ getExternalJCLPathString() + "]]]\n" + + "Sub types:\n", + h); + } finally { + if (project != null) + this.deleteProject(project); + } +} } diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaSearchBugsTests2.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaSearchBugsTests2.java index f5b556fb4..cbb3a9c07 100644 --- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaSearchBugsTests2.java +++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaSearchBugsTests2.java @@ -27,6 +27,7 @@ import org.eclipse.jdt.core.IJavaElement; import org.eclipse.jdt.core.IJavaProject; import org.eclipse.jdt.core.IMethod; import org.eclipse.jdt.core.IType; +import org.eclipse.jdt.core.JavaCore; import org.eclipse.jdt.core.JavaModelException; import org.eclipse.jdt.core.search.IJavaSearchConstants; import org.eclipse.jdt.core.search.IJavaSearchScope; @@ -1738,4 +1739,59 @@ public class JavaSearchBugsTests2 extends AbstractJavaSearchTests { deleteProject("P"); } } + public void testBug381392() throws CoreException { + IJavaProject egit = null; + IJavaProject jgit = null; + try { + jgit = createJavaProject("jgit", new String[] {""}, new String[] {"JCL15_LIB"}, "","1.5"); + createFolder("/jgit/base"); + createFile("/jgit/base/AbstractPlotRenderer.java", + "package base;\n" + + "public abstract class AbstractPlotRenderer<TLane extends PlotLane, TColor> {\n"+ + " protected abstract TColor laneColor(TLane myLane);\n"+ + "\n"+ + " @SuppressWarnings(\"unused\")\n"+ + " protected void paintCommit(final PlotCommit<TLane> commit) {\n"+ + " final TLane myLane = commit.getLane();\n"+ + " final TColor myColor = laneColor(myLane);\n"+ + " }\n"+ + "}\n"); + createFile("/jgit/base/PlotCommit.java", + "package base;\n"+ + "public class PlotCommit<L extends PlotLane> {\n"+ + " public L getLane() {\n"+ + " return null;\n"+ + " }\n"+ + "}"); + createFile("/jgit/base/PlotLane.java", + "package base;\n"+ + "public class PlotLane {\n"+ + "}"); + egit = createJavaProject("egit", new String[] {""}, new String[] {"JCL15_LIB"}, "","1.5"); + createFolder("/egit/bug"); + createFile("/egit/bug/SWTPlotLane.java", + "package bug;\n" + + "import base.PlotLane;\n" + + "public class SWTPlotLane extends PlotLane {}"); + createFile("/egit/bug/SWTPlotRenderer.java", + "package bug;\n" + + "import base.AbstractPlotRenderer;\n" + + "class SWTPlotRenderer extends AbstractPlotRenderer<SWTPlotLane, Integer> {\n" + + " @Override\n" + + " protected Integer laneColor(SWTPlotLane myLane) {\n" + + " return 1;\n" + + " }\n" + + "}"); + addClasspathEntry(egit, JavaCore.newProjectEntry(jgit.getPath())); + + // search + IType type = getCompilationUnit("/egit/bug/SWTPlotRenderer.java").getType("SWTPlotRenderer"); + IMethod method = type.getMethods()[0]; + search(method, REFERENCES, EXACT_RULE, SearchEngine.createWorkspaceScope(), this.resultCollector); + assertSearchResults("base/AbstractPlotRenderer.java void base.AbstractPlotRenderer.paintCommit(PlotCommit<TLane>) [laneColor(myLane)] EXACT_MATCH"); + } finally { + if (jgit != null) deleteProject(jgit); + if (egit != null) deleteProject(egit); + } + } } diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ResolveTests18.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ResolveTests18.java index 2b4f750d0..14efe24b1 100644 --- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ResolveTests18.java +++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ResolveTests18.java @@ -2187,7 +2187,7 @@ public void test428968() throws JavaModelException { IJavaElement[] elements = this.wc.codeSelect(start, length); assertElementsEqual( "Unexpected elements", - "comparing(java.util.function.Function<? super T,? extends U>) {key=Ljava/util/Comparator<>;.comparing<T:Ljava/lang/Object;U::Ljava/lang/Comparable<-TU;>;>(Ljava/util/function/Function<-TT;+TU;>;)Ljava/util/Comparator<TT;>;%<Ljava/lang/Object;^{218#0};>} [in Comparator [in Comparator.class [in java.util [in "+ getExternalPath() + "jclFull1.8.jar]]]]", + "comparing(java.util.function.Function<? super T,? extends U>) {key=Ljava/util/Comparator<>;.comparing<T:Ljava/lang/Object;U::Ljava/lang/Comparable<-TU;>;>(Ljava/util/function/Function<-TT;+TU;>;)Ljava/util/Comparator<TT;>;%<Ljava/lang/Object;^{259#0};>} [in Comparator [in Comparator.class [in java.util [in "+ getExternalPath() + "jclFull1.8.jar]]]]", elements, true ); } |