本文整理汇总了Java中org.netbeans.modules.parsing.spi.Parser.Result方法的典型用法代码示例。如果您正苦于以下问题:Java Parser.Result方法的具体用法?Java Parser.Result怎么用?Java Parser.Result使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.netbeans.modules.parsing.spi.Parser
的用法示例。
在下文中一共展示了Parser.Result方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: index
import org.netbeans.modules.parsing.spi.Parser; //导入方法依赖的package包/类
@Override
protected void index(Indexable indexable, Parser.Result parserResult, Context context) {
try {
System.out.println("EMB: " + parserResult.getSnapshot().getText());
IndexingSupport is = IndexingSupport.getInstance(context);
if (!indexable.equals(f.lastIndexable)) {
is.removeDocuments(indexable);
f.lastIndexable = indexable;
}
final IndexDocument doc = is.createDocument(indexable);
doc.addPair(
"key", //NOI18N
parserResult.getSnapshot().getText().toString(),
true,
true);
is.addDocument(doc);
} catch (IOException ex) {
Exceptions.printStackTrace(ex);
}
}
示例2: index
import org.netbeans.modules.parsing.spi.Parser; //导入方法依赖的package包/类
@Override
protected void index(Indexable indexable, Parser.Result parserResult, Context context) {
try {
System.err.println("Indexable: " + indexable);
final IndexingSupport support = IndexingSupport.getInstance(context);
final InnerParser.InnerResult ir = (InnerParser.InnerResult) parserResult;
if (!indexable.equals(f.lastIndexable)) {
support.removeDocuments(indexable);
}
f.lastIndexable = indexable;
final IndexDocument doc = support.createDocument(indexable);
doc.addPair("mode", Integer.toString(ir.getMode()), true, true); //NOI18N
support.addDocument(doc);
} catch (IOException ioe) {
Exceptions.printStackTrace(ioe);
}
}
示例3: createParserTask
import org.netbeans.modules.parsing.spi.Parser; //导入方法依赖的package包/类
@Override
protected ParserResultTask createParserTask(FileObject file, FoldProcessor processor) {
final ParserResultTask wrapped = super.createParserTask(file, processor);
return new JavaParserResultTask(JavaSource.Phase.RESOLVED, TaskIndexingMode.ALLOWED_DURING_SCAN) {
@Override
public void run(Parser.Result result, SchedulerEvent event) {
wrapped.run(result, event);
}
@Override
public int getPriority() {
return wrapped.getPriority();
}
@Override
public Class<? extends Scheduler> getSchedulerClass() {
return wrapped.getSchedulerClass();
}
@Override
public void cancel() {
wrapped.cancel();
}
};
}
示例4: get
import org.netbeans.modules.parsing.spi.Parser; //导入方法依赖的package包/类
/**
* Returns an instance of the {@link WorkingCopy} for
* given {@link Parser.Result} if it is a result
* of a java parser.
* @param result for which the {@link WorkingCopy} should be
* returned.
* @return a {@link WorkingCopy} or null when the given result
* is not a result of java parsing.
* @since 0.42
*/
public static @NullUnknown WorkingCopy get (final @NonNull Parser.Result result) {
Parameters.notNull("result", result); //NOI18N
WorkingCopy copy = instance != null ? instance.get() : null;
if (copy != null && result instanceof JavacParserResult) {
final JavacParserResult javacResult = (JavacParserResult)result;
CompilationController controller = javacResult.get(CompilationController.class);
if (controller != null && controller.impl == copy.impl)
return copy;
}
return null;
}
示例5: retrieveController
import org.netbeans.modules.parsing.spi.Parser; //导入方法依赖的package包/类
static CompilationController retrieveController(ResultIterator resIt, FileObject fo) throws ParseException {
Parser.Result res = resIt.getParserResult();
CompilationController ci = res != null ? CompilationController.get(res) : null;
if (ci == null) {
LOG.warning("Unable to get compilation controller " + fo);
}
return ci;
}
示例6: findDeclaration
import org.netbeans.modules.parsing.spi.Parser; //导入方法依赖的package包/类
protected DeclarationLocation findDeclaration(String relFilePath, final String caretLine) throws Exception {
Source testSource = getTestSource(getTestFile(relFilePath));
final int caretOffset = getCaretOffset(testSource.createSnapshot().getText().toString(), caretLine);
enforceCaretOffset(testSource, caretOffset);
final DeclarationLocation [] location = new DeclarationLocation[] { null };
UserTask task = new UserTask() {
public @Override void run(ResultIterator resultIterator) throws Exception {
Parser.Result r = resultIterator.getParserResult();
assertTrue(r instanceof ParserResult);
ParserResult pr = (ParserResult) r;
DeclarationFinder finder = getFinder();
location[0] = finder.findDeclaration(pr, caretOffset);
}
};
if (classPathsForTest == null || classPathsForTest.isEmpty()) {
ParserManager.parse(Collections.singleton(testSource), task);
} else {
Future<Void> future = ParserManager.parseWhenScanFinished(Collections.singleton(testSource), task);
if (!future.isDone()) {
future.get();
}
}
return location[0];
}
示例7: get
import org.netbeans.modules.parsing.spi.Parser; //导入方法依赖的package包/类
public static FxmlParserResult get(Parser.Result p) {
if (p instanceof FxmlParserResult) {
return (FxmlParserResult)p;
} else {
return null;
}
}
示例8: run
import org.netbeans.modules.parsing.spi.Parser; //导入方法依赖的package包/类
@Override
public void run(ResultIterator resultIterator) throws Exception {
Parser.Result result = resultIterator.getParserResult(caretOffset);
CompilationController controller = result != null ? CompilationController.get(result) : null;
if (controller != null && (cancel == null || !cancel.call())) {
try {
this.controller = controller;
caretInSnapshot = snapshotPos(caretOffset);
resolve(controller);
} finally {
this.controller = null;
}
}
}
示例9: run
import org.netbeans.modules.parsing.spi.Parser; //导入方法依赖的package包/类
@Override
public void run(Parser.Result result, SchedulerEvent event) {
cancelled = false;
final Snapshot mySnapshot = result.getSnapshot();
if (mySnapshot.getMimePath().size() > 1) {
// I do not want the inner mimetype
return;
}
if (mySnapshot.getMimeType().equals("text/x-java")) {
// ignore toplevel java
return;
}
try {
synchronized (hints) {
for (Snapshot snap : hints.keySet()) {
if (snap.getSource().equals(mySnapshot.getSource())) {
collectResult(snap);
}
}
}
if (cancelled) {
return;
}
if (allHints != null) {
HintsController.setErrors(result.getSnapshot().getSource().getDocument(false), "java-hints", allHints);
}
} finally {
synchronized (hints) {
hints.clear();
allHints = null;
}
}
}
示例10: run
import org.netbeans.modules.parsing.spi.Parser; //导入方法依赖的package包/类
@Override
public void run(Parser.Result r, SchedulerEvent event) {
final Document doc = r.getSnapshot().getSource().getDocument(false);
if (doc == null) {
return;
}
Updater theUpdater = new Updater(fileData, doc);
processor.runWith(theUpdater, r, doc);
}
示例11: checkSemantic
import org.netbeans.modules.parsing.spi.Parser; //导入方法依赖的package包/类
protected void checkSemantic(final String relFilePath, final String caretLine) throws Exception {
Source testSource = getTestSource(getTestFile(relFilePath));
if (caretLine != null) {
int caretOffset = getCaretOffset(testSource.createSnapshot().getText().toString(), caretLine);
enforceCaretOffset(testSource, caretOffset);
}
UserTask task = new UserTask() {
public @Override void run(ResultIterator resultIterator) throws Exception {
Parser.Result r = resultIterator.getParserResult();
assertTrue(r instanceof ParserResult);
ParserResult pr = (ParserResult) r;
SemanticAnalyzer analyzer = getSemanticAnalyzer();
assertNotNull("getSemanticAnalyzer must be implemented", analyzer);
analyzer.run(pr, null);
Map<OffsetRange, Set<ColoringAttributes>> highlights = analyzer.getHighlights();
if (highlights == null) {
highlights = Collections.emptyMap();
}
Document doc = GsfUtilities.getDocument(pr.getSnapshot().getSource().getFileObject(), true);
checkNoOverlaps(highlights.keySet(), doc);
String annotatedSource = annotateSemanticResults(doc, highlights);
assertDescriptionMatches(relFilePath, annotatedSource, false, ".semantic");
}
};
if (classPathsForTest == null || classPathsForTest.isEmpty()) {
ParserManager.parse(Collections.singleton(testSource), task);
} else {
Future<Void> future = ParserManager.parseWhenScanFinished(Collections.singleton(testSource), task);
if (!future.isDone()) {
future.get();
}
}
}
示例12: runWith
import org.netbeans.modules.parsing.spi.Parser; //导入方法依赖的package包/类
private synchronized void runWith(final Updater u, final Parser.Result r, final Document doc) {
if (doc == null) {
return;
}
assert this.updater == null;
try {
this.updater = u;
if (!processResult(r)) {
return;
}
final List<FoldManager> fms = fileData.getManagers();
final int[] carets = new int[fms.size()];
SwingUtilities.invokeLater(new Runnable() {
public void run() {
// do not use isCancelled, updater is going to be cleared.
if (fileData.getStamp() != u.initialStamp) {
return;
}
int index = -1;
for (FoldManager fm : fms) {
index++;
FoldOperation op = getFoldOperation(fm);
if (op == null) {
continue;
}
carets[index] = getCaretPos(op.getHierarchy());
}
u.setManagersAndCarets(fms, carets);
// todo: offload into a RP -- document lock from AWT ?
doc.render(u);
}
});
} catch (Stop stop) {
// OK, wait for the next round
} finally {
this.updater = null;
}
}
示例13: getResult
import org.netbeans.modules.parsing.spi.Parser; //导入方法依赖的package包/类
@Override
public Parser.Result getResult(Task task) throws ParseException {
return result;
}
示例14: get
import org.netbeans.modules.parsing.spi.Parser; //导入方法依赖的package包/类
/**
* Returns an instance of the {@link CompilationController} for
* given {@link Parser.Result} if it is a result
* of a java parser.
* @param result for which the {@link CompilationController} should be
* returned.
* @return a {@link CompilationController} or null when the given result
* is not a result of java parsing.
* @since 0.42
*/
public static @NullUnknown CompilationController get (final @NonNull Parser.Result result) {
Parameters.notNull("result", result); //NOI18N
CompilationController info = null;
if (result instanceof JavacParserResult) {
final JavacParserResult javacResult = (JavacParserResult)result;
info = javacResult.get(CompilationController.class);
}
return info;
}
示例15: resolve
import org.netbeans.modules.parsing.spi.Parser; //导入方法依赖的package包/类
/**
* Resolve the handle to an instance of {@link Node} from
* the given {@link Parser.Result}.
*
* @param result
* @return instance of {@link Node} or null if the source handle cannot be resolved.
*/
public Node resolve(Parser.Result result);