com.google.javascript.jscomp.parsing.Config.LanguageMode Java Examples

The following examples show how to use com.google.javascript.jscomp.parsing.Config.LanguageMode. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: 1_JsDocInfoParser.java    From SimFix with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Parses a string containing a JsDoc type declaration, returning the
 * type if the parsing succeeded or {@code null} if it failed.
 */
public static Node parseTypeString(String typeString) {
  Config config = new Config(
      Sets.<String>newHashSet(),
      Sets.<String>newHashSet(),
      false,
      LanguageMode.ECMASCRIPT3,
      false);
  JsDocInfoParser parser = new JsDocInfoParser(
      new JsDocTokenStream(typeString),
      null,
      "typeparsing",
      config,
      NullErrorReporter.forNewRhino());

  return parser.parseTopLevelTypeExpression(parser.next());
}
 
Example #2
Source File: JsDocInfoParser.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Parses a string containing a JsDoc type declaration, returning the
 * type if the parsing succeeded or {@code null} if it failed.
 */
public static Node parseTypeString(String typeString) {
  Config config = new Config(
      Sets.<String>newHashSet(),
      Sets.<String>newHashSet(),
      false,
      LanguageMode.ECMASCRIPT3,
      false);
  JsDocInfoParser parser = new JsDocInfoParser(
      new JsDocTokenStream(typeString),
      null,
      null,
      config,
      NullErrorReporter.forNewRhino());

  return parser.parseTopLevelTypeExpression(parser.next());
}
 
Example #3
Source File: 1_JsDocInfoParser.java    From SimFix with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Parses a string containing a JsDoc type declaration, returning the
 * type if the parsing succeeded or {@code null} if it failed.
 */
public static Node parseTypeString(String typeString) {
  Config config = new Config(
      Sets.<String>newHashSet(),
      Sets.<String>newHashSet(),
      false,
      LanguageMode.ECMASCRIPT3,
      false);
  JsDocInfoParser parser = new JsDocInfoParser(
      new JsDocTokenStream(typeString),
      null,
      "typeparsing",
      config,
      NullErrorReporter.forNewRhino());

  return parser.parseTopLevelTypeExpression(parser.next());
}
 
Example #4
Source File: Closure_109_JsDocInfoParser_s.java    From coming with MIT License 6 votes vote down vote up
/**
 * Parses a string containing a JsDoc type declaration, returning the
 * type if the parsing succeeded or {@code null} if it failed.
 */
public static Node parseTypeString(String typeString) {
  Config config = new Config(
      Sets.<String>newHashSet(),
      Sets.<String>newHashSet(),
      false,
      LanguageMode.ECMASCRIPT3,
      false);
  JsDocInfoParser parser = new JsDocInfoParser(
      new JsDocTokenStream(typeString),
      null,
      null,
      config,
      NullErrorReporter.forNewRhino());

  return parser.parseTopLevelTypeExpression(parser.next());
}
 
Example #5
Source File: Closure_109_JsDocInfoParser_t.java    From coming with MIT License 6 votes vote down vote up
/**
 * Parses a string containing a JsDoc type declaration, returning the
 * type if the parsing succeeded or {@code null} if it failed.
 */
public static Node parseTypeString(String typeString) {
  Config config = new Config(
      Sets.<String>newHashSet(),
      Sets.<String>newHashSet(),
      false,
      LanguageMode.ECMASCRIPT3,
      false);
  JsDocInfoParser parser = new JsDocInfoParser(
      new JsDocTokenStream(typeString),
      null,
      null,
      config,
      NullErrorReporter.forNewRhino());

  return parser.parseTopLevelTypeExpression(parser.next());
}
 
Example #6
Source File: Closure_133_JsDocInfoParser_s.java    From coming with MIT License 6 votes vote down vote up
/**
 * Parses a string containing a JsDoc type declaration, returning the
 * type if the parsing succeeded or {@code null} if it failed.
 */
public static Node parseTypeString(String typeString) {
  Config config = new Config(
      Sets.<String>newHashSet(),
      Sets.<String>newHashSet(),
      false,
      LanguageMode.ECMASCRIPT3,
      false);
  JsDocInfoParser parser = new JsDocInfoParser(
      new JsDocTokenStream(typeString),
      null,
      null,
      config,
      NullErrorReporter.forNewRhino());

  return parser.parseTopLevelTypeExpression(parser.next());
}
 
Example #7
Source File: Closure_133_JsDocInfoParser_t.java    From coming with MIT License 6 votes vote down vote up
/**
 * Parses a string containing a JsDoc type declaration, returning the
 * type if the parsing succeeded or {@code null} if it failed.
 */
public static Node parseTypeString(String typeString) {
  Config config = new Config(
      Sets.<String>newHashSet(),
      Sets.<String>newHashSet(),
      false,
      LanguageMode.ECMASCRIPT3,
      false);
  JsDocInfoParser parser = new JsDocInfoParser(
      new JsDocTokenStream(typeString),
      null,
      null,
      config,
      NullErrorReporter.forNewRhino());

  return parser.parseTopLevelTypeExpression(parser.next());
}
 
Example #8
Source File: Closure_68_JsDocInfoParser_s.java    From coming with MIT License 6 votes vote down vote up
/**
 * Parses a string containing a JsDoc type declaration, returning the
 * type if the parsing succeeded or {@code null} if it failed.
 */
public static Node parseTypeString(String typeString) {
  Config config = new Config(
      Sets.<String>newHashSet(),
      Sets.<String>newHashSet(),
      false,
      LanguageMode.ECMASCRIPT3,
      false);
  JsDocInfoParser parser = new JsDocInfoParser(
      new JsDocTokenStream(typeString),
      null,
      "typeparsing",
      config,
      NullErrorReporter.forNewRhino());

  return parser.parseTopLevelTypeExpression(parser.next());
}
 
Example #9
Source File: Closure_68_JsDocInfoParser_t.java    From coming with MIT License 6 votes vote down vote up
/**
 * Parses a string containing a JsDoc type declaration, returning the
 * type if the parsing succeeded or {@code null} if it failed.
 */
public static Node parseTypeString(String typeString) {
  Config config = new Config(
      Sets.<String>newHashSet(),
      Sets.<String>newHashSet(),
      false,
      LanguageMode.ECMASCRIPT3,
      false);
  JsDocInfoParser parser = new JsDocInfoParser(
      new JsDocTokenStream(typeString),
      null,
      "typeparsing",
      config,
      NullErrorReporter.forNewRhino());

  return parser.parseTopLevelTypeExpression(parser.next());
}
 
Example #10
Source File: Closure_32_JsDocInfoParser_s.java    From coming with MIT License 6 votes vote down vote up
/**
 * Parses a string containing a JsDoc type declaration, returning the
 * type if the parsing succeeded or {@code null} if it failed.
 */
public static Node parseTypeString(String typeString) {
  Config config = new Config(
      Sets.<String>newHashSet(),
      Sets.<String>newHashSet(),
      false,
      LanguageMode.ECMASCRIPT3,
      false);
  JsDocInfoParser parser = new JsDocInfoParser(
      new JsDocTokenStream(typeString),
      null,
      null,
      config,
      NullErrorReporter.forNewRhino());

  return parser.parseTopLevelTypeExpression(parser.next());
}
 
Example #11
Source File: Closure_32_JsDocInfoParser_t.java    From coming with MIT License 6 votes vote down vote up
/**
 * Parses a string containing a JsDoc type declaration, returning the
 * type if the parsing succeeded or {@code null} if it failed.
 */
public static Node parseTypeString(String typeString) {
  Config config = new Config(
      Sets.<String>newHashSet(),
      Sets.<String>newHashSet(),
      false,
      LanguageMode.ECMASCRIPT3,
      false);
  JsDocInfoParser parser = new JsDocInfoParser(
      new JsDocTokenStream(typeString),
      null,
      null,
      config,
      NullErrorReporter.forNewRhino());

  return parser.parseTopLevelTypeExpression(parser.next());
}
 
Example #12
Source File: JsDocInfoParserTest.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void setUp() throws Exception {
  super.setUp();
  extraAnnotations =
      Sets.newHashSet(
          ParserRunner.createConfig(true, LanguageMode.ECMASCRIPT3, false)
              .annotationNames.keySet());
  extraSuppressions =
      Sets.newHashSet(
          ParserRunner.createConfig(true, LanguageMode.ECMASCRIPT3, false)
              .suppressionNames);

  extraSuppressions.add("x");
  extraSuppressions.add("y");
  extraSuppressions.add("z");
}
 
Example #13
Source File: Nopol2017_0025_s.java    From coming with MIT License 6 votes vote down vote up
/**
 * Parses a string containing a JsDoc type declaration, returning the
 * type if the parsing succeeded or {@code null} if it failed.
 */
public static Node parseTypeString(String typeString) {
  Config config = new Config(
      Sets.<String>newHashSet(),
      Sets.<String>newHashSet(),
      false,
      LanguageMode.ECMASCRIPT3,
      false);
  JsDocInfoParser parser = new JsDocInfoParser(
      new JsDocTokenStream(typeString),
      null,
      null,
      config,
      NullErrorReporter.forNewRhino());

  return parser.parseTopLevelTypeExpression(parser.next());
}
 
Example #14
Source File: Nopol2017_0025_t.java    From coming with MIT License 6 votes vote down vote up
/**
 * Parses a string containing a JsDoc type declaration, returning the
 * type if the parsing succeeded or {@code null} if it failed.
 */
public static Node parseTypeString(String typeString) {
  Config config = new Config(
      Sets.<String>newHashSet(),
      Sets.<String>newHashSet(),
      false,
      LanguageMode.ECMASCRIPT3,
      false);
  JsDocInfoParser parser = new JsDocInfoParser(
      new JsDocTokenStream(typeString),
      null,
      null,
      config,
      NullErrorReporter.forNewRhino());

  return parser.parseTopLevelTypeExpression(parser.next());
}
 
Example #15
Source File: Cardumen_0017_s.java    From coming with MIT License 6 votes vote down vote up
/**
 * Parses a string containing a JsDoc type declaration, returning the
 * type if the parsing succeeded or {@code null} if it failed.
 */
public static Node parseTypeString(String typeString) {
  Config config = new Config(
      Sets.<String>newHashSet(),
      Sets.<String>newHashSet(),
      false,
      LanguageMode.ECMASCRIPT3,
      false);
  JsDocInfoParser parser = new JsDocInfoParser(
      new JsDocTokenStream(typeString),
      null,
      null,
      config,
      NullErrorReporter.forNewRhino());

  return parser.parseTopLevelTypeExpression(parser.next());
}
 
Example #16
Source File: Cardumen_0017_t.java    From coming with MIT License 6 votes vote down vote up
/**
 * Parses a string containing a JsDoc type declaration, returning the
 * type if the parsing succeeded or {@code null} if it failed.
 */
public static Node parseTypeString(String typeString) {
  Config config = new Config(
      Sets.<String>newHashSet(),
      Sets.<String>newHashSet(),
      false,
      LanguageMode.ECMASCRIPT3,
      false);
  JsDocInfoParser parser = new JsDocInfoParser(
      new JsDocTokenStream(typeString),
      null,
      null,
      config,
      NullErrorReporter.forNewRhino());

  return parser.parseTopLevelTypeExpression(parser.next());
}
 
Example #17
Source File: 1_JsDocInfoParser.java    From SimFix with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Parses a string containing a JsDoc type declaration, returning the
 * type if the parsing succeeded or {@code null} if it failed.
 */
public static Node parseTypeString(String typeString) {
  Config config = new Config(
      Sets.<String>newHashSet(),
      Sets.<String>newHashSet(),
      false,
      LanguageMode.ECMASCRIPT3,
      false);
  JsDocInfoParser parser = new JsDocInfoParser(
      new JsDocTokenStream(typeString),
      null,
      "typeparsing",
      config,
      NullErrorReporter.forNewRhino());

  return parser.parseTopLevelTypeExpression(parser.next());
}
 
Example #18
Source File: JsDocInfoParserTest.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
private void parseFull(String code, String... warnings) {
  CompilerEnvirons environment = new CompilerEnvirons();

  TestErrorReporter testErrorReporter = new TestErrorReporter(null, warnings);
  environment.setErrorReporter(testErrorReporter);

  environment.setRecordingComments(true);
  environment.setRecordingLocalJsDocComments(true);

  Parser p = new Parser(environment, testErrorReporter);
  AstRoot script = p.parse(code, null, 0);

  Config config =
      new Config(extraAnnotations, extraSuppressions,
          true, LanguageMode.ECMASCRIPT3, false);
  StaticSourceFile file = new SimpleSourceFile(script.getSourceName(), false);
  for (Comment comment : script.getComments()) {
    JsDocInfoParser jsdocParser =
      new JsDocInfoParser(
          new JsDocTokenStream(comment.getValue().substring(3),
              comment.getLineno()),
          comment,
          null,
          config,
          testErrorReporter);
    jsdocParser.parse();
    jsdocParser.retrieveAndResetParsedJSDocInfo();
  }

  assertTrue("some expected warnings were not reported",
      testErrorReporter.hasEncounteredAllWarnings());
}
 
Example #19
Source File: JsDocInfoParserTest.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
private JSDocInfo parse(String comment, boolean parseDocumentation,
    boolean parseFileOverview, String... warnings) {
  TestErrorReporter errorReporter = new TestErrorReporter(null, warnings);

  Config config = new Config(extraAnnotations, extraSuppressions,
      parseDocumentation, LanguageMode.ECMASCRIPT3, false);
  StaticSourceFile file = new SimpleSourceFile("testcode", false);
  Node associatedNode = new Node(Token.SCRIPT);
  associatedNode.setInputId(new InputId(file.getName()));
  associatedNode.setStaticSourceFile(file);
  JsDocInfoParser jsdocParser = new JsDocInfoParser(
      stream(comment),
      new Comment(0, 0, CommentType.JSDOC, comment),
      associatedNode,
      config, errorReporter);

  if (fileLevelJsDocBuilder != null) {
    jsdocParser.setFileLevelJsDocBuilder(fileLevelJsDocBuilder);
  }

  jsdocParser.parse();

  assertTrue("expected warnings were not reported",
      errorReporter.hasEncounteredAllWarnings());

  if (parseFileOverview) {
    return jsdocParser.getFileOverviewJSDocInfo();
  } else {
    return jsdocParser.retrieveAndResetParsedJSDocInfo();
  }
}
 
Example #20
Source File: ParserTest.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
public void testGetter() {
  mode = LanguageMode.ECMASCRIPT3;
  parseError("var x = {get 1(){}};",
      IRFactory.GETTER_ERROR_MESSAGE);
  parseError("var x = {get 'a'(){}};",
      IRFactory.GETTER_ERROR_MESSAGE);
  parseError("var x = {get a(){}};",
      IRFactory.GETTER_ERROR_MESSAGE);
  mode = LanguageMode.ECMASCRIPT5;
  parse("var x = {get 1(){}};");
  parse("var x = {get 'a'(){}};");
  parse("var x = {get a(){}};");
  parseError("var x = {get a(b){}};", "getters may not have parameters");
}
 
Example #21
Source File: IRFactoryTest.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
public void testSetter() {
  mode = LanguageMode.ECMASCRIPT5;
  testNewParser("({set a(x) {}})",
      "SCRIPT 1 [source_file: FileName.js] [length: 15]\n" +
      "    EXPR_RESULT 1 [source_file: FileName.js] [length: 14]\n" +
      "        OBJECTLIT 1 [source_file: FileName.js] [length: 13]\n" +
      "            SETTER_DEF a 1 [source_file: FileName.js] [length: 1]\n" +
      "                FUNCTION  1 [source_file: FileName.js] [length: 7]\n" +
      "                    NAME  1 [source_file: FileName.js]\n" +
      "                    PARAM_LIST 1 [source_file: FileName.js]\n" +
      "                        NAME x 1 [source_file: FileName.js] [length: 1]\n" +
      "                    BLOCK 1 [source_file: FileName.js] [length: 2]\n");
}
 
Example #22
Source File: IRFactoryTest.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
public void testGetter() {
  mode = LanguageMode.ECMASCRIPT5;
  testNewParser("({get a() {}})",
      "SCRIPT 1 [source_file: FileName.js] [length: 14]\n" +
      "    EXPR_RESULT 1 [source_file: FileName.js] [length: 13]\n" +
      "        OBJECTLIT 1 [source_file: FileName.js] [length: 12]\n" +
      "            GETTER_DEF a 1 [source_file: FileName.js] [length: 1]\n" +
      "                FUNCTION  1 [source_file: FileName.js] [length: 6]\n" +
      "                    NAME  1 [source_file: FileName.js]\n" +
      "                    PARAM_LIST 1 [source_file: FileName.js]\n" +
      "                    BLOCK 1 [source_file: FileName.js] [length: 2]\n");
}
 
Example #23
Source File: ParserTest.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
public void testSetter() {
  mode = LanguageMode.ECMASCRIPT3;
  parseError("var x = {set 1(x){}};",
      IRFactory.SETTER_ERROR_MESSAGE);
  parseError("var x = {set 'a'(x){}};",
      IRFactory.SETTER_ERROR_MESSAGE);
  parseError("var x = {set a(x){}};",
      IRFactory.SETTER_ERROR_MESSAGE);
  mode = LanguageMode.ECMASCRIPT5;
  parse("var x = {set 1(x){}};");
  parse("var x = {set 'a'(x){}};");
  parse("var x = {set a(x){}};");
  parseError("var x = {set a(){}};",
      "setters must have exactly one parameter");
}
 
Example #24
Source File: ParserTest.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
public void testReservedKeywords() {
  boolean isIdeMode = false;

  mode = LanguageMode.ECMASCRIPT3;

  parseError("var boolean;", "missing variable name");
  parseError("function boolean() {};",
      "missing ( before function parameters.");
  parseError("boolean = 1;", "identifier is a reserved word");
  parseError("class = 1;", "identifier is a reserved word");
  parseError("public = 2;", "identifier is a reserved word");

  mode = LanguageMode.ECMASCRIPT5;

  parse("var boolean;");
  parse("function boolean() {};");
  parse("boolean = 1;");
  parseError("class = 1;", "identifier is a reserved word");
  parse("public = 2;");

  mode = LanguageMode.ECMASCRIPT5_STRICT;

  parse("var boolean;");
  parse("function boolean() {};");
  parse("boolean = 1;");
  parseError("class = 1;", "identifier is a reserved word");
  parseError("public = 2;", "identifier is a reserved word");
}
 
Example #25
Source File: IRFactoryTest.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
public void testObjectLiteral8() {
  mode = LanguageMode.ECMASCRIPT5;

  testNewParser("({set 1(a) {}})",
      "SCRIPT 1 [source_file: FileName.js] [length: 15]\n" +
      "    EXPR_RESULT 1 [source_file: FileName.js] [length: 14]\n" +
      "        OBJECTLIT 1 [source_file: FileName.js] [length: 13]\n" +
      "            SETTER_DEF 1 1 [quoted: 1] [source_file: FileName.js] [length: 1]\n" +
      "                FUNCTION  1 [source_file: FileName.js] [length: 7]\n" +
      "                    NAME  1 [source_file: FileName.js]\n" +
      "                    PARAM_LIST 1 [source_file: FileName.js]\n" +
      "                        NAME a 1 [source_file: FileName.js] [length: 1]\n" +
      "                    BLOCK 1 [source_file: FileName.js] [length: 2]\n");
}
 
Example #26
Source File: IRFactoryTest.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
public void testObjectLiteral7() {
  mode = LanguageMode.ECMASCRIPT5;

  testNewParser("({get 1() {}})",
      "SCRIPT 1 [source_file: FileName.js] [length: 14]\n" +
      "    EXPR_RESULT 1 [source_file: FileName.js] [length: 13]\n" +
      "        OBJECTLIT 1 [source_file: FileName.js] [length: 12]\n" +
      "            GETTER_DEF 1 1 [quoted: 1] [source_file: FileName.js] [length: 1]\n" +
      "                FUNCTION  1 [source_file: FileName.js] [length: 6]\n" +
      "                    NAME  1 [source_file: FileName.js]\n" +
      "                    PARAM_LIST 1 [source_file: FileName.js]\n" +
      "                    BLOCK 1 [source_file: FileName.js] [length: 2]\n");
}
 
Example #27
Source File: Closure_42_IRFactory_s.java    From coming with MIT License 5 votes vote down vote up
@Override
Node processObjectLiteral(ObjectLiteral literalNode) {
  if (literalNode.isDestructuring()) {
    reportDestructuringAssign(literalNode);
  }

  Node node = newNode(Token.OBJECTLIT);
  for (ObjectProperty el : literalNode.getElements()) {
    if (config.languageMode == LanguageMode.ECMASCRIPT3) {
      if (el.isGetter()) {
        reportGetter(el);
        continue;
      } else if (el.isSetter()) {
        reportSetter(el);
        continue;
      }
    }

    Node key = transformAsString(el.getLeft());
    Node value = transform(el.getRight());
    if (el.isGetter()) {
      key.setType(Token.GETTER_DEF);
      Preconditions.checkState(value.isFunction());
      if (getFnParamNode(value).hasChildren()) {
        reportGetterParam(el.getLeft());
      }
    } else if (el.isSetter()) {
      key.setType(Token.SETTER_DEF);
      Preconditions.checkState(value.isFunction());
      if (!getFnParamNode(value).hasOneChild()) {
        reportSetterParam(el.getLeft());
      }
    }
    key.addChildToFront(value);
    node.addChildToBack(key);
  }
  return node;
}
 
Example #28
Source File: ParserRunner.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
public static Config createConfig(boolean isIdeMode,
                                  LanguageMode languageMode,
                                  boolean acceptConstKeyword,
                                  Set<String> extraAnnotationNames) {
  initResourceConfig();
  Set<String> effectiveAnnotationNames;
  if (extraAnnotationNames == null) {
    effectiveAnnotationNames = annotationNames;
  } else {
    effectiveAnnotationNames = new HashSet<String>(annotationNames);
    effectiveAnnotationNames.addAll(extraAnnotationNames);
  }
  return new Config(effectiveAnnotationNames, suppressionNames,
      isIdeMode, languageMode, acceptConstKeyword);
}
 
Example #29
Source File: IRFactory.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
@Override
Node processObjectLiteral(ObjectLiteral literalNode) {
  if (literalNode.isDestructuring()) {
    reportDestructuringAssign(literalNode);
  }

  Node node = newNode(Token.OBJECTLIT);
  for (ObjectProperty el : literalNode.getElements()) {
    if (config.languageMode == LanguageMode.ECMASCRIPT3) {
      if (el.isGetter()) {
        reportGetter(el);
        continue;
      } else if (el.isSetter()) {
        reportSetter(el);
        continue;
      }
    }

    Node key = transformAsString(el.getLeft());
    key.setType(Token.STRING_KEY);

    Node value = transform(el.getRight());
    if (el.isGetter()) {
      key.setType(Token.GETTER_DEF);
      Preconditions.checkState(value.isFunction());
      if (getFnParamNode(value).hasChildren()) {
        reportGetterParam(el.getLeft());
      }
    } else if (el.isSetter()) {
      key.setType(Token.SETTER_DEF);
      Preconditions.checkState(value.isFunction());
      if (!getFnParamNode(value).hasOneChild()) {
        reportSetterParam(el.getLeft());
      }
    }
    key.addChildToFront(value);
    node.addChildToBack(key);
  }
  return node;
}
 
Example #30
Source File: Closure_42_IRFactory_t.java    From coming with MIT License 5 votes vote down vote up
@Override
Node processObjectLiteral(ObjectLiteral literalNode) {
  if (literalNode.isDestructuring()) {
    reportDestructuringAssign(literalNode);
  }

  Node node = newNode(Token.OBJECTLIT);
  for (ObjectProperty el : literalNode.getElements()) {
    if (config.languageMode == LanguageMode.ECMASCRIPT3) {
      if (el.isGetter()) {
        reportGetter(el);
        continue;
      } else if (el.isSetter()) {
        reportSetter(el);
        continue;
      }
    }

    Node key = transformAsString(el.getLeft());
    Node value = transform(el.getRight());
    if (el.isGetter()) {
      key.setType(Token.GETTER_DEF);
      Preconditions.checkState(value.isFunction());
      if (getFnParamNode(value).hasChildren()) {
        reportGetterParam(el.getLeft());
      }
    } else if (el.isSetter()) {
      key.setType(Token.SETTER_DEF);
      Preconditions.checkState(value.isFunction());
      if (!getFnParamNode(value).hasOneChild()) {
        reportSetterParam(el.getLeft());
      }
    }
    key.addChildToFront(value);
    node.addChildToBack(key);
  }
  return node;
}