use of org.eclipse.xtext.ide.server.Document in project xtext-core by eclipse.
the class LanguageServerImpl method afterBuild.
@Override
public void afterBuild(final List<IResourceDescription.Delta> deltas) {
if ((this.client instanceof LanguageClientExtensions)) {
final Function1<IResourceDescription.Delta, Boolean> _function = (IResourceDescription.Delta it) -> {
IResourceDescription _new = it.getNew();
return Boolean.valueOf((_new != null));
};
final Function1<IResourceDescription.Delta, String> _function_1 = (IResourceDescription.Delta it) -> {
return it.getUri().toString();
};
final Consumer<String> _function_2 = (String it) -> {
final Function<ILanguageServerAccess.Context, Void> _function_3 = (ILanguageServerAccess.Context ctx) -> {
boolean _isDocumentOpen = ctx.isDocumentOpen();
if (_isDocumentOpen) {
Resource _resource = ctx.getResource();
if ((_resource instanceof XtextResource)) {
Resource _resource_1 = ctx.getResource();
final XtextResource resource = ((XtextResource) _resource_1);
final IResourceServiceProvider serviceProvider = this.languagesRegistry.getResourceServiceProvider(resource.getURI());
IColoringService _get = null;
if (serviceProvider != null) {
_get = serviceProvider.<IColoringService>get(IColoringService.class);
}
final IColoringService coloringService = _get;
if ((coloringService != null)) {
final Document doc = ctx.getDocument();
final List<? extends ColoringInformation> coloringInfos = coloringService.getColoring(resource, doc);
boolean _isNullOrEmpty = IterableExtensions.isNullOrEmpty(coloringInfos);
boolean _not = (!_isNullOrEmpty);
if (_not) {
final String uri = resource.getURI().toString();
ColoringParams _coloringParams = new ColoringParams(uri, coloringInfos);
((LanguageClientExtensions) this.client).updateColoring(_coloringParams);
}
}
}
return null;
}
return null;
};
this.access.<Void>doRead(it, _function_3);
};
IterableExtensions.<IResourceDescription.Delta, String>map(IterableExtensions.<IResourceDescription.Delta>filter(deltas, _function), _function_1).forEach(_function_2);
}
}
use of org.eclipse.xtext.ide.server.Document in project xtext-core by eclipse.
the class LanguageServerImpl method definition.
protected List<? extends Location> definition(final CancelIndicator cancelIndicator, final TextDocumentPositionParams params) {
final URI uri = this._uriExtensions.toUri(params.getTextDocument().getUri());
final IResourceServiceProvider resourceServiceProvider = this.languagesRegistry.getResourceServiceProvider(uri);
DocumentSymbolService _get = null;
if (resourceServiceProvider != null) {
_get = resourceServiceProvider.<DocumentSymbolService>get(DocumentSymbolService.class);
}
final DocumentSymbolService documentSymbolService = _get;
if ((documentSymbolService == null)) {
return CollectionLiterals.<Location>emptyList();
}
final Function2<Document, XtextResource, List<? extends Location>> _function = (Document document, XtextResource resource) -> {
return documentSymbolService.getDefinitions(document, resource, params, this.resourceAccess, cancelIndicator);
};
return this.workspaceManager.<List<? extends Location>>doRead(uri, _function);
}
use of org.eclipse.xtext.ide.server.Document in project xtext-core by eclipse.
the class LanguageServerImpl method completion.
protected Either<List<CompletionItem>, CompletionList> completion(final CancelIndicator origialCancelIndicator, final TextDocumentPositionParams params) {
final LanguageServerImpl.BufferedCancelIndicator cancelIndicator = new LanguageServerImpl.BufferedCancelIndicator(origialCancelIndicator);
final URI uri = this._uriExtensions.toUri(params.getTextDocument().getUri());
final IResourceServiceProvider resourceServiceProvider = this.languagesRegistry.getResourceServiceProvider(uri);
ContentAssistService _get = null;
if (resourceServiceProvider != null) {
_get = resourceServiceProvider.<ContentAssistService>get(ContentAssistService.class);
}
final ContentAssistService contentAssistService = _get;
if ((contentAssistService == null)) {
CompletionList _completionList = new CompletionList();
return Either.<List<CompletionItem>, CompletionList>forRight(_completionList);
}
final Function2<Document, XtextResource, CompletionList> _function = (Document document, XtextResource resource) -> {
return contentAssistService.createCompletionList(document, resource, params, cancelIndicator);
};
final CompletionList completionList = this.workspaceManager.<CompletionList>doRead(uri, _function);
return Either.<List<CompletionItem>, CompletionList>forRight(completionList);
}
use of org.eclipse.xtext.ide.server.Document in project xtext-core by eclipse.
the class WorkspaceManager method didChange.
public BuildManager.Buildable didChange(final URI uri, final int version, final Iterable<TextEdit> changes) {
boolean _containsKey = this.openDocuments.containsKey(uri);
boolean _not = (!_containsKey);
if (_not) {
WorkspaceManager.LOG.error((("The document " + uri) + " has not been opened."));
final BuildManager.Buildable _function = (CancelIndicator it) -> {
return null;
};
return _function;
}
final Document contents = this.openDocuments.get(uri);
this.openDocuments.put(uri, contents.applyChanges(changes));
return this.didChangeFiles(Collections.<URI>unmodifiableList(CollectionLiterals.<URI>newArrayList(uri)), CollectionLiterals.<URI>newArrayList());
}
use of org.eclipse.xtext.ide.server.Document in project xtext-core by eclipse.
the class WorkspaceManager method didOpen.
public BuildManager.Buildable didOpen(final URI uri, final int version, final String contents) {
Document _document = new Document(version, contents);
this.openDocuments.put(uri, _document);
return this.didChangeFiles(Collections.<URI>unmodifiableList(CollectionLiterals.<URI>newArrayList(uri)), CollectionLiterals.<URI>newArrayList());
}
Aggregations