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


Java Parser.Result方法代码示例

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

    
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:23,代码来源:QuerySupportLifeLock230220Test.java

示例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);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:18,代码来源:EmbeddedIndexerTest.java

示例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();
        }
    };
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:27,代码来源:ResourceStringFoldProvider.java

示例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;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:22,代码来源:WorkingCopy.java

示例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;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:9,代码来源:EditorContextSupport.java

示例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];
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:30,代码来源:CslTestBase.java

示例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;
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:8,代码来源:FxmlParserResult.java

示例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;
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:15,代码来源:BaseTask.java

示例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;
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:34,代码来源:EmbeddedHintsCollector.java

示例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);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:10,代码来源:ParsingFoldSupport.java

示例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();
        }
    }

}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:43,代码来源:CslTestBase.java

示例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;
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:42,代码来源:ParsingFoldSupport.java

示例13: getResult

import org.netbeans.modules.parsing.spi.Parser; //导入方法依赖的package包/类
@Override
public Parser.Result getResult(Task task) throws ParseException {
    return result;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:5,代码来源:EmptyParser.java

示例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;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:20,代码来源:CompilationController.java

示例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);
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:9,代码来源:SourceElementHandle.java


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