Java Code Examples for org.eclipse.xtext.ui.testing.util.IResourcesSetupUtil#reallyWaitForAutoBuild()

The following examples show how to use org.eclipse.xtext.ui.testing.util.IResourcesSetupUtil#reallyWaitForAutoBuild() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ActiveAnnotationsProcessingInIDETest.java    From xtext-xtend with Eclipse Public License 2.0 6 votes vote down vote up
@Override
public void assertProcessing(final Pair<String, String> macroContent, final Pair<String, String> clientContent, final Procedure1<? super CompilationUnitImpl> expectations) {
  try {
    this.macroFile = this.newSource(ActiveAnnotationsProcessingInIDETest.macroProject, macroContent.getKey(), macroContent.getValue().toString());
    final int lidx = macroContent.getKey().lastIndexOf("/");
    if ((lidx != (-1))) {
      this.exportedPackage = macroContent.getKey().substring(0, lidx).replace("/", ".");
      boolean _addExportedPackages = WorkbenchTestHelper.addExportedPackages(ActiveAnnotationsProcessingInIDETest.macroProject.getProject(), this.exportedPackage);
      if (_addExportedPackages) {
        IResourcesSetupUtil.reallyWaitForAutoBuild();
      }
    }
    this.clientFile = this.newSource(ActiveAnnotationsProcessingInIDETest.userProject, clientContent.getKey(), clientContent.getValue().toString());
    IResourcesSetupUtil.waitForBuild();
    final ResourceSet resourceSet = this.resourceSetProvider.get(ActiveAnnotationsProcessingInIDETest.userProject.getProject());
    final Resource resource = resourceSet.getResource(URI.createPlatformResourceURI(this.clientFile.getFullPath().toString(), true), true);
    EcoreUtil2.resolveLazyCrossReferences(resource, CancelIndicator.NullImpl);
    this.validator.validate(resource, CheckMode.FAST_ONLY, CancelIndicator.NullImpl);
    final CompilationUnitImpl unit = this.compilationUnitProvider.get();
    unit.setXtendFile(IterableExtensions.<XtendFile>head(Iterables.<XtendFile>filter(resource.getContents(), XtendFile.class)));
    expectations.apply(unit);
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
Example 2
Source File: SameClassNamesTest.java    From xtext-xtend with Eclipse Public License 2.0 6 votes vote down vote up
@Test
public void testDuplicateNames_04() {
  try {
    final IJavaProject javaProject = JavaCore.create(this.second);
    final IClasspathEntry[] cp = javaProject.getRawClasspath();
    final List<IClasspathEntry> reversed = ListExtensions.<IClasspathEntry>reverse(((List<IClasspathEntry>)Conversions.doWrapArray(cp)));
    javaProject.setRawClasspath(((IClasspathEntry[])Conversions.unwrapArray(reversed, IClasspathEntry.class)), null);
    IResourcesSetupUtil.reallyWaitForAutoBuild();
    this.testHelper.createFileImpl("first/src/com/acme/A.xtend", "package com.acme class A { new(String s) {} }");
    this.testHelper.createFileImpl("second/src/com/acme/A.xtend", "package com.acme class A { new(int i) {} }");
    this.testHelper.createFileImpl("second/src/com/acme/B.xtend", "package com.acme class B extends A { new() { super(1) } }");
    this.testHelper.createFileImpl("third/src/com/acme/A.xtend", "package com.acme class A {}");
    IResourcesSetupUtil.waitForBuild();
    IResourcesSetupUtil.assertNoErrorsInWorkspace();
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
Example 3
Source File: AbstractXtendUITestCase.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
protected void setJavaVersion(JavaVersion javaVersion) throws Exception {
	IJavaProject javaProject = JavaProjectSetupUtil.findJavaProject(WorkbenchTestHelper.TESTPROJECT_NAME);
	Pair<String,Boolean> result = WorkbenchTestHelper.changeBree(javaProject, javaVersion);
	IExecutionEnvironment execEnv = JavaRuntime.getExecutionEnvironmentsManager().getEnvironment(result.getKey());
	Assume.assumeNotNull("Execution environment not found for: " + javaVersion.getLabel(), execEnv);
	Assume.assumeTrue("No compatible VM was found for: " + javaVersion.getLabel(),
			execEnv.getCompatibleVMs().length > 0);
	if(result.getValue()) {
		WorkbenchTestHelper.makeCompliantFor(javaProject, javaVersion);
		IResourcesSetupUtil.reallyWaitForAutoBuild();
	}
}
 
Example 4
Source File: XtendLibClasspathAdderTest.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Behavior relies on scheduled jobs which are not really builds but still belong to the
 * {@link org.eclipse.core.resources.ResourcesPlugin#FAMILY_AUTO_BUILD} thus we wait for that one here.
 */
protected void waitForAutoBuild() {
	// changing classpath triggers multiple builds, the first one only sets forgetlastBuildState
	// we need to wait for that
	IResourcesSetupUtil.reallyWaitForAutoBuild();
	// now lets do a build
	syncUtil.waitForBuild(null);
}
 
Example 5
Source File: SameClassNamesTest.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
@Before
public void createProjects() {
  try {
    this.first = this.createPluginProject("first", ((String[])Conversions.unwrapArray(WorkbenchTestHelper.DEFAULT_REQ_BUNDLES, String.class)));
    Iterable<String> _plus = Iterables.<String>concat(WorkbenchTestHelper.DEFAULT_REQ_BUNDLES, Collections.<String>unmodifiableList(CollectionLiterals.<String>newArrayList("first")));
    this.second = this.createPluginProject("second", ((String[])Conversions.unwrapArray(_plus, String.class)));
    this.third = this.createPluginProject("third", ((String[])Conversions.unwrapArray(WorkbenchTestHelper.DEFAULT_REQ_BUNDLES, String.class)));
    IResourcesSetupUtil.reallyWaitForAutoBuild();
    this.testHelper.closeWelcomePage();
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
Example 6
Source File: SameClassNamesTest.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
@After
public void deleteProjects() {
  try {
    WorkbenchTestHelper.deleteProject(this.first);
    WorkbenchTestHelper.deleteProject(this.second);
    WorkbenchTestHelper.deleteProject(this.third);
    IResourcesSetupUtil.reallyWaitForAutoBuild();
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
Example 7
Source File: DirtyStateEditorSupportTest.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
@Before
public void start() {
  try {
    WorkbenchTestHelper.createPluginProject(WorkbenchTestHelper.TESTPROJECT_NAME);
    this._workbenchTestHelper.closeWelcomePage();
    IResourcesSetupUtil.reallyWaitForAutoBuild();
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
Example 8
Source File: PluginTestProjectManager.java    From dsl-devkit with Eclipse Public License 1.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override
public void setup(final Iterable<? extends TestSource> initialSources) {
  try {
    IResourcesSetupUtil.reallyWaitForAutoBuild();
    createPluginProject(injector, TEST_PROJECT_NAME);
  } catch (CoreException e) {
    throw new IllegalStateException("Failed to create plugin project"); //$NON-NLS-1$
  }
}
 
Example 9
Source File: XtextTestProjectManager.java    From dsl-devkit with Eclipse Public License 1.0 4 votes vote down vote up
/** {@inheritDoc} */
@Override
public void build() {
  IResourcesSetupUtil.reallyWaitForAutoBuild();
}
 
Example 10
Source File: AbstractGeneratorTest.java    From dsl-devkit with Eclipse Public License 1.0 3 votes vote down vote up
/**
 * Initializes a project with the given name, required bundles and sources.
 *
 * @param projectName
 *          the name of the project
 * @param folders
 *          the folders to create (source and source-generated folders will be created unless methods are overridden and specified as null or empty), or
 *          {@code null} if none
 * @param requiredBundles
 *          required bundles of the project to be created, or {@code null} if none
 * @param importedPackages
 *          imported packages of the project to be created, or {@code null} if none
 * @param exportedPackages
 *          exported packages of the project to be created, or {@code null} if none
 * @param sourceFileNames
 *          the source file names, mapping input filename to output filename
 * @throws CoreException
 *           the {@link CoreException}
 */
public void initializeProject(final String projectName, final List<String> folders, final List<String> requiredBundles, final List<String> importedPackages, final List<String> exportedPackages, final ImmutableMap<String, String> sourceFileNames) throws CoreException {
  // a project must be created
  createPluginProject(projectName, folders, requiredBundles, importedPackages, exportedPackages);
  // sources are copied into the project and then built by the Xtext builder
  addSourcesToWorkspace(projectName, sourceFileNames);

  // wait for build to finish, otherwise included catalog may not be resolvable
  IResourcesSetupUtil.reallyWaitForAutoBuild();
}