Interface ITextRegionAccess
-
- All Known Subinterfaces:
ITextRegionAccessDiff
- All Known Implementing Classes:
AbstractRegionAccess,NodeModelBasedRegionAccess,StringBasedRegionAccess,StringBasedTextRegionAccessDiff
public interface ITextRegionAccessThis class provides access to
text regionsbased 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 regionsandhidden 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
The purpose of this class is:IHiddenRegioncontains a list ofparts, which are eitherwhite spaceorcomments. A HiddenRegion can be empty.- 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 Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description ITextRegionExtensionsgetExtensions()XtextResourcegetResource()ITextRegionRewritergetRewriter()booleanhasSyntaxError()ITextSegmentregionForDocument()IEObjectRegionregionForEObject(org.eclipse.emf.ecore.EObject semanticElement)Returns a the text region for a semantic element (i.e.ILineRegionregionForLineAtOffset(int offset)ITextSegmentregionForOffset(int offset, int length)IEObjectRegionregionForRootEObject()java.lang.StringtextForOffset(int offset, int length)
-
-
-
Method Detail
-
getExtensions
ITextRegionExtensions getExtensions()
-
getResource
XtextResource getResource()
- Returns:
- The
XtextResourcethat backs the document this class provides access to.
-
getRewriter
ITextRegionRewriter getRewriter()
-
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).
-
regionForDocument
ITextSegment regionForDocument()
-
regionForOffset
ITextSegment regionForOffset(int offset, int length)
-
regionForRootEObject
IEObjectRegion regionForRootEObject()
-
textForOffset
java.lang.String textForOffset(int offset, int length)
-
hasSyntaxError
boolean hasSyntaxError()
-
-