public final class RawTextNode extends AbstractSoyNode implements SoyNode.StandaloneNode
Important: Do not use outside of Soy code (treat as superpackage-private).
| Modifier and Type | Class and Description |
|---|---|
static class |
RawTextNode.SourceOffsets
A helper object to calculate source location offsets inside of RawTextNodes.
|
SoyNode.BlockCommandNode, SoyNode.BlockNode, SoyNode.CommandNode, SoyNode.ConditionalBlockNode, SoyNode.ExprHolderNode, SoyNode.Kind, SoyNode.LocalVarBlockNode, SoyNode.LocalVarInlineNode, SoyNode.LocalVarNode, SoyNode.MsgBlockNode, SoyNode.MsgPlaceholderInitialNode, SoyNode.MsgSubstUnitNode, SoyNode.ParentSoyNode<N extends SoyNode>, SoyNode.RenderUnitNode, SoyNode.SplitLevelTopNode<N extends SoyNode>, SoyNode.StandaloneNode, SoyNode.StatementNode| Constructor and Description |
|---|
RawTextNode(int id,
String rawText,
SourceLocation sourceLocation) |
RawTextNode(int id,
String rawText,
SourceLocation sourceLocation,
HtmlContext htmlContext) |
RawTextNode(int id,
String rawText,
SourceLocation sourceLocation,
RawTextNode.SourceOffsets offsets) |
| Modifier and Type | Method and Description |
|---|---|
static RawTextNode |
concat(List<RawTextNode> nodes)
Concatenates the non-empty set of RawTextNodes, preserving source location information.
|
RawTextNode |
copy(CopyState copyState)
Copies this node.
|
HtmlContext |
getHtmlContext()
Gets the HTML source context (typically tag, attribute value, HTML PCDATA, or plain text) which
this node emits in.
|
SoyNode.Kind |
getKind()
Returns this node's kind (corresponding to this node's specific type).
|
SoyNode.ParentSoyNode<SoyNode.StandaloneNode> |
getParent()
Gets this node's parent.
|
String |
getRawText()
Returns the raw text string (after processing of special chars and literal blocks).
|
boolean |
isEmpty() |
SourceLocation.Point |
locationOf(int i) |
boolean |
missingWhitespaceAt(int index)
Returns true if there was whitespace deleted immediately prior to
index |
void |
setHtmlContext(HtmlContext value) |
RawTextNode |
substring(int newId,
int start)
Returns a new RawTextNode that represents the given
String.substring(int) of this raw
text node. |
RawTextNode |
substring(int newId,
int start,
int end)
Returns a new RawTextNode that represents the given
String.substring(int, int) of this
raw text node. |
SourceLocation |
substringLocation(int start,
int end)
Returns the source location of the given substring.
|
String |
toSourceString()
Builds a Soy source string that could be the source for this node.
|
getId, getSourceLocation, setId, toStringcouldHaveSyntaxVersionAtLeast, equals, getNearestAncestor, getSyntaxVersionUpperBound, hasAncestor, hashCode, maybeSetSyntaxVersionUpperBound, setParentclone, finalize, getClass, notify, notifyAll, wait, wait, waitcouldHaveSyntaxVersionAtLeast, getNearestAncestor, getSourceLocation, getSyntaxVersionUpperBound, hasAncestor, maybeSetSyntaxVersionUpperBound, setParentpublic RawTextNode(int id,
String rawText,
SourceLocation sourceLocation)
id - The id for this node.rawText - The raw text string.sourceLocation - The node's source location.public RawTextNode(int id,
String rawText,
SourceLocation sourceLocation,
HtmlContext htmlContext)
public RawTextNode(int id,
String rawText,
SourceLocation sourceLocation,
RawTextNode.SourceOffsets offsets)
public HtmlContext getHtmlContext()
public SoyNode.Kind getKind()
SoyNodepublic void setHtmlContext(HtmlContext value)
public String getRawText()
public boolean isEmpty()
public boolean missingWhitespaceAt(int index)
indexindex - the index in the raw text, this value should be in the range [0,
rawText.length()] if rawText.length() is passed, then this is equivalent to asking
if there is trailing whitespace missing.true if whitespace was droppedIndexOutOfBoundsException - if index is out of range.public SourceLocation.Point locationOf(int i)
public SourceLocation substringLocation(int start, int end)
public RawTextNode substring(int newId, int start)
String.substring(int) of this raw
text node.
Unlike String.substring(int) the range must be non-empty
newId - the new node id to usestart - the start locationpublic RawTextNode substring(int newId, int start, int end)
String.substring(int, int) of this
raw text node.
Unlike String.substring(int, int) the range must be non-empty
newId - the new node id to usestart - the start locationend - the end locationpublic static RawTextNode concat(List<RawTextNode> nodes)
public String toSourceString()
NodeNote: Some nodes do not have a direct mapping to Soy source (such as nodes created during some optimization passes). Thus this method may not always be supported.
toSourceString in interface Nodepublic SoyNode.ParentSoyNode<SoyNode.StandaloneNode> getParent()
NodegetParent in interface NodegetParent in interface SoyNodegetParent in interface SoyNode.StandaloneNodegetParent in class AbstractSoyNodepublic RawTextNode copy(CopyState copyState)
SoyNodeAll copy() overrides should follow this contract:
{@literal @}Override public T copy(CopyState copyState) {
return new T(this, copyState);
}
TODO(lukes): The usecases for a copy method are few and far between. Making the AST nodes immutable (or at least unmodifiable) would be preferable to maintaining our copy() methods.
Don't clone nodes unless you know what you're doing. The Soy AST is not actually a tree (it contains back edges from variables to their definitions), and naively copying nodes can result in pointers into stale ASTs
The copied nodes will have the same ids as the original nodes. If you need to copy a subtree
with new ids assigned to the copied nodes, use SoyTreeUtils.cloneWithNewIds(T, com.google.template.soy.base.internal.IdGenerator).