Package org.jetbrains.mps.openapi.model
Interface SReference
-
public interface SReference
Represents reference between nodes. Nodes are organized in AST with references going across the tree hierarchy and connecting nodes from different branches or trees.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Deprecated Methods Modifier and Type Method Description default ResolveInfo
describeTarget()
Captures information about reference target necessary to resolve it, unrelated to the source node and association link this reference is bound to.SReferenceLink
getLink()
Gets the associated Link - an abstract meta-definition for the referencedefault String
getRole()
Deprecated.usegetLink()
to identify reference role, or to access its nameSNode
getSourceNode()
Containing node for this reference.SNode
getTargetNode()
Resolves the target node in the containing repository.SNodeId
getTargetNodeId()
SNodeReference
getTargetNodeReference()
Builds and returns a reference to the target node.SModelReference
getTargetSModelReference()
The following two operations are defined only for references which can instantly respond to the request (e.g.
-
-
-
Method Detail
-
getRole
@Deprecated default String getRole()
Deprecated.usegetLink()
to identify reference role, or to access its name- Returns:
getLink().getName()
-
getLink
SReferenceLink getLink()
Gets the associated Link - an abstract meta-definition for the reference
-
getSourceNode
SNode getSourceNode()
Containing node for this reference.
-
getTargetNode
SNode getTargetNode()
Resolves the target node in the containing repository. This operation is not guaranteed to be fast. It may require to traverse the repository, compute types for some nodes or execute code provided by the language-designer.- Returns:
- the node behind the reference, or null if something is broken in the repository
-
getTargetNodeReference
SNodeReference getTargetNodeReference()
Builds and returns a reference to the target node. Tries to avoid lengthy computations whenever possible. Does exactly the same as getTargetNode().getReference(), but probably faster.
-
getTargetSModelReference
@Nullable SModelReference getTargetSModelReference()
The following two operations are defined only for references which can instantly respond to the request (e.g. they store the target model reference and/or node id as a part of the reference).- Returns:
- target model reference (if available)
-
describeTarget
@NotNull default ResolveInfo describeTarget()
Captures information about reference target necessary to resolve it, unrelated to the source node and association link this reference is bound to. Some reference implementations may choose to use simple string to describe target and rely on scopes to resolve actual node, others may keep target node identity as well as auxiliary information (aka 'resolveInfo') that helps to identify reference target.
To make a copy of a reference into another node with no extra hassle,newSource.setReference(newOrSameAssociation, oldSource.getReference(someAssociation).describeTarget()
is viable approach.- Returns:
- immutable object one can use to carry reference target information around
- Since:
- 2021.2
-
-