org.eclipse.xtext.ide.editor.syntaxcoloring.MergingHighlightedPositionAcceptor Java Examples

The following examples show how to use org.eclipse.xtext.ide.editor.syntaxcoloring.MergingHighlightedPositionAcceptor. 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: MergingHighlightedPositionAcceptorTest.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
public MergingHighlightedPositionAcceptor getAcceptor() {
	return acceptor;
}
 
Example #2
Source File: MergingHighlightedPositionAcceptorTest.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
protected MergingHighlightedPositionAcceptor createAcceptor() {
	return new MergingHighlightedPositionAcceptor(null);
}
 
Example #3
Source File: SemanticHighlightingRegistry.java    From xtext-core with Eclipse Public License 2.0 4 votes vote down vote up
public void update(final ILanguageServerAccess.Context context) {
  this.checkInitialized();
  Resource _resource = context.getResource();
  boolean _not = (!(_resource instanceof XtextResource));
  if (_not) {
    return;
  }
  boolean _isDocumentOpen = context.isDocumentOpen();
  boolean _not_1 = (!_isDocumentOpen);
  if (_not_1) {
    return;
  }
  Resource _resource_1 = context.getResource();
  final XtextResource resource = ((XtextResource) _resource_1);
  IResourceServiceProvider _resourceServiceProvider = resource.getResourceServiceProvider();
  ISemanticHighlightingCalculator _get = null;
  if (_resourceServiceProvider!=null) {
    _get=_resourceServiceProvider.<ISemanticHighlightingCalculator>get(ISemanticHighlightingCalculator.class);
  }
  final ISemanticHighlightingCalculator calculator = _get;
  IResourceServiceProvider _resourceServiceProvider_1 = resource.getResourceServiceProvider();
  ISemanticHighlightingStyleToTokenMapper _get_1 = null;
  if (_resourceServiceProvider_1!=null) {
    _get_1=_resourceServiceProvider_1.<ISemanticHighlightingStyleToTokenMapper>get(ISemanticHighlightingStyleToTokenMapper.class);
  }
  final ISemanticHighlightingStyleToTokenMapper mapper = _get_1;
  if (((calculator == null) || this.isIgnoredMapper(mapper))) {
    return;
  }
  final Document document = context.getDocument();
  final MergingHighlightedPositionAcceptor acceptor = new MergingHighlightedPositionAcceptor(calculator);
  calculator.provideHighlightingFor(resource, acceptor, CancelIndicator.NullImpl);
  final Function1<LightweightPosition, List<SemanticHighlightingRegistry.HighlightedRange>> _function = (LightweightPosition position) -> {
    final Function1<String, SemanticHighlightingRegistry.HighlightedRange> _function_1 = (String id) -> {
      final Position start = document.getPosition(position.getOffset());
      int _offset = position.getOffset();
      int _length = position.getLength();
      int _plus = (_offset + _length);
      final Position end = document.getPosition(_plus);
      final int scope = this.getIndex(mapper.toScopes(id));
      return new SemanticHighlightingRegistry.HighlightedRange(start, end, scope);
    };
    return ListExtensions.<String, SemanticHighlightingRegistry.HighlightedRange>map(((List<String>)Conversions.doWrapArray(position.getIds())), _function_1);
  };
  final Iterable<SemanticHighlightingRegistry.HighlightedRange> ranges = Iterables.<SemanticHighlightingRegistry.HighlightedRange>concat(ListExtensions.<LightweightPosition, List<SemanticHighlightingRegistry.HighlightedRange>>map(acceptor.getPositions(), _function));
  final List<SemanticHighlightingInformation> lines = this.toSemanticHighlightingInformation(ranges, document);
  final VersionedTextDocumentIdentifier textDocument = this.toVersionedTextDocumentIdentifier(context);
  SemanticHighlightingParams _semanticHighlightingParams = new SemanticHighlightingParams(textDocument, lines);
  this.notifyClient(_semanticHighlightingParams);
}