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


Java Node.setJSDocInfo方法代码示例

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


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

示例1: attachJsDoc

import com.google.javascript.rhino.Node; //导入方法依赖的package包/类
/** Attach JSDocInfo to a node, if we can find one. */
private void attachJsDoc(Comment comment, JSDocInfo info) {
  Collection<NodeWithJsDoc> candidates =
      nodesWithJsDoc.get(comment.getValue());
  if (candidates.isEmpty()) {
    return;
  }

  Iterator<NodeWithJsDoc> candidateIter = candidates.iterator();
  Node node = candidateIter.next().node;
  candidateIter.remove();
  node.setJSDocInfo(info);
  if (info.hasEnumParameterType()) {
    if (node.getType() == Token.NAME) {
      registry.identifyEnumName(node.getString());
    } else if (node.getType() == Token.VAR &&
          node.getChildCount() == 1) {
      registry.identifyEnumName(
          node.getFirstChild().getString());
    } else if (node.getType() == Token.ASSIGN) {
      registry.identifyEnumName(
          node.getFirstChild().getQualifiedName());
    }
  }
}
 
开发者ID:andyjko,项目名称:feedlack,代码行数:26,代码来源:IRFactory.java

示例2: transformTree

import com.google.javascript.rhino.Node; //导入方法依赖的package包/类
public static Node transformTree(AstRoot node,
                                 String sourceString,
                                 Config config,
                                 ErrorReporter errorReporter) {
  IRFactory irFactory = new IRFactory(sourceString, node.getSourceName(),
      config, errorReporter);
  Node irNode = irFactory.transform(node);
  // @license text gets appended onto the fileLevelJsDocBuilder as found,
  // and stored straight into the JSDocInfo for the root node.
  Node.FileLevelJsDocBuilder fileLevelJsDocBuilder =
      irNode.getJsDocBuilderForNode();
  // fileOverviewInfo stores the last bit of fileoverview data we saw.
  // We only permit one, so throwing away extras is fair.
  // The fileOverviewInfo gets passed into parseJSDocInfo so that
  // it can detect when multiple @fileoverviews exist in the same file.
  JSDocInfo fileOverviewInfo = null;
  if (node.getComments() != null) {
    for (Comment comment : node.getComments()) {
      if (comment.getCommentType() == JSDOC) {
        JsDocInfoParser jsDocParser =
            irFactory.createJsDocInfoParser(comment.getValue(),
                comment.getLineno(), comment.getAbsolutePosition(),
                fileLevelJsDocBuilder, fileOverviewInfo);
        if (jsDocParser.getFileOverviewJSDocInfo() != fileOverviewInfo) {
          fileOverviewInfo = jsDocParser.getFileOverviewJSDocInfo();
        } else {
          JSDocInfo info = jsDocParser.retrieveAndResetParsedJSDocInfo();
          if (info != null) {
            irFactory.attachJsDoc(comment, info);
          }
        }
      }
    }

    // Only after we've seen all @fileoverview entries, attach the
    // last one to the root node, and copy the found license strings
    // to that node.
    if (fileOverviewInfo != null) {
      if ((irNode.getJSDocInfo() != null) &&
          (irNode.getJSDocInfo().getLicense() != null)) {
        fileOverviewInfo.setLicense(irNode.getJSDocInfo().getLicense());
      }
      irNode.setJSDocInfo(fileOverviewInfo);
    }
  }
  return irNode;
}
 
开发者ID:andyjko,项目名称:feedlack,代码行数:48,代码来源:IRFactory.java

示例3: replace

import com.google.javascript.rhino.Node; //导入方法依赖的package包/类
/**
 * Replace the provide statement.
 *
 * If we're providing a name with no definition, then create one.
 * If we're providing a name with a duplicate definition, then make sure
 * that definition becomes a declaration.
 */
void replace() {
  if (firstNode == null) {
    // Don't touch the base case ('goog').
    replacementNode = candidateDefinition;
    return;
  }

  // Handle the case where there is a duplicate definition for an explicitly
  // provided symbol.
  if (candidateDefinition != null && explicitNode != null) {
    explicitNode.detachFromParent();
    compiler.reportCodeChange();

    // Does this need a VAR keyword?
    replacementNode = candidateDefinition;
    if (NodeUtil.isExpressionNode(candidateDefinition)) {
      candidateDefinition.putBooleanProp(Node.IS_NAMESPACE, true);
      Node assignNode = candidateDefinition.getFirstChild();
      Node nameNode = assignNode.getFirstChild();
      if (nameNode.getType() == Token.NAME) {
        // Need to convert this assign to a var declaration.
        Node valueNode = nameNode.getNext();
        assignNode.removeChild(nameNode);
        assignNode.removeChild(valueNode);
        nameNode.addChildToFront(valueNode);
        Node varNode = new Node(Token.VAR, nameNode);
        varNode.copyInformationFrom(candidateDefinition);
        candidateDefinition.getParent().replaceChild(
            candidateDefinition, varNode);
        nameNode.setJSDocInfo(assignNode.getJSDocInfo());
        compiler.reportCodeChange();
        replacementNode = varNode;
      }
    }
  } else {
    // Handle the case where there's not a duplicate definition.
    replacementNode = createDeclarationNode();
    if (firstModule == minimumModule) {
      firstNode.getParent().addChildBefore(replacementNode, firstNode);
    } else {
      // In this case, the name was implicitly provided by two independent
      // modules. We need to move this code up to a common module.
      int indexOfDot = namespace.indexOf('.');
      if (indexOfDot == -1) {
        // Any old place is fine.
        compiler.getNodeForCodeInsertion(minimumModule)
            .addChildToBack(replacementNode);
      } else {
        // Add it after the parent namespace.
        ProvidedName parentName =
            providedNames.get(namespace.substring(0, indexOfDot));
        Preconditions.checkNotNull(parentName);
        Preconditions.checkNotNull(parentName.replacementNode);
        parentName.replacementNode.getParent().addChildAfter(
            replacementNode, parentName.replacementNode);
      }
    }
    if (explicitNode != null) {
      explicitNode.detachFromParent();
    }
    compiler.reportCodeChange();
  }
}
 
开发者ID:andyjko,项目名称:feedlack,代码行数:71,代码来源:ProcessClosurePrimitives.java


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