IToken comment = new Token(
new TextAttribute(manager.getColor(CucumberColorConstants.COMMENT), null, SWT.ITALIC));
IRule[] rules = new IRule[6];
rules[0] = new HighlightFullLineRule("#", null, comment);
IWordDetector keywordDetector = new IWordDetector() {
@Override
public boolean isWordStart(char c) {
if (c == 'G' || c == 'A' || c == 'W' || c == 'T' || c == 'B') {
return true;
}
return false;
}
@Override
public boolean isWordPart(char c) {
return Character.isLowerCase(c);
}
};
WordRule wordRule = new WordRule(keywordDetector);
wordRule.addWord("Given", keyword);
wordRule.addWord("And", keyword);
wordRule.addWord("When", keyword);
wordRule.addWord("Then", keyword);
wordRule.addWord("But", keyword);
rules[1] = wordRule;
IWordDetector tableDetector = new IWordDetector() {
@Override
public boolean isWordStart(char c) {
if (c == '|') {
return true;
}
return false;
}
@Override
public boolean isWordPart(char c) {
return false;
}
};
WordRule tableRule = new WordRule(tableDetector);
tableRule.addWord("|", tablePipe);
rules[2] = tableRule;
rules[3] = new HighlightFullLineRule("Scenario:", null, scenario);
rules[4] = new HighlightFullLineRule("Scenario Outline:", null, scenario);
rules[5] = new HighlightFullLineRule("Examples:", null, scenario);
setRules(rules);
}