本文整理汇总了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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}