Examples of CompilerEnvirons


Examples of com.google.javascript.jscomp.mozilla.rhino.CompilerEnvirons

                           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);
    // ES5 specifically allows trailing commas
    compilerEnv.setWarnTrailingComma(
        config.languageMode == LanguageMode.ECMASCRIPT3);

    if (config.isIdeMode || config.languageMode != LanguageMode.ECMASCRIPT3) {
      // Do our own identifier check for ECMASCRIPT 5
      compilerEnv.setReservedKeywordAsIdentifier(true);
      compilerEnv.setAllowKeywordAsObjectPropertyName(true);
    }

    if (config.isIdeMode) {
      compilerEnv.setAllowMemberExprAsFunctionName(true);
    }
    compilerEnv.setIdeMode(config.isIdeMode);

    Parser p = new Parser(compilerEnv, errorReporter);
    AstRoot astRoot = null;
    try {
      astRoot = p.parse(sourceString, sourceFile.getName(), 1);
View Full Code Here

Examples of com.google.javascript.jscomp.mozilla.rhino.CompilerEnvirons

  private <T> void assertContains(Collection<T> collection, T item) {
    assertTrue(collection.contains(item));
  }

  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 =
View Full Code Here

Examples of com.google.javascript.jscomp.mozilla.rhino.CompilerEnvirons

  private Node newParse(String string) {
    return newParse(string, new TestErrorReporter(null, null));
  }

  private Node newParse(String string, TestErrorReporter errorReporter) {
    CompilerEnvirons environment = new CompilerEnvirons();

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

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

    Config config = ParserRunner.createConfig(true, mode, false);
View Full Code Here

Examples of net.sourceforge.htmlunit.corejs.javascript.CompilerEnvirons

     */
    public String preProcess(final HtmlPage htmlPage, String sourceCode, final String sourceName,
                final HtmlElement htmlElement) {

        try {
            final CompilerEnvirons environs = new CompilerEnvirons();
            environs.initFromContext(contextFactory_.enterContext());
            final AstNode root = new Parser(environs).parse(sourceCode, sourceName, lineNo_);
            final Map<Integer, Integer> strings = new TreeMap<Integer, Integer>();
            root.visit(new NodeVisitor() {

                public boolean visit(final AstNode node) {
View Full Code Here

Examples of org.mozilla.javascript.CompilerEnvirons

        }       
        return buffer.toString();
    }
   
    private static Parser createParser() {
        CompilerEnvirons env = new CompilerEnvirons();
        env.setIdeMode(true);
        env.setRecoverFromErrors(true);
        env.setStrictMode(false);
        env.setErrorReporter(new ErrorReporter() {

            public void warning(String message, String sourceName, int line, String lineSource, int lineOffset) {
            }

            public EvaluatorException runtimeError(String message, String sourceName, int line, String lineSource, int lineOffset) {
View Full Code Here

Examples of org.mozilla.javascript.CompilerEnvirons

  /**
   *
   */
  public WinkParser() {
    compilerEnv = new CompilerEnvirons();
    errorReporter = compilerEnv.getErrorReporter();
    parser = new Parser(compilerEnv, errorReporter);
    jsFiles = Common.newArrayList(1);
  }
View Full Code Here

Examples of org.mozilla.javascript.CompilerEnvirons

        }


        private Class<?> compileClass( final Context pContext, final String pSourceName, final String pClassName, final Class<?> pSuperClass, final Class<?>[] pInterfaces) {

            final CompilerEnvirons environments = new CompilerEnvirons();
            environments.initFromContext(pContext);
            final ClassCompiler compiler = new ClassCompiler(environments);

            if (pSuperClass != null) {
                compiler.setTargetExtends(pSuperClass);
            }
View Full Code Here

Examples of org.mozilla.javascript.CompilerEnvirons

public class JQueryScanner {

  public JQueryScanner(FileReader in) {
    final ErrorReporter reporter = new ToolErrorReporter(true);
    final CompilerEnvirons env = new CompilerEnvirons();
    final Parser parser = new Parser(env, reporter);

    try {
      parser.parse(in, null, 0);
    } catch (IOException e) {
View Full Code Here

Examples of org.mozilla.javascript.CompilerEnvirons

   * @throws Exception
   *           压缩过程中的错误
   */
  public void compress(Reader reader, Writer writer, boolean keepLineno,
      int mode) throws Exception {
    Parser parser = new Parser(new CompilerEnvirons(), reporter);
    ScriptOrFnNode root = parser.parse(reader, null, 1);

    Environment env = new Environment(keepLineno, mode);
    GlobalScope globalScope = new GlobalScope();
    StatementList statements = new StatementList();
View Full Code Here

Examples of org.mozilla.javascript.CompilerEnvirons

    }

    private AstRoot parse(
        String string, final String [] errors, final String [] warnings,
        boolean jsdoc) {
        CompilerEnvirons environment = new CompilerEnvirons();
        environment.setAllowKeywordAsObjectPropertyName(
            allowKeywordsAsObjectLiteralsKeys);

        TestErrorReporter testErrorReporter =
            new TestErrorReporter(errors, warnings) {
          @Override
          public EvaluatorException runtimeError(
               String message, String sourceName, int line, String lineSource,
               int lineOffset) {
             if (errors == null) {
               throw new UnsupportedOperationException();
             }
             return new EvaluatorException(
               message, sourceName, line, lineSource, lineOffset);
           }
        };
        environment.setErrorReporter(testErrorReporter);

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

        Parser p = new Parser(environment, testErrorReporter);
        AstRoot script = null;
        try {
          script = p.parse(string, null, 0);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.