Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2015, 2024 itemis AG (http://www.itemis.eu) and others.
* Copyright (c) 2015, 2026 itemis AG (http://www.itemis.eu) and others.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0.
Expand Down Expand Up @@ -61,6 +61,7 @@ class JavaVersionSettingTest extends Assert {
@Test def void testCompileWithJava8() {
workbenchTestHelper.tearDown
WorkbenchTestHelper.createPluginProject(WorkbenchTestHelper.TESTPROJECT_NAME, JavaVersion.JAVA8)
waitForJdtIndex()
val xtendFile = workbenchTestHelper.createFile('mypackage/OverrideTest.xtend', '''
package mypackage
class B implements A {
Expand Down Expand Up @@ -94,4 +95,4 @@ class JavaVersionSettingTest extends Assert {
}
}

}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright (c) 2015, 2024 itemis AG (http://www.itemis.eu) and others.
* Copyright (c) 2015, 2026 itemis AG (http://www.itemis.eu) and others.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0.
Expand Down Expand Up @@ -68,6 +68,7 @@ public void testCompileWithJava8() {
try {
this.workbenchTestHelper.tearDown();
WorkbenchTestHelper.createPluginProject(WorkbenchTestHelper.TESTPROJECT_NAME, JavaVersion.JAVA8);
IResourcesSetupUtil.waitForJdtIndex();
StringConcatenation _builder = new StringConcatenation();
_builder.append("package mypackage");
_builder.newLine();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import org.eclipse.xtext.resource.IEObjectDescription;
import org.eclipse.xtext.resource.IResourceDescription;
import org.eclipse.xtext.ui.notification.IStateChangeEventBroker;
import org.eclipse.xtext.ui.testing.util.IResourcesSetupUtil;
import org.eclipse.xtext.xbase.lib.Procedures;
import org.eclipse.xtext.xbase.lib.Procedures.Procedure0;
import org.junit.After;
Expand Down Expand Up @@ -78,8 +79,14 @@ public void setUp() throws Exception {
projectProvider = new MockJavaProjectProvider();
projectProvider.setUseSource(true);
project = projectProvider.getJavaProject(null);
// Ensure the JDT incremental builder state is fully populated before the test starts.
// Without this, JavaBuilderState.getDefinedTypeNamesFor(typeLocator) may return null
// and convertRemovedTypes(...) will only emit a delta for the primary type, causing
// e.g. testRenameClass to see 4 deltas instead of the expected 6.
IResourcesSetupUtil.waitForBuild();
type = project.findType(NESTED_TYPES);
compilationUnit = type.getCompilationUnit();
assertBuilderStateContainsNestedTypes();
compilationUnit.becomeWorkingCopy(null);

// wait until the BackgroundThread for the reconciler was started
Expand All @@ -105,13 +112,33 @@ public void tearDown() throws Exception {
eventBroker = null;
projectProvider = null;
compilationUnit.discardWorkingCopy();
// Make sure the rebuild triggered by doSave above is finished before the next
// @Before runs, so that JavaBuilderState is consistent for the following test.
IResourcesSetupUtil.waitForBuild();
compilationUnit = null;
editor = null;
type = null;
project = null;
event = null;
subsequentEvents = null;
}

/**
* Sanity check that the JDT builder state knows about all three nested types defined in
* {@code NestedTypes.java}. If this fails, the test environment is racing with the Java
* builder and the actual test assertions would be misleading.
*/
private void assertBuilderStateContainsNestedTypes() {
JavaBuilderState builderState = JavaBuilderState.getLastBuiltState(project.getProject());
assertNotNull("No JDT builder state available for project " + project.getElementName(), builderState);
TypeNames typeNames = builderState.getQualifiedTypeNames(compilationUnit);
Collection<String> names = typeNames.getTypeNames();
assertTrue("Builder state is missing " + NESTED_TYPES + ", was: " + names, names.contains(NESTED_TYPES));
assertTrue("Builder state is missing " + NESTED_TYPES + "$Outer, was: " + names,
names.contains(NESTED_TYPES + "$Outer"));
assertTrue("Builder state is missing " + NESTED_TYPES + "$Outer$Inner, was: " + names,
names.contains(NESTED_TYPES + "$Outer$Inner"));
}

@Test public void testNullChange() throws BadLocationException, InterruptedException {
waitForEvent(new Procedure0() {
Expand Down
Loading