use of org.eclipse.jface.text.rules.MultiLineRule in project titan.EclipsePlug-ins by eclipse.
the class CodeScanner method getTTCNRules.
public static List<IRule> getTTCNRules(final ColorManager colorManager) {
IToken singleLineComment = colorManager.createTokenFromPreference(PreferenceConstants.COLOR_COMMENTS);
IToken multiLineComment = colorManager.createTokenFromPreference(PreferenceConstants.COLOR_COMMENTS);
IToken keyword = colorManager.createTokenFromPreference(PreferenceConstants.COLOR_TTCN3_KEYWORDS);
IToken templateMatch = colorManager.createTokenFromPreference(PreferenceConstants.COLOR_TEMPLATE_MATCH);
IToken types = colorManager.createTokenFromPreference(PreferenceConstants.COLOR_TYPE);
IToken timerOp = colorManager.createTokenFromPreference(PreferenceConstants.COLOR_TIMER_OP);
IToken portOp = colorManager.createTokenFromPreference(PreferenceConstants.COLOR_PORT_OP);
IToken configOp = colorManager.createTokenFromPreference(PreferenceConstants.COLOR_CONFIG_OP);
IToken verdictOp = colorManager.createTokenFromPreference(PreferenceConstants.COLOR_VERDICT_OP);
IToken sutOp = colorManager.createTokenFromPreference(PreferenceConstants.COLOR_SUT_OP);
IToken functionOp = colorManager.createTokenFromPreference(PreferenceConstants.COLOR_FUNCTION_OP);
IToken predefinedOp = colorManager.createTokenFromPreference(PreferenceConstants.COLOR_PREDEFINED_OP);
IToken booleanConst = colorManager.createTokenFromPreference(PreferenceConstants.COLOR_BOOLEAN_CONST);
IToken verdictConst = colorManager.createTokenFromPreference(PreferenceConstants.COLOR_TTCN3_VERDICT_CONST);
IToken otherConst = colorManager.createTokenFromPreference(PreferenceConstants.COLOR_OTHER_CONST);
IToken macro = colorManager.createTokenFromPreference(PreferenceConstants.COLOR_PREPROCESSOR);
IToken visibility = colorManager.createTokenFromPreference(PreferenceConstants.COLOR_VISIBILITY_OP);
IToken string = colorManager.createTokenFromPreference(PreferenceConstants.COLOR_STRINGS);
IToken other = colorManager.createTokenFromPreference(PreferenceConstants.COLOR_NORMAL_TEXT);
List<IRule> rules = new ArrayList<IRule>();
rules.add(new EndOfLineRule("//", singleLineComment));
rules.add(new MultiLineRule("/*", "*/", multiLineComment, '\0', true));
rules.add(new WhitespaceRule(new WhiteSpaceDetector()));
rules.add(new TTCN3StringDetectionPatternRule(string));
rules.add(new StringDetectionPatternRule("'", new char[][] { { '\'', 'B' }, { '\'', 'H' }, { '\'', 'O' } }, string));
WordRule wordRule = new WordRule(new WordDetector(), other);
for (String element : CodeScanner.KEYWORDS) {
wordRule.addWord(element, keyword);
}
for (String element : CodeScanner.TEMPLATE_MATCH) {
wordRule.addWord(element, templateMatch);
}
for (String element : CodeScanner.TYPES) {
wordRule.addWord(element, types);
}
for (String element : CodeScanner.TIMER_OPERATIONS) {
wordRule.addWord(element, timerOp);
}
for (String element : CodeScanner.PORT_OPERATIONS) {
wordRule.addWord(element, portOp);
}
for (String element : CodeScanner.CONFIGURATION_OPERATIONS) {
wordRule.addWord(element, configOp);
}
for (String element : CodeScanner.VERDICT_OPERATIONS) {
wordRule.addWord(element, verdictOp);
}
for (String element : CodeScanner.SUT_OPERATION) {
wordRule.addWord(element, sutOp);
}
for (String element : CodeScanner.FUNCTION_OPERATIONS) {
wordRule.addWord(element, functionOp);
}
for (String element : CodeScanner.PREDEFINED_OPERATIONS) {
wordRule.addWord(element, predefinedOp);
}
for (String element : CodeScanner.BOOLEAN_CONSTANTS) {
wordRule.addWord(element, booleanConst);
}
for (String element : CodeScanner.VERDICT_CONSTANT) {
wordRule.addWord(element, verdictConst);
}
for (String element : CodeScanner.OTHER_CONSTANT) {
wordRule.addWord(element, otherConst);
}
for (String element : CodeScanner.VISIBILITY_MODIFIERS) {
wordRule.addWord(element, visibility);
}
rules.add(wordRule);
WordRule macroRule = new WordRule(new MacroDetector(), other);
for (String element : CodeScanner.MACROS) {
macroRule.addWord(element, macro);
}
rules.add(macroRule);
WordRule titanSpecificKeywordsRule = new WordRule(new TitanSpecificKeywordDetector(), other);
for (String element : CodeScanner.TITANSPECIFICKEYWORDS) {
// looks like a standard keyword
titanSpecificKeywordsRule.addWord(element, keyword);
}
rules.add(titanSpecificKeywordsRule);
return rules;
}
use of org.eclipse.jface.text.rules.MultiLineRule in project webtools.sourceediting by eclipse.
the class DefaultPartitionerZeroLengthTest method setUp.
public void setUp() {
fDoc = new Document();
IPartitionTokenScanner scanner = new RuleBasedPartitionScanner() {
{
IToken comment = new Token(COMMENT);
IPredicateRule[] rules = new IPredicateRule[] { new MultiLineRule("/*", "*/", comment) };
setPredicateRules(rules);
}
};
fPartitioner = new FastPartitioner(scanner, new String[] { DEFAULT, COMMENT });
fDoc.setDocumentPartitioner(fPartitioner);
fPartitioner.connect(fDoc);
}
use of org.eclipse.jface.text.rules.MultiLineRule in project webtools.sourceediting by eclipse.
the class JSDTCodeScanner method initializeRules.
public void initializeRules() {
List rules = new ArrayList();
// Add rule for multiple line comments.
// $NON-NLS-1$ //$NON-NLS-2$
rules.add(new MultiLineRule("/*", "*/", fMultiLineCommentToken));
// Add rule for single line comments.
// $NON-NLS-1$ //$NON-NLS-2$s
rules.add(new SingleLineRule("//", "\n", fSingleLineCommentToken));
// Add rule for strings and character constants.
// $NON-NLS-2$//$NON-NLS-1$
rules.add(new SingleLineRule("\"", "\"", fStringToken, '\\'));
// $NON-NLS-2$//$NON-NLS-1$
rules.add(new SingleLineRule("'", "'", fStringToken, '\\'));
// Add generic whitespace rule.
// rules.add(new WhitespaceRule(new JavaWhitespaceDetector()));
// Add word rule for keywords, types, and constants.
WordRule wordRule = new WordRule(new JavaWordDetector(), fDefaultToken);
for (int i = 0; i < JSDTCodeScanner.fgKeywords.length; i++) {
wordRule.addWord(JSDTCodeScanner.fgKeywords[i], fKeywordToken);
}
for (int i = 0; i < JSDTCodeScanner.fgTypes.length; i++) {
wordRule.addWord(JSDTCodeScanner.fgTypes[i], fTypeToken);
}
for (int i = 0; i < JSDTCodeScanner.fgConstants.length; i++) {
wordRule.addWord(JSDTCodeScanner.fgConstants[i], fTypeToken);
}
rules.add(wordRule);
// add word rule for HTML style comment delimiters
// $NON-NLS-1$ //$NON-NLS-2$
rules.add(new MultiLineRule("<!--", "-->", fHTMLCommentBorderToken));
IRule[] result = new IRule[rules.size()];
rules.toArray(result);
setRules(result);
}
use of org.eclipse.jface.text.rules.MultiLineRule in project webtools.sourceediting by eclipse.
the class FastPartitionerTest method setUp.
public void setUp() {
fDoc = new Document();
IPartitionTokenScanner scanner = new RuleBasedPartitionScanner() {
{
IToken comment = new Token(COMMENT);
IPredicateRule[] rules = new IPredicateRule[] { new MultiLineRule("/*", "*/", comment) };
setPredicateRules(rules);
}
};
fPartitioner = createPartitioner(scanner);
fDoc.setDocumentPartitioner(fPartitioner);
fPartitioner.connect(fDoc);
}
use of org.eclipse.jface.text.rules.MultiLineRule in project webtools.sourceediting by eclipse.
the class JavaCodeScanner method initializeRules.
public void initializeRules() {
List rules = new ArrayList();
// Add rule for multiple line comments.
// $NON-NLS-1$ //$NON-NLS-2$
rules.add(new MultiLineRule("/*", "*/", fSingleLineCommentToken));
// Add rule for single line comments.
// $NON-NLS-1$
rules.add(new EndOfLineRule("//", fSingleLineCommentToken));
// Add rule for strings and character constants.
// $NON-NLS-2$//$NON-NLS-1$
rules.add(new SingleLineRule("\"", "\"", fStringToken, '\\'));
// $NON-NLS-2$//$NON-NLS-1$
rules.add(new SingleLineRule("'", "'", fStringToken, '\\'));
// Add generic whitespace rule.
// rules.add(new WhitespaceRule(new JavaWhitespaceDetector()));
// Add word rule for keywords, types, and constants.
WordRule wordRule = new WordRule(new JavaWordDetector(), fDefaultToken);
for (int i = 0; i < fgKeywords.length; i++) wordRule.addWord(fgKeywords[i], fKeywordToken);
for (int i = 0; i < fgTypes.length; i++) wordRule.addWord(fgTypes[i], fTypeToken);
for (int i = 0; i < fgConstants.length; i++) wordRule.addWord(fgConstants[i], fTypeToken);
rules.add(wordRule);
// Add the double-quoted string rule
rules.add(new DoubleQuotedStringRule(fStringToken));
IRule[] result = new IRule[rules.size()];
rules.toArray(result);
setRules(result);
}
Aggregations