org.eclipse.xtext.builder.impl.XtextBuilder Java Examples

The following examples show how to use org.eclipse.xtext.builder.impl.XtextBuilder. 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: N4JSClusteringBuilderConfiguration.java    From n4js with Eclipse Public License 1.0 6 votes vote down vote up
@Override
protected void configure() {
	bind(IResourceClusteringPolicy.class).to(VerboseClusteringPolicy.class);
	bind(XtextBuilder.class).to(N4JSBuildTypeTrackingBuilder.class);
	bind(IBuilderState.class).to(N4JSGenerateImmediatelyBuilderState.class).in(Scopes.SINGLETON);
	bind(IMarkerUpdater.class).to(N4JSMarkerUpdater.class);
	bind(IStorage2UriMapper.class).to(N4JSStorage2UriMapper.class);
	bind(PersistedStateProvider.class).to(ContributingResourceDescriptionPersister.class);
	bind(IBuildLogger.class).annotatedWith(BuilderState.class).to(BuilderStateLogger.class);
	bind(DirtyStateManager.class).to(PrevStateAwareDirtyStateManager.class);
	bind(IResourceLoader.class).annotatedWith(
			Names.named(ClusteringBuilderState.RESOURCELOADER_GLOBAL_INDEX)).toProvider(
					new BuildScopeAwareParallelLoaderProvider());
	bind(BuilderStateDiscarder.class);
	bind(SharedStateContributionRegistryImpl.class).to(DefaultSharedContributionOverridingRegistry.class);
	binder().install(new MyReferenceSearchResultContentProviderCustomModule());
}
 
Example #2
Source File: XtextNature.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
@Override
public void configure() throws CoreException {
	IProjectDescription desc = project.getDescription();
	ICommand[] commands = desc.getBuildSpec();

	for (int i = 0; i < commands.length; ++i) {
		if (commands[i].getBuilderName().equals(XtextBuilder.BUILDER_ID)) {
			return;
		}
	}

	ICommand[] newCommands = new ICommand[commands.length + 1];
	System.arraycopy(commands, 0, newCommands, 1, commands.length);
	ICommand command = desc.newCommand();
	command.setBuilderName(XtextBuilder.BUILDER_ID);
	newCommands[0] = command;
	desc.setBuildSpec(newCommands);
	project.setDescription(desc, null);
}
 
Example #3
Source File: XtextNature.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
@Override
public void deconfigure() throws CoreException {
	IProjectDescription description = getProject().getDescription();
	ICommand[] commands = description.getBuildSpec();
	for (int i = 0; i < commands.length; ++i) {
		if (commands[i].getBuilderName().equals(XtextBuilder.BUILDER_ID)) {
			ICommand[] newCommands = new ICommand[commands.length - 1];
			System.arraycopy(commands, 0, newCommands, 0, i);
			System.arraycopy(commands, i + 1, newCommands, i,
					commands.length - i - 1);
			description.setBuildSpec(newCommands);
			project.setDescription(description, null);			
			project.deleteMarkers(MarkerTypes.ANY_VALIDATION, true, IResource.DEPTH_INFINITE);
			return;
		}
	}
}
 
Example #4
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 #5
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);
  }
}
 
Example #6
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 #7
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 #8
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 #9
Source File: ParallelBuildEnabledTest.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
@Test
public void testBuilderSchedulingRuleEnabledInWorkspace() {
	String schedulingRule = new ScopedPreferenceStore(InstanceScope.INSTANCE, Activator.PLUGIN_ID).getString(XtextBuilder.BuilderPreferences.PREF_SCHEDULING_RULE);
	assertEquals("non-default scheduling rule was not enabled", SchedulingOption.ALL_XTEXT_PROJECTS.name(), schedulingRule);
}
 
Example #10
Source File: BuildContext.java    From dsl-devkit with Eclipse Public License 1.0 3 votes vote down vote up
/**
 * Creates a new instance of {@link BuildContext}.
 * 
 * @param builder
 *          the {@link XtextBuilder}, may be {@code null}
 * @param builtProject
 *          the {@link IProject} being built, may be {@code null}
 * @param resourceSet
 *          the {@link ResourceSet}, must not be {@code null}
 * @param deltas
 *          the list of {@link Delta}, must not be {@code null}
 * @param type
 *          the {@link BuildType}, must not be {@code null}
 */
protected BuildContext(final XtextBuilder builder, final IProject builtProject, final ResourceSet resourceSet, final List<Delta> deltas, final BuildType type) {
  this.type = type;
  this.builder = builder;
  this.resourceSet = resourceSet;
  this.deltas = deltas;
  this.builtProject = builtProject;
}
 
Example #11
Source File: BuildContext.java    From dsl-devkit with Eclipse Public License 1.0 2 votes vote down vote up
/**
 * Creates a new instance of {@link BuildContext}.
 * 
 * @param builder
 *          the {@link XtextBuilder}, must not be {@code null}
 * @param resourceSet
 *          the {@link ResourceSet}, must not be {@code null}
 * @param deltas
 *          the list of {@link Delta}, must not be {@code null}
 * @param type
 *          the {@link BuildType}, must not be {@code null}
 */
public BuildContext(final XtextBuilder builder, final ResourceSet resourceSet, final List<Delta> deltas, final BuildType type) {
  this(builder, null, resourceSet, deltas, type);
}