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


Java DocumentReader类代码示例

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


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

示例1: parse

import org.fife.io.DocumentReader; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
public ParseResult parse(RSyntaxDocument doc, String style) {

	result.clearNotices();
	Element root = doc.getDefaultRootElement();
	result.setParsedLines(0, root.getElementCount()-1);

	if (spf==null || doc.getLength()==0) {
		return result;
	}

	try {
		SAXParser sp = spf.newSAXParser();
		Handler handler = new Handler(doc);
		DocumentReader r = new DocumentReader(doc);
		InputSource input = new InputSource(r);
		sp.parse(input, handler);
		r.close();
	} catch (SAXParseException spe) {
		// A fatal parse error - ignore; a ParserNotice was already created.
	} catch (Exception e) {
		//e.printStackTrace(); // Will print if DTD specified and can't be found
		result.addNotice(new DefaultParserNotice(this,
				"Error parsing XML: " + e.getMessage(), 0, -1, -1));
	}

	return result;

}
 
开发者ID:curiosag,项目名称:ftc,代码行数:32,代码来源:XmlParser.java

示例2: parse

import org.fife.io.DocumentReader; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
public ParseResult parse(RSyntaxDocument doc, String style) {

    result.clearNotices();
    Element root = doc.getDefaultRootElement();
    result.setParsedLines(0, root.getElementCount() - 1);

    if (spf == null) {
        return result;
    }

    try {
        SAXParser sp = spf.newSAXParser();
        Handler handler = new Handler();
        DocumentReader r = new DocumentReader(doc);
        InputSource input = new InputSource(r);
        sp.parse(input, handler);
        r.close();
    } catch (SAXParseException spe) {
        // A fatal parse error - ignore; a ParserNotice was already created.
    } catch (Exception e) {
        e.printStackTrace();
        result.addNotice(new DefaultParserNotice(this,
                "Error parsing XML: " + e.getMessage(), 0, -1, -1));
    }

    return result;

}
 
开发者ID:intuit,项目名称:Tank,代码行数:32,代码来源:XMLParser.java

示例3: parse

import org.fife.io.DocumentReader; //导入依赖的package包/类
/**
	 * {@inheritDoc}
	 */
	public ParseResult parse(RSyntaxDocument doc, String style) {

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

		DocumentReader r = new DocumentReader(doc);
		Scanner scanner = new Scanner(r);
		scanner.setDocument(doc);
		ASTFactory fact = new ASTFactory();
		long start = System.currentTimeMillis();
		try {
			cu = fact.getCompilationUnit("SomeFile.java", scanner); // TODO: Real name?
			long time = System.currentTimeMillis() - start;
			result.setParseTime(time);
		} catch (IOException ioe) {
			result.setError(ioe);
//			ioe.printStackTrace();
		}

		r.close();

		addNotices(doc);
		support.firePropertyChange(PROPERTY_COMPILATION_UNIT, null, cu);
		return result;

	}
 
开发者ID:pyros2097,项目名称:GdxStudio,代码行数:33,代码来源:JavaParser.java

示例4: parse

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

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

	DocumentReader r = new DocumentReader(doc);
	Scanner scanner = new Scanner(r);
	scanner.setDocument(doc);
	ASTFactory fact = new ASTFactory();
	long start = System.currentTimeMillis();
	try {
		cu = fact.getCompilationUnit("SomeFile.java", scanner); // TODO: Real name?
		long time = System.currentTimeMillis() - start;
		result.setParseTime(time);
	} finally {
		r.close();
	}

	addNotices(doc);
	support.firePropertyChange(PROPERTY_COMPILATION_UNIT, null, cu);
	return result;

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

示例5: AstFactory

import org.fife.io.DocumentReader; //导入依赖的package包/类
public AstFactory(RSyntaxDocument doc, Parser parser, CodeCompletionProvider ccp) {
	scanner = new Scanner(new DocumentReader(doc));
	result = new ZScriptParseResult(parser);
	//this.ccp = ccp;
}
 
开发者ID:bobbylight,项目名称:ZScriptLanguageSupport,代码行数:6,代码来源:AstFactory.java

示例6: parse

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

new ValidationConfigSniffer().sniff(doc);

		DefaultParseResult result = new DefaultParseResult(this);
		curElem = root = new XmlTreeNode("Root");

		if (spf==null || doc.getLength()==0) {
			return result;
		}

		//long start = System.currentTimeMillis();
		try {
			if (sp==null) { // New or reset for different validation
				sp = spf.newSAXParser();
			}
			Handler handler = new Handler(doc, result);
			if (validationConfig!=null) {
				validationConfig.configureHandler(handler);
			}
			DocumentReader r = new DocumentReader(doc);
			InputSource input = new InputSource(r);
			sp.parse(input, handler);
			r.close();
		} catch (Exception e) {
			// Don't give an error; they likely just saved an incomplete XML
			// file
			// Fall through
		}
		//long time = System.currentTimeMillis() - start;
		//System.err.println("DEBUG: IconGroupLoader parsing: " + time + " ms");

		if (locator!=null) {
			try {
				root.setStartOffset(doc.createPosition(0));
				root.setEndOffset(doc.createPosition(doc.getLength()));
			} catch (BadLocationException ble) {
				ble.printStackTrace();
			}
		}

		support.firePropertyChange(PROPERTY_AST, null, root);
		return result;

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

示例7: parse

import org.fife.io.DocumentReader; //导入依赖的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.fife.io.DocumentReader类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。