• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java Source类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: shouldCall

import org.netbeans.modules.parsing.api.Source; //导入依赖的package包/类
private static boolean shouldCall (
    @NonNull final Source source,
    @NullAllowed final SchedulerTask task,
    final boolean checkScan) {
    final boolean sourceInvalid = SourceAccessor.getINSTANCE().testFlag(
        source,
        SourceFlags.INVALID);
    boolean scanAffinity = true;
    if (checkScan) {
        final boolean scanInProgress = getIndexerBridge().isIndexing();
        final boolean canRunDuringScan = (task instanceof IndexingAwareParserResultTask)
            && ((IndexingAwareParserResultTask)task).getIndexingMode() == TaskIndexingMode.ALLOWED_DURING_SCAN;
        final boolean compatMode = "true".equals(System.getProperty(COMPAT_MODE));  //NOI18N
        scanAffinity = !scanInProgress || canRunDuringScan || compatMode;
    }
    final boolean taskCancelled = currentRequest.isCancelled(task);
    return !sourceInvalid && scanAffinity && !taskCancelled;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:19,代码来源:TaskProcessor.java


示例2: performEmbeddingTest

import org.netbeans.modules.parsing.api.Source; //导入依赖的package包/类
private void performEmbeddingTest(String code, String... golden) throws Exception {
    prepareTest(code, -1);

    Source s = Source.create(doc);
    final List<String> output = new LinkedList<String>();

    ParserManager.parse(Collections.singletonList(s), new UserTask() {
        @Override
        public void run(ResultIterator resultIterator) throws Exception {
            for (Embedding e : new EmbeddingProviderImpl().getEmbeddings(resultIterator.getSnapshot())) {
                output.add(e.getSnapshot().getText().toString());
            }
        }
    });

    Iterator<String> goldenIt = Arrays.asList(golden).iterator();
    Iterator<String> outputIt = output.iterator();

    while (goldenIt.hasNext() && outputIt.hasNext()) {
        assertEquals(goldenIt.next().replaceAll("[ \t\n]+", " "), outputIt.next().replaceAll("[ \t\n]+", " "));
    }

    assertEquals(output.toString(), goldenIt.hasNext(), outputIt.hasNext());
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:25,代码来源:EmbeddingProviderImplTest.java


示例3: createContent

import org.netbeans.modules.parsing.api.Source; //导入依赖的package包/类
@Override
@NonNull
protected final CharSequence createContent() throws IOException {
    final FileObject file = getHandle().resolveFileObject(false);
    if (file == null) {
        throw new FileNotFoundException("Cannot open file: " + toString());
    }
    final Source source = Source.create(file);
    if (source == null) {
        throw new IOException("No source for: " + FileUtil.getFileDisplayName(file));   //NOI18N
    }
    CharSequence content = source.createSnapshot().getText();
    if (hasFilter && source.getDocument(false) == null) {
        content = filter(content);
    }
    return content;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:18,代码来源:BasicSourceFileObject.java


示例4: setEditor

import org.netbeans.modules.parsing.api.Source; //导入依赖的package包/类
protected void setEditor (JTextComponent editor) {
    if (currentEditor != null)
        currentEditor.removeCaretListener (caretListener);
    currentEditor = editor;
    if (editor != null) {
        if (caretListener == null)
            caretListener = new ACaretListener ();
        editor.addCaretListener (caretListener);
        Document document = editor.getDocument ();
        if (currentDocument == document) return;
        currentDocument = document;
        final Source source = Source.create (currentDocument);
        schedule (source, new CursorMovedSchedulerEvent (this, editor.getCaret ().getDot (), editor.getCaret ().getMark ()) {});
    }
    else {
        currentDocument = null;
        schedule(null, null);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:20,代码来源:CursorSensitiveScheduler.java


示例5: create

import org.netbeans.modules.parsing.api.Source; //导入依赖的package包/类
/**
 * Create a names translator.
 * @param smt translator handling the source maps.
 * @param fileObject the generated source file
 * @param lineNumber line number of the position at which we translate the names
 * @param columnNumber column number of the position at which we translate the names
 * @return an instance of names translator, or <code>null</code> when the corresponding source can not be loaded.
 */
public static NamesTranslator create(SourceMapsTranslator smt, FileObject fileObject,
                                     int lineNumber, int columnNumber) {
    if (!USE_SOURCE_MAPS) {
        return null;
    }
    Source source = Source.create(fileObject);
    if (source == null) {
        return null;
    }
    Document doc = source.getDocument(true);
    if (doc == null) {
        return null;
    }
    // Check lineNumber:
    
    try {
        int lastLine = LineDocumentUtils.getLineIndex((LineDocument) doc, doc.getLength()-1);
        if (lineNumber > lastLine) {
            lineNumber = lastLine;
        }
    } catch (BadLocationException blex) {}
    int offset = LineDocumentUtils.getLineStartFromIndex((LineDocument) doc, lineNumber) + columnNumber;

    return new NamesTranslator(smt, fileObject, source, offset);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:34,代码来源:NamesTranslator.java


示例6: updateHints

import org.netbeans.modules.parsing.api.Source; //导入依赖的package包/类
/** Regenerate hints for the current file, if you change settings */
private void updateHints() {
    JTextComponent pane = EditorRegistry.lastFocusedComponent();
    if (pane != null) {
        Document doc = pane.getDocument();
        final Source source = Source.create(doc);
        // see issue #212967; non-file Source appears for some reason.
        if (source != null && source.getFileObject() != null) {
            RequestProcessor.getDefault().post(new Runnable() {
                public void run() {
                    try {
                        ParserManager.parse(Collections.singleton(source), new UserTask() {
                            public @Override void run(ResultIterator resultIterator) throws Exception {
                                GsfHintsManager.refreshHints(resultIterator);
                            }
                        });
                    } catch (ParseException ex) {
                        LOG.log(Level.WARNING, null, ex);
                    }
                }
            });
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:25,代码来源:HintsPanelLogic.java


示例7: getModel

import org.netbeans.modules.parsing.api.Source; //导入依赖的package包/类
/**
 * Will run parsing task!.
 *
 * @param file
 * @return
 */
public static CPModel getModel(FileObject file) throws ParseException {
    final AtomicReference<CPModel> model_ref = new AtomicReference<>();
    Source source = Source.create(file);
    ParserManager.parse(Collections.singleton(source), new UserTask() {
        @Override
        public void run(ResultIterator resultIterator) throws Exception {
            ResultIterator cssRI = WebUtils.getResultIterator(resultIterator, "text/css");
            if (cssRI != null) {
                CssParserResult result = (CssParserResult) cssRI.getParserResult();
                if (result != null) {
                    model_ref.set(CPModel.getModel(result));
                }
            }
        }
    });

    return model_ref.get();
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:25,代码来源:CPModel.java


示例8: holdsDocumentWriteLock

import org.netbeans.modules.parsing.api.Source; //导入依赖的package包/类
/**
 * Checks if the current thread holds a document write lock on some of given files
 * Slow should be used only in assertions
 * @param files to be checked
 * @return true when the current thread holds a edeitor write lock on some of given files
 */
private static boolean holdsDocumentWriteLock (final Iterable<Source> sources) {
    assert sources != null;
    final Class<AbstractDocument> docClass = AbstractDocument.class;
    try {
        final Method method = docClass.getDeclaredMethod("getCurrentWriter"); //NOI18N
        method.setAccessible(true);
        final Thread currentThread = Thread.currentThread();
        for (Source source : sources) {
            try {
                Document doc = source.getDocument (true);
                if (doc instanceof AbstractDocument) {
                    Object result = method.invoke(doc);
                    if (result == currentThread) {
                        return true;
                    }
                }
            } catch (Exception e) {
                Exceptions.printStackTrace(e);
            }            
        }
    } catch (NoSuchMethodException e) {
        Exceptions.printStackTrace(e);
    }
    return false;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:32,代码来源:TaskProcessor.java


示例9: testEmbeddedCSSSections

import org.netbeans.modules.parsing.api.Source; //导入依赖的package包/类
public void testEmbeddedCSSSections() throws Exception {
    Document doc = getDocument(getTestFile("testfiles/model/test3.html"));
    Source source = Source.create(doc);
    HtmlFileModel model = new HtmlFileModel(source);

    List<OffsetRange> entries = model.getEmbeddedCssSections();
    assertEquals(2, entries.size());
    OffsetRange entry = entries.get(0);
    
    //first section
    assertNotNull(entry);
    assertEquals(221, entry.getStart());
    assertEquals(295, entry.getEnd());

    //second section
    entry = entries.get(1);
    assertNotNull(entry);
    assertEquals(335, entry.getStart());
    assertEquals(411, entry.getEnd());
    
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:22,代码来源:HtmlFileModelTest.java


示例10: checkOffsets

import org.netbeans.modules.parsing.api.Source; //导入依赖的package包/类
protected void checkOffsets(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);
    }

    ParserManager.parse(Collections.singleton(testSource), new UserTask() {
        public @Override void run(ResultIterator resultIterator) throws Exception {
            Parser.Result r = resultIterator.getParserResult();
            assertTrue(r instanceof ParserResult);
            ParserResult pr = (ParserResult) r;

            List<Object> validNodes = new ArrayList<Object>();
            List<Object> invalidNodes = new ArrayList<Object>();
            Map<Object,OffsetRange> positions = new HashMap<Object,OffsetRange>();
            initializeNodes(pr, validNodes, positions, invalidNodes);

            String annotatedSource = annotateOffsets(validNodes, positions, invalidNodes, pr);
            assertDescriptionMatches(relFilePath, annotatedSource, false, ".offsets");
        }
    });
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:25,代码来源:CslTestBase.java


示例11: query

import org.netbeans.modules.parsing.api.Source; //导入依赖的package包/类
@Override
public void query(CompletionResultSet resultSet, Document doc, int caretOffset) {
    try {
        ClasspathInfo cpInfo = ClasspathInfo.create(doc);
        ParserManager.parse(Collections.singleton(Source.create(doc)), 
                createTask(cpInfo, 
                    component, 
                    resultSet, 
                    doc, caretOffset, queryType)
        );
        resultSet.setHasAdditionalItems(additionalItems);
        resultSet.addAllItems(items);
        resultSet.finish();
    } catch (ParseException ex) {
        Exceptions.printStackTrace(ex);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:18,代码来源:FXMLCompletion2.java


示例12: findBuilderClass

import org.netbeans.modules.parsing.api.Source; //导入依赖的package包/类
@Override
public String findBuilderClass(CompilationInfo cinfo, Source source, String beanClassName) {
    TypeElement classElement = cinfo.getElements().getTypeElement(beanClassName);
    if (classElement == null) {
        return null;
    }
    StringBuilder sb = new StringBuilder(((PackageElement)classElement.getEnclosingElement()).getQualifiedName().toString());
    if (sb.length() > 0) {
        sb.append("."); // NOI18N
    }
    sb.append(classElement.getSimpleName().toString()).append("Builder"); // NOI18N
    
    TypeElement builderEl = cinfo.getElements().getTypeElement(sb.toString());
    return builderEl != null ?
            sb.toString() :
            null;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:18,代码来源:SimpleBuilderResolver.java


示例13: testParserInvocation

import org.netbeans.modules.parsing.api.Source; //导入依赖的package包/类
public void testParserInvocation() throws Exception {
    Source fxmlSource = Source.create(document);
    
    ParserManager.parse(Collections.singleton(fxmlSource), new UserTask() {
        @Override
        public void run(ResultIterator resultIterator) throws Exception {
            Parser.Result result = resultIterator.getParserResult();
            
            if (result instanceof FxmlParserResult) {
                FxmlParserResult fxResult = (FxmlParserResult)result;
                appendParsedTree(fxResult, report);
                appendErrors(fxResult, report);
                assertContents(report);
            }
        }
    });
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:18,代码来源:FxmlParserTest.java


示例14: updatePhaseCompletionTask

import org.netbeans.modules.parsing.api.Source; //导入依赖的package包/类
public static void updatePhaseCompletionTask (
        final @NonNull Collection<Pair<SchedulerTask,Class<? extends Scheduler>>> add,
        final @NonNull Collection<SchedulerTask> remove,
        final @NonNull Source source,
        final @NonNull SourceCache cache) {
    Parameters.notNull("add", add);
    Parameters.notNull("remove", remove);
    Parameters.notNull("source", source);
    Parameters.notNull("cache", cache);
    if (add.isEmpty() && remove.isEmpty()) {
        return;
    }
    final Collection<? extends Request> rqs = toRequests(add, cache, false);
    synchronized (INTERNAL_LOCK) {
        removePhaseCompletionTasks(remove, source);
        handleAddRequests (source, rqs);
    }
    cancelLowPriorityTask(rqs);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:20,代码来源:TaskProcessor.java


示例15: createSourceElementHandle

import org.netbeans.modules.parsing.api.Source; //导入依赖的package包/类
/**
 * Resolves the {@link FileObject} and source element path to a parser
 * result and {@link OpenTag}.
 *
 * The returned value is not cached and will run a parsing api task each
 * time is called.
 *
 * @return An instance of {@link  SourceElementHandle}
 * exception is thrown.
 * @throws ParseException
 */
public SourceElementHandle createSourceElementHandle() throws ParseException {
    final AtomicReference<SourceElementHandle> seh_ref = new AtomicReference<>();
    Source source = Source.create(file);
    ParserManager.parse(Collections.singleton(source), new UserTask() {
        @Override
        public void run(ResultIterator resultIterator) throws Exception {
            ResultIterator ri = WebUtils.getResultIterator(resultIterator, "text/html");
            if (ri == null) {
                return;
            }

            HtmlParserResult result = (HtmlParserResult) ri.getParserResult();
            Snapshot snapshot = result.getSnapshot();

            Node root = result.root();
            OpenTag openTag = ElementUtils.query(root, elementPath);

            seh_ref.set(new SourceElementHandle(openTag, snapshot, file));

        }
    });
    return seh_ref.get();
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:35,代码来源:AbstractSourceElementAction.java


示例16: testXhtmlFile1

import org.netbeans.modules.parsing.api.Source; //导入依赖的package包/类
public void testXhtmlFile1() throws SAXException {
    FileObject fo = getTestFile("testfiles/test1.xhtml");
    Source source = Source.create(fo);
    String code = source.createSnapshot().getText().toString();
    SyntaxAnalyzerResult result = SyntaxAnalyzer.create(new HtmlSource(fo)).analyze();
    assertNotNull(result);

    HtmlVersion version = result.getHtmlVersion();
    assertSame(HtmlVersion.XHTML10_STICT, version);

    NbValidationTransaction vt = NbValidationTransaction.create(result.getHtmlVersion());
    validate(code, true, result.getHtmlVersion(), vt);

    assertSame(ParserMode.XML_NO_EXTERNAL_ENTITIES, vt.parser);
    assertNotNull(vt.xmlParser);
    assertNull(vt.htmlParser);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:18,代码来源:ValidationTransactionTest.java


示例17: testXhtmlFile2

import org.netbeans.modules.parsing.api.Source; //导入依赖的package包/类
public void testXhtmlFile2() throws SAXException {
    FileObject fo = getTestFile("testfiles/test2.xhtml");
    Source source = Source.create(fo);
    String code = source.createSnapshot().getText().toString();
    SyntaxAnalyzerResult result = SyntaxAnalyzer.create(new HtmlSource(fo)).analyze();
    assertNotNull(result);

    assertNull(result.getDetectedHtmlVersion());
    HtmlVersion version = result.getHtmlVersion();
    assertSame(HtmlVersion.XHTML5, version);

    NbValidationTransaction vt = NbValidationTransaction.create(result.getHtmlVersion());
    validate(code, true, result.getHtmlVersion(), vt);

    assertSame(ParserMode.XML_NO_EXTERNAL_ENTITIES, vt.parser);
    assertNotNull(vt.xmlParser);
    assertNull(vt.htmlParser);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:19,代码来源:ValidationTransactionTest.java


示例18: Rewriter

import org.netbeans.modules.parsing.api.Source; //导入依赖的package包/类
public Rewriter(FileObject fo, PositionConverter converter, Map<Integer, String> userInfo, Source src) throws IOException {
    this.src = src;
    this.converter = converter;
    this.userInfo = userInfo;
    if (fo != null) {
        prp = PositionRefProvider.get(fo);
    }
    if (prp == null)
        throw new IOException("Could not find CloneableEditorSupport for " + FileUtil.getFileDisplayName (fo)); //NOI18N
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:11,代码来源:DiffUtilities.java


示例19: isDirty

import org.netbeans.modules.parsing.api.Source; //导入依赖的package包/类
@Override
protected final Long isDirty() {
    final FileObject file = getHandle().resolveFileObject(false);
    if (file == null) {
        return null;
    }
    final Source source = Source.create(file);
    if (source != null) {
        Document doc = source.getDocument(false);
        if (doc != null) {
            return DocumentUtilities.getDocumentTimestamp(doc);
        }
    }
    return null;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:16,代码来源:BasicSourceFileObject.java


示例20: propertyChange

import org.netbeans.modules.parsing.api.Source; //导入依赖的package包/类
@Override
public void propertyChange(PropertyChangeEvent evt) {
    if (DataObject.PROP_PRIMARY_FILE.equals(evt.getPropertyName())) {
        final DataObject dobj = (DataObject) evt.getSource();
        final Source newSource = Source.create(dobj.getPrimaryFile());
        if (newSource != null) {
            LOGGER.log(
                Level.FINE,
                "Rescheduling {0} due to change of primary file.",  //NOI18N
                dobj.getPrimaryFile());
            
            control.sourceChanged(newSource);
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:16,代码来源:EventSupport.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java InBandBytestreamManager类代码示例发布时间:2022-05-22
下一篇:
Java CopyProvider类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap