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


Java CompilerEnvirons.getErrorReporter方法代码示例

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


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

示例1: compile

import org.mozilla.javascript.CompilerEnvirons; //导入方法依赖的package包/类
/**
 * Compiles {@code source} and returns the transformed and optimized
 * {@link ScriptNode}
 */
protected ScriptNode compile(CharSequence source) {
    final String mainMethodClassName = "Main";
    final String scriptClassName = "Main";

    CompilerEnvirons compilerEnv = new CompilerEnvirons();
    compilerEnv.initFromContext(cx);
    ErrorReporter compilationErrorReporter = compilerEnv
            .getErrorReporter();
    Parser p = new Parser(compilerEnv, compilationErrorReporter);
    AstRoot ast = p.parse(source.toString(), "<eval>", 1);
    IRFactory irf = new IRFactory(compilerEnv);
    ScriptNode tree = irf.transformTree(ast);

    Codegen codegen = new Codegen();
    codegen.setMainMethodClass(mainMethodClassName);
    codegen.compileToClassFile(compilerEnv, scriptClassName, tree,
            tree.getEncodedSource(), false);

    return tree;
}
 
开发者ID:F43nd1r,项目名称:rhino-android,代码行数:25,代码来源:Bug708801Test.java

示例2: parse

import org.mozilla.javascript.CompilerEnvirons; //导入方法依赖的package包/类
/**
 * @return a tree representation of the parsed JavaScript file
 * @throws IOException
 */
public ScriptOrFnNode parse() throws IOException {

  if (nodeTree == null) {
    Reader reader = new FileReader(jsFile);

    CompilerEnvirons compilerEnv = new CompilerEnvirons();
    ErrorReporter errorReporter = compilerEnv.getErrorReporter();

    Parser parser = new Parser(compilerEnv, errorReporter);

    String sourceURI;

    try {
      sourceURI = jsFile.getCanonicalPath();
    } catch (IOException e) {
      sourceURI = jsFile.toString();
    }

    nodeTree = parser.parse(reader, sourceURI, 1);
  }
  return nodeTree;
}
 
开发者ID:mauyr,项目名称:openbravo-brazil,代码行数:27,代码来源:JavaScriptParser.java

示例3: parse

import org.mozilla.javascript.CompilerEnvirons; //导入方法依赖的package包/类
private AstRoot parse(CharSequence cs) {
    CompilerEnvirons compilerEnv = new CompilerEnvirons();
    compilerEnv.initFromContext(cx);
    ErrorReporter compilationErrorReporter = compilerEnv.getErrorReporter();
    Parser p = new Parser(compilerEnv, compilationErrorReporter);
    return p.parse(cs.toString(), "<eval>", 1);
}
 
开发者ID:F43nd1r,项目名称:rhino-android,代码行数:8,代码来源:Bug689314Test.java

示例4: parseIntoTree

import org.mozilla.javascript.CompilerEnvirons; //导入方法依赖的package包/类
protected static AstRoot parseIntoTree(String formula) {
	Context cx = Context.enter();

	CompilerEnvirons compilerEnv = new CompilerEnvirons();
	compilerEnv.initFromContext(cx);
	ErrorReporter compilationErrorReporter = compilerEnv.getErrorReporter();

	Parser parser = new Parser(compilerEnv, compilationErrorReporter);
	AstRoot tree = parser.parse(formula, "(formula being checked by unit-checker)", 0);
	Context.exit();
	return tree;
}
 
开发者ID:nasa,项目名称:OpenSPIFe,代码行数:13,代码来源:AbstractFormulaParsingThing.java

示例5: validateScript

import org.mozilla.javascript.CompilerEnvirons; //导入方法依赖的package包/类
/**
 * Validates the specified script.
 * 
 * @param script
 *            the script to validate.
 * @throws ParseException
 *             if an syntax error is found.
 */
protected void validateScript( String script ) throws ParseException
{
	if ( script == null )
	{
		return;
	}

	CompilerEnvirons compilerEnv = new CompilerEnvirons( );
	Parser jsParser = new Parser( compilerEnv,
			compilerEnv.getErrorReporter( ) );

	try
	{
		jsParser.parse( script, null, 0 );
	}
	catch ( EvaluatorException e )
	{
		int offset = -1;

		if ( scriptViewer != null )
		{
			String[] lines = script.split( "\n" ); //$NON-NLS-1$

			for ( int i = 0; i < e.lineNumber( ); i++ )
			{
				offset += lines[i].length( ) + 1;
			}
			offset += e.columnNumber( );
		}
		throw new ParseException( e.getLocalizedMessage( ), offset );
	}
}
 
开发者ID:eclipse,项目名称:birt,代码行数:41,代码来源:ScriptValidator.java


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