本文整理汇总了Java中org.netbeans.modules.parsing.spi.ParserFactory类的典型用法代码示例。如果您正苦于以下问题:Java ParserFactory类的具体用法?Java ParserFactory怎么用?Java ParserFactory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ParserFactory类属于org.netbeans.modules.parsing.spi包,在下文中一共展示了ParserFactory类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: run
import org.netbeans.modules.parsing.spi.ParserFactory; //导入依赖的package包/类
public Void run () throws Exception {
final LowMemoryWatcher lMListener = LowMemoryWatcher.getInstance();
Parser parser = null;
final Collection<Snapshot> snapShots = new LazySnapshots(sources);
for (Source source : sources) {
if (parser == null) {
Lookup lookup = MimeLookup.getLookup (source.getMimeType ());
ParserFactory parserFactory = lookup.lookup (ParserFactory.class);
if (parserFactory != null) {
parser = parserFactory.createParser (snapShots);
}
}
final SourceCache uncachedSourceCache = new SourceCache(source, null, parser);
SourceCache origCache = SourceAccessor.getINSTANCE().getAndSetCache(source, uncachedSourceCache);
final ResultIterator resultIterator = new ResultIterator (uncachedSourceCache, parser, userTask);
try {
TaskProcessor.callUserTask(userTask, resultIterator);
} finally {
ResultIteratorAccessor.getINSTANCE().invalidate(resultIterator);
SourceAccessor.getINSTANCE().getAndSetCache(source, origCache);
}
if (lMListener.isLowMemory ())
parser = null;
}
return null;
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:27,代码来源:ParserManager.java
示例2: getParser
import org.netbeans.modules.parsing.spi.ParserFactory; //导入依赖的package包/类
/** Return a parser for use with this language. A parser is optional (in which
* case getParser() may return null) but in that case a lot of functionality
* will be disabled for this language.
* @todo Clarify whether clients should cache instances of this or if it will
* be called only once and management done by the IDE
*/
@CheckForNull
public Parser getParser(Collection<Snapshot> snapshots) {
Parser parser = null;
if (parserFile != null) {
// Lazily construct Parser
ParserFactory factory = (ParserFactory)createInstance(parserFile);
if (factory == null) {
// Don't keep trying
parserFile = null;
} else {
parser = factory.createParser(snapshots);
}
} else {
getGsfLanguage(); // Also initializes languageConfig
if (languageConfig != null) {
parser = languageConfig.getParser();
}
}
return parser;
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:29,代码来源:Language.java
示例3: findMimeParser
import org.netbeans.modules.parsing.spi.ParserFactory; //导入依赖的package包/类
public Parser findMimeParser(Lookup context, final String mimeType) {
Parser p = null;
final Reference<Parser> ref = cachedParsers.get (mimeType);
if (ref != null) {
p = ref.get();
}
if (p == null) {
final Lookup lookup = MimeLookup.getLookup (mimeType);
final ParserFactory parserFactory = lookup.lookup (ParserFactory.class);
if (parserFactory == null) {
throw new IllegalArgumentException("No parser for mime type: " + mimeType);
}
p = parserFactory.createParser(Collections.<Snapshot>emptyList());
cachedParsers.put(mimeType, new SoftReference<Parser>(p));
}
return p;
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:18,代码来源:DataObjectEnvFactory.java
示例4: findMimeParser
import org.netbeans.modules.parsing.spi.ParserFactory; //导入依赖的package包/类
@Override
public synchronized Parser findMimeParser(Lookup context, String mimeType) {
Reference<Parser> rp = cachedParsers.get(mimeType);
Parser p = null;
if (rp != null) {
p = rp.get();
}
if (p != null) {
return p;
}
ParserFactory f = MimeLookup.getLookup(mimeType).lookup(ParserFactory.class);
if (f != null) {
p = f.createParser(Collections.<Snapshot>emptyList());
} else {
p = MimeLookup.getDefault().lookup(ParserFactory.class).createParser(Collections.<Snapshot>emptyList());
}
cachedParsers.put(mimeType, new WeakReference<>(p));
return p;
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:20,代码来源:TestEnvironmentFactory.java
示例5: registerParser
import org.netbeans.modules.parsing.spi.ParserFactory; //导入依赖的package包/类
private static void registerParser(LayerBuilder b, String mimeType) {
instanceFile(b, "Editors/" + mimeType, null, GsfParserFactory.class, "create", ParserFactory.class).write(); //NOI18N
// // Parser factory
// item = createFile(doc, mimeFolder, "org-netbeans-modules-csl-core-GsfParserFactory.instance"); // NOI18N
// setFileAttribute(doc, item, "instanceCreate", METHODVALUE, "org.netbeans.modules.csl.core.GsfParserFactory.create"); //NOI18N
// setFileAttribute(doc, item, "instanceOf", STRINGVALUE, "org.netbeans.modules.parsing.spi.ParserFactory"); //NOI18N
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:9,代码来源:LanguageRegistrationProcessor.java
示例6: getParser
import org.netbeans.modules.parsing.spi.ParserFactory; //导入依赖的package包/类
public Parser getParser () {
synchronized (TaskProcessor.INTERNAL_LOCK) {
if (parserInitialized) {
return parser;
}
}
Parser _parser = null;
Lookup lookup = MimeLookup.getLookup (mimeType);
ParserFactory parserFactory = lookup.lookup (ParserFactory.class);
if (parserFactory != null) {
final Snapshot _snapshot = getSnapshot ();
final Collection<Snapshot> _tmp = Collections.singleton (_snapshot);
_parser = parserFactory.createParser (_tmp);
if (_parser == null) {
LOG.log(
Level.INFO,
"Parser factory: {0} returned null parser for {1}", //NOI18N
new Object[]{
parserFactory,
_snapshot
});
}
}
synchronized (TaskProcessor.INTERNAL_LOCK) {
if (!parserInitialized) {
parser = _parser;
if (parser != null) {
parser.addChangeListener(WeakListeners.change(
SourceAccessor.getINSTANCE().getParserEventForward(source),
parser));
}
parserInitialized = true;
}
return parser;
}
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:38,代码来源:SourceCache.java
示例7: getDefault
import org.netbeans.modules.parsing.spi.ParserFactory; //导入依赖的package包/类
public static JavacParserFactory getDefault () {
final Lookup lookup = MimeLookup.getLookup (JavacParser.MIME_TYPE);
return (JavacParserFactory)lookup.lookup (ParserFactory.class);
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:5,代码来源:JavacParserFactory.java
示例8: create
import org.netbeans.modules.parsing.spi.ParserFactory; //导入依赖的package包/类
public static ParserFactory create(FileObject f) {
String mimeType = f.getParent().getPath().substring("Editors/".length()); //NOI18N
return new GsfParserFactory(mimeType);
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:5,代码来源:GsfParserFactory.java
示例9: getDefault
import org.netbeans.modules.parsing.spi.ParserFactory; //导入依赖的package包/类
public static synchronized ParserFactory getDefault() {
if(INSTANCE == null) {
INSTANCE = new CssParserFactory();
}
return INSTANCE;
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:7,代码来源:CssParserFactory.java
示例10: findMimeParser
import org.netbeans.modules.parsing.spi.ParserFactory; //导入依赖的package包/类
@Override
public Parser findMimeParser(Lookup context, String mimeType) {
return MimeLookup.getLookup(mimeType).lookup(ParserFactory.class).createParser(Collections.<Snapshot>emptySet());
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:5,代码来源:TestEnvironmentFactory.java
注:本文中的org.netbeans.modules.parsing.spi.ParserFactory类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论