use of org.eclipse.jface.text.rules.MultiLineRule in project KaiZen-OpenAPI-Editor by RepreZen.
the class JsonScanner method init.
protected void init() {
TextAttribute keyAttr = tokenAttribute(PreferenceConstants.COLOR_KEY, PreferenceConstants.BOLD_KEY, PreferenceConstants.ITALIC_KEY, PreferenceConstants.UNDERLINE_KEY);
IToken keyToken = new YAMLToken(keyAttr, YAMLToken.KEY);
TextAttribute scalarAttr = tokenAttribute(PreferenceConstants.COLOR_SCALAR, PreferenceConstants.BOLD_SCALAR, PreferenceConstants.ITALIC_SCALAR, PreferenceConstants.UNDERLINE_SCALAR);
IToken scalarToken = new YAMLToken(scalarAttr, YAMLToken.SCALAR);
TextAttribute commentAttr = tokenAttribute(PreferenceConstants.COLOR_COMMENT, PreferenceConstants.BOLD_COMMENT, PreferenceConstants.ITALIC_COMMENT, PreferenceConstants.UNDERLINE_COMMENT);
IToken commentToken = new YAMLToken(commentAttr, YAMLToken.COMMENT);
TextAttribute documentAttr = tokenAttribute(PreferenceConstants.COLOR_DOCUMENT, PreferenceConstants.BOLD_DOCUMENT, PreferenceConstants.ITALIC_DOCUMENT, PreferenceConstants.UNDERLINE_DOCUMENT);
IToken documentStartToken = new YAMLToken(documentAttr, YAMLToken.DOCUMENT_START);
IToken documentEndToken = new YAMLToken(documentAttr, YAMLToken.DOCUMENT_END);
TextAttribute anchorAttr = tokenAttribute(PreferenceConstants.COLOR_ANCHOR, PreferenceConstants.BOLD_ANCHOR, PreferenceConstants.ITALIC_ANCHOR, PreferenceConstants.UNDERLINE_ANCHOR);
IToken anchorToken = new YAMLToken(anchorAttr, YAMLToken.ANCHOR);
TextAttribute aliasAttr = tokenAttribute(PreferenceConstants.COLOR_ALIAS, PreferenceConstants.BOLD_ALIAS, PreferenceConstants.ITALIC_ALIAS, PreferenceConstants.UNDERLINE_ALIAS);
IToken aliasToken = new YAMLToken(aliasAttr, YAMLToken.ALIAS);
IToken indicatorCharToken = new YAMLToken(new TextAttribute(null), YAMLToken.INDICATOR_CHARACTER);
TextAttribute tagAttr = tokenAttribute(PreferenceConstants.COLOR_TAG_PROPERTY, PreferenceConstants.BOLD_TAG_PROPERTY, PreferenceConstants.ITALIC_TAG_PROPERTY, PreferenceConstants.UNDERLINE_TAG_PROPERTY);
IToken tagPropToken = new YAMLToken(tagAttr, YAMLToken.TAG_PROPERTY);
TextAttribute constantAttr = tokenAttribute(PreferenceConstants.COLOR_CONSTANT, PreferenceConstants.BOLD_CONSTANT, PreferenceConstants.ITALIC_CONSTANT, PreferenceConstants.UNDERLINE_CONSTANT);
IToken predefinedValToken = new YAMLToken(constantAttr, YAMLToken.CONSTANT);
IToken whitespaceToken = new YAMLToken(new TextAttribute(null), YAMLToken.WHITESPACE);
IToken directiveToken = new YAMLToken(new TextAttribute(null), YAMLToken.DIRECTIVE);
ArrayList<IRule> rules = new ArrayList<IRule>();
rules.add(new KeyRule(keyToken));
rules.add(new SingleQuotedKeyRule(keyToken));
rules.add(new DoubleQuotedKeyRule(keyToken));
rules.add(new MultiLineRule("\"", "\"", scalarToken, '\\'));
rules.add(new MultiLineRule("'", "'", scalarToken));
rules.add(new EndOfLineRule("#", commentToken));
rules.add(new EndOfLineRule("%TAG", directiveToken));
rules.add(new EndOfLineRule("%YAML", directiveToken));
rules.add(new DocumentStartAndEndRule("---", documentStartToken));
rules.add(new DocumentStartAndEndRule("...", documentEndToken));
rules.add(new IndicatorCharacterRule(indicatorCharToken));
rules.add(new WhitespaceRule(whitespaceToken));
rules.add(new WordPatternRule(new AnchorWordDetector(), "&", "", anchorToken));
rules.add(new WordPatternRule(new AnchorWordDetector(), "*", "", aliasToken));
rules.add(new WordPatternRule(new TagWordDetector(), "!", "", tagPropToken));
rules.add(new PredefinedValueRule(predefinedValToken));
rules.add(new ScalarRule(scalarToken));
IRule[] rulesArray = new IRule[rules.size()];
rules.toArray(rulesArray);
setRules(rulesArray);
setDefaultReturnToken(scalarToken);
}
use of org.eclipse.jface.text.rules.MultiLineRule in project eclipse.platform.text by eclipse.
the class FastPartitionerTest method testBug409538_2.
@Test
public void testBug409538_2() throws Exception {
fPartitioner.disconnect();
IPartitionTokenScanner scanner = new RuleBasedPartitionScanner() {
{
IToken comment = new Token(COMMENT);
IPredicateRule[] rules = new IPredicateRule[] { new MultiLineRule("<!--", "-->", comment, (char) 0, true) };
setPredicateRules(rules);
}
};
fPartitioner = createPartitioner(scanner);
fDoc.setDocumentPartitioner(fPartitioner);
fPartitioner.connect(fDoc);
fDoc.set("<!-- blah");
assertEqualPartition(0, 9, COMMENT);
}
use of org.eclipse.jface.text.rules.MultiLineRule in project syncope by apache.
the class InnerCSSScanner method createRules.
@Override
protected List<IRule> createRules() {
RGB rgb = IHTMLColorConstants.TAGLIB;
Color color = new Color(Display.getCurrent(), rgb);
IToken tag = new Token(new TextAttribute(color));
rgb = IHTMLColorConstants.CSS_COMMENT;
color = new Color(Display.getCurrent(), rgb);
IToken comment = new Token(new TextAttribute(color));
List<IRule> rules = new ArrayList<IRule>();
rules.add(new SingleLineRule(" <style", ">", tag));
rules.add(new SingleLineRule(" </style", ">", tag));
rules.add(new MultiLineRule("/*", "*/", comment));
rules.addAll(super.createRules());
return rules;
}
use of org.eclipse.jface.text.rules.MultiLineRule in project syncope by apache.
the class InnerJavaScriptScanner method createRules.
@Override
protected List<IRule> createRules() {
IToken tag = new Token(new TextAttribute(new Color(Display.getCurrent(), IHTMLColorConstants.TAG)));
IToken comment = new Token(new TextAttribute(new Color(Display.getCurrent(), IHTMLColorConstants.JAVA_COMMENT)));
IToken jsdoc = new Token(new TextAttribute(new Color(Display.getCurrent(), IHTMLColorConstants.JSDOC)));
List<IRule> rules = super.createRules();
rules.add(new SingleLineRule(" <script", ">", tag));
rules.add(new SingleLineRule(" </script", ">", tag));
rules.add(new MultiLineRule("/**", "*/", jsdoc));
rules.add(new MultiLineRule("/*", "*/", comment));
return rules;
}
use of org.eclipse.jface.text.rules.MultiLineRule in project hale by halestudio.
the class GroovyPartitionScanner method createRules.
public static List<IRule> createRules(boolean withColor) {
IPreferenceStore store = GroovyUIPlugin.getDefault().getPreferenceStore();
Object objComment;
Object objdComment;
Object objmString;
Object objsString;
Object objsComment;
if (withColor) {
RGB rgb = PreferenceConverter.getColor(store, PreferenceConstants.GROOVY_EDITOR_HIGHLIGHT_STRINGS_COLOR);
objComment = objmString = objsString = objsComment = objdComment = new TextAttribute(new Color(null, rgb), null, SWT.ITALIC);
} else {
objComment = JAVA_MULTI_LINE_COMMENT;
objmString = GROOVY_MULTILINE_STRINGS;
objsString = JAVA_STRING;
objsComment = JAVA_SINGLE_LINE_COMMENT;
objdComment = JAVA_DOC;
}
IToken comment = new Token(objComment);
IToken mString = new Token(objmString);
IToken sString = new Token(objsString);
IToken sComment = new Token(objsComment);
IToken jdoc = new Token(objdComment);
List<IRule> rules = new ArrayList<IRule>();
// Add rule for single line comments.
rules.add(new EndOfLineRule("//", sComment));
// Add rule for strings and character constants.
rules.add(new MultiLineRule("'''", "'''", mString));
rules.add(new MultiLineRule("\"\"\"", "\"\"\"", mString));
// GRECLIPSE-1111 do not eagerly match these kinds of multiline strings
rules.add(new SingleLineRule("\"", "\"", sString, '\\'));
rules.add(new SingleLineRule("'", "'", sString, '\\'));
// GRECLIPSE-1203 make dollar slashies optionally highlighted
if (store.getBoolean(PreferenceConstants.GROOVY_EDITOR_HIGHLIGHT_SLASHY_STRINGS)) {
rules.add(new MultiLineRule("$/", "/$", mString, '\0', false));
}
// Add special case word rule.
rules.add(new WordPredicateRule(comment));
// Add rule for JavaDoc
// $NON-NLS-1$ //$NON-NLS-2$
rules.add(new MultiLineRule("/**", "*/", jdoc, (char) 0, true));
// Add rules for multi-line comments
// $NON-NLS-1$ //$NON-NLS-2$
rules.add(new MultiLineRule("/*", "*/", comment, (char) 0, true));
return rules;
}
Aggregations