public class NodeModelUtils
extends java.lang.Object
ILocationInFileProvider
and EObjectAtOffsetHelper
if they want to to access the region
of a semantic object
.Constructor and Description |
---|
NodeModelUtils() |
Modifier and Type | Method and Description |
---|---|
static java.lang.String |
compactDump(INode node,
boolean showHidden)
Creates a string representation of the given node.
|
static ICompositeNode |
findActualNodeFor(org.eclipse.emf.ecore.EObject semanticObject)
Returns the node that covers all assigned values of the given object.
|
static org.eclipse.emf.ecore.EObject |
findActualSemanticObjectFor(INode node)
Returns the semantic object that is really associated with the actual container node of the given node.
|
static ILeafNode |
findLeafNodeAtOffset(INode node,
int leafNodeOffset)
Find the leaf node at the given offset.
|
static java.util.List<INode> |
findNodesForFeature(org.eclipse.emf.ecore.EObject semanticObject,
org.eclipse.emf.ecore.EStructuralFeature structuralFeature)
Returns the list of nodes that were used to assign values to the given feature for the given object.
|
static ICompositeNode |
getNode(org.eclipse.emf.ecore.EObject object)
Returns the node that is directly associated with the given object by means of an EMF-Adapter.
|
static java.lang.String |
getTokenText(INode node)
This method converts a node to text.
|
public static ILeafNode findLeafNodeAtOffset(INode node, int leafNodeOffset)
null
if the given offset is not valid for the
node (sub-)tree.
A node matches the leafNodeOffset
if it fulfills the following condition:
node.totalOffset <= leafNodeOffset && node.totalEndOffset > leafNodeOffset
node
- the container node. May not be null
.leafNodeOffset
- the offset that is covered by the searched node.null
.public static ICompositeNode getNode(org.eclipse.emf.ecore.EObject object)
object
- the semantic object whose direct node should be provided.findActualNodeFor(EObject)
public static java.util.List<INode> findNodesForFeature(org.eclipse.emf.ecore.EObject semanticObject, org.eclipse.emf.ecore.EStructuralFeature structuralFeature)
public static ICompositeNode findActualNodeFor(org.eclipse.emf.ecore.EObject semanticObject)
Returns the node that covers all assigned values of the given object. It handles the semantics of actions
and unassigned rule calls
. The returned node will include unassigned surrounding leafs,
e.g. if you use something like Parenthesized expressions
redundant parentheses will be part of the returned node.
Consider the following simple expression (a number literal):
((1))Assuming it was parsed from a grammar like this:
Expression: Number | Parentheses; Parentheses: '(' Expression ')'; Number: value=INTThe actual node for the only semantic object that was produced from the input
((1))
is the root node
even though the minimal node would be the one with the text 1
.semanticObject
- the semantic object whose node should be provided.public static org.eclipse.emf.ecore.EObject findActualSemanticObjectFor(INode node)
Actions
and unassigned rule
calls
.public static java.lang.String compactDump(INode node, boolean showHidden)
public static java.lang.String getTokenText(INode node)
ICompositeNode
that has been created for a data
type rule to text.
This is also the recommended way to convert a node to text if you want to invoke
IValueConverterService.toValue(String, String, INode)