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

The following examples show how to use org.eclipse.xtext.ide.editor.syntaxcoloring.ISemanticHighlightingCalculator. 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: DotSubgrammarHighlighter.java    From gef with Eclipse Public License 2.0 5 votes vote down vote up
public void provideHightlightingFor(String text, int startOffset,
		IHighlightedPositionAcceptor hostGrammarAcceptor, String suffix) {

	Injector injector = DotActivator.getInstance().getInjector(language);
	ISemanticHighlightingCalculator subgrammarCalculator = injector
			.getInstance(ISemanticHighlightingCalculator.class);

	XtextResource xtextResource = DotEditorUtils.getXtextResource(injector,
			text);

	subgrammarCalculator.provideHighlightingFor(xtextResource,
			new IHighlightedPositionAcceptor() {

				@Override
				public void addPosition(int offset, int length,
						String... id) {
					if (suffix != null) {
						id = Arrays.stream(id).map(e -> e + suffix)
								.toArray(String[]::new);
					}

					hostGrammarAcceptor.addPosition(startOffset + offset,
							length, id);
				}

			}, null);
}
 
Example #2
Source File: SolidityUIModule.java    From solidity-ide with Eclipse Public License 1.0 4 votes vote down vote up
public Class<? extends ISemanticHighlightingCalculator> bindISemanticHighlightingCalculator() {
	return SoliditySemanticHighlighter.class;
}
 
Example #3
Source File: SARLHighlightingCalculatorTest.java    From sarl with Apache License 2.0 4 votes vote down vote up
/** {@inheritDoc}
 */
@Override
protected ISemanticHighlightingCalculator getCalculator() {
	return this.calculator;
}
 
Example #4
Source File: AbstractSARLUiModule.java    From sarl with Apache License 2.0 4 votes vote down vote up
public Class<? extends ISemanticHighlightingCalculator> bindIdeSemanticHighlightingCalculator() {
	return SARLHighlightingCalculator.class;
}
 
Example #5
Source File: XtxtUMLUiModule.java    From txtUML with Eclipse Public License 1.0 4 votes vote down vote up
@Override
public Class<? extends ISemanticHighlightingCalculator> bindIdeSemanticHighlightingCalculator() {
	return XtxtUMLHighlightingCalculator.class;
}
 
Example #6
Source File: CheckUiModule.java    From dsl-devkit with Eclipse Public License 1.0 4 votes vote down vote up
@Override
public Class<? extends ISemanticHighlightingCalculator> bindIdeSemanticHighlightingCalculator() {
  return CheckHighlightingCalculator.class;
}
 
Example #7
Source File: FixedHighlightingReconciler.java    From dsl-devkit with Eclipse Public License 1.0 4 votes vote down vote up
@Override
@Deprecated
public org.eclipse.xtext.ui.editor.syntaxcoloring.ISemanticHighlightingCalculator getCalculator() {
  return oldCalculator;
}
 
Example #8
Source File: FixedHighlightingReconciler.java    From dsl-devkit with Eclipse Public License 1.0 4 votes vote down vote up
@Override
@Deprecated
public void setCalculator(final org.eclipse.xtext.ui.editor.syntaxcoloring.ISemanticHighlightingCalculator calculator) {
  this.oldCalculator = calculator;
}
 
Example #9
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);
}
 
Example #10
Source File: TestLanguageRuntimeModule.java    From xtext-core with Eclipse Public License 2.0 4 votes vote down vote up
public Class<? extends ISemanticHighlightingCalculator> bindISemanticHighlightingCalculator() {
	return SemanticHighlightingCalculatorImpl.class;
}
 
Example #11
Source File: XtendUiModule.java    From xtext-xtend with Eclipse Public License 2.0 4 votes vote down vote up
@Override
public Class<? extends ISemanticHighlightingCalculator> bindIdeSemanticHighlightingCalculator() {
	return XtendHighlightingCalculator.class;
}
 
Example #12
Source File: DotUiModule.java    From gef with Eclipse Public License 2.0 4 votes vote down vote up
public Class<? extends ISemanticHighlightingCalculator> bindISemanticHighlightingCalculator() {
	return DotSemanticHighlightingCalculator.class;
}
 
Example #13
Source File: DotHtmlLabelUiModule.java    From gef with Eclipse Public License 2.0 4 votes vote down vote up
public Class<? extends ISemanticHighlightingCalculator> bindISemanticHighlightingCalculator() {
	return DotHtmlLabelSemanticHighlightingCalculator.class;
}
 
Example #14
Source File: DotArrowTypeUiModule.java    From gef with Eclipse Public License 2.0 4 votes vote down vote up
public Class<? extends ISemanticHighlightingCalculator> bindISemanticHighlightingCalculator() {
	return DotArrowTypeSemanticHighlightingCalculator.class;
}
 
Example #15
Source File: XtextUiModule.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
public Class<? extends ISemanticHighlightingCalculator> bindISemanticHighlightingCalculator() {
	return SemanticHighlightingCalculator.class;
}
 
Example #16
Source File: SingleCodetemplateUiModule.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
public Class<? extends ISemanticHighlightingCalculator> bindISemanticHighlightingCalculator() {
	return SemanticHighlighter.class;
}
 
Example #17
Source File: CodetemplatesUiModule.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
public Class<? extends ISemanticHighlightingCalculator> bindISemanticHighlightingCalculator() {
	return SemanticHighlighter.class;
}
 
Example #18
Source File: StatemachineIdeModule.java    From xtext-web with Eclipse Public License 2.0 4 votes vote down vote up
public Class<? extends ISemanticHighlightingCalculator> bindISemanticHighlightingCalculator() {
	return StatemachineSemanticHighlightingCalculator.class;
}
 
Example #19
Source File: DefaultXbaseIdeModule.java    From xtext-extras with Eclipse Public License 2.0 4 votes vote down vote up
public Class<? extends ISemanticHighlightingCalculator> bindSemanticHighlightingCalculator() {
	return XbaseHighlightingCalculator.class;
}
 
Example #20
Source File: JSONUiModule.java    From n4js with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * Bind a JSON-specific ISemanticHighlightingCalculator for syntax highlighting
 */
public Class<? extends ISemanticHighlightingCalculator> bindISemanticHighlightingCalculator() {
	return JSONSemanticHighlightingCalculator.class;
}
 
Example #21
Source File: GamlUiModule.java    From gama with GNU General Public License v3.0 2 votes vote down vote up
/**
 * @author Pierrick
 * @return GAMLSemanticHighlightingCalculator
 */
public Class<? extends ISemanticHighlightingCalculator> bindSemanticHighlightingCalculator() {
	return GamlSemanticHighlightingCalculator.class;
}
 
Example #22
Source File: AbstractSARLHighlightingCalculatorTest.java    From sarl with Apache License 2.0 2 votes vote down vote up
/** Replies the instance of the calculator to test.
 *
 * @return the highlight calculator.
 */
protected abstract ISemanticHighlightingCalculator getCalculator();