当前位置: 首页>>代码示例>>Java>>正文


Java Definition.getRValue方法代码示例

本文整理汇总了Java中com.google.javascript.jscomp.DefinitionsRemover.Definition.getRValue方法的典型用法代码示例。如果您正苦于以下问题:Java Definition.getRValue方法的具体用法?Java Definition.getRValue怎么用?Java Definition.getRValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.google.javascript.jscomp.DefinitionsRemover.Definition的用法示例。


在下文中一共展示了Definition.getRValue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getCallableDefinitions

import com.google.javascript.jscomp.DefinitionsRemover.Definition; //导入方法依赖的package包/类
/**
 * Query the DefinitionProvider for the list of definitions that
 * correspond to a given qualified name subtree.  Return null if
 * DefinitionProvider does not contain an entry for a given name,
 * one or more of the values returned by getDeclarations is not
 * callable, or the "name" node is not a GETPROP or NAME.
 *
 * @param definitionProvider The name reference graph
 * @param name Query node
 * @return non-empty definition list or null
 */
private static Collection<Definition> getCallableDefinitions(
    DefinitionProvider definitionProvider, Node name) {
  List<Definition> result = Lists.newArrayList();

  if (!NodeUtil.isGetProp(name) && !NodeUtil.isName(name)) {
    return null;
  }

  Collection<Definition> decls =
      definitionProvider.getDefinitionsReferencedAt(name);
  if (decls == null) {
    return null;
  }

  for (Definition current : decls) {
    Node rValue = current.getRValue();
    if ((rValue != null) && NodeUtil.isFunction(rValue)) {
      result.add(current);
    } else {
      return null;
    }
  }

  return result;
}
 
开发者ID:andyjko,项目名称:feedlack,代码行数:37,代码来源:PureFunctionIdentifier.java

示例2: definitionTypeContainsFunctionType

import com.google.javascript.jscomp.DefinitionsRemover.Definition; //导入方法依赖的package包/类
/**
 * Determines if the type of the value of the rhs expression can
 * be a function node.
 */
private static boolean definitionTypeContainsFunctionType(Definition def) {
  Node rhs = def.getRValue();
  if (rhs == null) {
    return true;
  }

  switch (rhs.getType()) {
    case Token.ASSIGN:
    case Token.AND:
    case Token.CALL:
    case Token.GETPROP:
    case Token.GETELEM:
    case Token.FUNCTION:
    case Token.HOOK:
    case Token.NAME:
    case Token.NEW:
    case Token.OR:
      return true;
    default:
      return false;
  }
}
 
开发者ID:andyjko,项目名称:feedlack,代码行数:27,代码来源:MarkNoSideEffectCalls.java

示例3: visit

import com.google.javascript.jscomp.DefinitionsRemover.Definition; //导入方法依赖的package包/类
public void visit(NodeTraversal traversal, Node node, Node parent) {
  Collection<Definition> defs =
      passUnderTest.getDefinitionsReferencedAt(node);
  if (defs != null) {
    StringBuffer sb = new StringBuffer();
    sb.append("USE ");
    sb.append(Token.name(node.getType()));
    sb.append(" ");
    sb.append(node.getQualifiedName());
    sb.append(" -> ");
    Multiset<String> defstrs = TreeMultiset.create();
    for (Definition def : defs) {
      Node rValue = def.getRValue();
      if (rValue != null) {
        defstrs.add(Token.name(rValue.getType()));
      } else {
        defstrs.add("<null>");
      }
    }

    sb.append(defstrs.toString());
    found.add(sb.toString());
  }
}
 
开发者ID:andyjko,项目名称:feedlack,代码行数:25,代码来源:SimpleDefinitionFinderTest.java

示例4: analyze

import com.google.javascript.jscomp.DefinitionsRemover.Definition; //导入方法依赖的package包/类
/**
 * Uses the provided {@link SimpleDefinitionFinder} to determine
 * which functions are aliased or exposed to .call() or .apply().
 */
public void analyze(SimpleDefinitionFinder finder) {
  Preconditions.checkState(aliasedFunctions == null);
  
  aliasedFunctions = Sets.newHashSet();
  functionsExposedToCallOrApply = Sets.newHashSet();
  
  for (DefinitionSite definitionSite : finder.getDefinitionSites()) {
    Definition definition = definitionSite.definition;
    
    if (!definition.isExtern()) {
      Node rValue = definition.getRValue();
      
      if (rValue != null && NodeUtil.isFunction(rValue)) {
        // rValue is a Token.FUNCTION from a definition
        
        for (UseSite useSite : finder.getUseSites(definition)) {
          updateFunctionForUse(rValue, useSite.node);
        }          
      }     
    }
  }   
}
 
开发者ID:ehsan,项目名称:js-symbolic-executor,代码行数:27,代码来源:SimpleFunctionAliasAnalysis.java

示例5: analyze

import com.google.javascript.jscomp.DefinitionsRemover.Definition; //导入方法依赖的package包/类
/**
 * Uses the provided {@link SimpleDefinitionFinder} to determine
 * which functions are aliased or exposed to .call() or .apply().
 */
public void analyze(SimpleDefinitionFinder finder) {
  Preconditions.checkState(aliasedFunctions == null);

  aliasedFunctions = Sets.newHashSet();
  functionsExposedToCallOrApply = Sets.newHashSet();

  for (DefinitionSite definitionSite : finder.getDefinitionSites()) {
    Definition definition = definitionSite.definition;

    if (!definition.isExtern()) {
      Node rValue = definition.getRValue();

      if (rValue != null && rValue.isFunction()) {
        // rValue is a Token.FUNCTION from a definition

        for (UseSite useSite : finder.getUseSites(definition)) {
          updateFunctionForUse(rValue, useSite.node);
        }
      }
    }
  }
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:27,代码来源:SimpleFunctionAliasAnalysis.java

示例6: definitionTypeContainsFunctionType

import com.google.javascript.jscomp.DefinitionsRemover.Definition; //导入方法依赖的package包/类
/**
 * Determines if the type of the value of the RHS expression can
 * be a function node.
 */
private static boolean definitionTypeContainsFunctionType(Definition def) {
  Node rhs = def.getRValue();
  if (rhs == null) {
    return true;
  }

  switch (rhs.getType()) {
    case Token.ASSIGN:
    case Token.AND:
    case Token.CALL:
    case Token.GETPROP:
    case Token.GETELEM:
    case Token.FUNCTION:
    case Token.HOOK:
    case Token.NAME:
    case Token.NEW:
    case Token.OR:
      return true;
    default:
      return false;
  }
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:27,代码来源:MarkNoSideEffectCalls.java

示例7: visitExterns

import com.google.javascript.jscomp.DefinitionsRemover.Definition; //导入方法依赖的package包/类
private void visitExterns(NodeTraversal traversal, Node node) {
  if (node.getJSDocInfo() != null) {
    for (Node typeRoot : node.getJSDocInfo().getTypeNodes()) {
      traversal.traverse(typeRoot);
    }
  }

  Definition definition = DefinitionsRemover.getDefinition(node, true);
  if (definition != null) {
    String name = definition.getSimplifiedName();
    if (name != null) {
      Node rValue = definition.getRValue();
      if ((rValue != null) && !NodeUtil.isImmutableValue(rValue) && !rValue.isFunction()) {
        // Unhandled complex expression
        Definition unknownDefinition = new UnknownDefinition(definition.getLValue(), true);
        definition = unknownDefinition;
      }
      addDefinition(name, definition, node, traversal);
    }
  }
}
 
开发者ID:google,项目名称:closure-compiler,代码行数:22,代码来源:NameBasedDefinitionProvider.java

示例8: allDefinitionsEquivalent

import com.google.javascript.jscomp.DefinitionsRemover.Definition; //导入方法依赖的package包/类
/** Given a set of method definitions, verify they are the same. */
boolean allDefinitionsEquivalent(Collection<Definition> definitions) {
  if (definitions.size() <= 1) {
    return true;
  }

  Definition first = null;
  for (Definition definition : definitions) {
    if (definition.getRValue() == null) {
      return false; // We can't tell if they're all the same.
    }

    if (first == null) {
      first = definition;
      continue;
    }

    if (!compiler.areNodesEqualForInlining(first.getRValue(), definition.getRValue())) {
      return false;
    }
  }
  return true;
}
 
开发者ID:google,项目名称:closure-compiler,代码行数:24,代码来源:DevirtualizePrototypeMethods.java

示例9: definitionTypeContainsFunctionType

import com.google.javascript.jscomp.DefinitionsRemover.Definition; //导入方法依赖的package包/类
/**
 * Determines if the type of the value of the RHS expression can
 * be a function node.
 */
private static boolean definitionTypeContainsFunctionType(Definition def) {
  Node rhs = def.getRValue();
  if (rhs == null) {
    return true;
  }

  switch (rhs.getToken()) {
    case ASSIGN:
    case AND:
    case CALL:
    case GETPROP:
    case GETELEM:
    case FUNCTION:
    case HOOK:
    case NAME:
    case NEW:
    case OR:
      return true;
    default:
      return false;
  }
}
 
开发者ID:google,项目名称:closure-compiler,代码行数:27,代码来源:MarkNoSideEffectCalls.java

示例10: process

import com.google.javascript.jscomp.DefinitionsRemover.Definition; //导入方法依赖的package包/类
@Override
public void process(Node externs, Node root) {
  passUnderTest.process(externs, root);
  NodeTraversal.traverse(compiler, externs, this);
  NodeTraversal.traverse(compiler, root, this);

  for (DefinitionSite defSite : passUnderTest.getDefinitionSites()) {
    Node node = defSite.node;
    Definition definition = defSite.definition;
    StringBuffer sb = new StringBuffer();
    sb.append("DEF ");
    sb.append(Token.name(node.getType()));
    sb.append(" ");
    sb.append(node.getQualifiedName());
    sb.append(" -> ");

    Node rValue = definition.getRValue();
    if (rValue != null) {
      sb.append(Token.name(rValue.getType()));
    } else {
      sb.append("<null>");
    }

    found.add(sb.toString());
  }

}
 
开发者ID:andyjko,项目名称:feedlack,代码行数:28,代码来源:SimpleDefinitionFinderTest.java

示例11: connectCallsiteToTargets

import com.google.javascript.jscomp.DefinitionsRemover.Definition; //导入方法依赖的package包/类
/**
 * Maps a Callsite to the Function(s) it could call 
 * and each Function to the Callsite(s) that could call it.
 * 
 * If the definitionProvider cannot determine the target of the Callsite,
 * the Callsite's hasUnknownTarget field is set to true.
 * 
 * If the definitionProvider determines that the target of the Callsite
 * could be an extern-defined function, then the Callsite's hasExternTarget
 * field is set to true.
 * 
 * @param callsite The callsite for which target functions should be found
 * @param definitionProvider The DefinitionProvider used to determine
 *    targets of callsites.
 */
private void connectCallsiteToTargets(Callsite callsite,
    DefinitionProvider definitionProvider) { 
  Collection<Definition> definitions =
    lookupDefinitionsForTargetsOfCall(callsite.getAstNode(),
        definitionProvider);

  if (definitions == null) {
    callsite.hasUnknownTarget = true; 
  } else {
    for (Definition definition : definitions) {
      if (definition.isExtern()) {
        callsite.hasExternTarget = true;
      } else {
        Node target = definition.getRValue();

        if (target != null && NodeUtil.isFunction(target)) {
          Function targetFunction = functionsByNode.get(target);
          
          if (targetFunction == null) {
            targetFunction = createFunction(target);
          }
          
          if (computeForwardGraph) {
            callsite.addPossibleTarget(targetFunction);
          }

          if (computeBackwardGraph) {
            targetFunction.addCallsitePossiblyTargetingFunction(callsite);
          }
        } else {
          callsite.hasUnknownTarget = true;                 
        }
      }
    }
  }
}
 
开发者ID:ehsan,项目名称:js-symbolic-executor,代码行数:52,代码来源:CallGraph.java

示例12: lookupFunctionForDefinition

import com.google.javascript.jscomp.DefinitionsRemover.Definition; //导入方法依赖的package包/类
/**
 * Returns a {@link CallGraph.Function} for the passed in {@link Definition}
 * or null if the definition isn't for a function.
 */
private Function lookupFunctionForDefinition(Definition definition) {
  if (definition != null && !definition.isExtern()) {
    Node rValue = definition.getRValue();
    
    if (rValue != null && NodeUtil.isFunction(rValue)) {
      Function function = functionsByNode.get(rValue);
      Preconditions.checkNotNull(function);
      
      return function;
    }
  }
  
  return null;
}
 
开发者ID:ehsan,项目名称:js-symbolic-executor,代码行数:19,代码来源:CallGraph.java

示例13: process

import com.google.javascript.jscomp.DefinitionsRemover.Definition; //导入方法依赖的package包/类
@Override
public void process(Node externs, Node root) {
  passUnderTest.process(externs, root);
  NodeTraversal.traverse(compiler, externs, this);
  NodeTraversal.traverse(compiler, root, this);

  for (DefinitionSite defSite : passUnderTest.getDefinitionSites()) {
    Node node = defSite.node;
    Definition definition = defSite.definition;
    StringBuilder sb = new StringBuilder();
    sb.append("DEF ");
    sb.append(Token.name(node.getType()));
    sb.append(" ");
    sb.append(node.getQualifiedName());
    sb.append(" -> ");

    if (definition.isExtern()) {
      sb.append("EXTERN ");
    }

    Node rValue = definition.getRValue();
    if (rValue != null) {
      sb.append(Token.name(rValue.getType()));
    } else {
      sb.append("<null>");
    }

    found.add(sb.toString());
  }

}
 
开发者ID:ehsan,项目名称:js-symbolic-executor,代码行数:32,代码来源:SimpleDefinitionFinderTest.java

示例14: visit

import com.google.javascript.jscomp.DefinitionsRemover.Definition; //导入方法依赖的package包/类
public void visit(NodeTraversal traversal, Node node, Node parent) {
  Collection<Definition> defs =
      passUnderTest.getDefinitionsReferencedAt(node);
  if (defs != null) {
    StringBuilder sb = new StringBuilder();
    sb.append("USE ");
    sb.append(Token.name(node.getType()));
    sb.append(" ");
    sb.append(node.getQualifiedName());
    sb.append(" -> ");
    Multiset<String> defstrs = TreeMultiset.create();
    for (Definition def : defs) {
      String defstr;

      Node rValue = def.getRValue();
      if (rValue != null) {
        defstr = Token.name(rValue.getType());
      } else {
        defstr = "<null>";
      }

      if (def.isExtern()) {
        defstr = "EXTERN " + defstr;
      }

      defstrs.add(defstr);
    }

    sb.append(defstrs.toString());
    found.add(sb.toString());
  }
}
 
开发者ID:ehsan,项目名称:js-symbolic-executor,代码行数:33,代码来源:SimpleDefinitionFinderTest.java

示例15: connectCallsiteToTargets

import com.google.javascript.jscomp.DefinitionsRemover.Definition; //导入方法依赖的package包/类
/**
 * Maps a Callsite to the Function(s) it could call
 * and each Function to the Callsite(s) that could call it.
 *
 * If the definitionProvider cannot determine the target of the Callsite,
 * the Callsite's hasUnknownTarget field is set to true.
 *
 * If the definitionProvider determines that the target of the Callsite
 * could be an extern-defined function, then the Callsite's hasExternTarget
 * field is set to true.
 *
 * @param callsite The callsite for which target functions should be found
 * @param definitionProvider The DefinitionProvider used to determine
 *    targets of callsites.
 */
private void connectCallsiteToTargets(Callsite callsite,
    DefinitionProvider definitionProvider) {
  Collection<Definition> definitions =
    lookupDefinitionsForTargetsOfCall(callsite.getAstNode(),
        definitionProvider);

  if (definitions == null) {
    callsite.hasUnknownTarget = true;
  } else {
    for (Definition definition : definitions) {
      if (definition.isExtern()) {
        callsite.hasExternTarget = true;
      } else {
        Node target = definition.getRValue();

        if (target != null && target.isFunction()) {
          Function targetFunction = functionsByNode.get(target);

          if (targetFunction == null) {
            targetFunction = createFunction(target);
          }

          if (computeForwardGraph) {
            callsite.addPossibleTarget(targetFunction);
          }

          if (computeBackwardGraph) {
            targetFunction.addCallsitePossiblyTargetingFunction(callsite);
          }
        } else {
          callsite.hasUnknownTarget = true;
        }
      }
    }
  }
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:52,代码来源:CallGraph.java


注:本文中的com.google.javascript.jscomp.DefinitionsRemover.Definition.getRValue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。