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.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 |
| 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.
|
String |
getCssBaseNamespace()
Returns the CSS base namespace for this file (usable in any template in this file).
|
String |
getDelPackageName()
Returns the name of the containing delegate package, or null if none.
|
String |
getFileName()
Returns this Soy file's name.
|
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.
|
NamespaceDeclaration |
getNamespaceDeclaration()
Returns the parsed namespace for the file.
|
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).
|
SourceLocation |
getSourceLocation()
Deprecated.
SoyFileNodes don't have source locations.
|
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, 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, 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.namespaceDeclaration - This Soy file's namespace and attributes. Nullable for backwards
compatibility only.headerInfo - Other file metadata, (e.g. delpackages, aliases)public SoyNode.Kind getKind()
SoyNodepublic SoyFileKind getSoyFileKind()
@Nullable public String getDelPackageName()
public String getNamespace()
public NamespaceDeclaration getNamespaceDeclaration()
public com.google.common.collect.ImmutableList<String> getRequiredCssNamespaces()
@Nullable public String getCssBaseNamespace()
public com.google.common.collect.ImmutableList<AliasDeclaration> getAliasDeclarations()
public String getFilePath()
@Deprecated public SourceLocation getSourceLocation()
AbstractSoyNodeThis is an optional operation. Some nodes don't have source locations.
getSourceLocation in interface NodegetSourceLocation in class AbstractSoyNodepublic 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 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).