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


Java ErrorCollector类代码示例

本文整理汇总了Java中org.mozilla.javascript.ast.ErrorCollector的典型用法代码示例。如果您正苦于以下问题:Java ErrorCollector类的具体用法?Java ErrorCollector怎么用?Java ErrorCollector使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: gatherParserErrorsRhino

import org.mozilla.javascript.ast.ErrorCollector; //导入依赖的package包/类
/**
 * Gathers the syntax errors found by Rhino in-process when parsing the
 * document.
 *
 * @param errorHandler The errors found by Rhino.
 * @param root The root element of the document parsed.
 * @see #gatherParserErrorsJsHint(RSyntaxDocument)
 */
private void gatherParserErrorsRhino(ErrorCollector errorHandler,
		Element root) {

	List<ParseProblem> errors = errorHandler.getErrors();
	if (errors != null && errors.size() > 0) {

		for (ParseProblem problem : errors) {

			int offs = problem.getFileOffset();
			int len = problem.getLength();
			int line = root.getElementIndex(offs);
			String desc = problem.getMessage();
			DefaultParserNotice notice = new DefaultParserNotice(this,
					desc, line, offs, len);
			if (problem.getType() == ParseProblem.Type.Warning) {
				notice.setLevel(ParserNotice.Level.WARNING);
			}
			result.addNotice(notice);

		}

	}

}
 
开发者ID:bobbylight,项目名称:RSTALanguageSupport,代码行数:33,代码来源:JavaScriptParser.java

示例2: ideEnvirons

import org.mozilla.javascript.ast.ErrorCollector; //导入依赖的package包/类
/**
 * Returns a {@code CompilerEnvirons} suitable for using Rhino
 * in an IDE environment.  Most features are enabled by default.
 * The {@link ErrorReporter} is set to an {@link ErrorCollector}.
 */
public static CompilerEnvirons ideEnvirons() {
    CompilerEnvirons env = new CompilerEnvirons();
    env.setRecoverFromErrors(true);
    env.setRecordingComments(true);
    env.setStrictMode(true);
    env.setWarnTrailingComma(true);
    env.setLanguageVersion(170);
    env.setReservedKeywordAsIdentifier(true);
    env.setIdeMode(true);
    env.setErrorReporter(new ErrorCollector());
    return env;
}
 
开发者ID:MikaGuraN,项目名称:HL4A,代码行数:18,代码来源:CompilerEnvirons.java

示例3: ideEnvirons

import org.mozilla.javascript.ast.ErrorCollector; //导入依赖的package包/类
/**
 * Returns a {@code CompilerEnvirons} suitable for using Rhino
 * in an IDE environment.  Most features are enabled by default.
 * The {@link ErrorReporter} is set to an {@link ErrorCollector}.
 */
public static CompilerEnvirons ideEnvirons() {
  CompilerEnvirons env = new CompilerEnvirons();
  env.setRecoverFromErrors(true);
  env.setRecordingComments(true);
  env.setStrictMode(true);
  env.setWarnTrailingComma(true);
  env.setLanguageVersion(170);
  env.setReservedKeywordAsIdentifier(true);
  env.setIdeMode(true);
  env.setErrorReporter(new ErrorCollector());
  return env;
}
 
开发者ID:middle2tw,项目名称:whackpad,代码行数:18,代码来源:CompilerEnvirons.java

示例4: ideEnvirons

import org.mozilla.javascript.ast.ErrorCollector; //导入依赖的package包/类
/**
 * Returns a {@code CompilerEnvirons} suitable for using Rhino
 * in an IDE environment.  Most features are enabled by default.
 * The {@link org.mozilla.javascript.ErrorReporter} is set to an {@link org.mozilla.javascript.ast.ErrorCollector}.
 */
public static CompilerEnvirons ideEnvirons() {
    CompilerEnvirons env = new CompilerEnvirons();
    env.setRecoverFromErrors(true);
    env.setRecordingComments(true);
    env.setStrictMode(true);
    env.setWarnTrailingComma(true);
    env.setLanguageVersion(170);
    env.setReservedKeywordAsIdentifier(true);
    env.setIdeMode(true);
    env.setErrorReporter(new ErrorCollector());
    return env;
}
 
开发者ID:bsorrentino,项目名称:android-js,代码行数:18,代码来源:CompilerEnvirons.java

示例5: parse

import org.mozilla.javascript.ast.ErrorCollector; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public ParseResult parse(RSyntaxDocument doc, String style) {

	astRoot = null;
	result.clearNotices();
	// Always spell check all lines, for now.
	Element root = doc.getDefaultRootElement();
	int lineCount = root.getElementCount();
	result.setParsedLines(0, lineCount - 1);

	DocumentReader r = new DocumentReader(doc);
	ErrorCollector errorHandler = new ErrorCollector();
	CompilerEnvirons env = createCompilerEnvironment(errorHandler, langSupport);
	long start = System.currentTimeMillis();
	try {
		Parser parser = new Parser(env);
		astRoot = parser.parse(r, null, 0);
		long time = System.currentTimeMillis() - start;
		result.setParseTime(time);
	} catch (IOException ioe) { // Never happens
		result.setError(ioe);
		ioe.printStackTrace();
	} catch (RhinoException re) {
		// Shouldn't happen since we're passing an ErrorCollector in
		int line = re.lineNumber();
		// if (line>0) {
		Element elem = root.getElement(line);
		int offs = elem.getStartOffset();
		int len = elem.getEndOffset() - offs - 1;
		String msg = re.details();
		result.addNotice(new DefaultParserNotice(this, msg, line, offs, len));
		// }
	} catch (Exception e) {
		result.setError(e); // catch all
	}

	r.close();

	// Get any parser errors.
	switch (langSupport.getErrorParser()) {
		default:
		case RHINO:
			gatherParserErrorsRhino(errorHandler, root);
			break;
		case JSHINT:
			gatherParserErrorsJsHint(doc);
			break;
	}

	// addNotices(doc);
	support.firePropertyChange(PROPERTY_AST, null, astRoot);

	return result;

}
 
开发者ID:bobbylight,项目名称:RSTALanguageSupport,代码行数:59,代码来源:JavaScriptParser.java


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