本文整理汇总了Java中org.eclipse.jface.text.rules.SingleLineRule类的典型用法代码示例。如果您正苦于以下问题:Java SingleLineRule类的具体用法?Java SingleLineRule怎么用?Java SingleLineRule使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SingleLineRule类属于org.eclipse.jface.text.rules包,在下文中一共展示了SingleLineRule类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addGroovyRules
import org.eclipse.jface.text.rules.SingleLineRule; //导入依赖的package包/类
protected void addGroovyRules(List<IPredicateRule> rules) {
IToken groovyAnnotation = createToken(ANNOTATION);
IToken javaDocComment = createToken(GROOVY_DOC);
IToken groovyComment = createToken(COMMENT);
IToken groovySimpleString = createToken(STRING);
IToken groovyGString = createToken(GSTRING);
IToken groovyKeyWord = createToken(GROOVY_KEYWORD);
IToken javaKeyWord = createToken(JAVA_KEYWORD);
IToken javaLiteral = createToken(JAVA_LITERAL);
rules.add(new MultiLineRule("/**", "*/", javaDocComment));
rules.add(new MultiLineRule("/*", "*/", groovyComment));
rules.add(new SingleLineRule("//", "", groovyComment));
rules.add(new MultiLineRule("\"", "\"", groovyGString, '\\'));
rules.add(new MultiLineRule("\'", "\'", groovySimpleString, '\\'));
buildWordRules(rules, javaKeyWord, JavaKeyWords.values(), javaWordDetector);
buildWordRules(rules, javaLiteral, JavaLiteralKeyWords.values(), javaWordDetector);
buildWordRules(rules, groovyKeyWord, GroovyKeyWords.values(), javaWordDetector);
buildAnnotationRules(rules, groovyAnnotation, onlyAnnotationWordDetector);
}
示例2: EiffelPartitionScanner
import org.eclipse.jface.text.rules.SingleLineRule; //导入依赖的package包/类
public EiffelPartitionScanner() {
super();
IToken multilineComment = new Token(MULTILINE_COMMENT);
IToken singlelineComment = new Token(SINGLELINE_COMMENT);
IToken string = new Token(STRING);
List<Object> rules = new ArrayList<>();
//Add rule for single line comments.
rules.add(new EndOfLineRule("--", singlelineComment));
// Add rule for strings and character constants.
rules.add(new SingleLineRule("\"", "\"", string, '\\'));
rules.add(new SingleLineRule("'", "'", string, '\\'));
//Add rules for multi-line comments and eiffeldocs
rules.add(new MultiLineRule("--[[", "]]", multilineComment, (char) 0, true));
IPredicateRule[] result = new IPredicateRule[rules.size()];
rules.toArray(result);
setPredicateRules(result);
}
示例3: SqlCommentPartitionScanner
import org.eclipse.jface.text.rules.SingleLineRule; //导入依赖的package包/类
private SqlCommentPartitionScanner() {
IToken commentToken = new Token(SQL_COMMENT);
List<IPredicateRule> rules= new ArrayList<>();
rules.add(new EndOfLineRule("--", commentToken, '\\'));
rules.add(new MultiLineRule("/*", "*/", commentToken, '\\'));
rules.add(new WordPredicateRule(commentToken));
rules.add(new SingleLineRule("\"", "\"", Token.UNDEFINED, '\\'));
rules.add(new SingleLineRule("'", "'", Token.UNDEFINED, '\\'));
IPredicateRule[] result= new IPredicateRule[rules.size()];
rules.toArray(result);
setPredicateRules(result);
}
示例4: XMLTagScanner
import org.eclipse.jface.text.rules.SingleLineRule; //导入依赖的package包/类
public XMLTagScanner(ColorManager manager) {
IToken string = new Token(new TextAttribute(manager
.getColor(IXMLColorConstants.STRING)));
IToken attrValue = new Token(XML_ATTR_VALUE);
IRule[] rules = new IRule[3];
// Add rule for double quotes
rules[0] = new SingleLineRule("\"", "\"", string, '\\');
// Add a rule for single quotes
rules[1] = new SingleLineRule("'", "'", string, '\\');
// Add generic whitespace rule.
rules[2] = new WhitespaceRule(new NCLWhitespaceDetector());
setRules(rules);
}
示例5: createRules
import org.eclipse.jface.text.rules.SingleLineRule; //导入依赖的package包/类
@Override
protected List<IRule> createRules() {
IToken keywordToken = getToken(Prefs.EDITOR_HTML_KEYWORD_COLOR);
IToken symbolToken = getToken(Prefs.EDITOR_HTML_SYMBOL_COLOR);
IToken stringToken = getToken(Prefs.EDITOR_HTML_STRING_COLOR);
IToken defaultToken = getToken(Prefs.EDITOR_DEFAULT_COLOR);
WordRule wordRule = new WordRule(new HtmlWordDetector(), defaultToken, true);
for (String keyword : keywords) {
wordRule.addWord(keyword, keywordToken);
}
WordRule symbolRule = new WordRule(new HtmlSymbolDetector(), defaultToken, true);
for (String symbol : symbols) {
symbolRule.addWord(symbol, symbolToken);
}
List<IRule> rules = new ArrayList<IRule>();
rules.add(new SingleLineRule("\"", "\"", stringToken, '\\', true));
rules.add(new SingleLineRule("'", "'", stringToken, '\\', true));
rules.add(wordRule);
rules.add(symbolRule);
rules.add(new WhitespaceRule(new WhitespaceDetector()));
return rules;
}
示例6: createRules
import org.eclipse.jface.text.rules.SingleLineRule; //导入依赖的package包/类
@Override
protected List<IRule> createRules() {
List<IRule> rules = new ArrayList<IRule>();
Token tagBorder = getToken(IJSXColorConstants.TAG_BORDER);
Token tagName = getToken(IJSXColorConstants.TAG_NAME);
Token tagAttributeName = getToken(IJSXColorConstants.TAG_ATTRIBUTE_NAME);
Token tagAttributeEquals = getToken(IJSXColorConstants.TAG_ATTRIBUTE_EQUALS);
Token tagAttributeValue = getToken(IJSXColorConstants.TAG_ATTRIBUTE_VALUE);
rules.add(new SingleLineRule("\"", "\"", tagAttributeValue, '\\'));
rules.add(new SingleLineRule("'", "'", tagAttributeValue, '\\'));
rules.add(new SingleLineRule("{", "}", tagAttributeValue, '\\'));
rules.add(new JSXTagRule(tagName, tagBorder));
rules.add(new WordRule(new NameDetector(), tagAttributeName));
// setDefaultReturnToken(token);
return rules;
}
示例7: UmpleTagScanner
import org.eclipse.jface.text.rules.SingleLineRule; //导入依赖的package包/类
public UmpleTagScanner(ColorManager manager) {
IToken string =
new Token(
new TextAttribute(manager.getColor(IUmpleColorConstants.STRING)));
IRule[] rules = new IRule[3];
// Add rule for double quotes
rules[0] = new SingleLineRule("\"", "\"", string, '\\');
// Add a rule for single quotes
rules[1] = new SingleLineRule("'", "'", string, '\\');
// Add generic whitespace rule.
rules[2] = new WhitespaceRule(new UmpleWhitespaceDetector());
setRules(rules);
}
示例8: XMLTagScanner
import org.eclipse.jface.text.rules.SingleLineRule; //导入依赖的package包/类
public XMLTagScanner(ColorManager manager) {
IToken string =
new Token(
new TextAttribute(manager.getColor(ColorManager.COLOR_STRING)));
IRule[] rules = new IRule[3];
// Add rule for double quotes
rules[0] = new SingleLineRule("\"", "\"", string, '\\');
// Add a rule for single quotes
rules[1] = new SingleLineRule("'", "'", string, '\\');
// Add generic whitespace rule.
rules[2] = new WhitespaceRule(new WhitespaceDetector());
setRules(rules);
}
示例9: XMLTagScanner
import org.eclipse.jface.text.rules.SingleLineRule; //导入依赖的package包/类
public XMLTagScanner(ColorManager manager) {
IToken string =
new Token(
new TextAttribute(manager.getColor(IXMLColorConstants.STRING)));
IRule[] rules = new IRule[3];
// Add rule for double quotes
rules[0] = new SingleLineRule("\"", "\"", string, '\\');
// Add a rule for single quotes
rules[1] = new SingleLineRule("'", "'", string, '\\');
// Add generic whitespace rule.
rules[2] = new WhitespaceRule(new XMLWhitespaceDetector());
setRules(rules);
}
示例10: GlslPartitionScanner
import org.eclipse.jface.text.rules.SingleLineRule; //导入依赖的package包/类
public GlslPartitionScanner() {
IToken preprocessorToken = new Token(GLSL_PREPROCESSOR);
IToken uniformToken = new Token(GLSL_UNIFORM);
IToken variableToken = new Token(GLSL_VARIABLE);
IToken commentToken = new Token(GLSL_COMMENT);
setPredicateRules(new IPredicateRule[] {
new SingleLineRule("#", null, preprocessorToken, '\0', true, false),
new SingleLineRule("//", null, commentToken, '\0', true, false),
new SingleLineRule("/*", "*/", commentToken),
new DeclarationRule(uniformToken, new DeclarationSection[] {
new DeclarationSection(Glsl.QUALIFIERS),
new DeclarationSection(Glsl.TYPES)
}),
new DeclarationRule(variableToken, new DeclarationSection[] {
new DeclarationSection(Glsl.TYPES)
}),
});
}
示例11: createPreprocessorScanner
import org.eclipse.jface.text.rules.SingleLineRule; //导入依赖的package包/类
public static final RuleBasedScanner createPreprocessorScanner() {
final TextAttribute attribute = new TextAttribute(
Activator.getDefault().getColor(GlslEditor.PREPROCESSOR_COLOR), null, SWT.BOLD
);
final Token preprocessorToken = new Token(attribute);
IRule[] rules = new IRule[Glsl.PREPROCESSORS.length];
for (int i = 0; i < rules.length; i++) {
rules[i] = new SingleLineRule(Glsl.PREPROCESSORS[i], null, preprocessorToken, '\0',
true, false);
}
RuleBasedScanner scanner = new RuleBasedScanner();
scanner.setRules(rules);
return scanner;
}
示例12: JSDocScanner
import org.eclipse.jface.text.rules.SingleLineRule; //导入依赖的package包/类
/**
* Create a new javadoc scanner for the given color provider.
*/
public JSDocScanner()
{
super();
List<IRule> list = new ArrayList<IRule>();
// Add rule for tags.
list.add(new SingleLineRule("<", ">", getToken("text.html.basic"))); //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-1$
// Add rule for links.
list.add(new SingleLineRule("{", "}", getToken("markup.underline.link"))); //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-1$
// Add word rule for keywords.
IToken keyword = getToken("meta.tag.documentation.js"); //$NON-NLS-1$
WordRule wordRule = new WordRule(new JSDocWordDetector());
for (String word : KEYWORDS)
{
wordRule.addWord(word, keyword);
}
list.add(wordRule);
setDefaultReturnToken(getToken("comment.block.documentation.js")); //$NON-NLS-1$
setRules(list.toArray(new IRule[list.size()]));
}
示例13: createAttrPartitioner
import org.eclipse.jface.text.rules.SingleLineRule; //导入依赖的package包/类
private IDocumentPartitioner createAttrPartitioner(IDocument document,
String[] attrs) {
IPredicateRule[] attrRules = new IPredicateRule[attrs.length + 2];
attrRules[0] = new SingleLineRule("\"", "\"", new Token(
DOUBLE_QUOTES_TOKEN));
attrRules[1] = new SingleLineRule("'", "'", new Token(
SINGLE_QUOTES_TOKEN));
String[] types = new String[attrs.length + 2];
types[0] = DOUBLE_QUOTES_TOKEN;
types[1] = SINGLE_QUOTES_TOKEN;
for (int i = 0; i < attrs.length; i++) {
attrRules[i + 2] = new WordPatternRule(new AttributeDetector(),
attrs[i], "=", new Token(attrs[i]));
types[i + 2] = attrs[i];
}
return createConnectPartitioner(document, attrRules, types);
}
示例14: createRules
import org.eclipse.jface.text.rules.SingleLineRule; //导入依赖的package包/类
/**
* Creates the list of <code>IRule</code>.
* If you have to customize rules, override this method.
*
* @return the list of <code>IRule</code>
*/
protected List<IRule> createRules() {
IToken normal = new Token(new TextAttribute(new Color(Display.getCurrent(),
IHTMLColorConstants.FOREGROUND)));
IToken string = new Token(new TextAttribute(new Color(Display.getCurrent(),
IHTMLColorConstants.JAVA_STRING)));
IToken comment = new Token(new TextAttribute(new Color(Display.getCurrent(),
IHTMLColorConstants.JAVA_COMMENT)));
IToken keyword = new Token(new TextAttribute(new Color(Display.getCurrent(),
IHTMLColorConstants.JAVA_KEYWORD)));
List<IRule> rules = new ArrayList<IRule>();
rules.add(new SingleLineRule("\"", "\"", string, '\\'));
rules.add(new SingleLineRule("'", "'", string, '\\'));
rules.add(new SingleLineRule("\\//", null, normal));
rules.add(new EndOfLineRule("//", comment));
WordRule wordRule = new WordRule(new JavaWordDetector(), normal);
for (int i = 0; i < KEYWORDS.length; i++) {
wordRule.addWord(KEYWORDS[i], keyword);
}
rules.add(wordRule);
return rules;
}
示例15: ApexPartitionScanner
import org.eclipse.jface.text.rules.SingleLineRule; //导入依赖的package包/类
/**
* Creates the partitioner and sets up the appropriate rules.
*/
public ApexPartitionScanner() {
super();
IToken comment = new Token(APEX_MULTILINE_COMMENT);
List<IPredicateRule> rules = new ArrayList<>();
// Add rule for single line comments.
rules.add(new EndOfLineRule("//", Token.UNDEFINED));
// Add rule for strings and character constants.
rules.add(new SingleLineRule("\"", "\"", Token.UNDEFINED, '\\'));
rules.add(new SingleLineRule("'", "'", Token.UNDEFINED, '\\'));
// Add special case word rule.
rules.add(new WordPredicateRule(comment));
// Add rules for multi-line comments.
rules.add(new MultiLineRule("/*", "*/", comment, (char) 0, true));
IPredicateRule[] result = new IPredicateRule[rules.size()];
rules.toArray(result);
setPredicateRules(result);
}