org.eclipse.xtext.ui.testing.util.IResourcesSetupUtil Java Examples

The following examples show how to use org.eclipse.xtext.ui.testing.util.IResourcesSetupUtil. 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: LiveShadowedAllContainerStateTest.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
@Test
public void testEmptyProject() {
  try {
    final IProject project = IResourcesSetupUtil.createProject("MyProject");
    IResourcesSetupUtil.addNature(project, XtextProjectHelper.NATURE_ID);
    final ResourceSet rs = this.liveScopeResourceSetProvider.get(project);
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("container MyProject isEmpty=true {");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    final String expected = _builder.toString();
    Assert.assertEquals(expected, this.formatContainers(rs));
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
Example #2
Source File: MultipleSingletonPluginUITest.java    From n4js with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * The tests first collects all injectors. The shared injector is identified using the class
 * {@link InjectorCollector}. Afterwards, it detects all singleton classes that are bound in N4JS related injectors.
 * Finally, for every such singleton class all injectors are checked whether they created an instance of the
 * singleton class and whether these instances are the same.
 */
@Test
public void identifyMultipleSingletons() throws Exception {
	ProjectTestsUtils.importProject(new File("probands"), new N4JSProjectName("ListBase"));
	IResourcesSetupUtil.waitForBuild();

	@SuppressWarnings("unused")
	TesterUiActivator testerUiActivator = new TesterUiActivator(); // force the TesterUI and Tester bundles to start

	Multimap<Class<?>, Injector> singletonInstances = HashMultimap.create();

	Map<Injector, String> injectors = getAllInjectors();
	for (Map.Entry<Injector, String> injectorAndName : injectors.entrySet()) {
		Injector injector = injectorAndName.getKey();
		String name = injectorAndName.getValue();
		assertTrue("Injector '" + name + "' is null.", injector != null);
		getN4JSSingletonsOfInjector(injector, singletonInstances);
	}

	String status = getMultipleSingletonStatusString(singletonInstances, injectors);

	assertEquals(MultiSingletonExpectation.get(), status);
}
 
Example #3
Source File: ProjectTestsUtils.java    From n4js with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Copies projects from the given location to the node_modules folder of the given project
 */
public static void importDependencies(N4JSProjectName projectName, java.net.URI externalRootLocation,
		LibraryManager libraryManager) throws IOException, CoreException {

	IProject clientProject = getProjectByName(projectName.toEclipseProjectName());
	java.net.URI clientLocation = clientProject.getLocationURI();
	File nodeModulesDir = new File(clientLocation.getPath(), N4JSGlobals.NODE_MODULES);
	if (!nodeModulesDir.isDirectory()) {
		Files.createDirectory(nodeModulesDir.toPath());
	}

	java.nio.file.Path probandsSource = Paths.get(externalRootLocation.getPath());
	FileCopier.copy(probandsSource, nodeModulesDir.toPath());

	libraryManager.synchronizeNpms(new NullProgressMonitor());

	IResourcesSetupUtil.fullBuild();
	waitForAllJobs();
}
 
Example #4
Source File: Storage2UriMapperJavaImplTest.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
@Test
public void testOnCloseOpenRemoveProject() {
  try {
    Assert.assertEquals(0, this.getCachedPackageFragmentRootData().size());
    final IJavaProject project = JavaProjectSetupUtil.createJavaProject("testProject");
    final IJavaProject project2 = JavaProjectSetupUtil.createJavaProject("testProject2");
    final int sizeBefore = this.getCachedPackageFragmentRootData().size();
    final IFile file = this.createJar(project);
    JavaProjectSetupUtil.addJarToClasspath(project, file);
    JavaProjectSetupUtil.addJarToClasspath(project2, file);
    this.assertBothProjects(sizeBefore);
    project2.getProject().close(IResourcesSetupUtil.monitor());
    this.assertFirstProject(sizeBefore);
    project.getProject().close(IResourcesSetupUtil.monitor());
    this.assertNonProjects();
    project.getProject().open(IResourcesSetupUtil.monitor());
    this.assertFirstProject(sizeBefore);
    project2.getProject().open(IResourcesSetupUtil.monitor());
    this.assertBothProjects(sizeBefore);
    project.getProject().delete(true, IResourcesSetupUtil.monitor());
    project2.getProject().delete(true, IResourcesSetupUtil.monitor());
    this.assertNonProjects();
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
Example #5
Source File: ExcludePckJson_PluginUITest.java    From n4js with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Checks that only one package.json is contained in the index. This one package.json is the one from the project
 * root folder.
 */
@Test
public void checkIndex() throws CoreException {
	final IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(PROJECT_NAME);
	assertTrue("Test project is not accessible.", project.isAccessible());

	IResourcesSetupUtil.fullBuild();
	waitForAutoBuild();

	ResourceSet resourceSet = core.createResourceSet(Optional.absent());
	IResourceDescriptions index = core.getXtextIndex(resourceSet);

	for (IResourceDescription res : index.getAllResourceDescriptions()) {
		String resLocation = res.getURI().toString();

		if (resLocation.endsWith(".json")) {
			System.out.println("Indexing found: " + resLocation);
		}
	}
}
 
Example #6
Source File: JdtFindReferencesTest.java    From xtext-xtend with Eclipse Public License 2.0 6 votes vote down vote up
@Test
public void testClassJavaElements() {
  try {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("class Xtend {");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    final XtendTypeDeclaration clazz = IterableExtensions.<XtendTypeDeclaration>head(this._workbenchTestHelper.xtendFile("Xtend.xtend", _builder.toString()).getXtendTypes());
    IResourcesSetupUtil.waitForBuild();
    Iterable<IJavaElement> _javaElements = this._jvmModelFindReferenceHandler.getJavaElements(clazz);
    final Procedure1<Iterable<IJavaElement>> _function = (Iterable<IJavaElement> it) -> {
      Assert.assertEquals(1, IterableExtensions.size(it));
      final Function1<IJavaElement, Boolean> _function_1 = (IJavaElement it_1) -> {
        return Boolean.valueOf(((it_1 instanceof IType) && Objects.equal(((IType) it_1).getElementName(), "Xtend")));
      };
      Assert.assertTrue(IterableExtensions.<IJavaElement>exists(it, _function_1));
    };
    ObjectExtensions.<Iterable<IJavaElement>>operator_doubleArrow(_javaElements, _function);
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
Example #7
Source File: TextChangeCombinerTest.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
@Test
public void testMixedChanges() throws Exception {
	IFile file1 = IResourcesSetupUtil.createFile(PROJECT + "/file1.txt", MODEL);
	ITextEditor editor1 = openInEditor(file1);
	CompositeChange compositeChange = new CompositeChange("test");
	compositeChange.add(createEditorDocumentChange(editor1, 1, 1, "foo"));
	compositeChange.add(createTextFileChange(file0, 1, 1, "foo"));
	CompositeChange compositeChange1 = new CompositeChange("test");
	compositeChange.add(compositeChange1);
	compositeChange1.add(createEditorDocumentChange(editor1, 3, 1, "baz"));
	compositeChange1.add(createTextFileChange(file0, 1, 1, "foo"));
	compositeChange1.add(createTextFileChange(file0, 3, 1, "baz"));
	Change combined = combiner.combineChanges(compositeChange);
	Change undo = combined.perform(new NullProgressMonitor());
	IDocument document1 = getDocument(editor1);
	assertEquals(MODEL.replace("123", "foo2baz"), document1.get());
	assertEquals(MODEL.replace("123", "foo2baz"), getContents(file0));
	undo.perform(new NullProgressMonitor());
	assertEquals(MODEL, document1.get());
	assertEquals(MODEL, getContents(file0));
}
 
Example #8
Source File: JdtFindReferencesTest.java    From xtext-xtend with Eclipse Public License 2.0 6 votes vote down vote up
@Test
public void testFieldJavaElements() {
  try {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("class Xtend {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("int foo");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    final XtendMember field = IterableExtensions.<XtendMember>head(IterableExtensions.<XtendClass>head(Iterables.<XtendClass>filter(this._workbenchTestHelper.xtendFile("Xtend.xtend", _builder.toString()).getXtendTypes(), XtendClass.class)).getMembers());
    IResourcesSetupUtil.waitForBuild();
    Iterable<IJavaElement> _javaElements = this._jvmModelFindReferenceHandler.getJavaElements(field);
    final Procedure1<Iterable<IJavaElement>> _function = (Iterable<IJavaElement> it) -> {
      Assert.assertEquals(1, IterableExtensions.size(it));
      final Function1<IJavaElement, Boolean> _function_1 = (IJavaElement it_1) -> {
        return Boolean.valueOf(((it_1 instanceof IField) && Objects.equal(((IField) it_1).getElementName(), "foo")));
      };
      Assert.assertTrue(IterableExtensions.<IJavaElement>exists(it, _function_1));
    };
    ObjectExtensions.<Iterable<IJavaElement>>operator_doubleArrow(_javaElements, _function);
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
Example #9
Source File: TypeDefinitionsShadowingPluginTest.java    From n4js with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Negative test case.
 *
 * Imports client, definition and implementation project that declare an invalid type definitions configuration.
 *
 * More specifically, the "definesPackage" property of the definition project does not point to the intended
 * implementation project. As a consequence, the client project cannot make use of any type information on the
 * implementation project.
 */
@Test
public void testInvalidTypeDefinitionsShadowing() throws CoreException {
	final File testdataLocation = new File(getResourceUri(PROBANDS, PROBANDS_SUBFOLDER, NEGATIVE_FIXTURE_FOLDER));

	ProjectTestsUtils.importYarnWorkspace(libraryManager, testdataLocation, YARN_WORKSPACE_PROJECT);

	final IProject clientProject = ResourcesPlugin.getWorkspace().getRoot().getProject("Broken_Client");
	final IProject definitionProject = ResourcesPlugin.getWorkspace().getRoot().getProject("Broken_Def");
	final IProject implProject = ResourcesPlugin.getWorkspace().getRoot().getProject("Impl");

	IResourcesSetupUtil.fullBuild();
	waitForAutoBuild();

	IResource clientModule = clientProject.findMember("src/Client.n4js");

	assertIssues("Client module should have compilation issues, as type definitions cannot be resolved",
			clientModule,
			"line 2: Import of A cannot be resolved.",
			"line 6: Couldn't resolve reference to IdentifiableElement 'A'.");

	assertMarkers("Definition project should not have any markers (no compilation issues)", definitionProject, 0);
	assertMarkers("Implementation project should not have any markers (no compilation issues)", implProject, 0);
}
 
Example #10
Source File: XtendEditorChangingClasspathTest.java    From xtext-xtend with Eclipse Public License 2.0 6 votes vote down vote up
@Test
public void testAddXtendLibWithDirtyEditor() {
  try {
    final IJavaProject project = JavaProjectSetupUtil.createJavaProject("testProject");
    final IFile file = IResourcesSetupUtil.createFile("testProject/src/Foo.xtend", "class Foo {}");
    IResourcesSetupUtil.waitForBuild();
    final XtextEditor editor = this.workbenchTestHelper.openEditor(file);
    final Procedure0 _function = () -> {
      this.changeContent(editor, "{}", "{ def foo () {} }");
    };
    this.waitForChangeEvent(_function);
    this.assertAddLibsToClasspath(project);
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
Example #11
Source File: JavaClasspathTest.java    From xtext-xtend with Eclipse Public License 2.0 6 votes vote down vote up
@Test
public void testJavaSourceLevelMismatch() throws Exception {
	IProject project = testHelper.getProject();

	// create a fake java.util.List without type param
	IFolder folder = project.getFolder(new Path("src/java/util"));
	IResourcesSetupUtil.createFolder(folder.getFullPath());
	IFile list = folder.getFile("List.xtend");
	list.create(new StringInputStream("package java.util; class List {}"), true, null);

	IFile file = project.getFile("src/Foo.xtend");
	if (!file.exists())
		file.create(new StringInputStream(TEST_CLAZZ),
				true, null);
	IResourcesSetupUtil.cleanBuild();
	IResourcesSetupUtil.waitForBuild();
	markerAssert.assertErrorMarker(file, IssueCodes.JDK_NOT_ON_CLASSPATH);

	list.delete(true, null);
	IResourcesSetupUtil.cleanBuild();
	IResourcesSetupUtil.waitForBuild();
	markerAssert.assertNoErrorMarker(file);
}
 
Example #12
Source File: EclipseResourceFileSystemAccessTest.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
@Test public void testDirsAreCreated() throws Exception {
	IProject project = workspace.createProject("test");
	EclipseResourceFileSystemAccess fileSystemAccess = new EclipseResourceFileSystemAccess();
	fileSystemAccess.setRoot(IResourcesSetupUtil.root());
	fileSystemAccess.setOutputPath("test");
	final List<String> newFiles = newArrayList();
	fileSystemAccess.setNewFileAcceptor(new IAcceptor<String>() {
		@Override
		public void accept(String t) {
			newFiles.add(t);
		}
	});
	fileSystemAccess.generateFile("tmp/X", "XX");
	IFolder dir = project.getFolder("tmp");
	assertTrue(dir.exists());
	IFile file = dir.getFile("X");
	assertTrue(file.exists());
	assertEquals(1, newFiles.size());
	assertTrue(newFiles.contains("/test/tmp/X"));
}
 
Example #13
Source File: WorkspaceScenariosTest.java    From xtext-xtend with Eclipse Public License 2.0 6 votes vote down vote up
@Test
public void testJarWithEverything() {
  try {
    final Function1<String, Boolean> _function = (String it) -> {
      return Boolean.valueOf(false);
    };
    final IProject project = this.createProjectWithJarDependency(_function);
    try {
      IResourcesSetupUtil.assertNoErrorsInWorkspace();
      Assert.assertEquals(1, ((Object[])Conversions.unwrapArray(this.persistedResourceDescriptions.get().getAllResourceDescriptions(), Object.class)).length);
    } finally {
      project.delete(true, true, null);
    }
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
Example #14
Source File: AbstractContainerRelatedTests.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
@Before
public void setUp() throws Exception {
	cleanWorkspace();
	waitForBuild();
	assertEquals(0, root().getProjects().length);
	project1 = createProject("someProject1");
	project2 = createProject("someProject2");
	IResourcesSetupUtil.addNature(project1, XtextProjectHelper.NATURE_ID);
	IResourcesSetupUtil.addNature(project2, XtextProjectHelper.NATURE_ID);
	uriToResourceDescription = Maps.newHashMap();
	selectableDelegate = new AbstractCompoundSelectable() {
		@Override
		protected Iterable<IResourceDescription> getSelectables() {
			return getAllResourceDescriptions();
		}
	};
}
 
Example #15
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 #16
Source File: RebuildAffectedResourcesTest.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void testAddReferencedType() {
  try {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("class Type3 {");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    final IFile type1 = this.workbenchTestHelper.createFile("Type1.xtend", _builder.toString());
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("class Type2 {");
    _builder_1.newLine();
    _builder_1.append("\t");
    _builder_1.append("Type1 myRef");
    _builder_1.newLine();
    _builder_1.append("}");
    _builder_1.newLine();
    final IFile type2 = this.workbenchTestHelper.createFile("Type2.xtend", _builder_1.toString());
    IResourcesSetupUtil.waitForBuild();
    this.assertHasErrors(type2, "Type1");
    StringConcatenation _builder_2 = new StringConcatenation();
    _builder_2.append("class Type1 {");
    _builder_2.newLine();
    _builder_2.append("}");
    _builder_2.newLine();
    StringInputStream _stringInputStream = new StringInputStream(_builder_2.toString());
    type1.setContents(_stringInputStream, true, true, null);
    IResourcesSetupUtil.waitForBuild();
    this.assertNoErrorsInWorkspace();
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
Example #17
Source File: WorkspaceProjectsStateTest.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
@Override
@Test public void testRemoveNature() throws CoreException {
	Collection<URI> containedURIs = projectsState.getContainedURIs(project1.getName());
	assertEquals(2, containedURIs.size());
	IResourcesSetupUtil.removeNature(project1, XtextProjectHelper.NATURE_ID);
	containedURIs = projectsState.getContainedURIs(project1.getName());
	assertTrue(containedURIs.isEmpty());
}
 
Example #18
Source File: PerformanceTest.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
@BeforeClass
public static void createTestProject() {
  try {
    PerformanceTestProjectSetup.setUp();
    IResourcesSetupUtil.waitForBuild();
    PerformanceTest.assertNoErrorsInWorkspace();
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
Example #19
Source File: XtendUnsugaredHoverTest.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void testBug380361() throws Exception {
  StringConcatenation _builder = new StringConcatenation();
  _builder.append("package testpackage");
  _builder.newLine();
  _builder.append("import static extension testpackage.Extension.*");
  _builder.newLine();
  _builder.append("class Foo {");
  _builder.newLine();
  _builder.append("\t");
  _builder.append("def foo() { 42 }");
  _builder.newLine();
  _builder.append("\t");
  _builder.append("def client() {");
  _builder.newLine();
  _builder.append("\t\t");
  _builder.append("foo //hover shows \'foo()\'");
  _builder.newLine();
  _builder.append("\t");
  _builder.append("}");
  _builder.newLine();
  _builder.append("}");
  _builder.newLine();
  final XtendFile xtendFile = this.testHelper.xtendFile(XtendUnsugaredHoverTest.FILEPATH, _builder.toString());
  IResourcesSetupUtil.waitForBuild();
  XtendMember _get = IterableExtensions.<XtendClass>head(Iterables.<XtendClass>filter(xtendFile.getXtendTypes(), XtendClass.class)).getMembers().get(1);
  final XtendFunction function = ((XtendFunction) _get);
  XExpression _expression = function.getExpression();
  final XBlockExpression block = ((XBlockExpression) _expression);
  final XExpression call = block.getExpressions().get(0);
  Assert.assertEquals("this.foo()", this.serializer.computeUnsugaredExpression(call));
}
 
Example #20
Source File: ResolvingCrossReferenceDuringIndexingTest.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
@After
@Override
public void tearDown() {
  try {
    IResourcesSetupUtil.cleanWorkspace();
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
Example #21
Source File: XtendUnsugaredHoverTest.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void testBug380361_1() throws Exception {
  StringConcatenation _builder = new StringConcatenation();
  _builder.append("package testpackage");
  _builder.newLine();
  _builder.append("import static java.lang.Integer.*");
  _builder.newLine();
  _builder.append("import static extension java.lang.String.*");
  _builder.newLine();
  _builder.append("class Foo {");
  _builder.newLine();
  _builder.append("\t");
  _builder.append("def void foo(String it) {");
  _builder.newLine();
  _builder.append("\t\t");
  _builder.append("valueOf()");
  _builder.newLine();
  _builder.append("\t\t");
  _builder.append("valueOf(it)");
  _builder.newLine();
  _builder.append("\t");
  _builder.append("}");
  _builder.newLine();
  _builder.append("}");
  _builder.newLine();
  final XtendFile xtendFile = this.testHelper.xtendFile(XtendUnsugaredHoverTest.FILEPATH, _builder.toString());
  IResourcesSetupUtil.waitForBuild();
  XtendMember _get = IterableExtensions.<XtendClass>head(Iterables.<XtendClass>filter(xtendFile.getXtendTypes(), XtendClass.class)).getMembers().get(0);
  final XtendFunction function = ((XtendFunction) _get);
  XExpression _expression = function.getExpression();
  final XBlockExpression block = ((XBlockExpression) _expression);
  final XExpression call = block.getExpressions().get(0);
  final XExpression call2 = block.getExpressions().get(1);
  Assert.assertEquals("String.valueOf(it)", this.serializer.computeUnsugaredExpression(call));
  Assert.assertEquals("", this.serializer.computeUnsugaredExpression(call2));
}
 
Example #22
Source File: AbstractJavaProjectsStateTest.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
@Override
@Test public void testRemoveNature() throws CoreException {
	Collection<URI> containedURIs = projectsState.getContainedURIs(srcRoot.getHandleIdentifier());
	assertEquals(2, containedURIs.size());
	IResourcesSetupUtil.removeNature(javaProject1.getProject(), XtextProjectHelper.NATURE_ID);
	containedURIs = projectsState.getContainedURIs(srcRoot.getHandleIdentifier());
	assertTrue(containedURIs.isEmpty());
}
 
Example #23
Source File: AccessRestrictionInWorkspaceTest.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void testDiscouragedReferenceInOtherProject() {
  try {
    final XtendFile xtendFile = this.parse(IResourcesSetupUtil.createFile("secondProject/src/Dummy.xtend", "class D { discouraged.B b }"));
    XtendTypeDeclaration _head = IterableExtensions.<XtendTypeDeclaration>head(xtendFile.getXtendTypes());
    final XtendClass c = ((XtendClass) _head);
    this._validationTestHelper.assertWarning(c, TypesPackage.Literals.JVM_TYPE_REFERENCE, IssueCodes.DISCOURAGED_REFERENCE, "Discouraged access: The type B is not accessible", "on required project firstProject");
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
Example #24
Source File: SameClassNamesTest.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void testNoDuplicateNames() {
  try {
    this.testHelper.createFileImpl("first/src/com/acme/A.xtend", "package com.acme class A {}");
    this.testHelper.createFileImpl("second/src/com/acme/B.xtend", "package com.acme class B {}");
    this.testHelper.createFileImpl("third/src/com/acme/C.xtend", "package com.acme class C {}");
    IResourcesSetupUtil.waitForBuild();
    IResourcesSetupUtil.assertNoErrorsInWorkspace();
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
Example #25
Source File: EditorResourceAccessTest.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public void setUp() throws Exception {
	super.setUp();
	IProject project = IResourcesSetupUtil.createProject("test");
	IResourcesSetupUtil.addNature(project, "org.eclipse.xtext.ui.shared.xtextNature");
	file = project.getFile("test.refactoringtestlanguage");
	file.create(new StringInputStream(""), true, null);
	uri = URI.createPlatformResourceURI(file.getFullPath().toString(), true);
}
 
Example #26
Source File: AbstractHyperlinkingTest.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
protected XtextEditor openInEditor(IFile dslFile) {
	// Wait for the cross-reference resolution
	IResourcesSetupUtil.waitForBuild();
	try {
		return openEditor(dslFile);
	} catch (Exception e) {
		throw new RuntimeException(e);
	}
}
 
Example #27
Source File: BuilderWithTracesTest.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
@Before
public void setUp() throws Exception {
	IResourcesSetupUtil.cleanWorkspace();
	javaProject = JavaProjectSetupUtil.createJavaProject("foo");
	project = javaProject.getProject();
	addNature(project, XtextProjectHelper.NATURE_ID);
	injector.injectMembers(this);
}
 
Example #28
Source File: AccessRestrictionInWorkspaceTest.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void testForbiddenReferenceInSameProject() {
  try {
    final XtendFile xtendFile = this.parse(IResourcesSetupUtil.createFile("firstProject/src/Dummy.xtend", "class D { restricted.A a }"));
    XtendTypeDeclaration _head = IterableExtensions.<XtendTypeDeclaration>head(xtendFile.getXtendTypes());
    final XtendClass c = ((XtendClass) _head);
    this._validationTestHelper.assertNoError(c, IssueCodes.DISCOURAGED_REFERENCE);
    this._validationTestHelper.assertNoError(c, IssueCodes.FORBIDDEN_REFERENCE);
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
Example #29
Source File: RebuildAffectedResourcesTest.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * see https://bugs.eclipse.org/bugs/show_bug.cgi?id=388828
 */
@Test
public void testBug388828() {
  try {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("abstract class A {}");
    _builder.newLine();
    final IFile typeA = this.workbenchTestHelper.createFile("A.xtend", _builder.toString());
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("class B extends A {");
    _builder_1.newLine();
    _builder_1.append("}");
    _builder_1.newLine();
    final IFile typeB = this.workbenchTestHelper.createFile("B.xtend", _builder_1.toString());
    IResourcesSetupUtil.waitForBuild();
    this.assertNoErrorsInWorkspace();
    StringConcatenation _builder_2 = new StringConcatenation();
    _builder_2.append("abst ract class A {");
    _builder_2.newLine();
    _builder_2.append("}");
    _builder_2.newLine();
    StringInputStream _stringInputStream = new StringInputStream(_builder_2.toString());
    typeA.setContents(_stringInputStream, true, true, null);
    IResourcesSetupUtil.waitForBuild();
    this.assertHasErrors(typeA, "abst");
    this.assertHasErrors(typeB, "A");
    StringConcatenation _builder_3 = new StringConcatenation();
    _builder_3.append("abstract class A {}");
    _builder_3.newLine();
    StringInputStream _stringInputStream_1 = new StringInputStream(_builder_3.toString());
    typeA.setContents(_stringInputStream_1, true, true, null);
    IResourcesSetupUtil.waitForBuild();
    this.assertNoErrorsInWorkspace();
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
Example #30
Source File: RebuildAffectedResourcesTest.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void testRemoveReferencedType() {
  try {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("class Type1 {");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    final IFile type1 = this.workbenchTestHelper.createFile("Type1.xtend", _builder.toString());
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("class Type2 {");
    _builder_1.newLine();
    _builder_1.append("\t");
    _builder_1.append("Type1 myRef");
    _builder_1.newLine();
    _builder_1.append("}");
    _builder_1.newLine();
    final IFile type2 = this.workbenchTestHelper.createFile("Type2.xtend", _builder_1.toString());
    IResourcesSetupUtil.waitForBuild();
    this.assertNoErrorsInWorkspace();
    StringConcatenation _builder_2 = new StringConcatenation();
    _builder_2.append("class Type3 {");
    _builder_2.newLine();
    _builder_2.append("}");
    _builder_2.newLine();
    StringInputStream _stringInputStream = new StringInputStream(_builder_2.toString());
    type1.setContents(_stringInputStream, true, true, null);
    IResourcesSetupUtil.waitForBuild();
    this.assertHasErrors(type2, "Type1");
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}