Class DefaultSemanticHighlightingCalculator

    • Constructor Detail

      • DefaultSemanticHighlightingCalculator

        public DefaultSemanticHighlightingCalculator()
    • Method Detail

      • provideHighlightingFor

        public void provideHighlightingFor​(org.eclipse.xtext.resource.XtextResource resource,
                                           IHighlightedPositionAcceptor acceptor,
                                           org.eclipse.xtext.util.CancelIndicator cancelIndicator)
        Specified by:
        provideHighlightingFor in interface ISemanticHighlightingCalculator
        Parameters:
        resource - the resource that will be highlighted. May be null in some rare cases.
        acceptor - used to announce the mapping from text-range to the style's id. The acceptor will never be null.
        cancelIndicator - used to determine whether we should stop searching for highlighting positions (use OperationCanceledManager to check)
      • doProvideHighlightingFor

        protected void doProvideHighlightingFor​(org.eclipse.xtext.resource.XtextResource resource,
                                                IHighlightedPositionAcceptor acceptor,
                                                org.eclipse.xtext.util.CancelIndicator cancelIndicator)

        Actual implementation of the semantic highlighting calculation. It is ensured, that the given resource is not null and refers to an initialized parse result.

        By default this will visit the elements in the resource recursively and call highlightElement(EObject, IHighlightedPositionAcceptor, CancelIndicator) for each of them. As the last step, tasks will be highlighted.

        Clients can override this method if the default recursive approach does not fit their use case

        Parameters:
        resource - a valid to-be-processed resource. Is never null.
        acceptor - the acceptor. Is never null.
      • searchAndHighlightElements

        protected void searchAndHighlightElements​(org.eclipse.xtext.resource.XtextResource resource,
                                                  IHighlightedPositionAcceptor acceptor,
                                                  org.eclipse.xtext.util.CancelIndicator cancelIndicator)
      • highlightElementRecursively

        protected void highlightElementRecursively​(org.eclipse.emf.ecore.EObject element,
                                                   IHighlightedPositionAcceptor acceptor,
                                                   org.eclipse.xtext.util.CancelIndicator cancelIndicator)
      • highlightElement

        protected boolean highlightElement​(org.eclipse.emf.ecore.EObject object,
                                           IHighlightedPositionAcceptor acceptor,
                                           org.eclipse.xtext.util.CancelIndicator cancelIndicator)
        Returns:
        true to skip the children of this element, false otherwise
      • highlightTasks

        protected void highlightTasks​(org.eclipse.xtext.resource.XtextResource resource,
                                      IHighlightedPositionAcceptor acceptor)
      • highlightFeature

        protected void highlightFeature​(IHighlightedPositionAcceptor acceptor,
                                        org.eclipse.emf.ecore.EObject object,
                                        org.eclipse.emf.ecore.EStructuralFeature feature,
                                        java.lang.String... styleIds)
        Highlights an object at the position of the given EStructuralFeature
      • highlightNode

        protected void highlightNode​(IHighlightedPositionAcceptor acceptor,
                                     org.eclipse.xtext.nodemodel.INode node,
                                     java.lang.String... styleIds)
        Highlights the non-hidden parts of node with the styles given by the styleIds