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


Java CompilerEnvirons.setRecordingComments方法代码示例

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


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

示例1: parse

import org.mozilla.javascript.CompilerEnvirons; //导入方法依赖的package包/类
private AstRoot parse(String string, boolean jsdoc) {
    CompilerEnvirons environment = new CompilerEnvirons();

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

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

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

    assertTrue(testErrorReporter.hasEncounteredAllErrors());
    assertTrue(testErrorReporter.hasEncounteredAllWarnings());

    return script;
}
 
开发者ID:middle2tw,项目名称:whackpad,代码行数:18,代码来源:ParserTest.java

示例2: parseAsReader

import org.mozilla.javascript.CompilerEnvirons; //导入方法依赖的package包/类
private AstRoot parseAsReader(String string) throws IOException {
    CompilerEnvirons environment = new CompilerEnvirons();

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

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

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

    assertTrue(testErrorReporter.hasEncounteredAllErrors());
    assertTrue(testErrorReporter.hasEncounteredAllWarnings());

    return script;
}
 
开发者ID:middle2tw,项目名称:whackpad,代码行数:18,代码来源:ParserTest.java

示例3: parseFile

import org.mozilla.javascript.CompilerEnvirons; //导入方法依赖的package包/类
/**
 *
 * @param fileName
 * @param staticMethods
 * @param staticFields
 * @return
 * @throws FileNotFoundException
 * @throws IOException
 */
Collection<JsFile> parseFile(final String fileName,
    final List<JsMethod> staticMethods,
    final Map<String, JsElement> staticFields)
        throws FileNotFoundException, IOException {
  try (final Reader reader = new FileReader(fileName)) {
    final CompilerEnvirons env = new CompilerEnvirons();
    env.setRecordingLocalJsDocComments(true);
    env.setAllowSharpComments(true);
    env.setRecordingComments(true);
    final AstRoot node = new Parser(env).parse(reader, fileName, 1);
    final JavaScriptFileParser parser = new JavaScriptFileParser(fileName);
    node.visitAll(parser);
    staticMethods.addAll(parser.getStaticMethods());
    staticFields.putAll(parser.getConsts());
    return parser.getFiles();
  }
}
 
开发者ID:gruifo,项目名称:gruifo,代码行数:27,代码来源:Controller.java

示例4: createCompilerEnvironment

import org.mozilla.javascript.CompilerEnvirons; //导入方法依赖的package包/类
/**
 * Creates options for Rhino based off of the user's preferences.
 *
 * @param errorHandler The container for errors found while parsing.
 * @return The properties for the JS compiler to use.
 */
public static CompilerEnvirons createCompilerEnvironment(ErrorReporter
		errorHandler, JavaScriptLanguageSupport langSupport) {
	CompilerEnvirons env = new CompilerEnvirons();
	env.setErrorReporter(errorHandler);
	env.setIdeMode(true);
	env.setRecordingComments(true);
	env.setRecordingLocalJsDocComments(true);
	env.setRecoverFromErrors(true);
	if(langSupport != null) {
		env.setXmlAvailable(langSupport.isXmlAvailable());
		env.setStrictMode(langSupport.isStrictMode());
		int version = langSupport.getLanguageVersion();
		if (version > 0) {
			Logger.log("[JavaScriptParser]: JS language version set to: " + version);
			env.setLanguageVersion(version);
		}
	}
	return env;
}
 
开发者ID:bobbylight,项目名称:RSTALanguageSupport,代码行数:26,代码来源:JavaScriptParser.java

示例5: parseScript

import org.mozilla.javascript.CompilerEnvirons; //导入方法依赖的package包/类
protected AstRoot parseScript(String script){
    CompilerEnvirons ce = new CompilerEnvirons();
    ce.setRecordingComments(false);
    ce.setStrictMode(true);
    ce.setXmlAvailable(false);

    final AstRoot root;
    try {
        root = new Parser(ce).parse(script,"S1RestrictedScript",1);
    } catch (Throwable e) {
        String message = "";
        int line = 0;
        int column = 0;
        String m = null;
        if(e instanceof EvaluatorException){
            EvaluatorException ex = (EvaluatorException)e;
            message = "Syntax error: "+ex.getMessage();
            line = ex.getLineNumber()-1;
            column = ex.getColumnNumber();
            String arr [] = script.split("\n",-1);
            m = (arr.length>line?(arr[line]):"");
        }else{
            message = e.getMessage();
        }
        throw new SyntaxException(m,line,column,message,e);
    }
    if(LOG.isDebugEnabled()){
        LOG.debug(root.debugPrint());
    }
    return root;
}
 
开发者ID:s1-platform,项目名称:s1,代码行数:32,代码来源:S1ScriptEngine.java


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