use of org.eclipse.xtext.build.BuildRequest in project xtext-xtend by eclipse.
the class XtendIncrementalBuilderTest method testSimpleFullBuild.
@Test
public void testSimpleFullBuild() {
final Procedure1<BuildRequest> _function = (BuildRequest it) -> {
StringConcatenation _builder = new StringConcatenation();
_builder.append("class A {");
_builder.newLine();
_builder.append("\t");
_builder.append("public String a");
_builder.newLine();
_builder.append("\t");
_builder.append("public B someB");
_builder.newLine();
_builder.append("}");
_builder.newLine();
_builder.append("class B {");
_builder.newLine();
_builder.append("}");
_builder.newLine();
URI _minus = this.operator_minus("src/MyFile.xtend", _builder.toString());
it.setDirtyFiles(Collections.<URI>unmodifiableList(CollectionLiterals.<URI>newArrayList(_minus)));
};
final BuildRequest buildRequest = this.newBuildRequest(_function);
this.build(buildRequest);
Assert.assertTrue(this.issues.toString(), this.issues.isEmpty());
Assert.assertEquals(4, this.generated.size());
Assert.assertTrue(this.containsSuffix(this.generated.values(), "xtend-gen/B.java"));
Assert.assertTrue(this.containsSuffix(this.generated.values(), "xtend-gen/A.java"));
Assert.assertTrue(this.containsSuffix(this.generated.values(), "xtend-gen/.B.java._trace"));
Assert.assertTrue(this.containsSuffix(this.generated.values(), "xtend-gen/.A.java._trace"));
}
use of org.eclipse.xtext.build.BuildRequest in project xtext-xtend by eclipse.
the class XtendIncrementalBuilderTest method testBug487806.
@Test
public void testBug487806() {
final Procedure1<BuildRequest> _function = (BuildRequest it) -> {
StringConcatenation _builder = new StringConcatenation();
_builder.append("package test;");
_builder.newLine();
_builder.append("public class BaseException extends java.lang.Exception {");
_builder.newLine();
_builder.append("\t");
_builder.append("private static final long serialVersionUID = 1L;");
_builder.newLine();
_builder.append("\t");
_builder.append("public BaseException() {");
_builder.newLine();
_builder.append("\t\t");
_builder.append("super();");
_builder.newLine();
_builder.append("\t");
_builder.append("}");
_builder.newLine();
_builder.append("}");
_builder.newLine();
URI _minus = this.operator_minus("src/test/BaseException.java", _builder.toString());
StringConcatenation _builder_1 = new StringConcatenation();
_builder_1.append("package test;");
_builder_1.newLine();
_builder_1.append("public interface ClientGame extends Game<ClientPlayer> {");
_builder_1.newLine();
_builder_1.append("}");
URI _minus_1 = this.operator_minus("src/test/ClientGame.java", _builder_1.toString());
StringConcatenation _builder_2 = new StringConcatenation();
_builder_2.append("package test;");
_builder_2.newLine();
_builder_2.append("public interface ClientPlayer extends Player {");
_builder_2.newLine();
_builder_2.append("}");
URI _minus_2 = this.operator_minus("src/test/ClientPlayer.java", _builder_2.toString());
StringConcatenation _builder_3 = new StringConcatenation();
_builder_3.append("package test;");
_builder_3.newLine();
_builder_3.append("import java.util.Collection;");
_builder_3.newLine();
_builder_3.append("public interface Game<P extends Player> extends IDElement {");
_builder_3.newLine();
_builder_3.append("\t");
_builder_3.append("Collection<P> getPlayers();");
_builder_3.newLine();
_builder_3.append("\t");
_builder_3.append("void addPlayer(P player) throws BaseException;");
_builder_3.newLine();
_builder_3.append("}");
URI _minus_3 = this.operator_minus("src/test/Game.java", _builder_3.toString());
StringConcatenation _builder_4 = new StringConcatenation();
_builder_4.append("package test;");
_builder_4.newLine();
_builder_4.append("public interface IDElement {");
_builder_4.newLine();
_builder_4.append("\t");
_builder_4.append("public int getId();");
_builder_4.newLine();
_builder_4.append("}");
URI _minus_4 = this.operator_minus("src/test/IDElement.java", _builder_4.toString());
StringConcatenation _builder_5 = new StringConcatenation();
_builder_5.append("package test;");
_builder_5.newLine();
_builder_5.append("public interface Player extends IDElement {");
_builder_5.newLine();
_builder_5.append("}");
URI _minus_5 = this.operator_minus("src/test/Player.java", _builder_5.toString());
StringConcatenation _builder_6 = new StringConcatenation();
_builder_6.append("package test");
_builder_6.newLine();
_builder_6.append("class BoardUpdateCommandProcessor {");
_builder_6.newLine();
_builder_6.append("\t");
_builder_6.append("new(ClientGame game) {");
_builder_6.newLine();
_builder_6.append("\t\t");
_builder_6.append("var player = game.players.findFirst[it.id == 343]");
_builder_6.newLine();
_builder_6.append("\t\t");
_builder_6.append("player = null");
_builder_6.newLine();
_builder_6.append("\t\t");
_builder_6.append("println(player)");
_builder_6.newLine();
_builder_6.append("\t");
_builder_6.append("}");
_builder_6.newLine();
_builder_6.append("}");
URI _minus_6 = this.operator_minus("src/test/BoardUpdateCommandProcessor.xtend", _builder_6.toString());
it.setDirtyFiles(Collections.<URI>unmodifiableList(CollectionLiterals.<URI>newArrayList(_minus, _minus_1, _minus_2, _minus_3, _minus_4, _minus_5, _minus_6)));
};
final BuildRequest buildRequest = this.newBuildRequest(_function);
this.build(buildRequest);
Assert.assertTrue(this.issues.toString(), this.issues.isEmpty());
}
use of org.eclipse.xtext.build.BuildRequest in project xtext-xtend by eclipse.
the class XtendIncrementalBuilderTest method testDelete_01.
@Test
public void testDelete_01() {
final Procedure1<BuildRequest> _function = (BuildRequest it) -> {
StringConcatenation _builder = new StringConcatenation();
_builder.append("class A {");
_builder.newLine();
_builder.append("\t");
_builder.append("public foo.B myField");
_builder.newLine();
_builder.append("}");
_builder.newLine();
URI _minus = this.operator_minus("src/A.xtend", _builder.toString());
StringConcatenation _builder_1 = new StringConcatenation();
_builder_1.append("package foo");
_builder_1.newLine();
_builder_1.append("class B {");
_builder_1.newLine();
_builder_1.append("}");
_builder_1.newLine();
URI _minus_1 = this.operator_minus("src/foo/B.xtend", _builder_1.toString());
it.setDirtyFiles(Collections.<URI>unmodifiableList(CollectionLiterals.<URI>newArrayList(_minus, _minus_1)));
};
this.build(this.newBuildRequest(_function));
final AtomicBoolean validateCalled = new AtomicBoolean(false);
final Procedure1<BuildRequest> _function_1 = (BuildRequest it) -> {
URI _delete = this.delete(this.uri("src/foo/B.xtend"));
it.setDeletedFiles(Collections.<URI>unmodifiableList(CollectionLiterals.<URI>newArrayList(_delete)));
final BuildRequest.IPostValidationCallback _function_2 = (URI uri, Iterable<Issue> issues) -> {
Assert.assertEquals(this.uri("src/A.xtend"), uri);
Assert.assertTrue(IterableExtensions.<Issue>head(issues).getMessage(), IterableExtensions.<Issue>head(issues).getMessage().contains("foo.B cannot be resolved to a type"));
validateCalled.set(true);
return false;
};
it.setAfterValidate(_function_2);
};
this.build(this.newBuildRequest(_function_1));
Assert.assertTrue(validateCalled.get());
}
use of org.eclipse.xtext.build.BuildRequest in project xtext-core by eclipse.
the class ProjectManager method doBuild.
public IncrementalBuilder.Result doBuild(final List<URI> dirtyFiles, final List<URI> deletedFiles, final List<IResourceDescription.Delta> externalDeltas, final CancelIndicator cancelIndicator) {
final BuildRequest request = this.newBuildRequest(dirtyFiles, deletedFiles, externalDeltas, cancelIndicator);
final Function1<URI, IResourceServiceProvider> _function = (URI it) -> {
return this.languagesRegistry.getResourceServiceProvider(it);
};
final IncrementalBuilder.Result result = this.incrementalBuilder.build(request, _function);
this.indexState = result.getIndexState();
this.resourceSet = request.getResourceSet();
this.indexProvider.get().put(this.projectDescription.getName(), this.indexState.getResourceDescriptions());
return result;
}
use of org.eclipse.xtext.build.BuildRequest in project xtext-core by eclipse.
the class AbstractIncrementalBuilderTest method newBuildRequest.
protected BuildRequest newBuildRequest(final Procedure1<? super BuildRequest> init) {
BuildRequest _buildRequest = new BuildRequest();
final Procedure1<BuildRequest> _function = (BuildRequest it) -> {
final ResourceDescriptionsData newIndex = this.indexState.getResourceDescriptions().copy();
it.setBaseDir(this.uri(""));
XtextResourceSet _get = this.resourceSetProvider.get();
final Procedure1<XtextResourceSet> _function_1 = (XtextResourceSet it_1) -> {
it_1.getURIConverter().getURIHandlers().clear();
EList<URIHandler> _uRIHandlers = it_1.getURIConverter().getURIHandlers();
_uRIHandlers.add(this.inMemoryURIHandler);
it_1.setClasspathURIContext(AbstractIncrementalBuilderTest.class.getClassLoader());
ProjectDescription _projectDescription = new ProjectDescription();
final Procedure1<ProjectDescription> _function_2 = (ProjectDescription it_2) -> {
it_2.setName("test-project");
};
final ProjectDescription projectDescription = ObjectExtensions.<ProjectDescription>operator_doubleArrow(_projectDescription, _function_2);
projectDescription.attachToEmfObject(it_1);
Map<String, ResourceDescriptionsData> _emptyMap = CollectionLiterals.<String, ResourceDescriptionsData>emptyMap();
final ChunkedResourceDescriptions index = new ChunkedResourceDescriptions(_emptyMap, it_1);
index.setContainer(projectDescription.getName(), newIndex);
};
XtextResourceSet _doubleArrow = ObjectExtensions.<XtextResourceSet>operator_doubleArrow(_get, _function_1);
it.setResourceSet(_doubleArrow);
it.setDirtyFiles(Collections.<URI>unmodifiableList(CollectionLiterals.<URI>newArrayList()));
it.setDeletedFiles(Collections.<URI>unmodifiableList(CollectionLiterals.<URI>newArrayList()));
final BuildRequest.IPostValidationCallback _function_2 = (URI uri, Iterable<Issue> issues) -> {
Iterables.<Issue>addAll(this.issues, issues);
return IterableExtensions.isEmpty(issues);
};
it.setAfterValidate(_function_2);
final Procedure1<URI> _function_3 = (URI it_1) -> {
this.deleted.add(it_1);
};
it.setAfterDeleteFile(_function_3);
final Procedure2<URI, URI> _function_4 = (URI source, URI target) -> {
this.generated.put(source, target);
};
it.setAfterGenerateFile(_function_4);
Source2GeneratedMapping _copy = this.indexState.getFileMappings().copy();
IndexState _indexState = new IndexState(newIndex, _copy);
it.setState(_indexState);
};
final BuildRequest result = ObjectExtensions.<BuildRequest>operator_doubleArrow(_buildRequest, _function);
init.apply(result);
return result;
}
Aggregations