eclipse-jdtls / eclipse-jdt-core-incubator

Eclipse Public License 2.0
8 stars 1 forks source link

[DOM-first] Fix `org.eclipse.jdt.core.tests.model.CompletionTests*` test suites #80

Closed datho7561 closed 7 months ago

datho7561 commented 8 months ago

See https://github.com/eclipse-jdtls/eclipse-jdt-core-incubator/issues/12, treat this as a subissue for that epic

mickaelistria commented 7 months ago

CompletionTests9.test486988_0015 (and others) fail because with DOM, the used method CompletionEngine.getAllTypesInHierarchy() returns empty results while it's supposed to return some types

mickaelistria commented 7 months ago

More specifically, it's

ITypeHierarchy newTypeHierarchy = typeHandle.newTypeHierarchy(this.javaProject, null);
IType[] implementingClasses = newTypeHierarchy.getImplementingClasses(typeHandle);

returning an empty set.

mickaelistria commented 7 months ago

Even more specifically, the project.getResolvedClasspath() misses reference to the other project when using DOM-first.

mickaelistria commented 7 months ago

Here is a minimized test to reproduce the root issue of some failures

    IJavaProject project1 = createJavaProject("Completion9_1", new String[] {"src"}, new String[] {"JCL18_LIB"}, "bin", "9");
    IJavaProject project2 = createJavaProject("Completion9_2", new String[] {"src"}, new String[] {"JCL18_LIB"}, "bin", "9");
    try {
        project1.open(null);
        String filePath1 = "/Completion9_1/src/module-info.java";
        String fileContent1 =  "module first {\n"
                + "requires second;\n"
                + "}\n";
        createFile(filePath1, fileContent1);
        addClasspathEntry(project1, JavaCore.newContainerEntry(new Path("org.eclipse.jdt.MODULE_PATH")));

        project2.open(null);
        String fileContent2 =  "module second { "
                + "exports pack21 to first;\n"
                + "exports pack22 to first;\n"
                + "}\n";
        String filePath2 = "/Completion9_2/src/module-info.java";
        createFile(filePath2, fileContent2);
        addClasspathEntry(project1, JavaCore.newContainerEntry(project2.getPath()));
        assertEquals(2, ((JavaProject)project1).getResolvedClasspath().length);

        project1.close();
        project1.open(null);

        IClasspathEntry[] resolvedClasspath = ((JavaProject)project1).getResolvedClasspath();
        assertEquals(2, resolvedClasspath.length);

fails with

junit.framework.AssertionFailedError: expected:<2> but was:<1>
    at junit.framework.Assert.fail(Assert.java:57)
    at junit.framework.Assert.failNotEquals(Assert.java:329)
    at junit.framework.Assert.assertEquals(Assert.java:78)
    at junit.framework.Assert.assertEquals(Assert.java:234)
    at junit.framework.Assert.assertEquals(Assert.java:241)
    at junit.framework.TestCase.assertEquals(TestCase.java:384)

on the 2nd assert when going DOM-first (passes with regular ECJ)

mickaelistria commented 7 months ago

https://ci.eclipse.org/ls/job/jdt-core-incubator/job/dom-based-operations/98/#showFailuresLink shows no remaining related failure.