use of org.eclipse.xtext.build.IndexState in project xtext-core by eclipse.
the class ProjectManager method newBuildRequest.
protected BuildRequest newBuildRequest(final List<URI> changedFiles, final List<URI> deletedFiles, final List<IResourceDescription.Delta> externalDeltas, final CancelIndicator cancelIndicator) {
BuildRequest _buildRequest = new BuildRequest();
final Procedure1<BuildRequest> _function = (BuildRequest it) -> {
it.setBaseDir(this.baseDir);
ResourceDescriptionsData _copy = this.indexState.getResourceDescriptions().copy();
Source2GeneratedMapping _copy_1 = this.indexState.getFileMappings().copy();
IndexState _indexState = new IndexState(_copy, _copy_1);
it.setState(_indexState);
it.setResourceSet(this.createFreshResourceSet(it.getState().getResourceDescriptions()));
it.setDirtyFiles(changedFiles);
it.setDeletedFiles(deletedFiles);
it.setExternalDeltas(externalDeltas);
final BuildRequest.IPostValidationCallback _function_1 = (URI uri, Iterable<Issue> issues) -> {
this.issueAcceptor.apply(uri, issues);
return true;
};
it.setAfterValidate(_function_1);
it.setCancelIndicator(cancelIndicator);
};
return ObjectExtensions.<BuildRequest>operator_doubleArrow(_buildRequest, _function);
}
use of org.eclipse.xtext.build.IndexState 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;
}
use of org.eclipse.xtext.build.IndexState in project xtext-core by eclipse.
the class IncrementalBuilder method build.
public IncrementalBuilder.Result build(final BuildRequest request, final Function1<? super URI, ? extends IResourceServiceProvider> languages, final IResourceClusteringPolicy clusteringPolicy) {
try {
final XtextResourceSet resourceSet = request.getResourceSet();
ResourceDescriptionsData _copy = request.getState().getResourceDescriptions().copy();
Source2GeneratedMapping _copy_1 = request.getState().getFileMappings().copy();
final IndexState oldState = new IndexState(_copy, _copy_1);
CancelIndicator _cancelIndicator = request.getCancelIndicator();
final BuildContext context = new BuildContext(languages, resourceSet, oldState, clusteringPolicy, _cancelIndicator);
final IncrementalBuilder.InternalStatefulIncrementalBuilder builder = this.provider.get();
builder.context = context;
builder.request = request;
try {
return builder.launch();
} catch (final Throwable _t) {
if (_t instanceof Throwable) {
final Throwable t = (Throwable) _t;
this._operationCanceledManager.propagateIfCancelException(t);
throw t;
} else {
throw Exceptions.sneakyThrow(_t);
}
}
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
}
use of org.eclipse.xtext.build.IndexState in project xtext-core by eclipse.
the class IncrementalBuilderTest method testIndexOnly.
@Test
public void testIndexOnly() {
final Procedure1<BuildRequest> _function = (BuildRequest it) -> {
it.setIndexOnly(true);
StringConcatenation _builder = new StringConcatenation();
_builder.append("foo {");
_builder.newLine();
_builder.append("\t");
_builder.append("entity A {}");
_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.IPostValidationCallback _function_1 = (URI $0, Iterable<Issue> $1) -> {
throw new IllegalStateException();
};
it.setAfterValidate(_function_1);
final Procedure2<URI, URI> _function_2 = (URI $0, URI $1) -> {
throw new IllegalStateException();
};
it.setAfterGenerateFile(_function_2);
};
final BuildRequest buildRequest = this.newBuildRequest(_function);
final IndexState result = this.build(buildRequest);
Assert.assertEquals(1, IterableExtensions.size(result.getResourceDescriptions().getAllResourceDescriptions()));
}
Aggregations