public final class SoyFileNode extends AbstractParentSoyNode<TemplateNode> implements SoyNode.SplitLevelTopNode<TemplateNode>
Important: Do not use outside of Soy code (treat as superpackage-private).
SoyNode.BlockCommandNode, SoyNode.BlockNode, SoyNode.CommandNode, SoyNode.ConditionalBlockNode, SoyNode.ExprHolderNode, SoyNode.Kind, SoyNode.LocalVarBlockNode, SoyNode.LocalVarInlineNode, SoyNode.LocalVarNode, SoyNode.LoopNode, SoyNode.MsgBlockNode, SoyNode.MsgPlaceholderInitialNode, SoyNode.MsgSubstUnitNode, SoyNode.ParentSoyNode<N extends SoyNode>, SoyNode.RenderUnitNode, SoyNode.SplitLevelTopNode<N extends SoyNode>, SoyNode.StandaloneNode, SoyNode.StatementNode| Modifier and Type | Field and Description |
|---|---|
static com.google.common.base.Predicate<SoyFileNode> |
MATCH_SRC_FILENODE |
SPACES| Constructor and Description |
|---|
SoyFileNode(int id,
String filePath,
SoyFileKind soyFileKind,
NamespaceDeclaration namespaceDeclaration,
TemplateNode.SoyFileHeaderInfo headerInfo) |
| Modifier and Type | Method and Description |
|---|---|
SoyFileNode |
copy(CopyState copyState)
Copies this node.
|
com.google.common.collect.ImmutableList<AliasDeclaration> |
getAliasDeclarations()
Returns the syntactic alias directives in the file.
|
com.google.common.collect.ImmutableMap<String,String> |
getAliasToNamespaceMap()
Returns the map from aliases to namespaces for this file.
|
String |
getCssBaseNamespace()
Returns the CSS base namespace for this file (usable in any template in this file).
|
AutoescapeMode |
getDefaultAutoescapeMode()
Returns the default autoescaping mode for contained templates.
|
String |
getDelPackageName()
Returns the name of the containing delegate package, or null if none.
|
String |
getFileName()
Returns this Soy file's name (null if not supplied).
|
String |
getFilePath()
Returns the path to the source Soy file ("unknown" if not supplied).
|
SoyNode.Kind |
getKind()
Returns this node's kind (corresponding to this node's specific type).
|
String |
getNamespace()
Returns this Soy file's namespace, or null if syntax version V1.
|
SoyFileSetNode |
getParent()
Gets this node's parent.
|
com.google.common.collect.ImmutableList<String> |
getRequiredCssNamespaces()
Returns the CSS namespaces required by this file (usable in any template in this file).
|
SoyFileKind |
getSoyFileKind()
Returns the kind of this Soy file.
|
String |
toSourceString()
Builds a Soy source string that could be the source for this node.
|
addChild, addChild, addChildren, addChildren, appendSourceStringForChildren, clearChildren, getChild, getChildIndex, getChildren, numChildren, removeChild, removeChild, replaceChild, replaceChildgetId, getSourceLocation, setId, toStringcouldHaveSyntaxVersionAtLeast, equals, getNearestAncestor, getSyntaxVersionUpperBound, hasAncestor, hashCode, maybeSetSyntaxVersionUpperBound, setParentclone, finalize, getClass, notify, notifyAll, wait, wait, waitaddChild, addChild, addChildren, addChildren, appendSourceStringForChildren, clearChildren, getChild, getChildIndex, getChildren, numChildren, removeChild, removeChild, replaceChild, replaceChildcouldHaveSyntaxVersionAtLeast, getNearestAncestor, getSourceLocation, getSyntaxVersionUpperBound, hasAncestor, maybeSetSyntaxVersionUpperBound, setParentpublic static final com.google.common.base.Predicate<SoyFileNode> MATCH_SRC_FILENODE
public SoyFileNode(int id,
String filePath,
SoyFileKind soyFileKind,
NamespaceDeclaration namespaceDeclaration,
TemplateNode.SoyFileHeaderInfo headerInfo)
id - The id for this node.filePath - The path to the Soy source file.soyFileKind - The kind of this Soy file.delPackageName - This Soy file's delegate package, or null if none.namespaceDeclaration - This Soy file's namespace and attributes. Nullable for backwards
compatibility only.aliases - The command texts of the 'alias' declarations. Allowed to be null.public SoyNode.Kind getKind()
SoyNodepublic SoyFileKind getSoyFileKind()
@Nullable public String getDelPackageName()
@Nullable public String getNamespace()
public AutoescapeMode getDefaultAutoescapeMode()
public com.google.common.collect.ImmutableList<String> getRequiredCssNamespaces()
@Nullable public String getCssBaseNamespace()
public com.google.common.collect.ImmutableMap<String,String> getAliasToNamespaceMap()
public com.google.common.collect.ImmutableList<AliasDeclaration> getAliasDeclarations()
public String getFilePath()
@Nullable public String getFileName()
public String toSourceString()
NodetoSourceString in interface Nodepublic SoyFileSetNode getParent()
Nodepublic SoyFileNode 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).