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


Java Node.setIsSyntheticBlock方法代码示例

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


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

示例1: testTypeCheckStandaloneAST

import com.google.javascript.rhino.Node; //导入方法依赖的package包/类
public void testTypeCheckStandaloneAST() throws Exception {
  Node n = compiler.parseTestCode("function Foo() { }");
  typeCheck(n);
  TypedScopeCreator scopeCreator = new TypedScopeCreator(compiler);
  Scope topScope = scopeCreator.createScope(n, null);

  Node second = compiler.parseTestCode("new Foo");

  Node externs = new Node(Token.BLOCK);
  Node externAndJsRoot = new Node(Token.BLOCK, externs, second);
  externAndJsRoot.setIsSyntheticBlock(true);

  new TypeCheck(
      compiler,
      new SemanticReverseAbstractInterpreter(
          compiler.getCodingConvention(), registry),
      registry, topScope, scopeCreator, CheckLevel.WARNING, CheckLevel.OFF)
      .process(null, second);

  assertEquals(1, compiler.getWarningCount());
  assertEquals("cannot instantiate non-constructor",
      compiler.getWarnings()[0].description);
}
 
开发者ID:andyjko,项目名称:feedlack,代码行数:24,代码来源:TypeCheckTest.java

示例2: parse

import com.google.javascript.rhino.Node; //导入方法依赖的package包/类
static Node parse(String js, boolean checkTypes) {
  Compiler compiler = new Compiler();
  Node n = compiler.parseTestCode(js);

  if (checkTypes) {
    CompilerPass typeResolver = new DefaultPassConfig(null)
        .resolveTypes.create(compiler);
    Node externs = new Node(Token.SCRIPT);
    Node externAndJsRoot = new Node(Token.BLOCK, externs, n);
    externAndJsRoot.setIsSyntheticBlock(true);
    typeResolver.process(externs, n);
  }

  assertEquals("Errors for: " + js, 0, compiler.getErrorCount());
  return n;
}
 
开发者ID:andyjko,项目名称:feedlack,代码行数:17,代码来源:CodePrinterTest.java

示例3: parse

import com.google.javascript.rhino.Node; //导入方法依赖的package包/类
/**
 * Parses the JavaScript text given by a reader.
 *
 * @param sourceName The filename.
 * @param sourceString Source code from the file.
 * @param errorReporter An error.
 * @param logger A logger.
 * @return The AST of the given text.
 * @throws IOException
 */
public static Node parse(String sourceName,
                         String sourceString,
                         Config config,
                         ErrorReporter errorReporter,
                         Logger logger) throws IOException {
  Context cx = Context.enter();
  cx.setErrorReporter(errorReporter);
  cx.setLanguageVersion(Context.VERSION_1_5);
  CompilerEnvirons compilerEnv = new CompilerEnvirons();
  compilerEnv.initFromContext(cx);
  compilerEnv.setRecordingComments(true);
  compilerEnv.setRecordingLocalJsDocComments(true);
  compilerEnv.setWarnTrailingComma(true);
  if (config.isIdeMode) {
    compilerEnv.setReservedKeywordAsIdentifier(true);
    compilerEnv.setAllowMemberExprAsFunctionName(true);
  }

  Parser p = new Parser(compilerEnv, errorReporter);
  AstRoot astRoot = null;
  try {
    astRoot = p.parse(sourceString, sourceName, 1);
  } catch (EvaluatorException e) {
    logger.info("Error parsing " + sourceName + ": " + e.getMessage());
  } finally {
    Context.exit();
  }
  Node root = null;
  if (astRoot != null) {
    root = IRFactory.transformTree(
        astRoot, sourceString, config, errorReporter);
    root.setIsSyntheticBlock(true);
  }
  return root;
}
 
开发者ID:andyjko,项目名称:feedlack,代码行数:46,代码来源:ParserRunner.java

示例4: testNameNode

import com.google.javascript.rhino.Node; //导入方法依赖的package包/类
/**
 * Type checks a NAME node and retrieve its type.
 */
private JSType testNameNode(String name) {
  Node node = Node.newString(Token.NAME, name);
  Node parent = new Node(Token.SCRIPT, node);

  Node externs = new Node(Token.BLOCK);
  Node externAndJsRoot = new Node(Token.BLOCK, externs, parent);
  externAndJsRoot.setIsSyntheticBlock(true);

  makeTypeCheck().processForTesting(null, parent);
  return node.getJSType();
}
 
开发者ID:andyjko,项目名称:feedlack,代码行数:15,代码来源:TypeCheckTest.java

示例5: getTypedPercent

import com.google.javascript.rhino.Node; //导入方法依赖的package包/类
private double getTypedPercent(String js) throws Exception {
  Node n = compiler.parseTestCode(js);

  Node externs = new Node(Token.BLOCK);
  Node externAndJsRoot = new Node(Token.BLOCK, externs, n);
  externAndJsRoot.setIsSyntheticBlock(true);

  TypeCheck t = makeTypeCheck();
  t.processForTesting(null, n);
  return t.getTypedPercent();
}
 
开发者ID:andyjko,项目名称:feedlack,代码行数:12,代码来源:TypeCheckTest.java

示例6: testClosureTypes

import com.google.javascript.rhino.Node; //导入方法依赖的package包/类
private void testClosureTypes(String js, String description)
    throws Exception {
  Node n = compiler.parseTestCode(js);
  Node externs = new Node(Token.BLOCK);
  Node externAndJsRoot = new Node(Token.BLOCK, externs, n);
  externAndJsRoot.setIsSyntheticBlock(true);

  assertEquals("parsing error: " +
      Joiner.on(", ").join(compiler.getErrors()),
      0, compiler.getErrorCount());

  // For processing goog.addDependency for forward typedefs.
  new ProcessClosurePrimitives(compiler, CheckLevel.ERROR, true)
      .process(null, n);

  CodingConvention convention = compiler.getCodingConvention();
  new TypeCheck(compiler,
      new ClosureReverseAbstractInterpreter(
          convention, registry).append(
              new SemanticReverseAbstractInterpreter(
                  convention, registry))
          .getFirst(),
      registry)
      .processForTesting(null, n);

  assertEquals(0, compiler.getErrorCount());

  if (description == null) {
    assertEquals(
        "unexpected warning(s) : " +
        Joiner.on(", ").join(compiler.getWarnings()),
        0, compiler.getWarningCount());
  } else {
    assertEquals(1, compiler.getWarningCount());
    assertEquals(description, compiler.getWarnings()[0].description);
  }
}
 
开发者ID:andyjko,项目名称:feedlack,代码行数:38,代码来源:TypeCheckTest.java

示例7: parseAndTypeCheckWithScope

import com.google.javascript.rhino.Node; //导入方法依赖的package包/类
private TypeCheckResult parseAndTypeCheckWithScope(String externs,
                                                     String js) {
  Node externsNode = compiler.parseTestCode(externs);
  Node n = compiler.parseTestCode(js);
  Node externAndJsRoot = new Node(Token.BLOCK, externsNode, n);
  externAndJsRoot.setIsSyntheticBlock(true);

  assertEquals("parsing error: " +
      Joiner.on(", ").join(compiler.getErrors()),
      0, compiler.getErrorCount());

  Scope s = makeTypeCheck().processForTesting(externsNode, n);
  return new TypeCheckResult(n, s);
}
 
开发者ID:andyjko,项目名称:feedlack,代码行数:15,代码来源:TypeCheckTest.java

示例8: typeCheck

import com.google.javascript.rhino.Node; //导入方法依赖的package包/类
private Node typeCheck(Node n) {
  Node externsNode = new Node(Token.BLOCK);
  Node externAndJsRoot = new Node(Token.BLOCK, externsNode, n);
  externAndJsRoot.setIsSyntheticBlock(true);

  makeTypeCheck().processForTesting(null, n);
  return n;
}
 
开发者ID:andyjko,项目名称:feedlack,代码行数:9,代码来源:TypeCheckTest.java


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