Skip to content

Commit

Permalink
Eclipse 4.21 (M2) JDT Patch for Groovy-Eclipse
Browse files Browse the repository at this point in the history
  • Loading branch information
eric-milles committed Jul 30, 2021
1 parent 08f6c3b commit 76fc7da
Show file tree
Hide file tree
Showing 60 changed files with 1,608 additions and 791 deletions.
2 changes: 1 addition & 1 deletion groovy-eclipse.setup
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@
<repository
url="https://download.eclipse.org/eclipse/updates/4.21"/>
<repository
url="https://download.eclipse.org/eclipse/updates/4.21-I-builds/I20210709-0030"/>
url="https://download.eclipse.org/eclipse/updates/4.21-I-builds/I20210729-1800"/>
</repositoryList>
<repositoryList
name="2021-06">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
</license>

<requires>
<import feature="org.eclipse.jdt" version="3.18.900.v20210709-0030" patch="true"/>
<import feature="org.eclipse.jdt" version="3.18.900.v20210729-1800" patch="true"/>
</requires>

<plugin
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,16 @@
import java.util.Set;

import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IncrementalProjectBuilder;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
import org.eclipse.jdt.core.IAccessRule;
import org.eclipse.jdt.core.IClasspathAttribute;
import org.eclipse.jdt.core.IClasspathEntry;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jdt.core.compiler.CharOperation;
Expand Down Expand Up @@ -143,6 +148,82 @@ public void testBug567532() throws JavaModelException, Exception {

writeReadAndCompareTestBinaryLocations(project);
}
public void testSelfAnnotatedJars() throws CoreException, IOException {
// derived from the same named test in ExternalAnnotation18Test:
IPath projectPath = env.addProject("PrjTest", "1.8"); //$NON-NLS-1$
IJavaProject project = JavaCore.create(ResourcesPlugin.getWorkspace().getRoot().getProject(projectPath.segment(0)));

project.setOption(JavaCore.CORE_JAVA_BUILD_EXTERNAL_ANNOTATIONS_FROM_ALL_LOCATIONS, JavaCore.ENABLED);

String projectLoc = project.getProject().getLocation().toString();
Util.createJar(new String[] {
"pgen/CGen.java",
"package pgen;\n" +
"public class CGen {\n" +
" public String get(String in) { return in; }\n" +
"}\n"
},
new String[] {
"pgen/CGen.eea",
"class pgen/CGen\n" +
"\n" +
"get\n" +
" (Ljava/lang/String;)Ljava/lang/String;\n" +
" (L1java/lang/String;)L1java/lang/String;\n"
},
projectLoc+"/lib/prj1.jar",
"1.8");
IClasspathEntry entry = JavaCore.newLibraryEntry(
new Path("/PrjTest/lib/prj1.jar"),
null/*access rules*/,
null,
false/*exported*/);
env.addEntry(project.getPath(), entry);

Util.createJar(new String[] {
"pgen2/CGen2.java",
"package pgen2;\n" +
"public class CGen2 {\n" +
" public String get2(Exception in) { return in.toString(); }\n" +
"}\n"
},
new String[] {
"pgen2/CGen2.eea",
"class pgen2/CGen2\n" +
"\n" +
"get2\n" +
" (Ljava/lang/Exception;)Ljava/lang/String;\n" +
" (L1java/lang/Exception;)L1java/lang/String;\n",
},
projectLoc+"/lib/prj2.jar",
"1.8");
entry = JavaCore.newLibraryEntry(
new Path("/PrjTest/lib/prj2.jar"),
null/*access rules*/,
null,
false/*exported*/);
env.addEntry(project.getPath(), entry);
project.getProject().refreshLocal(IResource.DEPTH_INFINITE, null);

env.addFolder(project.getPath(), "src/p");
env.addFile(project.getPath().append("src").append("p"), "Use.java",
"package p;\n" +
"import pgen.CGen;\n" +
"import pgen2.CGen2;\n" +
"import org.eclipse.jdt.annotation.NonNull;\n" +
"public class Use {\n" +
" public @NonNull String test(CGen c) {\n" +
" String s = c.get(null);\n" +
" return s;\n" +
" }\n" +
" public @NonNull String test2(CGen2 c) {\n" +
" String s = c.get2(null);\n" +
" return s;\n" +
" }\n" +
"}\n");
project.getProject().build(IncrementalProjectBuilder.FULL_BUILD, null);
writeReadAndCompareExternalAnnotationLocations(project.getProject());
}

private void writeReadAndCompareTestBinaryLocations(IPath projectPath)
throws JavaModelException, IOException, CoreException {
Expand All @@ -163,6 +244,22 @@ private void assertEqualBinaryLocations(ClasspathLocation[] a,
assertArrayEquals(a, b);
}

private void writeReadAndCompareExternalAnnotationLocations(IProject project)
throws JavaModelException, IOException, CoreException {
JavaModelManager javaModelManager = JavaModelManager.getJavaModelManager();
PerProjectInfo info = javaModelManager.getPerProjectInfoCheckExistence(project);
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
State savedState = (State) info.savedState;
JavaBuilder.writeState(savedState, new DataOutputStream(outputStream));
byte[] bytes = outputStream.toByteArray();
State readState = JavaBuilder.readState(project, new DataInputStream(new ByteArrayInputStream(bytes)));
assertArrayEquals(savedState.binaryLocations, readState.binaryLocations);
// beyond this point we know that both arrays have the same length
for (int i=0; i < savedState.binaryLocations.length; i++) {
assertTrue("comparing eea locations of "+savedState.binaryLocations[i], savedState.binaryLocations[i].externalAnnotationsEquals(readState.binaryLocations[i]));
}
}

private void writeReadAndCompareReferences(IPath projectPath)
throws JavaModelException, IOException, CoreException {
JavaModelManager javaModelManager = JavaModelManager.getJavaModelManager();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -301,20 +301,20 @@ public void testAfterEmptyAnonymous() {
// completeBehind:
"fred(new Runnable() {}, ",
// expectedCompletionNodeToString:
"<CompleteOnMessageSend:this.fred(new Runnable() {\n})>",
"<CompleteOnName:>",
// expectedUnitDisplayString:
"class Bar {\n" +
" Bar() {\n" +
" }\n" +
" void foo() {\n" +
" <CompleteOnMessageSend:this.fred(new Runnable() {\n" +
"})>;\n" +
" this.fred(new Runnable() {\n" +
"}, <CompleteOnName:>, i);\n" +
" }\n" +
"}\n",
// expectedCompletionIdentifier:
"",
// expectedReplacedSource:
"fred(new Runnable() {}, ",
"",
// test name
"<completion just before second parameter, the first parameter being an empty anonymous class>"
);
Expand Down Expand Up @@ -364,19 +364,19 @@ public void testBeforeFirstParameter() {
// completeBehind:
"fred(",
// expectedCompletionNodeToString:
"<CompleteOnMessageSend:this.fred()>",
"<CompleteOnMessageSend:this.fred(<CompleteOnName:>, 2, i)>",
// expectedUnitDisplayString:
"class Bar {\n" +
" Bar() {\n" +
" }\n" +
" void foo() {\n" +
" <CompleteOnMessageSend:this.fred()>;\n" +
" <CompleteOnMessageSend:this.fred(<CompleteOnName:>, 2, i)>;\n" +
" }\n" +
"}\n",
// expectedCompletionIdentifier:
"",
// expectedReplacedSource:
"fred(",
"fred(1, 2, i)",
// test name
"<completion just before first parameter>"
);
Expand Down Expand Up @@ -426,19 +426,19 @@ public void testBeforeSecondParameter() {
// completeBehind:
"fred(1, ",
// expectedCompletionNodeToString:
"<CompleteOnMessageSend:this.fred(1)>",
"<CompleteOnName:>",
// expectedUnitDisplayString:
"class Bar {\n" +
" Bar() {\n" +
" }\n" +
" void foo() {\n" +
" <CompleteOnMessageSend:this.fred(1)>;\n" +
" this.fred(1, <CompleteOnName:>, i);\n" +
" }\n" +
"}\n",
// expectedCompletionIdentifier:
"",
// expectedReplacedSource:
"fred(1, ",
"",
// test name
"<completion just before second parameter>"
);
Expand Down Expand Up @@ -652,19 +652,19 @@ public void testSpaceThenFirstParameter() {
// completeBehind:
"fred( ",
// expectedCompletionNodeToString:
"<CompleteOnMessageSend:this.fred()>",
"<CompleteOnName:>",
// expectedUnitDisplayString:
"class Bar {\n" +
" Bar() {\n" +
" }\n" +
" void foo() {\n" +
" <CompleteOnMessageSend:this.fred()>;\n" +
" this.fred(<CompleteOnName:>, 2, i);\n" +
" }\n" +
"}\n",
// expectedCompletionIdentifier:
"",
// expectedReplacedSource:
"fred( ",
"",
// test name
"<completion just before first parameter with a space after open parenthesis>"
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10301,4 +10301,28 @@ public void testBug573378() {
"The type of count() from the type Stream<Object> is long, this is incompatible with the descriptor\'s return type: int\n" +
"----------\n");
}
public void testBug549446() {
if (this.complianceLevel < ClassFileConstants.JDK12)
return; // uses interface Constable
runConformTest(
new String[] {
"TestFile.java",
"import java.lang.constant.Constable;\n" +
"public class TestFile {\n" +
"\n" +
" @SafeVarargs\n" +
" public final <E> E elements(E... args) {\n" +
" return null;\n" +
" }\n" +
"\n" +
" public void test1() {\n" +
" var v = elements(\"a\", 1);\n" +
" }\n" +
"\n" +
" public void test2() {\n" +
" var v = elements(\"a\", (Comparable<String> & Constable) null);\n" +
" }\n" +
"}\n"
});
}
}
Loading

0 comments on commit 76fc7da

Please sign in to comment.