本文整理汇总了Java中org.eclipse.jface.text.rules.RuleBasedPartitionScanner类的典型用法代码示例。如果您正苦于以下问题:Java RuleBasedPartitionScanner类的具体用法?Java RuleBasedPartitionScanner怎么用?Java RuleBasedPartitionScanner使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
RuleBasedPartitionScanner类属于org.eclipse.jface.text.rules包,在下文中一共展示了RuleBasedPartitionScanner类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createRecipePartitioner
import org.eclipse.jface.text.rules.RuleBasedPartitionScanner; //导入依赖的package包/类
IDocumentPartitioner createRecipePartitioner() {
IPredicateRule[] rules = {
new SingleLineRule("--", null, new Token(SQL_SINGLE_COMMENT), (char) 0, true, false), //$NON-NLS-1$
new MultiLineRule("/*", "*/", new Token(SQL_MULTI_COMMENT), (char) 0, true), //$NON-NLS-1$ //$NON-NLS-2$
new MultiLineRule( "'", "'", new Token(SQL_CHARACTER_STRING_LITERAL), (char) 0 , true) //$NON-NLS-1$ //$NON-NLS-2$
};
RuleBasedPartitionScanner scanner = new RuleBasedPartitionScanner();
scanner.setPredicateRules(rules);
return new FastPartitioner(scanner, CONTENT_TYPES);
}
示例2: createKspPartitionScanner
import org.eclipse.jface.text.rules.RuleBasedPartitionScanner; //导入依赖的package包/类
private IPartitionTokenScanner createKspPartitionScanner() {
RuleBasedPartitionScanner scanner = new RuleBasedPartitionScanner();
scanner.setPredicateRules(new IPredicateRule[] {
/* String entre double quote. */
new PatternRule("\"", "\"", new Token(KspRegionType.STRING.getContentType()), '\\', false),
/* Commentaire multi-lignes */
new PatternRule("/*", "*/", new Token(KspRegionType.COMMENT.getContentType()), '\\', false),
/* Commentaire fin de ligne */
new EndOfLineRule("//", new Token(KspRegionType.COMMENT.getContentType())) });
return scanner;
}
示例3: createConnectPartitioner
import org.eclipse.jface.text.rules.RuleBasedPartitionScanner; //导入依赖的package包/类
private IDocumentPartitioner createConnectPartitioner(IDocument document,
IPredicateRule[] rules, String[] types) {
RuleBasedPartitionScanner scanner = new RuleBasedPartitionScanner();
scanner.setPredicateRules(rules);
IDocumentPartitioner partitioner = new FastPartitioner(scanner, types);
partitioner.connect(document);
return partitioner;
}
示例4: setupDocument
import org.eclipse.jface.text.rules.RuleBasedPartitionScanner; //导入依赖的package包/类
public String setupDocument(Document document) {
IPartitionTokenScanner scanner = new RuleBasedPartitionScanner();
FastPartitioner partitioner = new FastPartitioner(scanner, new String[] { IDocument.DEFAULT_CONTENT_TYPE });
String[] managingPositionCategories = partitioner.getManagingPositionCategories();
String category = managingPositionCategories[0];
document.setDocumentPartitioner(partitioner);
document.addPositionCategory(category);
return category;
}
示例5: getKeyRegion
import org.eclipse.jface.text.rules.RuleBasedPartitionScanner; //导入依赖的package包/类
public IRegion getKeyRegion(IDocument document, final String searchKey) {
IPredicateRule[] rules = new IPredicateRule[4];
rules[0] = new EndOfLineRule("#", Token.UNDEFINED);
rules[1] = new EndOfLineRule("!", Token.UNDEFINED);
rules[2] = new WordPatternRule(new PropertyKeyDetector(), "\n", "=",
KEY_TOKEN);
rules[3] = new WordPatternRule(new PropertyKeyDetector(), "\n", ":",
KEY_TOKEN);
RuleBasedPartitionScanner scanner = new RuleBasedPartitionScanner();
scanner.setPredicateRules(rules);
IDocumentPartitioner partitioner = new FastPartitioner(scanner,
new String[] { KEY });
IRegion region = null;
try {
partitioner.connect(document);
ITypedRegion[] tagRegions = partitioner.computePartitioning(0,
document.getLength());
boolean firstRegion = true;
for (ITypedRegion tagRegion : tagRegions) {
if (KEY.equals(tagRegion.getType()) || firstRegion) {
String key = null;
try {
// -1 remove =
key = document.get(tagRegion.getOffset(),
tagRegion.getLength() - 1);
key = key.trim();
} catch (BadLocationException e) {
e.printStackTrace();
}
// first line isn't caught by the key_token rule
if (firstRegion && key != null) {
int indx = key.indexOf('=');
if (indx != -1) {
key = key.substring(0, indx).trim();
}
}
if (key != null) {
key = key.replace("\\ ", " ");
if (key.equals(searchKey)) {
region = tagRegion;
break;
}
}
}
firstRegion = false;
}
} finally {
if (partitioner != null) {
partitioner.disconnect();
}
}
return region;
}