Interface ITextRegionAccess

  • All Known Subinterfaces:
    ITextRegionAccessDiff
    All Known Implementing Classes:
    AbstractRegionAccess, NodeModelBasedRegionAccess, StringBasedRegionAccess, StringBasedTextRegionAccessDiff

    public interface ITextRegionAccess

    This class provides access to text regions based on the semantic model. A text region describes the offset and length in characters of a semantic elements within a text document.

    Technically, it is a lightweight facade over the node model or the serializer's output.

    The text regions are arranged as a linked list of strictly alternating semantic regions and hidden region. HiddenRegions group all hidden tokens (typically whitespace, newlines, tabs and comments) between two semantic tokens. HiddenRegions are empty, but do exist, if there are no hidden tokens between two semantic elements.

    Tokens are considered to be hidden, when they have been parsed via terminal rule referenced in "hidden(...)" in the Xtext grammar. In the node model, hidden tokens are usually marked as hidden == true.

    A semantic token can be the value of an EAttribute, a CrossReference or a keyword.

    A IHiddenRegion contains a list of parts, which are either white space or comments. A HiddenRegion can be empty.

    The purpose of this class is:
    • Allow the formatter to operate on a parsed document (node model) and a serialized model.
    • Provide a convenient abstraction for formatting (tokens, HiddenRegions).
    • Fast access to TextRegions. The node model would be too slow to traverse due to its large expression trees.
    Since:
    2.8
    See Also:
    ISemanticRegion, IHiddenRegion
    Noextend:
    This interface is not intended to be extended by clients.
    Noimplement:
    This interface is not intended to be implemented by clients.
    • Method Detail

      • regionForLineAtOffset

        ILineRegion regionForLineAtOffset​(int offset)
      • regionForEObject

        IEObjectRegion regionForEObject​(org.eclipse.emf.ecore.EObject semanticElement)
        Returns a the text region for a semantic element (i.e. and EObject from the AST).
      • regionForOffset

        ITextSegment regionForOffset​(int offset,
                                     int length)
      • textForOffset

        java.lang.String textForOffset​(int offset,
                                       int length)
      • hasSyntaxError

        boolean hasSyntaxError()