public interface ITextRegionAccess
ITextSegment
s) 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 ISemanticRegion
s and
IHiddenRegion
s. 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 carry ILeafNode.isHidden()
== true.
A semantic token can be the value of an EAttribute, a CrossReference or a keyword.
A IHiddenRegion
contains a list of IHiddenRegionPart
s, which are either IWhitespace
s or
IComment
s. A HidenRegion can be empty.
The purpose of this class is:
ISemanticRegion
,
IHiddenRegion
Modifier and Type | Method and Description |
---|---|
ITextSegment |
expandRegionsByLines(int leadingLines,
int trailingLines,
ITextSegment... regions) |
IHiddenRegion |
getFirstRegionInFile() |
AbstractElement |
getInvokingGrammarElement(org.eclipse.emf.ecore.EObject obj) |
XtextResource |
getResource() |
java.lang.String |
getText(int offset,
int length) |
boolean |
hasSyntaxError() |
boolean |
hasSyntaxError(org.eclipse.emf.ecore.EObject object) |
ISemanticRegion |
immediatelyFollowingKeyword(org.eclipse.emf.ecore.EObject owner,
java.lang.String keyword) |
ISemanticRegion |
immediatelyFollowingKeyword(ISequentialRegion region,
java.lang.String keyword) |
ISemanticRegion |
immediatelyPrecedingKeyword(org.eclipse.emf.ecore.EObject owner) |
ISemanticRegion |
immediatelyPrecedingKeyword(org.eclipse.emf.ecore.EObject owner,
java.lang.String keyword) |
ISemanticRegion |
immediatelyPrecedingKeyword(ISequentialRegion region) |
ISemanticRegion |
immediatelyPrecedingKeyword(ISequentialRegion region,
java.lang.String keyword) |
ITextSegment |
indentationRegion(int offset) |
boolean |
isMultiline(org.eclipse.emf.ecore.EObject object) |
IHiddenRegion |
leadingHiddenRegion(org.eclipse.emf.ecore.EObject owner) |
ITextSegment |
regionForEObject(org.eclipse.emf.ecore.EObject object) |
ISemanticRegion |
regionForFeature(org.eclipse.emf.ecore.EObject owner,
org.eclipse.emf.ecore.EStructuralFeature feature) |
ISemanticRegion |
regionForKeyword(org.eclipse.emf.ecore.EObject owner,
java.lang.String keyword) |
ISemanticRegion |
regionForRuleCallTo(org.eclipse.emf.ecore.EObject owner,
AbstractRule rule) |
java.util.List<ISemanticRegion> |
regionsForKeywords(org.eclipse.emf.ecore.EObject owner,
java.lang.String... string) |
java.util.List<ISemanticRegion> |
regionsForRuleCallsTo(org.eclipse.emf.ecore.EObject owner,
AbstractRule... rule) |
IHiddenRegion |
trailingHiddenRegion(org.eclipse.emf.ecore.EObject owner) |
ITextSegment expandRegionsByLines(int leadingLines, int trailingLines, ITextSegment... regions)
IHiddenRegion getFirstRegionInFile()
IHiddenRegion
inside the linked list of alternating IHiddenRegion
s and
ISemanticRegion
s.AbstractElement getInvokingGrammarElement(org.eclipse.emf.ecore.EObject obj)
XtextResource getResource()
java.lang.String getText(int offset, int length)
boolean hasSyntaxError()
boolean hasSyntaxError(org.eclipse.emf.ecore.EObject object)
ISemanticRegion immediatelyFollowingKeyword(org.eclipse.emf.ecore.EObject owner, java.lang.String keyword)
ISemanticRegion immediatelyFollowingKeyword(ISequentialRegion region, java.lang.String keyword)
ISemanticRegion immediatelyPrecedingKeyword(org.eclipse.emf.ecore.EObject owner)
ISemanticRegion immediatelyPrecedingKeyword(org.eclipse.emf.ecore.EObject owner, java.lang.String keyword)
ISemanticRegion immediatelyPrecedingKeyword(ISequentialRegion region)
ISemanticRegion immediatelyPrecedingKeyword(ISequentialRegion region, java.lang.String keyword)
ITextSegment indentationRegion(int offset)
Character.isWhitespace(char)
.boolean isMultiline(org.eclipse.emf.ecore.EObject object)
IHiddenRegion leadingHiddenRegion(org.eclipse.emf.ecore.EObject owner)
IHiddenRegion
that precedes the EObject's first ISemanticRegion
.trailingHiddenRegion(EObject)
ITextSegment regionForEObject(org.eclipse.emf.ecore.EObject object)
ISemanticRegion regionForFeature(org.eclipse.emf.ecore.EObject owner, org.eclipse.emf.ecore.EStructuralFeature feature)
ISemanticRegion
that represents the value of owner.eGet(feature). May be null.ISemanticRegion regionForKeyword(org.eclipse.emf.ecore.EObject owner, java.lang.String keyword)
ISemanticRegion
that represent 'keyword' and directly belongs to the provided
'EObject'. Keywords of child-EObjects are not considered. May be null.ISemanticRegion regionForRuleCallTo(org.eclipse.emf.ecore.EObject owner, AbstractRule rule)
ISemanticRegion
that represent a RuleCall to the provided AbstractRule and directly
belongs to the provided 'EObject'. RuleCalls of child-EObjects are not considered. May be null.java.util.List<ISemanticRegion> regionsForKeywords(org.eclipse.emf.ecore.EObject owner, java.lang.String... string)
ISemanticRegion
s that represent one of the provided 'keyword's and directly belong to the
provided 'EObject'. Keywords of child-EObjects are not considered.java.util.List<ISemanticRegion> regionsForRuleCallsTo(org.eclipse.emf.ecore.EObject owner, AbstractRule... rule)
ISemanticRegion
s that represent a RuleCall to one of the provided AbstractRules and directly
belong to the provided 'EObject'. RuleCalls of child-EObjects are not considered. May be null.IHiddenRegion trailingHiddenRegion(org.eclipse.emf.ecore.EObject owner)
IHiddenRegion
that follows after the EObject's last ISemanticRegion
.leadingHiddenRegion(EObject)