org.eclipse.xtext.builder.nature.ToggleXtextNatureCommand Java Examples

The following examples show how to use org.eclipse.xtext.builder.nature.ToggleXtextNatureCommand. 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: PerformanceTestProjectSetup.java    From xtext-xtend with Eclipse Public License 2.0 6 votes vote down vote up
public static void setUp() throws Exception {
	testProject = createJavaProject("performance.test.project",
			new String[] {
					JavaCore.NATURE_ID,
					"org.eclipse.pde.PluginNature"
			}
	);
	new ToggleXtextNatureCommand().toggleNature(testProject.getProject());
	IFolder sourceFolder = JavaProjectSetupUtil.addSourceFolder(testProject, "src");
	JavaProjectSetupUtil.addSourceFolder(testProject, "xtend-gen");

	List<String> filesToCopy = readResource("/files.list");
	
	for(String fileToCopy: filesToCopy) {
		IPath filePath = new Path(fileToCopy);
		IFolder packageFolder = sourceFolder.getFolder(filePath.removeLastSegments(1));
		if (!packageFolder.exists())
			createFolderRecursively(packageFolder);
		List<String> content = readResource(fileToCopy);
		String contentAsString = Strings.concat("\n", content);
		String fileName = filePath.lastSegment();
		createFile(fileName.substring(0, fileName.length() - ".txt".length()), packageFolder, contentAsString);
	}
	waitForBuild();
}
 
Example #2
Source File: BuilderPerformanceTest.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
private void toggleNature(IJavaProject javaProject1) {
	long before = System.currentTimeMillis();
	new ToggleXtextNatureCommand().toggleNature(javaProject1.getProject());
	build();
	if (doPrint) {
		System.out.println("Toggle Nature - Took " + (System.currentTimeMillis() - before) + "ms");
	}
}
 
Example #3
Source File: PerformanceTest.java    From xtext-xtend with Eclipse Public License 2.0 4 votes vote down vote up
@Test
public void testBuildOfDownstreamProject() throws Exception {
  final IJavaProject project = PerformanceTestProjectSetup.testProject;
  final IJavaProject downStreamProject = PerformanceTestProjectSetup.createJavaProject("performance.test.project.downstream", 
    new String[] { JavaCore.NATURE_ID, "org.eclipse.pde.PluginNature" });
  JavaProjectSetupUtil.addProjectReference(downStreamProject, project);
  new ToggleXtextNatureCommand().toggleNature(downStreamProject.getProject());
  final IFolder sourceFolder = JavaProjectSetupUtil.addSourceFolder(downStreamProject, "src");
  JavaProjectSetupUtil.addSourceFolder(downStreamProject, "xtend-gen");
  sourceFolder.getFolder("foo").create(true, true, null);
  final IFile sourceFile = sourceFolder.getFile("foo/MyFile.xtend");
  StringConcatenation _builder = new StringConcatenation();
  _builder.append("package foo");
  _builder.newLine();
  _builder.newLine();
  _builder.append("import org.eclipse.xtext.xbase.formatting.BasicFormatterPreferenceKeys");
  _builder.newLine();
  _builder.append("import org.eclipse.xtext.xbase.formatting.FormattableDocument");
  _builder.newLine();
  _builder.append("import org.eclipse.xtext.xbase.formatting.HiddenLeafAccess");
  _builder.newLine();
  _builder.append("import org.eclipse.xtext.xbase.formatting.NodeModelAccess");
  _builder.newLine();
  _builder.append("import org.eclipse.xtext.xbase.formatting.XbaseFormatter2");
  _builder.newLine();
  _builder.newLine();
  _builder.append("class MyFile extends XbaseFormatter2 {");
  _builder.newLine();
  _builder.append("\t");
  _builder.newLine();
  _builder.append("\t");
  _builder.append("def a(BasicFormatterPreferenceKeys keys) {");
  _builder.newLine();
  _builder.append("\t\t");
  _builder.append("BasicFormatterPreferenceKeys::indentation");
  _builder.newLine();
  _builder.append("\t");
  _builder.append("}");
  _builder.newLine();
  _builder.append("\t");
  _builder.newLine();
  _builder.append("\t");
  _builder.append("def b(FormattableDocument doc) {");
  _builder.newLine();
  _builder.append("\t\t");
  _builder.append("doc.cfg.get(BasicFormatterPreferenceKeys::indentation)");
  _builder.newLine();
  _builder.append("\t");
  _builder.append("}");
  _builder.newLine();
  _builder.append("\t");
  _builder.newLine();
  _builder.append("\t");
  _builder.append("def c(HiddenLeafAccess x) {");
  _builder.newLine();
  _builder.append("\t\t");
  _builder.append("x.getHiddenLeafsAfter(null).newLines");
  _builder.newLine();
  _builder.append("\t");
  _builder.append("}");
  _builder.newLine();
  _builder.append("\t");
  _builder.newLine();
  _builder.append("\t");
  _builder.append("def d(NodeModelAccess x) {");
  _builder.newLine();
  _builder.append("\t\t");
  _builder.append("x.nodeForEObject(null).asTreeIterable");
  _builder.newLine();
  _builder.append("\t");
  _builder.append("}");
  _builder.newLine();
  _builder.append("}");
  _builder.newLine();
  StringInputStream _stringInputStream = new StringInputStream(_builder.toString());
  sourceFile.create(_stringInputStream, true, null);
  final IProject p = downStreamProject.getProject();
  p.build(IncrementalProjectBuilder.FULL_BUILD, null);
  p.build(IncrementalProjectBuilder.FULL_BUILD, null);
  Stopwatches.resetAll();
  p.build(IncrementalProjectBuilder.FULL_BUILD, null);
}