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


Java JSDocInfoBuilder类代码示例

本文整理汇总了Java中com.google.javascript.rhino.JSDocInfoBuilder的典型用法代码示例。如果您正苦于以下问题:Java JSDocInfoBuilder类的具体用法?Java JSDocInfoBuilder怎么用?Java JSDocInfoBuilder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: gatherStaticsJsDocs

import com.google.javascript.rhino.JSDocInfoBuilder; //导入依赖的package包/类
private void gatherStaticsJsDocs(
    Node staticsNode, Map<String, JSDocInfo> staticsJsDocs) {
  if (!staticsNode.hasOneChild() ||
        !staticsNode.getFirstChild().isObjectLit()) {
    compiler.report(JSError.make(staticsNode, STATICS_UNEXPECTED_TYPE));
    return;
  }
  for (Node staticKeyNode : staticsNode.getFirstChild().children()) {
    String staticName = staticKeyNode.getString();
    JSDocInfo staticJsDoc = staticKeyNode.getJSDocInfo();
    if (staticJsDoc == null) {
      // We need to have some kind of JSDoc so that the CheckSideEffects pass
      // doesn't flag this as useless code.
      // TODO: synthesize type based on value if it's a simple constant
      // like a function or number.
      staticJsDoc = new JSDocInfoBuilder(true).build(true);
    } else {
      staticJsDoc = staticJsDoc.clone();
    }
    staticsJsDocs.put(staticName, staticJsDoc);
  }
}
 
开发者ID:mihaip,项目名称:react-closure-compiler,代码行数:23,代码来源:ReactCompilerPass.java

示例2: JsDocInfoParser

import com.google.javascript.rhino.JSDocInfoBuilder; //导入依赖的package包/类
JsDocInfoParser(JsDocTokenStream stream,
                Comment commentNode,
                Node associatedNode,
                Config config,
                ErrorReporter errorReporter) {
  this.stream = stream;
  this.associatedNode = associatedNode;

  // Sometimes this will be null in tests.
  this.sourceFile = associatedNode == null
      ? null : associatedNode.getStaticSourceFile();

  this.jsdocBuilder = new JSDocInfoBuilder(config.parseJsDocDocumentation);
  if (commentNode != null) {
    this.jsdocBuilder.recordOriginalCommentString(commentNode.getValue());
  }
  this.annotationNames = config.annotationNames;
  this.suppressionNames = config.suppressionNames;

  this.errorReporter = errorReporter;
  this.templateNode = this.createTemplateNode();
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:23,代码来源:JsDocInfoParser.java

示例3: getConstructorDoc

import com.google.javascript.rhino.JSDocInfoBuilder; //导入依赖的package包/类
/** @return The proper constructor doc for the Polymer call. */
private JSDocInfoBuilder getConstructorDoc(final PolymerClassDefinition cls) {
  JSDocInfoBuilder constructorDoc = JSDocInfoBuilder.maybeCopyFrom(cls.constructor.info);
  constructorDoc.recordConstructor();

  JSTypeExpression baseType = new JSTypeExpression(
      new Node(Token.BANG, IR.string(PolymerPassStaticUtils.getPolymerElementType(cls))),
      PolymerPass.VIRTUAL_FILE);
  constructorDoc.recordBaseType(baseType);

  String interfaceName = getInterfaceName(cls);
  JSTypeExpression interfaceType = new JSTypeExpression(
      new Node(Token.BANG, IR.string(interfaceName)), PolymerPass.VIRTUAL_FILE);
  constructorDoc.recordImplementedInterface(interfaceType);

  return constructorDoc;
}
 
开发者ID:google,项目名称:closure-compiler,代码行数:18,代码来源:PolymerClassRewriter.java

示例4: appendPropertiesToBlock

import com.google.javascript.rhino.JSDocInfoBuilder; //导入依赖的package包/类
/**
 * Appends all properties in the ClassDefinition to the prototype of the custom element.
 */
private void appendPropertiesToBlock(
    final PolymerClassDefinition cls, Node block, String basePath) {
  for (MemberDefinition prop : cls.props) {
    Node propertyNode = IR.exprResult(
        NodeUtil.newQName(compiler, basePath + prop.name.getString()));

    // If a property string is quoted, make sure the added prototype properties are also quoted
    if (prop.name.isQuotedString()) {
      continue;
    }

    propertyNode.useSourceInfoIfMissingFromForTree(prop.name);
    JSDocInfoBuilder info = JSDocInfoBuilder.maybeCopyFrom(prop.info);

    JSTypeExpression propType = PolymerPassStaticUtils.getTypeFromProperty(prop, compiler);
    if (propType == null) {
      return;
    }
    info.recordType(propType);
    propertyNode.getFirstChild().setJSDocInfo(info.build());

    block.addChildToBack(propertyNode);
  }
}
 
开发者ID:google,项目名称:closure-compiler,代码行数:28,代码来源:PolymerClassRewriter.java

示例5: makeReadOnlySetter

import com.google.javascript.rhino.JSDocInfoBuilder; //导入依赖的package包/类
/**
 * Adds the generated setter for a readonly property.
 * @see https://www.polymer-project.org/0.8/docs/devguide/properties.html#read-only
 */
private Node makeReadOnlySetter(String propName, String qualifiedPath) {
  String setterName = "_set" + propName.substring(0, 1).toUpperCase() + propName.substring(1);
  Node fnNode = IR.function(IR.name(""), IR.paramList(IR.name(propName)), IR.block());
  compiler.reportChangeToChangeScope(fnNode);
  Node exprResNode = IR.exprResult(
      IR.assign(NodeUtil.newQName(compiler, qualifiedPath + setterName), fnNode));

  JSDocInfoBuilder info = new JSDocInfoBuilder(true);
  // This is overriding a generated function which was added to the interface in
  // {@code addInterfaceExterns}.
  info.recordOverride();
  exprResNode.getFirstChild().setJSDocInfo(info.build());

  return exprResNode;
}
 
开发者ID:google,项目名称:closure-compiler,代码行数:20,代码来源:PolymerClassRewriter.java

示例6: addGetterExport

import com.google.javascript.rhino.JSDocInfoBuilder; //导入依赖的package包/类
private void addGetterExport(
    Node script, Node forSourceInfo, Node objLit, String exportedName, String localName) {
  // Type checker doesn't infer getters so mark the return as unknown.
  // { /** @return {?} */ get foo() { return foo; } }
  Node getter = Node.newString(Token.GETTER_DEF, exportedName);
  getter.putBooleanProp(Node.MODULE_EXPORT, true);
  objLit.addChildToBack(getter);

  Node name = NodeUtil.newQName(compiler, localName);
  Node function = IR.function(IR.name(""), IR.paramList(), IR.block(IR.returnNode(name)));
  getter.addChildToFront(function);

  JSDocInfoBuilder builder = new JSDocInfoBuilder(true);
  builder.recordReturnType(
      new JSTypeExpression(new Node(Token.QMARK), script.getSourceFileName()));
  getter.setJSDocInfo(builder.build());

  getter.useSourceInfoIfMissingFromForTree(forSourceInfo);
  compiler.reportChangeToEnclosingScope(getter.getFirstChild().getLastChild());
  compiler.reportChangeToEnclosingScope(getter);
}
 
开发者ID:google,项目名称:closure-compiler,代码行数:22,代码来源:Es6RewriteModules.java

示例7: visitMethod

import com.google.javascript.rhino.JSDocInfoBuilder; //导入依赖的package包/类
/**
 * Handles transpilation of a standard class member function. Getters, setters, and the
 * constructor are not handled here.
 */
private void visitMethod(Node member, ClassDeclarationMetadata metadata) {
  Node qualifiedMemberAccess = getQualifiedMemberAccess(
      member,
      NodeUtil.newQName(compiler, metadata.fullClassName),
      NodeUtil.newQName(compiler, metadata.fullClassName + ".prototype"));
  Node method = member.getLastChild().detach();

  Node assign = IR.assign(qualifiedMemberAccess, method);
  assign.useSourceInfoIfMissingFromForTree(member);

  JSDocInfo info = member.getJSDocInfo();
  if (member.isStaticMember() && NodeUtil.referencesThis(assign.getLastChild())) {
    JSDocInfoBuilder memberDoc = JSDocInfoBuilder.maybeCopyFrom(info);
    memberDoc.recordThisType(
        new JSTypeExpression(new Node(Token.BANG, new Node(Token.QMARK)),
        member.getSourceFileName()));
    info = memberDoc.build();
  }
  if (info != null) {
    assign.setJSDocInfo(info);
  }

  Node newNode = NodeUtil.newExpr(assign);
  metadata.insertNodeAndAdvance(newNode);
}
 
开发者ID:google,项目名称:closure-compiler,代码行数:30,代码来源:Es6RewriteClass.java

示例8: visitNamespaceDeclaration

import com.google.javascript.rhino.JSDocInfoBuilder; //导入依赖的package包/类
private void visitNamespaceDeclaration(NodeTraversal t, Node n, Node parent) {
  popNamespace(n, parent);
  for (Node name = NodeUtil.getRootOfQualifiedName(n.getFirstChild()); name != n;
      name = name.getParent()) {
    String fullName = maybePrependCurrNamespace(name.getQualifiedName());
    if (!convertedNamespaces.contains(fullName)) {
      JSDocInfoBuilder doc = JSDocInfoBuilder.maybeCopyFrom(n.getJSDocInfo());
      doc.recordConstancy();
      Node namespaceDec = NodeUtil.newQNameDeclaration(
          compiler, fullName, IR.objectlit(), doc.build()).useSourceInfoFromForTree(n);
      parent.addChildBefore(namespaceDec, n);
      convertedNamespaces.add(fullName);
    }
  }

  replaceWithNodes(t, n, n.getLastChild().children());
}
 
开发者ID:google,项目名称:closure-compiler,代码行数:18,代码来源:Es6TypedToEs6Converter.java

示例9: maybeAddGenerics

import com.google.javascript.rhino.JSDocInfoBuilder; //导入依赖的package包/类
private void maybeAddGenerics(Node n, Node jsDocNode) {
  Node name = n.getFirstChild();
  Node generics = (Node) name.getProp(Node.GENERIC_TYPE_LIST);
  if (generics != null) {
    JSDocInfoBuilder doc = JSDocInfoBuilder.maybeCopyFrom(jsDocNode.getJSDocInfo());
    // Discard the type bound (the "extends" part) for now
    for (Node typeName : generics.children()) {
      doc.recordTemplateTypeName(typeName.getString());
      if (typeName.hasChildren()) {
        compiler.report(JSError.make(name, CANNOT_CONVERT_BOUNDED_GENERICS));
        typeName.removeChildren();
      }
    }
    name.removeProp(Node.GENERIC_TYPE_LIST);
    jsDocNode.setJSDocInfo(doc.build());
  }
}
 
开发者ID:google,项目名称:closure-compiler,代码行数:18,代码来源:Es6TypedToEs6Converter.java

示例10: visitTypeAlias

import com.google.javascript.rhino.JSDocInfoBuilder; //导入依赖的package包/类
private void visitTypeAlias(NodeTraversal t, Node n, Node parent) {
  String alias = n.getString();
  if (t.getScope().isDeclared(alias, true)) {
    compiler.report(
        JSError.make(n, TYPE_ALIAS_ALREADY_DECLARED, alias));
  }
  JSDocInfoBuilder builder = JSDocInfoBuilder.maybeCopyFrom(n.getJSDocInfo());
  builder.recordTypedef(new JSTypeExpression(
      convertWithLocation(n.getFirstChild()), n.getSourceFileName()));

  Node newName =
      maybeGetQualifiedNameNode(IR.name(n.getString())).useSourceInfoIfMissingFromForTree(n);
  Node newDec1 = NodeUtil.newQNameDeclaration(
      compiler,
      newName.getQualifiedName(),
      null,
      builder.build()).useSourceInfoFromForTree(n);
  parent.replaceChild(n, newDec1);
  t.reportCodeChange();
}
 
开发者ID:google,项目名称:closure-compiler,代码行数:21,代码来源:Es6TypedToEs6Converter.java

示例11: visitVarInsideNamespace

import com.google.javascript.rhino.JSDocInfoBuilder; //导入依赖的package包/类
private void visitVarInsideNamespace(NodeTraversal t, Node n, Node parent) {
  if (currNamespace != null) {
    Node insertPoint = n;
    for (Node child : n.children()) {
      Node name = child;
      String oldName = name.getString();
      String qName = maybePrependCurrNamespace(oldName);
      JSDocInfoBuilder builder = JSDocInfoBuilder.maybeCopyFrom(child.getJSDocInfo());
      if (n.isConst()) {
        builder.recordConstancy();
      }

      Node newDec = NodeUtil.newQNameDeclaration(
          compiler,
          qName,
          child.removeFirstChild(),
          builder.build()).useSourceInfoFromForTree(n);
      parent.addChildAfter(newDec, insertPoint);
      insertPoint = newDec;
    }

    n.detach();
    t.reportCodeChange();
  }
}
 
开发者ID:google,项目名称:closure-compiler,代码行数:26,代码来源:Es6TypedToEs6Converter.java

示例12: visit

import com.google.javascript.rhino.JSDocInfoBuilder; //导入依赖的package包/类
@Override
public void visit(NodeTraversal t, Node n, Node parent) {
  if (isBehavior(n)) {
    if (!NodeUtil.isNameDeclaration(n) && !n.isAssign()) {
      compiler.report(JSError.make(n, PolymerPassErrors.POLYMER_UNQUALIFIED_BEHAVIOR));
      return;
    }

    // Add @nocollapse.
    JSDocInfoBuilder newDocs = JSDocInfoBuilder.maybeCopyFrom(n.getJSDocInfo());
    newDocs.recordNoCollapse();
    n.setJSDocInfo(newDocs.build());

    Node behaviorValue = n.getSecondChild();
    if (NodeUtil.isNameDeclaration(n)) {
      behaviorValue = n.getFirstFirstChild();
    }
    suppressBehavior(behaviorValue);
  }
}
 
开发者ID:google,项目名称:closure-compiler,代码行数:21,代码来源:PolymerPassSuppressBehaviors.java

示例13: suppressDefaultValues

import com.google.javascript.rhino.JSDocInfoBuilder; //导入依赖的package包/类
private void suppressDefaultValues(Node behaviorValue) {
  for (MemberDefinition property :
      PolymerPassStaticUtils.extractProperties(
          behaviorValue, PolymerClassDefinition.DefinitionType.ObjectLiteral, compiler)) {
    if (!property.value.isObjectLit()) {
      continue;
    }

    Node defaultValue = NodeUtil.getFirstPropMatchingKey(property.value, "value");
    if (defaultValue == null || !defaultValue.isFunction()) {
      continue;
    }
    Node defaultValueKey = defaultValue.getParent();
    JSDocInfoBuilder suppressDoc =
        JSDocInfoBuilder.maybeCopyFrom(defaultValueKey.getJSDocInfo());
    suppressDoc.addSuppression("checkTypes");
    suppressDoc.addSuppression("globalThis");
    suppressDoc.addSuppression("visibility");
    defaultValueKey.setJSDocInfo(suppressDoc.build());
  }
}
 
开发者ID:google,项目名称:closure-compiler,代码行数:22,代码来源:PolymerPassSuppressBehaviors.java

示例14: setFileOverviewJsDoc

import com.google.javascript.rhino.JSDocInfoBuilder; //导入依赖的package包/类
private void setFileOverviewJsDoc(Node irNode) {
  // 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.
  JSDocInfo rootNodeJsDoc = fileLevelJsDocBuilder.build();
  if (rootNodeJsDoc != null) {
    irNode.setJSDocInfo(rootNodeJsDoc);
  }

  if (fileOverviewInfo != null) {
    if ((irNode.getJSDocInfo() != null) &&
        (irNode.getJSDocInfo().getLicense() != null)) {
      JSDocInfoBuilder builder = JSDocInfoBuilder.copyFrom(fileOverviewInfo);
      builder.recordLicense(irNode.getJSDocInfo().getLicense());
      fileOverviewInfo = builder.build();
    }
    irNode.setJSDocInfo(fileOverviewInfo);
  }
}
 
开发者ID:google,项目名称:closure-compiler,代码行数:20,代码来源:IRFactory.java

示例15: JsDocInfoParser

import com.google.javascript.rhino.JSDocInfoBuilder; //导入依赖的package包/类
JsDocInfoParser(JsDocTokenStream stream,
                String comment,
                int commentPosition,
                Node templateNode,
                Config config,
                ErrorReporter errorReporter) {
  this.stream = stream;

  boolean parseDocumentation = config.jsDocParsingMode().shouldParseDescriptions();
  this.jsdocBuilder = new JSDocInfoBuilder(parseDocumentation);
  if (comment != null) {
    this.jsdocBuilder.recordOriginalCommentString(comment);
    this.jsdocBuilder.recordOriginalCommentPosition(commentPosition);
  }
  this.annotations = config.annotations();
  this.suppressionNames = config.suppressionNames();
  this.preserveWhitespace = config.jsDocParsingMode().shouldPreserveWhitespace();

  this.errorReporter = errorReporter;
  this.templateNode = templateNode == null ? IR.script() : templateNode;
}
 
开发者ID:google,项目名称:closure-compiler,代码行数:22,代码来源:JsDocInfoParser.java


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