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


Java Definition.isExtern方法代码示例

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


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

示例1: 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

示例2: 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

示例3: addDefinition

import com.google.javascript.jscomp.DefinitionsRemover.Definition; //导入方法依赖的package包/类
private void addDefinition(
    String name, Definition definition, Node definitionSiteNode, NodeTraversal traversal) {
  Node definitionNode = definition.getLValue();

  definitionNodes.add(definitionNode);
  definitionsByName.put(name, definition);
  DefinitionSite definitionSite =
      new DefinitionSite(
          definitionSiteNode,
          definition,
          traversal.getModule(),
          traversal.inGlobalScope(),
          definition.isExtern());
  definitionSitesByDefinitionSiteNode.put(definitionSiteNode, definitionSite);
  Node scopeNode = NodeUtil.getEnclosingChangeScopeRoot(definitionSiteNode);
  definitionSitesByScopeNode.put(scopeNode, definitionSite);
}
 
开发者ID:google,项目名称:closure-compiler,代码行数:18,代码来源:NameBasedDefinitionProvider.java

示例4: 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

示例5: 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

示例6: 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

示例7: 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

示例8: 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

示例9: 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 && rValue.isFunction()) {
      Function function = functionsByNode.get(rValue);
      Preconditions.checkNotNull(function);

      return function;
    }
  }

  return null;
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:19,代码来源:CallGraph.java

示例10: visit

import com.google.javascript.jscomp.DefinitionsRemover.Definition; //导入方法依赖的package包/类
@Override
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:SpoonLabs,项目名称:astor,代码行数:34,代码来源:SimpleDefinitionFinderTest.java


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