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

The following examples show how to use org.eclipse.xtext.ui.testing.util.IResourcesSetupUtil#addNature() . 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: 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 2
Source File: LiveShadowedAllContainerStateTest.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
@Test
public void testInMemoryResourceWithProject() {
  try {
    final IProject project = IResourcesSetupUtil.createProject("MyProject");
    IResourcesSetupUtil.addNature(project, XtextProjectHelper.NATURE_ID);
    final ResourceSet rs = this.liveScopeResourceSetProvider.get(project);
    String _primaryFileExtension = this._fileExtensionProvider.getPrimaryFileExtension();
    String _plus = ("MyProject/myfile." + _primaryFileExtension);
    final Resource resource = rs.createResource(URI.createPlatformResourceURI(_plus, true));
    StringInputStream _stringInputStream = new StringInputStream("stuff foo");
    resource.load(_stringInputStream, CollectionLiterals.<Object, Object>emptyMap());
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("container MyProject isEmpty=false {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("resourceURI=platform:/resource/MyProject/myfile.testlanguage exported=[foo]");
    _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 3
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 4
Source File: LiveShadowedAllContainerStateTest.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
@Test
public void testPersistedWithoutResource() {
  try {
    final IProject project = IResourcesSetupUtil.createProject("MyProject");
    IResourcesSetupUtil.addNature(project, XtextProjectHelper.NATURE_ID);
    String _primaryFileExtension = this._fileExtensionProvider.getPrimaryFileExtension();
    final String fileName = ("MyProject/myfile." + _primaryFileExtension);
    IResourcesSetupUtil.createFile(fileName, "stuff foo");
    IResourcesSetupUtil.waitForBuild();
    final ResourceSet rs = this.liveScopeResourceSetProvider.get(project);
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("container MyProject isEmpty=false {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("resourceURI=platform:/resource/MyProject/myfile.testlanguage exported=[foo]");
    _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 5
Source File: LiveShadowedAllContainerStateTest.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
@Test
public void testPersistedWithResource() {
  try {
    final IProject project = IResourcesSetupUtil.createProject("MyProject");
    IResourcesSetupUtil.addNature(project, XtextProjectHelper.NATURE_ID);
    String _primaryFileExtension = this._fileExtensionProvider.getPrimaryFileExtension();
    final String fileName = ("MyProject/myfile." + _primaryFileExtension);
    IResourcesSetupUtil.createFile(fileName, "stuff foo");
    IResourcesSetupUtil.waitForBuild();
    final ResourceSet rs = this.liveScopeResourceSetProvider.get(project);
    Assert.assertNotNull(rs.getResource(URI.createPlatformResourceURI(fileName, true), true));
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("container MyProject isEmpty=false {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("resourceURI=platform:/resource/MyProject/myfile.testlanguage exported=[foo]");
    _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 6
Source File: XtendJavaElementDelegateJunitLaunchTest.java    From xtext-xtend with Eclipse Public License 2.0 6 votes vote down vote up
private IFile dslFile(final CharSequence text) {
  try {
    IFile _xblockexpression = null;
    {
      final IFile file = IResourcesSetupUtil.createFile(this.getProjectName(), "src/foo/FooTest", this._fileExtensionProvider.getPrimaryFileExtension(), this.getContent(text));
      final IProject project = file.getProject();
      boolean _hasNature = project.hasNature(XtextProjectHelper.NATURE_ID);
      boolean _not = (!_hasNature);
      if (_not) {
        IResourcesSetupUtil.addNature(project, XtextProjectHelper.NATURE_ID);
      }
      IResourcesSetupUtil.fullBuild();
      _xblockexpression = file;
    }
    return _xblockexpression;
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
Example 7
Source File: AbstractResourceRelocationTest.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
@Before
public void setup() throws Exception {
	IResourcesSetupUtil.setAutobuild(false);
	project = IResourcesSetupUtil.createProject("test");
	IResourcesSetupUtil.addNature(project, XtextProjectHelper.NATURE_ID);
	IResourcesSetupUtil.addBuilder(project, XtextProjectHelper.BUILDER_ID);
}
 
Example 8
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 9
Source File: MarkOccurrencesTest.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public void setUp() throws Exception {
	super.setUp();
	IJavaProject project = JavaProjectSetupUtil.createJavaProject("MarkOccurrencesTest");
	IResourcesSetupUtil.addNature(project.getProject(), XtextProjectHelper.NATURE_ID);
	IResourcesSetupUtil.waitForBuild();
	setMarkOccurrences(false);
}
 
Example 10
Source File: LiveShadowedAllContainerStateTest.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void testPersistedWithOtherResource() {
  try {
    final IProject project = IResourcesSetupUtil.createProject("MyProject");
    IResourcesSetupUtil.addNature(project, XtextProjectHelper.NATURE_ID);
    String _primaryFileExtension = this._fileExtensionProvider.getPrimaryFileExtension();
    final String fileName = ("MyProject/myfile1." + _primaryFileExtension);
    IResourcesSetupUtil.createFile(fileName, "stuff foo");
    IResourcesSetupUtil.waitForBuild();
    final ResourceSet rs = this.liveScopeResourceSetProvider.get(project);
    String _primaryFileExtension_1 = this._fileExtensionProvider.getPrimaryFileExtension();
    String _plus = ("MyProject/myfile2." + _primaryFileExtension_1);
    final Resource resource = rs.createResource(URI.createPlatformResourceURI(_plus, true));
    StringInputStream _stringInputStream = new StringInputStream("stuff bar");
    resource.load(_stringInputStream, CollectionLiterals.<Object, Object>emptyMap());
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("container MyProject isEmpty=false {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("resourceURI=platform:/resource/MyProject/myfile1.testlanguage exported=[foo]");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("resourceURI=platform:/resource/MyProject/myfile2.testlanguage exported=[bar]");
    _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 11
Source File: AutoEditTest.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
private void createTestProjectWithXtextNature() {
  try {
    IResourcesSetupUtil.addNature(IResourcesSetupUtil.createProject("foo"), XtextProjectHelper.NATURE_ID);
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
Example 12
Source File: AbstractEditorTest.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
protected IFile dslFile(String projectName, String fileName, String fileExtension, CharSequence content) {
	try {
		IFile file = IResourcesSetupUtil.createFile(projectName, fileName, fileExtension, content.toString());
		IProject project = file.getProject();
		if (!project.hasNature(XtextProjectHelper.NATURE_ID)) {
			IResourcesSetupUtil.addNature(project, XtextProjectHelper.NATURE_ID);
		}
		return file;
	} catch (InvocationTargetException | CoreException | InterruptedException e) {
		throw new RuntimeException(e);
	}
}