@SuppressWarnings({"unchecked", "rawtypes"}) protected List createRules() { final List<IRule> rules = new ArrayList<>(); final IToken keyword = getToken(JuliaColourConstants.KEYWORD); final IToken comment = getToken(JuliaColourConstants.COMMENT); final IToken other = getToken(JuliaColourConstants.DEFAULT); rules.add(new EndOfLineRule("#", comment)); rules.add(new WhitespaceRule(new JuliaWhitespaceDetector())); final WordRule wordRule = new WordRule(new JuliaWordDetector(), other); for (final String entry : Julia.keywords()) wordRule.addWord(entry, keyword); rules.add(wordRule); setDefaultReturnToken(other); return rules; }
public SoarCommentScanner() { ColorProvider cp = SoarPlugin.getDefault().getColorProvider(); ArrayList rules = new ArrayList(); IRule temp; // SoarDoc IToken soarDoc = new Token( new TextAttribute( cp.getColor(ColorProvider.SOAR_DOC), cp.getColor(ColorProvider.BACKGROUND), SWT.BOLD)); temp = new WordRule(new SoarDocWordDetector()); for (int i = 0; i < ISoarSyntax.SOAR_DOC.length; ++i) { ((WordRule) temp).addWord("@" + ISoarSyntax.SOAR_DOC[i], soarDoc); } rules.add(temp); // Comments IToken comment = new Token(new TextAttribute(cp.getColor(ColorProvider.COMMENT))); this.fDefaultReturnToken = comment; // Package the rules and send them off IRule[] rules2 = new IRule[rules.size()]; rules.toArray(rules2); setRules(rules2); }