本文整理汇总了Java中com.google.javascript.jscomp.NodeTraversal.AbstractPostOrderCallback类的典型用法代码示例。如果您正苦于以下问题:Java AbstractPostOrderCallback类的具体用法?Java AbstractPostOrderCallback怎么用?Java AbstractPostOrderCallback使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AbstractPostOrderCallback类属于com.google.javascript.jscomp.NodeTraversal包,在下文中一共展示了AbstractPostOrderCallback类的18个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: searchForParameter
import com.google.javascript.jscomp.NodeTraversal.AbstractPostOrderCallback; //导入依赖的package包/类
private Node searchForParameter(final String parameterName) {
Preconditions.checkArgument(parameterName != null);
final Node[] foundNode = new Node[1];
AbstractPostOrderCallback findParameter = new AbstractPostOrderCallback() {
@Override
public void visit(NodeTraversal t, Node n, Node parent) {
if (n.getParent().getType() == Token.LP
&& parameterName.equals(n.getString())) {
foundNode[0] = n;
}
}
};
new NodeTraversal(lastCompiler, findParameter)
.traverse(lastCompiler.jsRoot);
return foundNode[0];
}
开发者ID:ehsan,项目名称:js-symbolic-executor,代码行数:23,代码来源:VariableVisibilityAnalysisTest.java
示例2: searchForFunction
import com.google.javascript.jscomp.NodeTraversal.AbstractPostOrderCallback; //导入依赖的package包/类
private Node searchForFunction(final String functionName) {
Preconditions.checkArgument(functionName != null);
final Node[] foundNode = new Node[1];
AbstractPostOrderCallback findFunction = new AbstractPostOrderCallback() {
@Override
public void visit(NodeTraversal t, Node n, Node parent) {
if (NodeUtil.isFunction(n)
&& functionName.equals(NodeUtil.getFunctionName(n))) {
foundNode[0] = n;
}
}
};
new NodeTraversal(lastCompiler, findFunction)
.traverse(lastCompiler.jsRoot);
return foundNode[0];
}
开发者ID:ehsan,项目名称:js-symbolic-executor,代码行数:22,代码来源:VariableVisibilityAnalysisTest.java
示例3: searchForParameter
import com.google.javascript.jscomp.NodeTraversal.AbstractPostOrderCallback; //导入依赖的package包/类
private Node searchForParameter(final String parameterName) {
Preconditions.checkArgument(parameterName != null);
final Node[] foundNode = new Node[1];
AbstractPostOrderCallback findParameter = new AbstractPostOrderCallback() {
@Override
public void visit(NodeTraversal t, Node n, Node parent) {
if (n.getParent().isParamList()
&& parameterName.equals(n.getString())) {
foundNode[0] = n;
}
}
};
new NodeTraversal(lastCompiler, findParameter)
.traverse(lastCompiler.jsRoot);
return foundNode[0];
}
开发者ID:SpoonLabs,项目名称:astor,代码行数:23,代码来源:VariableVisibilityAnalysisTest.java
示例4: searchForFunction
import com.google.javascript.jscomp.NodeTraversal.AbstractPostOrderCallback; //导入依赖的package包/类
private Node searchForFunction(final String functionName) {
Preconditions.checkArgument(functionName != null);
final Node[] foundNode = new Node[1];
AbstractPostOrderCallback findFunction = new AbstractPostOrderCallback() {
@Override
public void visit(NodeTraversal t, Node n, Node parent) {
if (n.isFunction()
&& functionName.equals(NodeUtil.getFunctionName(n))) {
foundNode[0] = n;
}
}
};
new NodeTraversal(lastCompiler, findFunction)
.traverse(lastCompiler.jsRoot);
return foundNode[0];
}
开发者ID:SpoonLabs,项目名称:astor,代码行数:22,代码来源:VariableVisibilityAnalysisTest.java
示例5: collectClinitReferences
import com.google.javascript.jscomp.NodeTraversal.AbstractPostOrderCallback; //导入依赖的package包/类
private Multimap<String, Node> collectClinitReferences(Node root) {
final Multimap<String, Node> clinitReferences = HashMultimap.create();
NodeTraversal.traverseEs6(
compiler,
root,
new AbstractPostOrderCallback() {
@Override
public void visit(NodeTraversal t, Node node, Node parent) {
String clinitName = getClinitMethodName(node);
if (clinitName != null) {
clinitReferences.put(clinitName, node);
}
}
});
return clinitReferences;
}
开发者ID:google,项目名称:closure-compiler,代码行数:17,代码来源:J2clClinitPrunerPass.java
示例6: testUnexpectedException
import com.google.javascript.jscomp.NodeTraversal.AbstractPostOrderCallback; //导入依赖的package包/类
public void testUnexpectedException() {
NodeTraversal.Callback cb = new NodeTraversal.AbstractPostOrderCallback() {
@Override
public void visit(NodeTraversal t, Node n, Node parent) {
throw new RuntimeException(TEST_EXCEPTION);
}
};
Compiler compiler = new Compiler();
try {
String code = "function foo() {}";
Node tree = parse(compiler, code);
NodeTraversal.traverseEs6(compiler, tree, cb);
fail("Expected RuntimeException");
} catch (RuntimeException e) {
assertThat(e)
.hasMessageThat()
.startsWith("INTERNAL COMPILER ERROR.\nPlease report this problem.\n\ntest me");
}
}
开发者ID:google,项目名称:closure-compiler,代码行数:23,代码来源:NodeTraversalTest.java
示例7: findNodesWithProperty
import com.google.javascript.jscomp.NodeTraversal.AbstractPostOrderCallback; //导入依赖的package包/类
private Set<Node> findNodesWithProperty(Node root, final byte prop) {
final Set<Node> set = new HashSet<>();
NodeTraversal.traverseEs6(
getLastCompiler(),
root,
new AbstractPostOrderCallback() {
@Override
public void visit(NodeTraversal t, Node node, Node parent) {
if (node.getBooleanProp(prop)) {
set.add(node);
}
}
});
return set;
}
开发者ID:google,项目名称:closure-compiler,代码行数:17,代码来源:NormalizeTest.java
示例8: searchForParameter
import com.google.javascript.jscomp.NodeTraversal.AbstractPostOrderCallback; //导入依赖的package包/类
private Node searchForParameter(final String parameterName) {
checkArgument(parameterName != null);
final Node[] foundNode = new Node[1];
AbstractPostOrderCallback findParameter = new AbstractPostOrderCallback() {
@Override
public void visit(NodeTraversal t, Node n, Node parent) {
if (n.getParent().isParamList()
&& parameterName.equals(n.getString())) {
foundNode[0] = n;
}
}
};
NodeTraversal.traverseEs6(getLastCompiler(), getLastCompiler().jsRoot, findParameter);
return foundNode[0];
}
开发者ID:google,项目名称:closure-compiler,代码行数:22,代码来源:VariableVisibilityAnalysisTest.java
示例9: searchForFunction
import com.google.javascript.jscomp.NodeTraversal.AbstractPostOrderCallback; //导入依赖的package包/类
private Node searchForFunction(final String functionName) {
checkArgument(functionName != null);
final Node[] foundNode = new Node[1];
AbstractPostOrderCallback findFunction =
new AbstractPostOrderCallback() {
@Override
public void visit(NodeTraversal t, Node n, Node parent) {
if (n.isFunction() && functionName.equals(NodeUtil.getName(n))) {
foundNode[0] = n;
}
}
};
NodeTraversal.traverseEs6(getLastCompiler(), getLastCompiler().jsRoot, findFunction);
return foundNode[0];
}
开发者ID:google,项目名称:closure-compiler,代码行数:21,代码来源:VariableVisibilityAnalysisTest.java
示例10: process
import com.google.javascript.jscomp.NodeTraversal.AbstractPostOrderCallback; //导入依赖的package包/类
@Override
public void process(Node externs, Node root) {
NodeTraversal.traverseRootsEs6(
compiler,
new AbstractPostOrderCallback() {
@Override
public void visit(NodeTraversal t, Node n, Node parent) {
if (n.isName() && !parent.isFunction() && !parent.isLabel()) {
assertWithMessage("Variable %s should have been declared", n)
.that(t.getScope().isDeclared(n.getString(), true))
.isTrue();
}
}
},
externs,
root);
}
开发者ID:google,项目名称:closure-compiler,代码行数:18,代码来源:VarCheckTest.java
示例11: processSubtree
import com.google.javascript.jscomp.NodeTraversal.AbstractPostOrderCallback; //导入依赖的package包/类
@Override
public Result processSubtree(Node subtree) {
NodeTraversal.traverse(compiler, subtree,
new AbstractPostOrderCallback() {
@Override
public void visit(NodeTraversal t, Node n, Node parent) {
if ((NodeUtil.isString(n) || NodeUtil.isName(n))
&& n.getString().equals("foo")) {
n.setString("bar");
}
}
});
return result;
}
开发者ID:andyjko,项目名称:feedlack,代码行数:15,代码来源:ParallelCompilerPassTest.java
示例12: process
import com.google.javascript.jscomp.NodeTraversal.AbstractPostOrderCallback; //导入依赖的package包/类
@Override
public void process(Node externs, Node root) {
NodeTraversal.traverseRoots(compiler, Lists.newArrayList(externs, root),
new AbstractPostOrderCallback() {
@Override
public void visit(NodeTraversal t, Node n, Node parent) {
if (NodeUtil.isName(n) && !NodeUtil.isFunction(parent)
&& parent.getType() != Token.LABEL) {
assertTrue("Variable " + n.getString() + " should have be declared",
t.getScope().isDeclared(n.getString(), true));
}
}
});
}
开发者ID:andyjko,项目名称:feedlack,代码行数:15,代码来源:VarCheckTest.java
示例13: createFunctionsAndCallsites
import com.google.javascript.jscomp.NodeTraversal.AbstractPostOrderCallback; //导入依赖的package包/类
/**
* Creates {@link Function}s and {@link Callsite}s in a single
* AST traversal.
*/
private void createFunctionsAndCallsites(Node jsRoot,
final DefinitionProvider provider) {
// Create fake function representing global execution
mainFunction = createFunction(jsRoot);
NodeTraversal.traverse(compiler, jsRoot, new AbstractPostOrderCallback() {
@Override
public void visit(NodeTraversal t, Node n, Node parent) {
int nodeType = n.getType();
if (nodeType == Token.CALL || nodeType == Token.NEW) {
Callsite callsite = createCallsite(n);
Node containingFunctionNode = t.getScopeRoot();
Function containingFunction =
functionsByNode.get(containingFunctionNode);
if (containingFunction == null) {
containingFunction = createFunction(containingFunctionNode);
}
callsite.containingFunction = containingFunction;
containingFunction.addCallsiteInFunction(callsite);
connectCallsiteToTargets(callsite, provider);
} else if (NodeUtil.isFunction(n)) {
if (!functionsByNode.containsKey(n)) {
createFunction(n);
}
}
}
});
}
开发者ID:ehsan,项目名称:js-symbolic-executor,代码行数:39,代码来源:CallGraph.java
示例14: createFunctionsAndCallsites
import com.google.javascript.jscomp.NodeTraversal.AbstractPostOrderCallback; //导入依赖的package包/类
/**
* Creates {@link Function}s and {@link Callsite}s in a single
* AST traversal.
*/
private void createFunctionsAndCallsites(Node jsRoot,
final DefinitionProvider provider) {
// Create fake function representing global execution
mainFunction = createFunction(jsRoot);
NodeTraversal.traverse(compiler, jsRoot, new AbstractPostOrderCallback() {
@Override
public void visit(NodeTraversal t, Node n, Node parent) {
int nodeType = n.getType();
if (nodeType == Token.CALL || nodeType == Token.NEW) {
Callsite callsite = createCallsite(n);
Node containingFunctionNode = t.getScopeRoot();
Function containingFunction =
functionsByNode.get(containingFunctionNode);
if (containingFunction == null) {
containingFunction = createFunction(containingFunctionNode);
}
callsite.containingFunction = containingFunction;
containingFunction.addCallsiteInFunction(callsite);
connectCallsiteToTargets(callsite, provider);
} else if (n.isFunction()) {
if (!functionsByNode.containsKey(n)) {
createFunction(n);
}
}
}
});
}
开发者ID:SpoonLabs,项目名称:astor,代码行数:39,代码来源:CallGraph.java
示例15: findNodesWithProperty
import com.google.javascript.jscomp.NodeTraversal.AbstractPostOrderCallback; //导入依赖的package包/类
private Set<Node> findNodesWithProperty(Node root, final int prop) {
final Set<Node> set = Sets.newHashSet();
NodeTraversal.traverse(
getLastCompiler(), root, new AbstractPostOrderCallback() {
@Override
public void visit(NodeTraversal t, Node node, Node parent) {
if (node.getBooleanProp(prop)) {
set.add(node);
}
}
});
return set;
}
开发者ID:SpoonLabs,项目名称:astor,代码行数:14,代码来源:NormalizeTest.java
示例16: process
import com.google.javascript.jscomp.NodeTraversal.AbstractPostOrderCallback; //导入依赖的package包/类
@Override
public void process(Node externs, Node root) {
NodeTraversal.traverseRoots(compiler, Lists.newArrayList(externs, root),
new AbstractPostOrderCallback() {
@Override
public void visit(NodeTraversal t, Node n, Node parent) {
if (n.isName() && !parent.isFunction()
&& !parent.isLabel()) {
assertTrue("Variable " + n.getString() + " should have be declared",
t.getScope().isDeclared(n.getString(), true));
}
}
});
}
开发者ID:SpoonLabs,项目名称:astor,代码行数:15,代码来源:VarCheckTest.java
示例17: process
import com.google.javascript.jscomp.NodeTraversal.AbstractPostOrderCallback; //导入依赖的package包/类
@Override
public void process(Node externs, Node root) {
if (!J2clSourceFileChecker.shouldRunJ2clPasses(compiler)) {
return;
}
final Multimap<String, Node> fieldAssignments = ArrayListMultimap.create();
final Set<Node> hoistableFunctions = new HashSet<>();
NodeTraversal.traverseEs6(
compiler,
root,
new AbstractPostOrderCallback() {
@Override
public void visit(NodeTraversal t, Node node, Node parent) {
// TODO(stalcup): don't gather assignments ourselves, switch to a persistent
// DefinitionUseSiteFinder instead.
if (parent != null && NodeUtil.isLValue(node)) {
fieldAssignments.put(node.getQualifiedName(), parent);
}
// TODO(stalcup): convert to a persistent index of hoistable functions.
if (isHoistableFunction(t, node)) {
hoistableFunctions.add(node);
}
}
});
for (Collection<Node> assignments : fieldAssignments.asMap().values()) {
maybeHoistClassField(assignments, hoistableFunctions);
}
}
开发者ID:google,项目名称:closure-compiler,代码行数:32,代码来源:J2clConstantHoisterPass.java
示例18: testNodeTraversalInterruptable
import com.google.javascript.jscomp.NodeTraversal.AbstractPostOrderCallback; //导入依赖的package包/类
public void testNodeTraversalInterruptable() {
Compiler compiler = new Compiler();
String code = "var a; \n";
Node tree = parse(compiler, code);
final AtomicInteger counter = new AtomicInteger(0);
NodeTraversal.Callback countingCallback =
new NodeTraversal.AbstractPostOrderCallback() {
@Override
public void visit(NodeTraversal t, Node n, Node parent) {
counter.incrementAndGet();
}
};
NodeTraversal.traverseEs6(compiler, tree, countingCallback);
assertThat(counter.get()).isEqualTo(3);
counter.set(0);
Thread.currentThread().interrupt();
try {
NodeTraversal.traverseEs6(compiler, tree, countingCallback);
fail("Expected a RuntimeException;");
} catch (RuntimeException e) {
assertThat(e).hasCauseThat().hasCauseThat().isInstanceOf(InterruptedException.class);
}
}
开发者ID:google,项目名称:closure-compiler,代码行数:28,代码来源:NodeTraversalTest.java
注:本文中的com.google.javascript.jscomp.NodeTraversal.AbstractPostOrderCallback类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论