use of org.eclipse.xtext.build.BuildRequest in project xtext-core by eclipse.
the class IncrementalBuilderTest method testSimpleFullBuild.
@Test
public void testSimpleFullBuild() {
final Procedure1<BuildRequest> _function = (BuildRequest it) -> {
StringConcatenation _builder = new StringConcatenation();
_builder.append("foo {");
_builder.newLine();
_builder.append("\t");
_builder.append("entity B {}");
_builder.newLine();
_builder.append("\t");
_builder.append("entity A { foo.B myReference }");
_builder.newLine();
_builder.append("}");
_builder.newLine();
URI _minus = this.operator_minus("src/MyFile.indextestlanguage", _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(2, this.generated.size());
Assert.assertTrue(this.containsSuffix(this.generated.values(), "src-gen/B.txt"));
Assert.assertTrue(this.containsSuffix(this.generated.values(), "src-gen/A.txt"));
}
use of org.eclipse.xtext.build.BuildRequest in project xtext-core by eclipse.
the class IncrementalBuilderTest method testDelete_01.
@Test
public void testDelete_01() {
final Procedure1<BuildRequest> _function = (BuildRequest it) -> {
StringConcatenation _builder = new StringConcatenation();
_builder.append("foo {");
_builder.newLine();
_builder.append("\t");
_builder.append("entity A {foo.B references}");
_builder.newLine();
_builder.append("}");
_builder.newLine();
URI _minus = this.operator_minus("src/A.indextestlanguage", _builder.toString());
StringConcatenation _builder_1 = new StringConcatenation();
_builder_1.append("foo {");
_builder_1.newLine();
_builder_1.append("\t");
_builder_1.append("entity B");
_builder_1.newLine();
_builder_1.append("}");
_builder_1.newLine();
URI _minus_1 = this.operator_minus("src/B.indextestlanguage", _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 _uri = this.uri("src/B.indextestlanguage");
it.setDeletedFiles(Collections.<URI>unmodifiableList(CollectionLiterals.<URI>newArrayList(_uri)));
final BuildRequest.IPostValidationCallback _function_2 = (URI uri, Iterable<Issue> issues) -> {
Assert.assertEquals(this.uri("src/A.indextestlanguage"), uri);
Assert.assertTrue(issues.toString(), IterableExtensions.<Issue>head(issues).getMessage().contains("Couldn\'t resolve reference to Type \'foo.B\'"));
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 IncrementalBuilderTest method testCancellation.
@Test(expected = OperationCanceledException.class)
public void testCancellation() {
final IncrementalBuilderTest.CancelOnFirstModel cancelOnFirstModel = new IncrementalBuilderTest.CancelOnFirstModel();
final Procedure1<BuildRequest> _function = (BuildRequest it) -> {
StringConcatenation _builder = new StringConcatenation();
_builder.append("foo {");
_builder.newLine();
_builder.append("\t");
_builder.append("entity A { foo.B myReference }");
_builder.newLine();
_builder.append("}");
_builder.newLine();
URI _minus = this.operator_minus("src/MyFile.indextestlanguage", _builder.toString());
StringConcatenation _builder_1 = new StringConcatenation();
_builder_1.append("foo {");
_builder_1.newLine();
_builder_1.append("\t");
_builder_1.append("entity B {}");
_builder_1.newLine();
_builder_1.append("}");
_builder_1.newLine();
URI _minus_1 = this.operator_minus("src/MyFile2.indextestlanguage", _builder_1.toString());
it.setDirtyFiles(Collections.<URI>unmodifiableList(CollectionLiterals.<URI>newArrayList(_minus, _minus_1)));
it.setCancelIndicator(cancelOnFirstModel);
it.setAfterValidate(cancelOnFirstModel);
};
final BuildRequest buildRequest = this.newBuildRequest(_function);
this.build(buildRequest);
}
use of org.eclipse.xtext.build.BuildRequest in project xtext-core by eclipse.
the class IncrementalBuilderTest method testDeleteClearsReusedResourceSet.
@Test
public void testDeleteClearsReusedResourceSet() {
final Procedure1<BuildRequest> _function = (BuildRequest it) -> {
StringConcatenation _builder = new StringConcatenation();
_builder.append("foo {");
_builder.newLine();
_builder.append(" ");
_builder.append("entity A {foo.B references}");
_builder.newLine();
_builder.append("}");
_builder.newLine();
URI _minus = this.operator_minus("src/A.indextestlanguage", _builder.toString());
StringConcatenation _builder_1 = new StringConcatenation();
_builder_1.append("foo {");
_builder_1.newLine();
_builder_1.append(" ");
_builder_1.append("entity B");
_builder_1.newLine();
_builder_1.append("}");
_builder_1.newLine();
URI _minus_1 = this.operator_minus("src/B.indextestlanguage", _builder_1.toString());
it.setDirtyFiles(Collections.<URI>unmodifiableList(CollectionLiterals.<URI>newArrayList(_minus, _minus_1)));
};
final BuildRequest req = this.newBuildRequest(_function);
final XtextResourceSet resourceSet = req.getResourceSet();
this.build(req);
final AtomicBoolean validateCalled = new AtomicBoolean(false);
final Procedure1<BuildRequest> _function_1 = (BuildRequest it) -> {
URI _uri = this.uri("src/B.indextestlanguage");
it.setDeletedFiles(Collections.<URI>unmodifiableList(CollectionLiterals.<URI>newArrayList(_uri)));
final BuildRequest.IPostValidationCallback _function_2 = (URI uri, Iterable<Issue> issues) -> {
Assert.assertEquals(this.uri("src/A.indextestlanguage"), uri);
String _string = issues.toString();
Assert.assertTrue(_string, ((!IterableExtensions.isEmpty(issues)) && IterableExtensions.<Issue>head(issues).getMessage().contains("Couldn\'t resolve reference to Type \'foo.B\'")));
validateCalled.set(true);
return false;
};
it.setAfterValidate(_function_2);
it.setResourceSet(resourceSet);
final ChunkedResourceDescriptions desc = ChunkedResourceDescriptions.findInEmfObject(it.getResourceSet());
desc.setContainer("test-project", it.getState().getResourceDescriptions());
};
this.build(this.newBuildRequest(_function_1));
Assert.assertTrue(validateCalled.get());
Assert.assertNull(resourceSet.getResource(this.uri("src/B.indextestlanguage"), false));
}
use of org.eclipse.xtext.build.BuildRequest in project xtext-xtend by eclipse.
the class XtendIncrementalBuilderTest method testIncrementalBuild.
@Test
public void testIncrementalBuild() {
final Procedure1<BuildRequest> _function = (BuildRequest it) -> {
StringConcatenation _builder = new StringConcatenation();
_builder.append("class A extends B {");
_builder.newLine();
_builder.append("}");
_builder.newLine();
URI _minus = this.operator_minus("src/A.xtend", _builder.toString());
StringConcatenation _builder_1 = new StringConcatenation();
_builder_1.append("class B { ");
_builder_1.newLine();
_builder_1.append("\t");
_builder_1.append("public A myReference");
_builder_1.newLine();
_builder_1.append("}");
_builder_1.newLine();
URI _minus_1 = this.operator_minus("src/B.xtend", _builder_1.toString());
it.setDirtyFiles(Collections.<URI>unmodifiableList(CollectionLiterals.<URI>newArrayList(_minus, _minus_1)));
};
this.build(this.newBuildRequest(_function));
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"));
final Procedure1<BuildRequest> _function_1 = (BuildRequest it) -> {
StringConcatenation _builder = new StringConcatenation();
_builder.append("// some comment");
_builder.newLine();
_builder.append("class A extends B { }");
_builder.newLine();
URI _minus = this.operator_minus("src/A.xtend", _builder.toString());
it.setDirtyFiles(Collections.<URI>unmodifiableList(CollectionLiterals.<URI>newArrayList(_minus)));
};
this.build(this.newBuildRequest(_function_1));
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"));
final Procedure1<BuildRequest> _function_2 = (BuildRequest it) -> {
StringConcatenation _builder = new StringConcatenation();
_builder.append("class X extends B { }");
_builder.newLine();
URI _minus = this.operator_minus("src/A.xtend", _builder.toString());
it.setDirtyFiles(Collections.<URI>unmodifiableList(CollectionLiterals.<URI>newArrayList(_minus)));
};
this.build(this.newBuildRequest(_function_2));
Assert.assertEquals(this.issues.toString(), 1, this.issues.size());
Assert.assertEquals(2, this.generated.size());
Assert.assertFalse(this.containsSuffix(this.generated.values(), "xtend-gen/B.java"));
Assert.assertTrue(this.containsSuffix(this.generated.values(), "xtend-gen/X.java"));
Assert.assertTrue(IterableExtensions.<URI>toSet(this.indexState.getFileMappings().getGenerated(this.uri("src/A.xtend"))).contains(this.uri("xtend-gen/X.java")));
Assert.assertEquals(2, this.deleted.size());
Assert.assertTrue(this.containsSuffix(this.deleted, "xtend-gen/A.java"));
Assert.assertTrue(this.containsSuffix(this.deleted, "xtend-gen/.A.java._trace"));
final Procedure1<BuildRequest> _function_3 = (BuildRequest it) -> {
StringConcatenation _builder = new StringConcatenation();
_builder.append("class A extends B {\t}");
_builder.newLine();
URI _minus = this.operator_minus("src/A.xtend", _builder.toString());
it.setDirtyFiles(Collections.<URI>unmodifiableList(CollectionLiterals.<URI>newArrayList(_minus)));
};
this.build(this.newBuildRequest(_function_3));
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.deleted, "xtend-gen/X.java"));
final Procedure1<BuildRequest> _function_4 = (BuildRequest it) -> {
URI _delete = this.delete(this.uri("src/A.xtend"));
it.setDeletedFiles(Collections.<URI>unmodifiableList(CollectionLiterals.<URI>newArrayList(_delete)));
};
this.build(this.newBuildRequest(_function_4));
Assert.assertEquals(this.issues.toString(), 1, this.issues.size());
Assert.assertEquals(0, this.generated.size());
Assert.assertEquals(2, this.deleted.size());
Assert.assertTrue(this.containsSuffix(this.deleted, "xtend-gen/A.java"));
}
Aggregations