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


Java NodeTraversal.traverseEs6方法代码示例

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


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

示例1: compileFiles

import com.google.javascript.jscomp.NodeTraversal; //导入方法依赖的package包/类
@SuppressWarnings("deprecation")
private OOPSourceCodeModel compileFiles(List<RawFile> files, List<String> projectFileTypes) {
    OOPSourceCodeModel model = new OOPSourceCodeModel();
    for (RawFile file : files) {
        try {
            Compiler compiler = new Compiler();
            CompilerOptions options = new CompilerOptions();
            options.setIdeMode(true);
            options.setParseJsDocDocumentation(JsDocParsing.INCLUDE_DESCRIPTIONS_WITH_WHITESPACE);
            compiler.initOptions(options);
            Node root = new JsAst(SourceFile.fromCode(file.name(), file.content())).getAstRoot(compiler);
            JavaScriptListener jsListener = new JavaScriptListener(model, file, projectFileTypes);
            NodeTraversal.traverseEs6(compiler, root, jsListener);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    return model;
}
 
开发者ID:Zir0-93,项目名称:clarpse,代码行数:20,代码来源:ClarpseJSCompiler.java

示例2: process

import com.google.javascript.jscomp.NodeTraversal; //导入方法依赖的package包/类
@Override
public void process(Node externs, Node root) {
  this.typesToRename = new LinkedHashMap<>();
  this.typesToFilename = new LinkedHashMap<>();
  for (Node child : root.children()) {
    // We convert each file independently to avoid merging class methods from different files.
    if (child.isScript()) {
      this.types = new LinkedHashMap<>();
      NodeTraversal.traverseEs6(compiler, child, new TypeConverter());
      NodeTraversal.traverseEs6(compiler, child, new TypeMemberConverter());
      NodeTraversal.traverseEs6(compiler, child, new FieldOnThisConverter());
      NodeTraversal.traverseEs6(compiler, child, new InheritanceConverter());
      NodeTraversal.traverseEs6(compiler, child, new EnumConverter());
    }
  }
  convertTypeAlias();
}
 
开发者ID:angular,项目名称:clutz,代码行数:18,代码来源:TypeConversionPass.java

示例3: hotSwapScript

import com.google.javascript.jscomp.NodeTraversal; //导入方法依赖的package包/类
@Override
public void hotSwapScript(Node scriptRoot, Node originalRoot) {
  NodeTraversal.traverseEs6(compiler, scriptRoot, this);
  // Inline React.createMixin calls, since they're just decorators.
  for (Node mixinSpecNode : reactMixinsByName.values()) {
    Node mixinSpecParentNode = mixinSpecNode.getParent();
    if (mixinSpecParentNode.isCall() &&
        mixinSpecParentNode.hasMoreThanOneChild() &&
        mixinSpecParentNode.getFirstChild().getQualifiedName().equals(
          "React.createMixin")) {
      mixinSpecNode.detachFromParent();
      mixinSpecParentNode.getParent().replaceChild(
        mixinSpecParentNode,
        mixinSpecNode);
      compiler.reportChangeToEnclosingScope(mixinSpecNode.getParent());
    }
  }
}
 
开发者ID:mihaip,项目名称:react-closure-compiler,代码行数:19,代码来源:ReactCompilerPass.java

示例4: getFixForUnsortedRequiresOrProvides

import com.google.javascript.jscomp.NodeTraversal; //导入方法依赖的package包/类
private static SuggestedFix getFixForUnsortedRequiresOrProvides(
    JSError error, AbstractCompiler compiler, String... closureFunctions) {
  SuggestedFix.Builder fix = new SuggestedFix.Builder();
  fix.attachMatchedNodeInfo(error.node, compiler);
  Node script = NodeUtil.getEnclosingScript(error.node);
  RequireProvideSorter cb = new RequireProvideSorter(closureFunctions);
  NodeTraversal.traverseEs6(compiler, script, cb);
  Node first = cb.calls.get(0);
  Node last = Iterables.getLast(cb.calls);

  cb.sortCallsAlphabetically();
  StringBuilder sb = new StringBuilder();
  for (Node n : cb.calls) {
    String statement = fix.generateCode(compiler, n);
    JSDocInfo jsDoc = NodeUtil.getBestJSDocInfo(n);
    if (jsDoc != null) {
      statement = jsDoc.getOriginalCommentString() + "\n" + statement;
    }
    sb.append(statement);
  }
  // Trim to remove the newline after the last goog.require/provide.
  String newContent = sb.toString().trim();
  return fix.replaceRange(first, last, newContent).build();
}
 
开发者ID:google,项目名称:closure-compiler,代码行数:25,代码来源:ErrorToFixMapper.java

示例5: process

import com.google.javascript.jscomp.NodeTraversal; //导入方法依赖的package包/类
@Override
public void process(Node externs, Node root) {
  NodeTraversal.traverseEs6(compiler, root, new TypeAnnotationConverter());
  NodeTraversal.traverseEs6(compiler, root, new AccessModifierConverter());
  for (Node script : root.children()) {
    addTypeOnlyImports(script);
  }
}
 
开发者ID:angular,项目名称:clutz,代码行数:9,代码来源:TypeAnnotationPass.java

示例6: process

import com.google.javascript.jscomp.NodeTraversal; //导入方法依赖的package包/类
@Override
public void process(Node externs, Node root) {
  for (Node script : root.children()) {
    if (script.isScript()) {
      // Note: this doesn't actually copy the list since the underlying list is already an
      // immutable list.
      ImmutableList<Comment> comments =
          ImmutableList.copyOf(compiler.getComments(script.getSourceFileName()));
      NodeTraversal.traverseEs6(compiler, script, new LinkCommentsForOneFile(comments));
    }
  }
}
 
开发者ID:angular,项目名称:clutz,代码行数:13,代码来源:CommentLinkingPass.java

示例7: createTypesNode

import com.google.javascript.jscomp.NodeTraversal; //导入方法依赖的package包/类
private Node createTypesNode() {
  if (templateTypesNode == null) {
    String typesJs = React.getTypesJs();
    Result previousResult = compiler.getResult();
    templateTypesNode =
      compiler.parse(SourceFile.fromCode(React.TYPES_JS_RESOURCE_PATH, typesJs));
    Result result = compiler.getResult();
    if ((result.success != previousResult.success && previousResult.success) ||
        result.errors.length > previousResult.errors.length ||
        result.warnings.length > previousResult.warnings.length) {
      String message = "Could not parse " + React.TYPES_JS_RESOURCE_PATH + ".";
      if (result.errors.length > 0) {
        message += "\nErrors: " + Joiner.on(",").join(result.errors);
      }
      if (result.warnings.length > 0) {
        message += "\nWarnings: " + Joiner.on(",").join(result.warnings);
      }
      throw new RuntimeException(message);
    }
    // Gather ReactComponent prototype methods.
    NodeTraversal.traverseEs6(
        compiler,
        templateTypesNode,
        new NodeTraversal.AbstractPostOrderCallback() {
          @Override public void visit(NodeTraversal t, Node n, Node parent) {
            if (!n.isAssign() || !n.getFirstChild().isQualifiedName() ||
                !n.getFirstChild().getQualifiedName().startsWith(
                    "ReactComponent.prototype.") ||
                !n.getLastChild().isFunction()) {
                return;
            }
            componentMethodJsDocs.put(
                n.getFirstChild().getLastChild().getString(),
                n.getJSDocInfo());
          }
        });
  }
  return templateTypesNode.cloneTree();
}
 
开发者ID:mihaip,项目名称:react-closure-compiler,代码行数:40,代码来源:ReactCompilerPass.java

示例8: processFile

import com.google.javascript.jscomp.NodeTraversal; //导入方法依赖的package包/类
private void processFile(Node scriptNode) {
  checkArgument(scriptNode.isScript());
  FileInfo currentFile = new FileInfo();
  NodeTraversal.traverseEs6(compiler, scriptNode, new RemoveNonDeclarations());
  NodeTraversal.traverseEs6(compiler, scriptNode, new PropagateConstJsdoc(currentFile));
  new SimplifyDeclarations(compiler, currentFile).simplifyAll();
}
 
开发者ID:google,项目名称:closure-compiler,代码行数:8,代码来源:ConvertToTypedInterface.java

示例9: usesConstGoogRequires

import com.google.javascript.jscomp.NodeTraversal; //导入方法依赖的package包/类
/** True if the file uses {@code const foo = goog.require('namespace.foo');} */
private boolean usesConstGoogRequires(final NodeMetadata metadata, Node script) {
  if (script.isModuleBody()) {
    return true;
  }
  HasConstRequireOrModuleCallback callback = new HasConstRequireOrModuleCallback(metadata);
  NodeTraversal.traverseEs6(metadata.getCompiler(), script, callback);
  return callback.getUsesConstRequires();
}
 
开发者ID:google,项目名称:closure-compiler,代码行数:10,代码来源:SuggestedFix.java

示例10: parse

import com.google.javascript.jscomp.NodeTraversal; //导入方法依赖的package包/类
/** Internal implementation to produce the {@link FileInfo} object. */
private static FileInfo parse(String code, String filename, @Nullable Reporter reporter) {
  ErrorReporter errorReporter = new DelegatingReporter(reporter);
  Compiler compiler = new Compiler();
  compiler.init(
      ImmutableList.<SourceFile>of(), ImmutableList.<SourceFile>of(), new CompilerOptions());

  Config config =
      ParserRunner.createConfig(
          // TODO(sdh): ES8 STRICT, with a non-strict fallback - then give warnings.
          Config.LanguageMode.ECMASCRIPT8,
          Config.JsDocParsing.INCLUDE_DESCRIPTIONS_NO_WHITESPACE,
          Config.RunMode.KEEP_GOING,
          /* extraAnnotationNames */ ImmutableSet.<String>of(),
          /* parseInlineSourceMaps */ true,
          Config.StrictMode.SLOPPY);

  SourceFile source = SourceFile.fromCode(filename, code);
  FileInfo info = new FileInfo(errorReporter);
  ParserRunner.ParseResult parsed = ParserRunner.parse(source, code, config, errorReporter);
  parsed.ast.setInputId(new InputId(filename));
  String version = parsed.features.version();
  if (!version.equals("es3")) {
    info.loadFlags.add(JsArray.of("lang", version));
  }

  for (Comment comment : parsed.comments) {
    if (comment.type == Comment.Type.JSDOC) {
      parseComment(comment, info);
    }
  }
  NodeTraversal.traverseEs6(compiler, parsed.ast, new Traverser(info));
  return info;
}
 
开发者ID:google,项目名称:closure-compiler,代码行数:35,代码来源:JsfileParser.java

示例11: drive

import com.google.javascript.jscomp.NodeTraversal; //导入方法依赖的package包/类
/** Run a refactoring and return any suggested fixes as a result. */
public List<SuggestedFix> drive(Scanner scanner, Pattern includeFilePattern) {
  JsFlumeCallback callback = new JsFlumeCallback(scanner, includeFilePattern);
  NodeTraversal.traverseEs6(compiler, rootNode, callback);
  List<SuggestedFix> fixes = callback.getFixes();
  fixes.addAll(scanner.processAllMatches(callback.getMatches()));
  return fixes;
}
 
开发者ID:google,项目名称:closure-compiler,代码行数:9,代码来源:RefactoringDriver.java

示例12: process

import com.google.javascript.jscomp.NodeTraversal; //导入方法依赖的package包/类
@Override
public void process(Node externs, Node root) {
  NodeTraversal.traverseEs6(compiler, root, this);
}
 
开发者ID:angular,项目名称:clutz,代码行数:5,代码来源:CollectModuleMetadata.java

示例13: process

import com.google.javascript.jscomp.NodeTraversal; //导入方法依赖的package包/类
@Override
public void process(Node externs, Node root) {
  NodeTraversal.traverseEs6(compiler, root, new ModuleExportConverter());
  NodeTraversal.traverseEs6(compiler, root, new ModuleImportConverter());
  NodeTraversal.traverseEs6(compiler, root, new ModuleImportRewriter());
}
 
开发者ID:angular,项目名称:clutz,代码行数:7,代码来源:ModuleConversionPass.java

示例14: hotSwapScript

import com.google.javascript.jscomp.NodeTraversal; //导入方法依赖的package包/类
@Override
public void hotSwapScript(Node scriptRoot, Node originalRoot) {
  NodeTraversal.traverseEs6(compiler, originalRoot, this);
}
 
开发者ID:google,项目名称:closure-compiler,代码行数:5,代码来源:CheckNullableReturn.java

示例15: hotSwapScript

import com.google.javascript.jscomp.NodeTraversal; //导入方法依赖的package包/类
@Override
public void hotSwapScript(Node scriptRoot, Node originalRoot) {
  NodeTraversal.traverseEs6(compiler, scriptRoot, this);
}
 
开发者ID:google,项目名称:closure-compiler,代码行数:5,代码来源:CheckUselessBlocks.java


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