本文整理汇总了Java中com.google.javascript.jscomp.graph.GraphNode类的典型用法代码示例。如果您正苦于以下问题:Java GraphNode类的具体用法?Java GraphNode怎么用?Java GraphNode使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
GraphNode类属于com.google.javascript.jscomp.graph包,在下文中一共展示了GraphNode类的17个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: shouldTraverse
import com.google.javascript.jscomp.graph.GraphNode; //导入依赖的package包/类
@Override
public boolean shouldTraverse(NodeTraversal t, Node n, Node parent) {
GraphNode<Node, Branch> gNode = t.getControlFlowGraph().getNode(n);
if (gNode != null && gNode.getAnnotation() != GraphReachability.REACHABLE) {
// Only report error when there are some line number informations.
// There are synthetic nodes with no line number informations, nodes
// introduce by other passes (although not likely since this pass should
// be executed early) or some rhino bug.
if (n.getLineno() != -1 &&
// Allow spurious semi-colons and spurious breaks.
n.getType() != Token.EMPTY && n.getType() != Token.BREAK) {
compiler.report(JSError.make(t, n, level, UNREACHABLE_CODE));
// From now on, we are going to assume the user fixed the error and not
// give more warning related to code section reachable from this node.
new GraphReachability<Node, ControlFlowGraph.Branch>(
t.getControlFlowGraph()).recompute(n);
// Saves time by not traversing children.
return false;
}
}
return true;
}
开发者ID:andyjko,项目名称:feedlack,代码行数:25,代码来源:CheckUnreachableCode.java
示例2: shouldTraverse
import com.google.javascript.jscomp.graph.GraphNode; //导入依赖的package包/类
@Override
public boolean shouldTraverse(NodeTraversal t, Node n, Node parent) {
GraphNode<Node, Branch> gNode = t.getControlFlowGraph().getNode(n);
if (gNode != null && gNode.getAnnotation() != GraphReachability.REACHABLE) {
// Only report error when there are some line number informations.
// There are synthetic nodes with no line number informations, nodes
// introduce by other passes (although not likely since this pass should
// be executed early) or some rhino bug.
if (n.getLineno() != -1 &&
// Allow spurious semi-colons and spurious breaks.
!n.isEmpty() && !n.isBreak()) {
compiler.report(t.makeError(n, level, UNREACHABLE_CODE));
// From now on, we are going to assume the user fixed the error and not
// give more warning related to code section reachable from this node.
new GraphReachability<Node, ControlFlowGraph.Branch>(
t.getControlFlowGraph()).recompute(n);
// Saves time by not traversing children.
return false;
}
}
return true;
}
开发者ID:SpoonLabs,项目名称:astor,代码行数:25,代码来源:CheckUnreachableCode.java
示例3: shouldTraverse
import com.google.javascript.jscomp.graph.GraphNode; //导入依赖的package包/类
@Override
public boolean shouldTraverse(NodeTraversal t, Node n, Node parent) {
GraphNode<Node, Branch> gNode = t.getControlFlowGraph().getNode(n);
if (gNode != null && gNode.getAnnotation() != GraphReachability.REACHABLE) {
// Only report error when there are some line number informations.
// There are synthetic nodes with no line number informations, nodes
// introduce by other passes (although not likely since this pass should
// be executed early) or some rhino bug.
if (n.getLineno() != -1 &&
// Allow spurious semi-colons and spurious breaks.
!n.isEmpty() && !n.isBreak()) {
compiler.report(t.makeError(n, UNREACHABLE_CODE));
// From now on, we are going to assume the user fixed the error and not
// give more warning related to code section reachable from this node.
new GraphReachability<>(t.getControlFlowGraph()).recompute(n);
// Saves time by not traversing children.
return false;
}
}
return true;
}
开发者ID:google,项目名称:closure-compiler,代码行数:24,代码来源:CheckUnreachableCode.java
示例4: shouldTraverse
import com.google.javascript.jscomp.graph.GraphNode; //导入依赖的package包/类
@Override
public boolean shouldTraverse(NodeTraversal t, Node n, Node parent) {
GraphNode<Node, Branch> gNode = t.getControlFlowGraph().getNode(n);
if (gNode != null && gNode.getAnnotation() != GraphReachability.REACHABLE) {
// Only report error when there are some line number informations.
// There are synthetic nodes with no line number informations, nodes
// introduce by other passes (although not likely since this pass should
// be executed early) or some rhino bug.
if (n.getLineno() != -1 &&
// Allow spurious semi-colons and spurious breaks.
!n.isEmpty() && !n.isBreak()) {
compiler.report(t.makeError(n, UNREACHABLE_CODE));
// From now on, we are going to assume the user fixed the error and not
// give more warning related to code section reachable from this node.
new GraphReachability<>(
t.getControlFlowGraph()).recompute(n);
// Saves time by not traversing children.
return false;
}
}
return true;
}
开发者ID:nicks,项目名称:closure-compiler-old,代码行数:25,代码来源:CheckUnreachableCode.java
示例5: visit
import com.google.javascript.jscomp.graph.GraphNode; //导入依赖的package包/类
@Override
public void visit(NodeTraversal t, Node n, Node parent) {
if (parent == null) {
return;
}
if (n.getType() == Token.FUNCTION || n.getType() == Token.SCRIPT) {
return;
}
// Removes TRYs that had its CATCH removed and/or empty FINALLY.
if (n.getType() == Token.TRY) {
Node body = n.getFirstChild();
Node catchOrFinallyBlock = body.getNext();
Node finallyBlock = catchOrFinallyBlock.getNext();
if (!catchOrFinallyBlock.hasChildren() &&
(finallyBlock == null || !finallyBlock.hasChildren())) {
n.removeChild(body);
parent.replaceChild(n, body);
compiler.reportCodeChange();
n = body;
}
}
GraphNode<Node, Branch> gNode = curCfg.getNode(n);
if (gNode == null) { // Not in CFG.
return;
}
if (gNode.getAnnotation() != GraphReachability.REACHABLE ||
(removeNoOpStatements && !NodeUtil.mayHaveSideEffects(n))) {
removeDeadExprStatementSafely(n, parent);
}
}
开发者ID:andyjko,项目名称:feedlack,代码行数:32,代码来源:UnreachableCodeElimination.java
示例6: connectUnknowns
import com.google.javascript.jscomp.graph.GraphNode; //导入依赖的package包/类
private void connectUnknowns() {
for (GraphNode<Name, Reference> node : graph.getNodes()) {
Name name = node.getValue();
String propName = name.getPropertyName();
if (propName == null) {
continue;
}
Collection<NameUse> uses = unknownNameUse.get(propName);
if (uses != null) {
for (NameUse use : uses) {
graph.connect(use.name, use.reference, name);
}
}
}
}
开发者ID:andyjko,项目名称:feedlack,代码行数:16,代码来源:NameReferenceGraphConstruction.java
示例7: getDef
import com.google.javascript.jscomp.graph.GraphNode; //导入依赖的package包/类
/**
* Gets the must reaching definition of a given node. The node must be one of
* the control flow graph nodes.
*
* @param name name of the variable. It can only be names of local variable
* that are not function parameters, escaped variables or variables
* declared in catch.
* @param useNode the location of the use where the definition reaches.
*/
Node getDef(String name, Node useNode) {
Preconditions.checkArgument(getCfg().hasNode(useNode));
GraphNode<Node, Branch> n = getCfg().getNode(useNode);
FlowState<MustDef> state = n.getAnnotation();
Definition def = state.getIn().reachingDef.get(jsScope.getVar(name));
if (def == null) {
return null;
} else {
return def.node;
}
}
开发者ID:andyjko,项目名称:feedlack,代码行数:21,代码来源:MustBeReachingVariableDef.java
示例8: removeUnusedProperties
import com.google.javascript.jscomp.graph.GraphNode; //导入依赖的package包/类
/**
* Remove all properties under a given name if the property name is
* never referenced.
*/
private void removeUnusedProperties(NameReferenceGraph graph) {
for (GraphNode<Name, Reference> node : graph.getNodes()) {
Name name = node.getValue();
NameInfo nameInfo = node.getAnnotation();
if (nameInfo == null || !nameInfo.isReferenced()) {
name.remove();
compiler.reportCodeChange();
logger.fine("Removed unused name" + name);
}
}
}
开发者ID:andyjko,项目名称:feedlack,代码行数:16,代码来源:RemoveUnusedNames.java
示例9: getInfo
import com.google.javascript.jscomp.graph.GraphNode; //导入依赖的package包/类
private NameInfo getInfo(Name symbol) {
GraphNode<Name, Reference> name = graph.getNode(symbol);
NameInfo info = name.getAnnotation();
if (info == null) {
info = new NameInfo();
name.setAnnotation(info);
}
return info;
}
开发者ID:andyjko,项目名称:feedlack,代码行数:10,代码来源:AnalyzeNameReferences.java
示例10: recompute
import com.google.javascript.jscomp.graph.GraphNode; //导入依赖的package包/类
public void recompute(N reachableNode) {
GraphNode<N, E> newReachable = graph.getNode(reachableNode);
Preconditions.checkState(newReachable.getAnnotation() != REACHABLE);
newReachable.setAnnotation(REACHABLE);
FixedPointGraphTraversal.newTraversal(this)
.computeFixedPoint(graph, reachableNode);
}
开发者ID:andyjko,项目名称:feedlack,代码行数:8,代码来源:GraphReachability.java
示例11: traverseEdge
import com.google.javascript.jscomp.graph.GraphNode; //导入依赖的package包/类
@Override
public boolean traverseEdge(N source, E e, N destination) {
if (graph.getNode(source).getAnnotation() == REACHABLE) {
GraphNode<N, E> destNode = graph.getNode(destination);
if (destNode.getAnnotation() != REACHABLE) {
destNode.setAnnotation(REACHABLE);
return true;
}
}
return false;
}
开发者ID:andyjko,项目名称:feedlack,代码行数:12,代码来源:GraphReachability.java
示例12: validateColoring
import com.google.javascript.jscomp.graph.GraphNode; //导入依赖的package包/类
/**
* Validate that each node has been colored and connected nodes have different
* coloring.
*/
private static <N, E> void validateColoring(Graph<N, E> graph) {
for (GraphNode<N, E> node : graph.getNodes()) {
assertTrue(node.getAnnotation() != null);
}
for (GraphEdge<N, E> edge : graph.getEdges()) {
Color c1 = edge.getNodeA().getAnnotation();
Color c2 = edge.getNodeB().getAnnotation();
assertTrue(c1 != null);
assertTrue(c2 != null);
assertTrue(!c1.equals(c2));
}
}
开发者ID:andyjko,项目名称:feedlack,代码行数:17,代码来源:GraphColoringTest.java
示例13: assertListCount
import com.google.javascript.jscomp.graph.GraphNode; //导入依赖的package包/类
private <T extends GraphNode<String, String>> void assertListCount(
List<T> list, String target, int count) {
for (GraphNode<String, String> node : list) {
if (node.getValue().equals(target)) {
count--;
}
}
assertTrue(count == 0);
}
开发者ID:andyjko,项目名称:feedlack,代码行数:10,代码来源:GraphTest.java
示例14: assertSetEquals
import com.google.javascript.jscomp.graph.GraphNode; //导入依赖的package包/类
private <T extends GraphNode<String, String>> void assertSetEquals(
List<T> list, String ... targets) {
Set<String> set = new HashSet<String>();
for (GraphNode<String, String> node : list) {
set.add(node.getValue());
}
Set<String> otherSet = new HashSet<String>();
for (String target : targets) {
otherSet.add(target);
}
assertTrue(otherSet.equals(set));
}
开发者ID:andyjko,项目名称:feedlack,代码行数:13,代码来源:GraphTest.java
示例15: dependsOnOuterScopeVars
import com.google.javascript.jscomp.graph.GraphNode; //导入依赖的package包/类
boolean dependsOnOuterScopeVars(String name, Node useNode) {
Preconditions.checkArgument(getCfg().hasNode(useNode));
GraphNode<Node, Branch> n = getCfg().getNode(useNode);
FlowState<MustDef> state = n.getAnnotation();
Definition def = state.getIn().reachingDef.get(jsScope.getVar(name));
for (Var s : def.depends) {
if (s.scope != jsScope) {
return true;
}
}
return false;
}
开发者ID:ehsan,项目名称:js-symbolic-executor,代码行数:13,代码来源:MustBeReachingVariableDef.java
示例16: removeUnusedProperties
import com.google.javascript.jscomp.graph.GraphNode; //导入依赖的package包/类
/**
* Remove all properties under a given name if the property name is
* never referenced.
*/
private void removeUnusedProperties(NameReferenceGraph graph) {
for (GraphNode<Name, Reference> node : graph.getNodes()) {
Name name = node.getValue();
NameInfo nameInfo = node.getAnnotation();
if (nameInfo == null || !nameInfo.isReferenced()) {
if (canModifyExterns || !name.isExtern()) {
name.remove();
compiler.reportCodeChange();
logger.fine("Removed unused name" + name);
}
}
}
}
开发者ID:ehsan,项目名称:js-symbolic-executor,代码行数:18,代码来源:RemoveUnusedNames.java
示例17: shouldTraverse
import com.google.javascript.jscomp.graph.GraphNode; //导入依赖的package包/类
@Override
public boolean shouldTraverse(NodeTraversal t, Node n, Node parent) {
if (!shouldCheck(n)) {
return false;
}
if (scopeNeedsInit) {
initScope(t.getControlFlowGraph());
scopeNeedsInit = false;
}
GraphNode<Node, Branch> gNode = t.getControlFlowGraph().getNode(n);
if (gNode != null && gNode.getAnnotation() != GraphReachability.REACHABLE) {
// Only report error when there are some line number informations.
// There are synthetic nodes with no line number informations, nodes
// introduce by other passes (although not likely since this pass should
// be executed early) or some rhino bug.
if (n.getLineno() != -1 &&
// Allow spurious semi-colons and spurious breaks.
n.getType() != Token.EMPTY && n.getType() != Token.BREAK) {
compiler.report(t.makeError(n, level, UNREACHABLE_CODE));
// From now on, we are going to assume the user fixed the error and not
// give more warning related to code section reachable from this node.
new GraphReachability<Node, ControlFlowGraph.Branch>(
t.getControlFlowGraph()).recompute(n);
// Saves time by not traversing children.
return false;
}
}
return true;
}
开发者ID:ehsan,项目名称:js-symbolic-executor,代码行数:34,代码来源:CheckUnreachableCode.java
注:本文中的com.google.javascript.jscomp.graph.GraphNode类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论