本文整理汇总了Java中org.netbeans.spi.editor.bracesmatching.BracesMatcherFactory类的典型用法代码示例。如果您正苦于以下问题:Java BracesMatcherFactory类的具体用法?Java BracesMatcherFactory怎么用?Java BracesMatcherFactory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
BracesMatcherFactory类属于org.netbeans.spi.editor.bracesmatching包,在下文中一共展示了BracesMatcherFactory类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: findFactories
import org.netbeans.spi.editor.bracesmatching.BracesMatcherFactory; //导入依赖的package包/类
private static Collection<? extends BracesMatcherFactory> findFactories(final Document document,
final int offset, final boolean backward
) {
final MimePath[] mimePath = { null };
document.render(new Runnable() {
public void run() {
TokenHierarchy<? extends Document> th = TokenHierarchy.get(document);
if (th.isActive()) {
List<TokenSequence<?>> sequences = th.embeddedTokenSequences(offset, backward);
if (!sequences.isEmpty()) {
String path = sequences.get(sequences.size() - 1).languagePath().mimePath();
mimePath[0] = MimePath.parse(path);
}
} else {
String mimeType = (String) document.getProperty("mimeType"); //NOI18N
mimePath[0] = mimeType != null ? MimePath.parse(mimeType) : MimePath.EMPTY;
}
}
});
Collection<? extends BracesMatcherFactory> factories = mimePath[0] == null ?
Collections.<BracesMatcherFactory>emptyList() :
MimeLookup.getLookup(mimePath[0]).lookupAll(BracesMatcherFactory.class);
// System.out.println("@@@ '" + (mimePath == null ? "null" : mimePath.getPath()) + "', offset = " + offset + ", backward = " + backward + " -> {");
// for(BracesMatcherFactory f : factories) {
// System.out.println("@@@ " + f);
// }
// System.out.println("@@@ } --------------");
return factories;
}
示例2: defaultMatcherFactory
import org.netbeans.spi.editor.bracesmatching.BracesMatcherFactory; //导入依赖的package包/类
private static BracesMatcherFactory defaultMatcherFactory() {
return new BracesMatcherFactory() {
public BracesMatcher createMatcher(MatcherContext context) {
return defaultMatcher(context, -1, -1);
}
};
}