本文整理汇总了Java中com.google.javascript.jscomp.GlobalNamespace.Name.needsToBeStubbed方法的典型用法代码示例。如果您正苦于以下问题:Java Name.needsToBeStubbed方法的具体用法?Java Name.needsToBeStubbed怎么用?Java Name.needsToBeStubbed使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.javascript.jscomp.GlobalNamespace.Name
的用法示例。
在下文中一共展示了Name.needsToBeStubbed方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addStubsForUndeclaredProperties
import com.google.javascript.jscomp.GlobalNamespace.Name; //导入方法依赖的package包/类
/**
* Adds global variable "stubs" for any properties of a global name that are only set in a local
* scope or read but never set.
*
* @param n An object representing a global name (e.g. "a", "a.b.c")
* @param alias The flattened name of the object whose properties we are adding stubs for (e.g.
* "a$b$c")
* @param parent The node to which new global variables should be added as children
* @param addAfter The child of after which new variables should be added
*/
private void addStubsForUndeclaredProperties(Name n, String alias, Node parent, Node addAfter) {
checkState(n.canCollapseUnannotatedChildNames(), n);
checkArgument(NodeUtil.isStatementBlock(parent), parent);
checkNotNull(addAfter);
if (n.props == null) {
return;
}
for (Name p : n.props) {
if (p.needsToBeStubbed()) {
String propAlias = appendPropForAlias(alias, p.getBaseName());
Node nameNode = IR.name(propAlias);
Node newVar = IR.var(nameNode).useSourceInfoIfMissingFromForTree(addAfter);
parent.addChildAfter(newVar, addAfter);
addAfter = newVar;
compiler.reportChangeToEnclosingScope(newVar);
// Determine if this is a constant var by checking the first
// reference to it. Don't check the declaration, as it might be null.
if (p.getRefs().get(0).node.getLastChild().getBooleanProp(
Node.IS_CONSTANT_NAME)) {
nameNode.putBooleanProp(Node.IS_CONSTANT_NAME, true);
compiler.reportChangeToEnclosingScope(nameNode);
}
}
}
}
示例2: addStubsForUndeclaredProperties
import com.google.javascript.jscomp.GlobalNamespace.Name; //导入方法依赖的package包/类
/**
* Adds global variable "stubs" for any properties of a global name that are
* only set in a local scope or read but never set.
*
* @param n An object representing a global name (e.g. "a", "a.b.c")
* @param alias The flattened name of the object whose properties we are
* adding stubs for (e.g. "a$b$c")
* @param parent The node to which new global variables should be added
* as children
* @param addAfter The child of after which new
* variables should be added (may be null)
* @return The number of variables added
*/
private int addStubsForUndeclaredProperties(
Name n, String alias, Node parent, Node addAfter) {
Preconditions.checkArgument(NodeUtil.isStatementBlock(parent));
int numStubs = 0;
if (n.props != null) {
for (Name p : n.props) {
if (p.needsToBeStubbed()) {
String propAlias = appendPropForAlias(alias, p.name);
Node nameNode = Node.newString(Token.NAME, propAlias);
Node newVar = new Node(Token.VAR, nameNode);
if (addAfter == null) {
parent.addChildToFront(newVar);
} else {
parent.addChildAfter(newVar, addAfter);
addAfter = newVar;
}
numStubs++;
compiler.reportCodeChange();
// Determine if this is a constant var by checking the first
// reference to it. Don't check the declaration, as it might be null.
if (p.refs.get(0).node.getLastChild().getBooleanProp(
Node.IS_CONSTANT_NAME)) {
nameNode.putBooleanProp(Node.IS_CONSTANT_NAME, true);
}
}
}
}
return numStubs;
}
示例3: addStubsForUndeclaredProperties
import com.google.javascript.jscomp.GlobalNamespace.Name; //导入方法依赖的package包/类
/**
* Adds global variable "stubs" for any properties of a global name that are
* only set in a local scope or read but never set.
*
* @param n An object representing a global name (e.g. "a", "a.b.c")
* @param alias The flattened name of the object whose properties we are
* adding stubs for (e.g. "a$b$c")
* @param parent The node to which new global variables should be added
* as children
* @param addAfter The child of after which new
* variables should be added (may be null)
* @return The number of variables added
*/
private int addStubsForUndeclaredProperties(
Name n, String alias, Node parent, Node addAfter) {
Preconditions.checkArgument(NodeUtil.isStatementBlock(parent));
Preconditions.checkNotNull(addAfter);
int numStubs = 0;
if (n.props != null) {
for (Name p : n.props) {
if (p.needsToBeStubbed()) {
String propAlias = appendPropForAlias(alias, p.name);
Node nameNode = Node.newString(Token.NAME, propAlias);
Node newVar = new Node(Token.VAR, nameNode)
.copyInformationFromForTree(addAfter);
parent.addChildAfter(newVar, addAfter);
addAfter = newVar;
numStubs++;
compiler.reportCodeChange();
// Determine if this is a constant var by checking the first
// reference to it. Don't check the declaration, as it might be null.
if (p.refs.get(0).node.getLastChild().getBooleanProp(
Node.IS_CONSTANT_NAME)) {
nameNode.putBooleanProp(Node.IS_CONSTANT_NAME, true);
}
}
}
}
return numStubs;
}
示例4: addStubsForUndeclaredProperties
import com.google.javascript.jscomp.GlobalNamespace.Name; //导入方法依赖的package包/类
/**
* Adds global variable "stubs" for any properties of a global name that are
* only set in a local scope or read but never set.
*
* @param n An object representing a global name (e.g. "a", "a.b.c")
* @param alias The flattened name of the object whose properties we are
* adding stubs for (e.g. "a$b$c")
* @param parent The node to which new global variables should be added
* as children
* @param addAfter The child of after which new
* variables should be added (may be null)
* @return The number of variables added
*/
private int addStubsForUndeclaredProperties(
Name n, String alias, Node parent, Node addAfter) {
Preconditions.checkState(n.canCollapseUnannotatedChildNames());
Preconditions.checkArgument(NodeUtil.isStatementBlock(parent));
Preconditions.checkNotNull(addAfter);
int numStubs = 0;
if (n.props != null) {
for (Name p : n.props) {
if (p.needsToBeStubbed()) {
String propAlias = appendPropForAlias(alias, p.getBaseName());
Node nameNode = IR.name(propAlias);
Node newVar = IR.var(nameNode)
.copyInformationFromForTree(addAfter);
parent.addChildAfter(newVar, addAfter);
addAfter = newVar;
numStubs++;
compiler.reportCodeChange();
// Determine if this is a constant var by checking the first
// reference to it. Don't check the declaration, as it might be null.
if (p.getRefs().get(0).node.getLastChild().getBooleanProp(
Node.IS_CONSTANT_NAME)) {
nameNode.putBooleanProp(Node.IS_CONSTANT_NAME, true);
}
}
}
}
return numStubs;
}