org.eclipse.core.resources.IncrementalProjectBuilder Java Examples

The following examples show how to use org.eclipse.core.resources.IncrementalProjectBuilder. 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: LangNature.java    From goclipse with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Adds a builder to the build spec for the configured project.
 */
protected void addToBuildSpec(String builderID) throws CoreException {
	IProjectDescription description = project.getDescription();
	ICommand[] commands = description.getBuildSpec();
	int commandIndex = getCommandIndex(commands, builderID);
	if (commandIndex == -1) {
		ICommand command = description.newCommand();
		command.setBuilderName(builderID);
		command.setBuilding(IncrementalProjectBuilder.AUTO_BUILD, false);
		
		// Add a build command to the build spec
		ICommand[] newCommands = ArrayUtil.prepend(command, commands);
		description.setBuildSpec(newCommands);
		project.setDescription(description, null);
	}
}
 
Example #2
Source File: Repository.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void build(IProgressMonitor monitor) {
    if (isBuildEnable()) {
        try {
            if (monitor == null) {
                monitor = NULL_PROGRESS_MONITOR;
            }
            if (!getProject().isSynchronized(IResource.DEPTH_ONE)) {
                getProject().refreshLocal(IResource.DEPTH_ONE, monitor);
            }
            new ProjectClasspathFactory().refresh(this, monitor);
            project.build(IncrementalProjectBuilder.INCREMENTAL_BUILD, monitor);
        } catch (final Exception ex) {
            BonitaStudioLog.error(ex);
        }
    }
}
 
Example #3
Source File: BuilderUtilities.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Schedules a full rebuild on a project.
 * 
 * @param project the project to rebuild
 */
public static void scheduleRebuild(final IProject project) {
  WorkspaceJob buildJob = new WorkspaceJob("Building " + project.getName()) {
    @Override
    public boolean belongsTo(Object family) {
      return ResourcesPlugin.FAMILY_MANUAL_BUILD.equals(family);
    }

    @Override
    public IStatus runInWorkspace(IProgressMonitor monitor)
        throws CoreException {
      project.build(IncrementalProjectBuilder.FULL_BUILD, monitor);
      return Status.OK_STATUS;
    }
  };

  buildJob.setRule(ResourcesPlugin.getWorkspace().getRuleFactory().buildRule());
  buildJob.setUser(true);
  buildJob.schedule();
}
 
Example #4
Source File: DependencyFileStore.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
@Override
protected void doDelete() {
    try {
        final IResource r = getResource();
        if (r != null && r.exists()) {
            r.delete(true, Repository.NULL_PROGRESS_MONITOR);
            final Repository repository = getRepository();
            final IProject project = repository.getProject();
            project.refreshLocal(IResource.DEPTH_ONE, Repository.NULL_PROGRESS_MONITOR);
            if (repository.isBuildEnable()) {
                project.build(IncrementalProjectBuilder.INCREMENTAL_BUILD, Repository.NULL_PROGRESS_MONITOR);
            }

        }
    } catch (final CoreException e) {
        BonitaStudioLog.error(e);
    }
}
 
Example #5
Source File: SyntaxErrorsView.java    From gama with GNU General Public License v3.0 6 votes vote down vote up
static private void doBuild(final IProgressMonitor monitor) {
	try {
		ResourcesPlugin.getWorkspace().build(IncrementalProjectBuilder.CLEAN_BUILD, monitor);

		// monitor.beginTask("Cleaning and building entire workspace", size);
		// for (final IProject p : projects) {
		// if (p.exists() && p.isAccessible()) {
		// monitor.subTask("Building " + p.getName());
		// p.build(IncrementalProjectBuilder.CLEAN_BUILD, monitor);
		// monitor.worked(1);
		// }
		// }

	} catch (final CoreException e) {
		e.printStackTrace();
	}
}
 
Example #6
Source File: JSMetadataLoader.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
/**
 * rebuildProjectIndexes
 */
private void rebuildProjectIndexes()
{
	Job job = new Job(Messages.JSMetadataLoader_Rebuilding_Project_Indexes)
	{
		@Override
		protected IStatus run(IProgressMonitor monitor)
		{
			IWorkspace ws = ResourcesPlugin.getWorkspace();

			try
			{
				ws.build(IncrementalProjectBuilder.FULL_BUILD, monitor);
			}
			catch (final CoreException e)
			{
				return e.getStatus();
			}

			return Status.OK_STATUS;
		}
	};

	job.schedule();
}
 
Example #7
Source File: BuildActionGroup.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
private BuildActionGroup(IWorkbenchSite site, ISelectionProvider specialSelectionProvider, RefreshAction refreshAction) {
	fSelectionProvider= specialSelectionProvider != null ? specialSelectionProvider : site.getSelectionProvider();

	fBuildAction= new BuildAction(new ShellProviderAdapter(site.getShell()), IncrementalProjectBuilder.INCREMENTAL_BUILD);
	fBuildAction.setText(ActionMessages.BuildAction_label);
	fBuildAction.setActionDefinitionId(IWorkbenchCommandConstants.PROJECT_BUILD_PROJECT);

	fRefreshAction= refreshAction;
	fRefreshAction.setActionDefinitionId(IWorkbenchCommandConstants.FILE_REFRESH);

	if (specialSelectionProvider != null) {
		fRefreshAction.setSpecialSelectionProvider(specialSelectionProvider);
	}

	fSelectionProvider.addSelectionChangedListener(fBuildAction);
	fSelectionProvider.addSelectionChangedListener(fRefreshAction);
}
 
Example #8
Source File: AddParameterWizard.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
@Override
public boolean performFinish() {
    editingDomain.getCommandStack().execute(
            AddCommand.create(editingDomain, container,
                    ProcessPackage.Literals.ABSTRACT_PROCESS__PARAMETERS,
                    parameterWorkingCopy));

    try {
        RepositoryManager.getInstance().getCurrentRepository().getProject()
                .build(IncrementalProjectBuilder.FULL_BUILD, XtextProjectHelper.BUILDER_ID, Collections.<String, String> emptyMap(), null);
    } catch (final CoreException e1) {
        BonitaStudioLog.error(e1, ParameterPlugin.PLUGIN_ID);
        return false;
    }

    return true;
}
 
Example #9
Source File: JavaUtils.java    From developer-studio with Apache License 2.0 6 votes vote down vote up
public static File buildProject(IProject project) throws CoreException{
	project.build(IncrementalProjectBuilder.CLEAN_BUILD, new NullProgressMonitor());
	project.build(IncrementalProjectBuilder.FULL_BUILD, new NullProgressMonitor());
	IMarker[] markers;
	markers = project.findMarkers(IMarker.PROBLEM, true,IResource.DEPTH_INFINITE);
	boolean errorsExists=false;
	StringBuffer sb=new StringBuffer();
	for (IMarker marker : markers) {
		if(marker.getAttribute(IMarker.SEVERITY, IMarker.SEVERITY_ERROR) == IMarker.SEVERITY_ERROR) {
			sb.append(marker.getAttribute(IMarker.MESSAGE)).append("\n");
			errorsExists=true;
		}
	}
	if (errorsExists){
		throw new CoreException(new Status(IStatus.ERROR,Activator.PLUGIN_ID,"Compilation error exists in the project "+project.getName()+". Please resolve these error before continuing:\n"+sb.toString()));
	}
	return new File(project.getWorkspace().getRoot().getFolder(getJavaOutputDirectory(project)).getLocation().toOSString());
}
 
Example #10
Source File: IntegrationTest.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
@Test public void testCleanBuild() throws Exception {
	IJavaProject project = createJavaProject("foo");
	addNature(project.getProject(), XtextProjectHelper.NATURE_ID);
	IFolder folder = project.getProject().getFolder("src");
	IFile file = folder.getFile("Foo" + F_EXT);
	file.create(new StringInputStream("object Foo"), true, monitor());
	build();
	assertTrue(indexContainsElement(file.getFullPath().toString(), "Foo"));
	assertEquals(1, countResourcesInIndex());

	getBuilderState().addListener(this);
	project.getProject().build(IncrementalProjectBuilder.CLEAN_BUILD, monitor());
	build();
	// clean build should first remove the IResourceDescriptor and then add it again  
	assertEquals(2, getEvents().size());
	assertEquals(1, getEvents().get(0).getDeltas().size());
	assertNotNull(getEvents().get(0).getDeltas().get(0).getOld());
	assertNull(getEvents().get(0).getDeltas().get(0).getNew());
	assertEquals(1, getEvents().get(1).getDeltas().size());
	assertNull(getEvents().get(1).getDeltas().get(0).getOld());
	assertNotNull(getEvents().get(1).getDeltas().get(0).getNew());
}
 
Example #11
Source File: CheckstyleBuilder.java    From eclipse-cs with GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
 * Builds all checkstyle enabled projects that are open from the given collection of projects.
 *
 * @param projects
 *          the projects to build
 * @throws CheckstylePluginException
 *           Error during the build
 */
public static void buildProjects(final Collection<IProject> projects)
        throws CheckstylePluginException {

  // Build only open projects with Checkstyle enabled
  List<IProject> checkstyleProjects = new ArrayList<>();

  for (IProject project : projects) {

    try {
      if (project.exists() && project.isOpen() && project.hasNature(CheckstyleNature.NATURE_ID)) {
        checkstyleProjects.add(project);
      }
    } catch (CoreException e) {
      CheckstylePluginException.rethrow(e);
    }
  }

  // uses the new Jobs API to run the build in the background
  BuildProjectJob buildJob = new BuildProjectJob(
          checkstyleProjects.toArray(new IProject[checkstyleProjects.size()]),
          IncrementalProjectBuilder.FULL_BUILD);
  buildJob.setRule(ResourcesPlugin.getWorkspace().getRoot());
  buildJob.schedule();
}
 
Example #12
Source File: ASTReader.java    From JDeodorant with MIT License 6 votes vote down vote up
private List<IMarker> buildProject(IJavaProject iJavaProject, IProgressMonitor pm) {
	ArrayList<IMarker> result = new ArrayList<IMarker>();
	try {
		IProject project = iJavaProject.getProject();
		project.refreshLocal(IResource.DEPTH_INFINITE, pm);	
		project.build(IncrementalProjectBuilder.INCREMENTAL_BUILD, pm);
		IMarker[] markers = null;
		markers = project.findMarkers(IJavaModelMarker.JAVA_MODEL_PROBLEM_MARKER, true, IResource.DEPTH_INFINITE);
		for (IMarker marker: markers) {
			Integer severityType = (Integer) marker.getAttribute(IMarker.SEVERITY);
			if (severityType.intValue() == IMarker.SEVERITY_ERROR) {
				result.add(marker);
			}
		}
	} catch (CoreException e) {
		e.printStackTrace();
	}
	return result;
}
 
Example #13
Source File: JCasGenM2ETest.java    From uima-uimaj with Apache License 2.0 6 votes vote down vote up
public void testEmptyOutputDirectory() throws Exception {
  ResolverConfiguration configuration = new ResolverConfiguration();
  IProject project = importProject("target/projects/jcasgen/simple/pom.xml", configuration);
  waitForJobsToComplete();
  assertNoErrors(project);

  project.build(IncrementalProjectBuilder.INCREMENTAL_BUILD, monitor);
  waitForJobsToComplete();
  assertNoErrors(project);

  // make sure the Java sources were generated
  assertTrue(project.getFolder("target/generated-sources/jcasgen").exists());

  // remove the generated directory
  project.getFolder("target/generated-sources/jcasgen").delete(IProject.FORCE, monitor);
  assertFalse(project.getFolder("target/generated-sources/jcasgen").exists());

  // re-build
  project.build(IncrementalProjectBuilder.INCREMENTAL_BUILD, monitor);
  waitForJobsToComplete();
  assertNoErrors(project);

  // make sure the Java sources were generated
  assertTrue(project.getFolder("target/generated-sources/jcasgen").exists());
}
 
Example #14
Source File: SimpleProjectsIntegrationTest.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
@Test public void testCleanBuild() throws Exception {
	IProject project = createProject("foo");
	addNature(project.getProject(), XtextProjectHelper.NATURE_ID);
	IFolder folder = createSubFolder(project, "subFolder");
	IFile file = folder.getFile("Foo" + F_EXT);
	file.create(new StringInputStream("object Foo"), true, monitor());
	build();
	assertTrue(indexContainsElement(file.getFullPath().toString(),"Foo"));
	assertEquals(1, countResourcesInIndex());
	
	getBuilderState().addListener(this);
	
	project.getProject().build(IncrementalProjectBuilder.CLEAN_BUILD, monitor());
	assertEquals(1, getEvents().size());
	build();
	// clean build should first remove the IResourceDescriptor and then add it again  
	assertEquals(2, getEvents().size());
	assertEquals(1, getEvents().get(0).getDeltas().size());
	assertNotNull(getEvents().get(0).getDeltas().get(0).getOld());
	assertNull(getEvents().get(0).getDeltas().get(0).getNew());
	assertEquals(1,getEvents().get(1).getDeltas().size());
	assertNull(getEvents().get(1).getDeltas().get(0).getOld());
	assertNotNull(getEvents().get(1).getDeltas().get(0).getNew());
}
 
Example #15
Source File: XSPParentEditor.java    From XPagesExtensionLibrary with Apache License 2.0 6 votes vote down vote up
@Override
public void doSave(IProgressMonitor progress) {
    if (isDirty()) {
        // save the contents of the source editor, always
        pfe.doSave(progress);
        dbBean.save(progress);  // no real saving here, but some necessary cleanup
        xspDesignPropsBean.save(progress);
        page1.getDataNode().setModelModified(false);
        page2.getDataNode().setModelModified(false);
        page3.getDataNode().setModelModified(false);
        setModified(false);
        
        if (isBPromptRecompileOnExit()) {
            if( LWPDMessageDialog.openQuestion(null, "Domino Designer", // $NLX-XSPParentEditor.DominoDesigner-1$
                "You have changed the minimum supported version for XPages in this application.  Do you want to rebuild this application now?") ) {  // $NLX-XSPParentEditor.Youhavechangedtheminimumsupported-1$
                try {
                    getDesignerProject().build(IncrementalProjectBuilder.FULL_BUILD, new NullProgressMonitor());
                } catch (CoreException e) {
                }
            }
            setBPromptRecompileOnExit(false);   // if they chose no, still should not prompt again
        }
        NSFComponentModule.setLastDesignerSave(System.currentTimeMillis()); 
    }
}
 
Example #16
Source File: ProjectUtils.java    From XPagesExtensionLibrary with Apache License 2.0 5 votes vote down vote up
public static void buildProject(final IProject project) throws Exception {
    try {
        project.build(IncrementalProjectBuilder.CLEAN_BUILD, null);
        project.build(IncrementalProjectBuilder.INCREMENTAL_BUILD, null);
    } catch (Exception e) {
        throw new Exception("Could not build project", e); // $NLX-ProjectUtils.Couldnotbuildproject-1$
    }

    IMarker[] markers = project.findMarkers(IJavaModelMarker.JAVA_MODEL_PROBLEM_MARKER, true, IResource.DEPTH_INFINITE);
    if (markers.length > 0) {
        throw new Exception("Plug-in project did not compile. Ensure that the Class and JAR files are correct."); // $NLX-ProjectUtils.PluginprojectdidnotcompileEnsuret-1$
    }
}
 
Example #17
Source File: CheckLoaderDialog.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
public void downloadBaseloader(final Shell shell, int id) {
	try {
		DownLoadJob downloadjob = new DownLoadJob(Messages.DOWNLOADOFFICIALLOADER, id);
		downloadjob.setUser(true);
		downloadjob.schedule();

		downloadjob.addJobChangeListener(new JobChangeAdapter() {
			public void done(IJobChangeEvent event) {
				if (event.getResult().isOK())
					Display.getDefault().syncExec(new Runnable() {
						public void run() {
							MessageDialog.openInformation(null, Messages.DOWNLOADSUCCESS,
									Messages.LOADERDOWNLOADSUCC);
						}
					});
				else
					Display.getDefault().syncExec(new Runnable() {
						public void run() {
							MessageDialog.openError(null, Messages.DOWNLOADEXCEPTION, Messages.DOWNLOADERROR);
						}
					});
				close();
			}
		});

		ResourcesPlugin.getWorkspace().build(
				IncrementalProjectBuilder.CLEAN_BUILD, null);
		ResourcesPlugin.getWorkspace().getRoot()
				.refreshLocal(IResource.DEPTH_INFINITE, null);
	com.apicloud.loader.platforms.android.ADBActivator.setHasBaseLoader(true);
	com.apicloud.loader.platforms.android.ADBActivator.setHasAppLoader(true);
	} catch (Exception e) {
		e.printStackTrace();
	}
}
 
Example #18
Source File: ProjectArtifactHandler.java    From developer-studio with Apache License 2.0 5 votes vote down vote up
protected void clearTarget(IProject project) {
	try {
		project.build(IncrementalProjectBuilder.CLEAN_BUILD, getProgressMonitor());
		File target = project.getFolder("target").getLocation().toFile();
		FileUtils.cleanDirectory(target);
	} catch (Exception e) {
		log.error("Error while cleaning the target directory", e);
	}
}
 
Example #19
Source File: DocumentWizard.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
private void refreshProject() {
    try {
        RepositoryManager.getInstance().getCurrentRepository().getProject()
                .build(IncrementalProjectBuilder.FULL_BUILD, XTEXT_BUILDER_ID, Collections.<String, String> emptyMap(),
                        null);
    } catch (final CoreException e1) {
        BonitaStudioLog.error(e1, DocumentPlugin.PLUGIN_ID);
    }
}
 
Example #20
Source File: ProjectArtifactHandler.java    From developer-studio with Apache License 2.0 5 votes vote down vote up
/**
 * 
 * @param project
 * @return
 * @throws Exception
 */
protected IPath buildJavaProject(IProject project) throws Exception {
	project.build(IncrementalProjectBuilder.CLEAN_BUILD, getProgressMonitor());
	project.build(IncrementalProjectBuilder.FULL_BUILD, getProgressMonitor());
	IJavaProject javaProject = JavaCore.create(project);
	return getOutputPath(javaProject);
}
 
Example #21
Source File: GTestHelper.java    From statecharts with Eclipse Public License 1.0 5 votes vote down vote up
protected void performFullBuild() {
	try {
		ResourcesPlugin.getWorkspace().build(IncrementalProjectBuilder.FULL_BUILD, null);
	} catch (CoreException e) {
		throw new RuntimeException(e);
	}
}
 
Example #22
Source File: UniqueClassNameValidatorUITest.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void testTwoXtendFilesSameProject() {
  try {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("package acme");
    _builder.newLine();
    _builder.append("class A {");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    final IFile firstFile = IResourcesSetupUtil.createFile("first.p384008/src/acme/A.xtend", _builder.toString());
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("package acme");
    _builder_1.newLine();
    _builder_1.append("class A {");
    _builder_1.newLine();
    _builder_1.append("}");
    _builder_1.newLine();
    final IFile secondFile = IResourcesSetupUtil.createFile("first.p384008/src/acme/B.xtend", _builder_1.toString());
    final IWorkspaceRunnable _function = (IProgressMonitor it) -> {
      this.first.build(IncrementalProjectBuilder.INCREMENTAL_BUILD, XtextBuilder.BUILDER_ID, UniqueClassNameValidatorUITest.emptyStringMap(), null);
    };
    this.runInWorkspace(_function);
    final IMarker[] firstFileMarkers = firstFile.findMarkers(IMarker.PROBLEM, true, IResource.DEPTH_INFINITE);
    Assert.assertEquals(IResourcesSetupUtil.printMarker(firstFileMarkers), 1, firstFileMarkers.length);
    Assert.assertEquals("The type A is already defined in B.xtend.", IterableExtensions.<IMarker>head(((Iterable<IMarker>)Conversions.doWrapArray(firstFileMarkers))).getAttribute(IMarker.MESSAGE));
    final Iterable<IMarker> secondFileMarkers = this.onlyErrors(((Iterable<IMarker>)Conversions.doWrapArray(secondFile.findMarkers(IMarker.PROBLEM, true, IResource.DEPTH_INFINITE))));
    Assert.assertEquals(IResourcesSetupUtil.printMarker(((IMarker[])Conversions.unwrapArray(secondFileMarkers, IMarker.class))), 1, ((Object[])Conversions.unwrapArray(secondFileMarkers, Object.class)).length);
    Assert.assertEquals("The type A is already defined in A.xtend.", IterableExtensions.<IMarker>head(secondFileMarkers).getAttribute(IMarker.MESSAGE));
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
Example #23
Source File: DeployJob.java    From dsl-devkit with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Builds the project.
 *
 * @return the file
 * @throws CoreException
 *           the core exception
 */
private File buildProject() throws CoreException {
  /*
   * Doing clean build takes too long with Xtend. With auto build even full build is not necessary,
   * but keep full build in case auto build is disabled. Then bin folder may be outdated or even empty.
   * project.build(IncrementalProjectBuilder.CLEAN_BUILD, new NullProgressMonitor());
   */
  project.build(IncrementalProjectBuilder.FULL_BUILD, new NullProgressMonitor());
  return new File(project.getWorkspace().getRoot().getFolder(getJavaOutputDirectory()).getLocation().toOSString());
}
 
Example #24
Source File: UniqueClassNameValidatorUITest.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void testXtendAndJavaDifferentProject() {
  try {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("package acme;");
    _builder.newLine();
    _builder.append("public class A {");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    IResourcesSetupUtil.createFile("first.p384008/src/acme/A.java", _builder.toString());
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("package acme");
    _builder_1.newLine();
    _builder_1.append("class A {");
    _builder_1.newLine();
    _builder_1.append("}");
    _builder_1.newLine();
    final IFile secondFile = IResourcesSetupUtil.createFile("second.p384008/src/acme/B.xtend", _builder_1.toString());
    final IWorkspaceRunnable _function = (IProgressMonitor it) -> {
      this.first.build(IncrementalProjectBuilder.INCREMENTAL_BUILD, XtextBuilder.BUILDER_ID, UniqueClassNameValidatorUITest.emptyStringMap(), null);
      this.first.build(IncrementalProjectBuilder.INCREMENTAL_BUILD, JavaCore.BUILDER_ID, UniqueClassNameValidatorUITest.emptyStringMap(), null);
    };
    this.runInWorkspace(_function);
    final IMarker[] secondFileMarkers = secondFile.findMarkers(IMarker.PROBLEM, true, IResource.DEPTH_INFINITE);
    Assert.assertEquals(IResourcesSetupUtil.printMarker(secondFileMarkers), 0, secondFileMarkers.length);
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
Example #25
Source File: UniqueClassNameValidatorUITest.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void testXtendAndJavaSameProject() {
  try {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("package acme;");
    _builder.newLine();
    _builder.append("public class A {");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    IResourcesSetupUtil.createFile("first.p384008/src/acme/A.java", _builder.toString());
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("package acme");
    _builder_1.newLine();
    _builder_1.append("class A {");
    _builder_1.newLine();
    _builder_1.append("}");
    _builder_1.newLine();
    final IFile secondFile = IResourcesSetupUtil.createFile("first.p384008/src/acme/B.xtend", _builder_1.toString());
    final IWorkspaceRunnable _function = (IProgressMonitor it) -> {
      this.first.build(IncrementalProjectBuilder.INCREMENTAL_BUILD, XtextBuilder.BUILDER_ID, UniqueClassNameValidatorUITest.emptyStringMap(), null);
      this.first.build(IncrementalProjectBuilder.INCREMENTAL_BUILD, JavaCore.BUILDER_ID, UniqueClassNameValidatorUITest.emptyStringMap(), null);
    };
    this.runInWorkspace(_function);
    final Iterable<IMarker> secondFileMarkers = this.onlyErrors(((Iterable<IMarker>)Conversions.doWrapArray(secondFile.findMarkers(IMarker.PROBLEM, true, IResource.DEPTH_INFINITE))));
    Assert.assertEquals(IResourcesSetupUtil.printMarker(((IMarker[])Conversions.unwrapArray(secondFileMarkers, IMarker.class))), 1, ((Object[])Conversions.unwrapArray(secondFileMarkers, Object.class)).length);
    Assert.assertEquals("The type A is already defined in A.java.", IterableExtensions.<IMarker>head(secondFileMarkers).getAttribute(IMarker.MESSAGE));
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
Example #26
Source File: PerformanceTest.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void testCleanFullBuild() throws Exception {
  final IProject project = PerformanceTestProjectSetup.testProject.getProject();
  project.build(IncrementalProjectBuilder.CLEAN_BUILD, null);
  project.build(IncrementalProjectBuilder.FULL_BUILD, null);
  project.build(IncrementalProjectBuilder.CLEAN_BUILD, null);
  project.build(IncrementalProjectBuilder.FULL_BUILD, null);
  Stopwatches.resetAll();
  project.build(IncrementalProjectBuilder.CLEAN_BUILD, null);
  project.build(IncrementalProjectBuilder.FULL_BUILD, null);
}
 
Example #27
Source File: PerformanceTest.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void testFullBuild() throws Exception {
  final IProject project = PerformanceTestProjectSetup.testProject.getProject();
  project.build(IncrementalProjectBuilder.FULL_BUILD, null);
  project.build(IncrementalProjectBuilder.FULL_BUILD, null);
  Stopwatches.resetAll();
  project.build(IncrementalProjectBuilder.FULL_BUILD, null);
}
 
Example #28
Source File: PerformanceTest.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void testCleanBuild() throws Exception {
  final IProject project = PerformanceTestProjectSetup.testProject.getProject();
  project.build(IncrementalProjectBuilder.CLEAN_BUILD, null);
  project.build(IncrementalProjectBuilder.CLEAN_BUILD, null);
  Stopwatches.resetAll();
  project.build(IncrementalProjectBuilder.CLEAN_BUILD, null);
}
 
Example #29
Source File: UniqueClassNameValidatorUITest.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
@Ignore("Since the name acme.A is considered to be derived, it is filtered from the Java delta")
@Test
public void testXtendAndJavaSameProjectXtendFirst() {
  try {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("package acme");
    _builder.newLine();
    _builder.append("class A {");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    final IFile firstFile = IResourcesSetupUtil.createFile("first.p384008/src/acme/B.xtend", _builder.toString());
    this.first.build(IncrementalProjectBuilder.INCREMENTAL_BUILD, XtextBuilder.BUILDER_ID, UniqueClassNameValidatorUITest.emptyStringMap(), null);
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("package acme;");
    _builder_1.newLine();
    _builder_1.append("class A2 {");
    _builder_1.newLine();
    _builder_1.append("}");
    _builder_1.newLine();
    final IFile javaFile = IResourcesSetupUtil.createFile("first.p384008/src/acme/A.java", _builder_1.toString());
    this.first.build(IncrementalProjectBuilder.INCREMENTAL_BUILD, JavaCore.BUILDER_ID, UniqueClassNameValidatorUITest.emptyStringMap(), null);
    this.first.build(IncrementalProjectBuilder.INCREMENTAL_BUILD, XtextBuilder.BUILDER_ID, UniqueClassNameValidatorUITest.emptyStringMap(), null);
    StringInputStream _stringInputStream = new StringInputStream("package acme; class A{}");
    javaFile.setContents(_stringInputStream, false, false, null);
    this.first.build(IncrementalProjectBuilder.INCREMENTAL_BUILD, JavaCore.BUILDER_ID, UniqueClassNameValidatorUITest.emptyStringMap(), null);
    this.first.build(IncrementalProjectBuilder.INCREMENTAL_BUILD, XtextBuilder.BUILDER_ID, UniqueClassNameValidatorUITest.emptyStringMap(), null);
    final IMarker[] markers = firstFile.findMarkers(IMarker.PROBLEM, true, IResource.DEPTH_INFINITE);
    Assert.assertEquals(IResourcesSetupUtil.printMarker(markers), 1, markers.length);
    Assert.assertEquals("The type A is already defined in A.java.", IterableExtensions.<IMarker>head(((Iterable<IMarker>)Conversions.doWrapArray(markers))).getAttribute(IMarker.MESSAGE));
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
Example #30
Source File: UniqueClassNameValidatorUITest.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void testTwoXtendFilesDifferentProject() {
  try {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("package acme");
    _builder.newLine();
    _builder.append("class A {");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    final IFile firstFile = IResourcesSetupUtil.createFile("first.p384008/src/acme/A.xtend", _builder.toString());
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("package acme");
    _builder_1.newLine();
    _builder_1.append("class A {");
    _builder_1.newLine();
    _builder_1.append("}");
    _builder_1.newLine();
    final IFile secondFile = IResourcesSetupUtil.createFile("second.p384008/src/acme/B.xtend", _builder_1.toString());
    final IWorkspaceRunnable _function = (IProgressMonitor it) -> {
      this.first.build(IncrementalProjectBuilder.INCREMENTAL_BUILD, XtextBuilder.BUILDER_ID, UniqueClassNameValidatorUITest.emptyStringMap(), null);
    };
    this.runInWorkspace(_function);
    final IMarker[] firstFileMarkers = firstFile.findMarkers(IMarker.PROBLEM, true, IResource.DEPTH_INFINITE);
    Assert.assertEquals(IResourcesSetupUtil.printMarker(firstFileMarkers), 0, firstFileMarkers.length);
    final IMarker[] secondFileMarkers = secondFile.findMarkers(IMarker.PROBLEM, true, IResource.DEPTH_INFINITE);
    Assert.assertEquals(IResourcesSetupUtil.printMarker(secondFileMarkers), 0, secondFileMarkers.length);
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}