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


Java Source.getFileObject方法代码示例

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


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

示例1: 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

示例2: activate

import org.netbeans.modules.parsing.api.Source; //导入方法依赖的package包/类
@Override
public void activate() {
    final Source source = getSourceControl().getSource();
    final FileObject fo = source.getFileObject();
    Document doc;
    if (fo != null) {
        try {
            listenOnFileChanges();
            listenOnParser();
            DataObject dObj = DataObject.find(fo);
            assignDocumentListener (dObj);
            dobjListener = new DataObjectListener(dObj);
        } catch (DataObjectNotFoundException e) {
            LOGGER.log(Level.WARNING, "Ignoring events non existent file: {0}", FileUtil.getFileDisplayName(fo));     //NOI18N
        }
    } else if ((doc=source.getDocument(false)) != null) {
        listenOnParser();
        docListener = new DocListener (doc);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:21,代码来源:EventSupport.java

示例3: toString

import org.netbeans.modules.parsing.api.Source; //导入方法依赖的package包/类
@Override
public String toString () {
    StringBuilder sb = new StringBuilder ("SourceCache ");
    sb.append (hashCode ());
    sb.append (": ");
    Snapshot _snapshot = getSnapshot ();
    Source _source = _snapshot.getSource ();
    FileObject fileObject = _source.getFileObject ();
    if (fileObject != null)
        sb.append (fileObject.getNameExt ());
    else
        sb.append (mimeType).append (" ").append (_source.getDocument (false));
    if (!_snapshot.getMimeType ().equals (_source.getMimeType ())) {
        sb.append ("( ").append (_snapshot.getMimeType ()).append (" ");
        sb.append (_snapshot.getOriginalOffset (0)).append ("-").append (_snapshot.getOriginalOffset (_snapshot.getText ().length () - 1)).append (")");
    }
    return sb.toString ();
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:19,代码来源:SourceCache.java

示例4: JavacParser

import org.netbeans.modules.parsing.api.Source; //导入方法依赖的package包/类
JavacParser (final Collection<Snapshot> snapshots, boolean privateParser) {
    this.privateParser = privateParser;
    this.sourceCount = snapshots.size();
    final boolean singleJavaFile = this.sourceCount == 1 && MIME_TYPE.equals(snapshots.iterator().next().getSource().getMimeType());
    this.supportsReparse = singleJavaFile && !DISABLE_PARTIAL_REPARSE;
    JavaFileFilterImplementation filter = null;
    if (singleJavaFile) {
        final Source source = snapshots.iterator().next().getSource();
        FileObject fo = source.getFileObject();
        if (fo != null) {
            //fileless Source -- ie. debugger watch CC etc
            filter = JavaFileFilterQuery.getFilter(fo);
        }
    }
    this.filterListener = filter != null ? new FilterListener (filter) : null;
    this.cpInfoListener = new ClasspathInfoListener (
        listeners,
        new Runnable() {
            @Override
            public void run() {
                if (sourceCount == 0) {
                    invalidate(true);
                }
            }
        });
    this.sequentialParsing = Lookup.getDefault().lookup(SequentialParsing.class);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:28,代码来源:JavacParser.java

示例5: findFor

import org.netbeans.modules.parsing.api.Source; //导入方法依赖的package包/类
public static CssProjectSupport findFor(Source source) {
FileObject fo = source.getFileObject();
if (fo == null) {
    return null;
} else {
    return findFor(fo);
}
   }
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:9,代码来源:CssProjectSupport.java

示例6: Model

import org.netbeans.modules.parsing.api.Source; //导入方法依赖的package包/类
Model(CssParserResult parserResult) {
    this(++globalModelSerialNumber);
    Node styleSheetNode = NodeUtil.query(parserResult.getParseTree(), NodeType.styleSheet.name());

    Collection<Object> lookupContent = new ArrayList<>();
    if (styleSheetNode == null) {
        //empty file
        lookupContent.add(getElementFactory().createStyleSheet());
    } else {
        lookupContent.add(styleSheetNode);
        lookupContent.add((StyleSheet) getElementFactoryImpl(this).createElement(this, styleSheetNode));
    }

    Snapshot snapshot = parserResult.getSnapshot();
    Source source = snapshot.getSource();
    FileObject file = source.getFileObject();
    Document doc = source.getDocument(true);

    lookupContent.add(parserResult);
    lookupContent.add(snapshot);
    lookupContent.add(snapshot.getText());
    if (file != null) {
        lookupContent.add(file);
        
        //Listen on the EditorCookie.Observable so we may re-new the document instance
        //if the original document was closed.
        //See issue http://netbeans.org/bugzilla/show_bug.cgi?id=219493 for more details
        try {
            dataObject = DataObject.find(file);
            editorCookie = dataObject.getLookup().lookup(EditorCookie.Observable.class);
            editorCookie.addPropertyChangeListener(WeakListeners.propertyChange(this, editorCookie));
        } catch (DataObjectNotFoundException ex) {
            Exceptions.printStackTrace(ex);
        }
    }
    
    documentLookup = new DocumentLookup();
    if (doc != null) {
        documentLookup.updateLookup(Lookups.fixed(doc));
    }

    MODEL_LOOKUP = new ProxyLookup(Lookups.fixed(lookupContent.toArray()), documentLookup);
    
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:45,代码来源:Model.java


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