public ModelScanner(final ColorManager colorManager) { final IToken bracketsToken = new Token(new TextAttribute(colorManager.getColor(IValidationColorConstants.BRACKETS))); final IToken commToken = new Token(new TextAttribute(colorManager.getColor(IValidationColorConstants.COMMENT))); final List<IRule> rules = new ArrayList<>(); rules.add(new WhitespaceRule(new ValidationWhitespaceDetector())); rules.add(new BracketsRule(bracketsToken)); rules.add(new MultiLineRule("/**", "**/", commToken)); rules.add(new EndOfLineRule("--", commToken)); final IRule[] result = new IRule[rules.size()]; rules.toArray(result); this.setRules(result); }
/** * A default constructor. * @param manager */ public TexArgScanner(ColorManager manager) { IToken commentToken = new Token(new TextAttribute(manager .getColor(ColorManager.COMMENT), null, manager.getStyle(ColorManager.COMMENT_STYLE))); //Commands are colored in argument color with command styles IToken commandToken = new Token( new TextAttribute( manager.getColor(ColorManager.CURLY_BRACKETS), null, manager.getStyle(ColorManager.COMMAND_STYLE))); List<IRule> rules = new ArrayList<IRule>(); rules.add(new EndOfLineRule("%", commentToken, '\\')); rules.add(new WhitespaceRule(new WhitespaceDetector())); rules.add(new WordRule(new TexWord(), commandToken)); IRule[] result = new IRule[rules.size()]; rules.toArray(result); setRules(result); }
/** * A default constructor. * @param manager */ public TexOptArgScanner(ColorManager manager) { IToken commentToken = new Token(new TextAttribute(manager .getColor(ColorManager.COMMENT), null, manager.getStyle(ColorManager.COMMENT_STYLE))); //Commands are colored in argument color with command styles IToken commandToken = new Token( new TextAttribute( manager.getColor(ColorManager.SQUARE_BRACKETS), null, manager.getStyle(ColorManager.COMMAND_STYLE))); List<IRule> rules = new ArrayList<IRule>(); rules.add(new EndOfLineRule("%", commentToken, '\\')); rules.add(new WhitespaceRule(new WhitespaceDetector())); rules.add(new WordRule(new TexWord(), commandToken)); IRule[] result = new IRule[rules.size()]; rules.toArray(result); setRules(result); }
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); }
@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; }
@Override protected List<IRule> createRules() { IToken keywordToken = getToken(Prefs.EDITOR_MATH_KEYWORD_COLOR); IToken symbolToken = getToken(Prefs.EDITOR_MATH_SYMBOL_COLOR); IToken commentToken = getToken(Prefs.EDITOR_MATH_COMMENT_COLOR); // IToken defaultToken = getToken(Prefs.EDITOR_DEFAULT_COLOR); WordRule wordRule = new WordRule(new MathWordDetector(), keywordToken, true); WordRule symbolRule = new WordRule(new MathSymbolDetector(), symbolToken, true); List<IRule> rules = new ArrayList<IRule>(); rules.add(wordRule); rules.add(symbolRule); rules.add(new EndOfLineRule("%", commentToken)); rules.add(new WhitespaceRule(new WhitespaceDetector())); return rules; }
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); }
public VelocityStringScanner(VelocityColorProvider manager) { List rules = new ArrayList(); // Add generic whitespace rule rules.add(new WhitespaceRule(new WhitespaceDetector())); // Add pattern rule for formal references Token token = (Token) manager.getToken(IColorConstants.STRING_REFERENCE); rules.add(new PatternRule("$!{", "}", token, (char) 0, true)); rules.add(new PatternRule("${", "}", token, (char) 0, true)); // Add pattern rule for shorthand references token = (Token) manager.getToken(IColorConstants.STRING_REFERENCE); rules.add(new WordPatternRule(new IdentifierDetector(), "$!", null, token)); rules.add(new WordPatternRule(new IdentifierDetector(), "$", null, token)); IRule[] result = new IRule[rules.size()]; rules.toArray(result); setRules(result); setDefaultReturnToken(manager.getToken(IColorConstants.STRING)); }
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); }
public DMScanner(final ColorManager manager) { final IToken dmPreprocessor = new Token(new TextAttribute(manager.getColor(IDMColorConstants.DM_PREPROCESSOR))); final IToken keyword = new Token(new TextAttribute(manager.getColor(IDMColorConstants.KEYWORD))); final IToken defaultToken = new Token(new TextAttribute(manager.getColor(IDMColorConstants.DEFAULT))); final IToken numberToken = new Token(new TextAttribute(manager.getColor(IDMColorConstants.NUMBER))); final IRule[] rules = new IRule[4]; //Add rule for processing instructions rules[0] = new EndOfLineRule("#", dmPreprocessor); // Add generic whitespace rule. rules[1] = new WhitespaceRule(new DMWhitespaceDetector()); // Add keyword detection rules[2] = new DMKeywordRule(keyword, defaultToken, false); // Add number detection rules[3] = new FloatRule(numberToken); this.setRules(rules); }
public XMLScanner(ColorManager manager) { IToken procInstr = new Token( new TextAttribute( manager.getColor(IXMLColorConstants.PROC_INSTR))); IToken docType = new Token( new TextAttribute( manager.getColor(IXMLColorConstants.DOCTYPE))); IRule[] rules = new IRule[3]; //Add rule for processing instructions and doctype rules[0] = new MultiLineRule("<?", "?>", procInstr); rules[1] = new MultiLineRule("<!DOCTYPE", ">", docType); // Add generic whitespace rule. rules[2] = new WhitespaceRule(new XMLWhitespaceDetector()); setRules(rules); }
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); }
/** * This method is called when the we need to recreate the scanning rules. * It is called when the scanner is created and when colour preferences * and task preferences change. */ /* Override */ protected void update() { LinkedList<IRule> rules = new LinkedList<IRule>(); this.setDefaultReturnToken( getTokenForPreference( Preference.COLOUR_COMMENT ) ); // Add whitespace matcher rules.add( new WhitespaceRule( new WhiteSpaceDetector() ) ); WordRule taskRule = new WordRule( new WordDetector(), getTokenForPreference( Preference.COLOUR_COMMENT ) ); // Add all the task tags for( String tag : TaskTag.getTaskTagStrings( PreferenceManager.getPreference( Preference.TASK_TAGS ) ) ) { taskRule.addWord( tag, getTokenForPreference( Preference.COLOUR_TASK ) ); } rules.add( taskRule ); // Set the rules this.setRules( rules.toArray( new IRule[rules.size()] ) ); }
/** * XMLTokenScanner */ public XMLTokenScanner() { List<IRule> rules = new ArrayList<IRule>(); rules.add(new WhitespaceRule(new WhitespaceDetector())); rules.add(new MultiLineRule("<!--", "-->", createToken(XMLTokenType.COMMENT))); //$NON-NLS-1$ //$NON-NLS-2$ rules.add(new DocTypeRule(createToken(XMLTokenType.DOCTYPE), false)); rules.add(new MultiLineRule("<![CDATA[", "]]>", createToken(XMLTokenType.CDATA))); //$NON-NLS-1$ //$NON-NLS-2$ rules.add(new TagRule("?xml", createToken(XMLTokenType.DECLARATION))); //$NON-NLS-1$ rules.add(new TagRule("/", createToken(XMLTokenType.END_TAG))); //$NON-NLS-1$ rules.add(new TagRule(createToken(XMLTokenType.START_TAG))); // text IToken token = createToken(XMLTokenType.TEXT); rules.add(new WordRule(new WordDetector(), token)); setRules(rules.toArray(new IRule[rules.size()])); setDefaultReturnToken(token); }
@Override protected List<IRule> createRules() { setDefaultReturnToken(getToken(PreferenceConstants.PROPERTIES_FILE_COLORING_VALUE)); List<IRule> rules= new ArrayList<IRule>(); // Add rule for arguments. IToken token= getToken(PreferenceConstants.PROPERTIES_FILE_COLORING_ARGUMENT); rules.add(new ArgumentRule(token)); // Add word rule for assignment operator. token= getToken(PreferenceConstants.PROPERTIES_FILE_COLORING_ASSIGNMENT); WordRule wordRule= new WordRule(new AssignmentDetector(), token); rules.add(wordRule); // Add generic whitespace rule. rules.add(new WhitespaceRule(new JavaWhitespaceDetector())); return rules; }
public MDScanner(ColorManager cm) { this.cm = cm; Token heading = new Token(new TextAttribute(cm.getColor(MDColorConstants.HEADER), null, SWT.BOLD)); Token comment = new Token(new TextAttribute(cm.getColor(MDColorConstants.COMMENT))); Token emphasis = new Token(new TextAttribute(cm.getColor(MDColorConstants.DEFAULT), null, SWT.ITALIC)); setRules(new IRule[] { new HeaderRule(heading), new EmphasisRule("_", emphasis), new EmphasisRule("***", emphasis), new EmphasisRule("**", emphasis), new EmphasisRule("*", emphasis), new MultiLineRule("<!--", "-->", comment), new WhitespaceRule(new IWhitespaceDetector() { public boolean isWhitespace(char c) { return Character.isWhitespace(c); } }), }); }
public XMLTagScanner(ColorManager manager) { Color color = manager.getColor(PreferenceConstants.EDITOR_COLOR_STRING); IToken string = new Token(new TextAttribute(color)); // CheckStyle:MagicNumber| OFF IRule[] rules = new IRule[3]; // CheckStyle:MagicNumber| ON // 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); }
@Override protected List<IRule> createRules() { List<IRule> rules = new ArrayList<IRule>(); IToken keyword = this.getToken(GnColorConstants.GN_KEYWORD); IToken numberToken = getToken(GnColorConstants.GN_NUMBER); IToken comment = this.getToken(GnColorConstants.GN_COMMENT); IToken other = this.getToken(GnColorConstants.GN_DEFAULT); rules.add(new EndOfLineRule("#", comment)); rules.add(new WhitespaceRule(new GnWhitespaceDetector())); WordRule wordRule = new WordRule(new GnWordDetector(), other); for (int i = 0; i < GnCodeUtil.KEYWORDS.length; i++) { wordRule.addWord(GnCodeUtil.KEYWORDS[i], keyword); } rules.add(wordRule); NumberRule numberRule = new NumberRule(numberToken); rules.add(numberRule); this.setDefaultReturnToken(other); return rules; }
/** * */ public SQLKeywordScanner( ) { super( ); IToken sqlKeywordsToken = new Token( new TextAttribute( ColorManager.getColor(127, 0, 85), null, SWT.BOLD ) ); ArrayList rules = new ArrayList( ); rules.add( new SQLKeywordRule( sqlKeywordsToken, reservedwords ) ); rules.add( new SQLKeywordRule( sqlKeywordsToken, types ) ); rules.add( new SQLKeywordRule( sqlKeywordsToken, constants ) ); rules.add( new SQLKeywordRule( sqlKeywordsToken, functions ) ); rules.add( new SQLKeywordRule( sqlKeywordsToken, predicates ) ); // Add generic whitespace rule. rules.add( new WhitespaceRule( new IWhitespaceDetector( ) { public boolean isWhitespace( char c ) { return Character.isWhitespace( c ); } } ) ); setRules( (IRule[]) rules.toArray( new IRule[rules.size( )] ) ); this.setDefaultReturnToken( new Token( new TextAttribute( Display.getDefault( ).getSystemColor( SWT.COLOR_LIST_FOREGROUND )))); }
/** * Creates a new JSScanner object. * */ public JSScanner( ) { List rules = new ArrayList( ); // Add generic whitespace rule. rules.add( new WhitespaceRule( new IWhitespaceDetector( ) { public boolean isWhitespace( char c ) { return Character.isWhitespace( c ); } } ) ); IRule[] result = new IRule[rules.size( )]; rules.toArray( result ); setRules( result ); }
private void initScanner() { IToken string = new Token(new TextAttribute(getPreferenceColor(JsonPreferenceStore.STRING_COLOR))); IToken value = new Token(new TextAttribute(getPreferenceColor(JsonPreferenceStore.VALUE_COLOR))); IToken defaultText = new Token(new TextAttribute(getPreferenceColor(JsonPreferenceStore.DEFAULT_COLOR))); IToken nullValue = new Token(new TextAttribute(getPreferenceColor(JsonPreferenceStore.NULL_COLOR))); List<IRule> rules= new LinkedList<IRule>(); rules.add(new MultiLineRule(":\"", "\"", value, '\\')); rules.add(new MultiLineRule("\"", "\"", string, '\\')); //$NON-NLS-2$ //$NON-NLS-1$ WordRule wordRule= new WordRule(new JsonWordDetector(), defaultText); wordRule.addWord("null", nullValue); rules.add(wordRule); rules.add(new WhitespaceRule(new JsonWhitespaceDetector())); IRule[] result= new IRule[rules.size()]; rules.toArray(result); setRules(result); }
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); }
public RelBoundScanner(final ColorManager manager) { final IToken token = new Token(new TextAttribute(manager.getColor(IColorConstants.REL_BOUND))); final IToken bracketsToken = new Token(new TextAttribute(manager.getColor(IColorConstants.REL_BOUND_BRACKETS))); final IToken commentToken = new Token(new TextAttribute(manager.getColor(IColorConstants.COMMENT))); final List<IRule> rules = new ArrayList<IRule>(); rules.add(new MultiLineRule("/**", "**/", commentToken)); rules.add(new EndOfLineRule("--", commentToken)); // rules.add(new EndOfLineRule("//", commentToken)); rules.add(new BracketsRule(bracketsToken)); rules.add(new WhitespaceRule(new IWhitespaceDetector() { @Override public boolean isWhitespace(final char c) { return Character.isWhitespace(c); } })); this.setDefaultReturnToken(token); final IRule[] result = new IRule[rules.size()]; rules.toArray(result); this.setRules(result); }
public EiffelCodeScanner(EiffelColorProvider provider) { IToken keyword = new Token(new TextAttribute(provider .getColor(EiffelColorProvider.KEYWORD))); IToken string = new Token(new TextAttribute(provider .getColor(EiffelColorProvider.STRING))); IToken comment = new Token(new TextAttribute(provider .getColor(EiffelColorProvider.SINGLE_LINE_COMMENT))); IToken other = new Token(new TextAttribute(provider .getColor(EiffelColorProvider.DEFAULT))); List<Object> rules = new ArrayList<>(); //add rule for single line comments. rules.add(new EndOfLineRule("--", comment)); // Add rule for strings and character constants. rules.add(new SingleLineRule("\"", "\"", string, '\\')); rules.add(new SingleLineRule("'", "'", string, '\\')); //Add generic whitespace rule. rules.add(new WhitespaceRule(new EiffelWhitespaceDetector())); //Add word rule for keywords. WordRule wordRule = new WordRule(new EiffelWordDetector(), other); for (int i = 0; i < eKeywords.length; i++) { wordRule.addWord(eKeywords[i], keyword); rules.add(wordRule); IRule[] result = new IRule[rules.size()]; rules.toArray(result); setRules(result); } }
public EiffelCodeScanner(EiffelColorProvider provider) { IToken keyword = new Token(new TextAttribute(provider .getColor(EiffelColorProvider.KEYWORD))); IToken string = new Token(new TextAttribute(provider .getColor(EiffelColorProvider.STRING))); IToken comment = new Token(new TextAttribute(provider .getColor(EiffelColorProvider.SINGLE_LINE_COMMENT))); IToken other = new Token(new TextAttribute(provider .getColor(EiffelColorProvider.DEFAULT))); List<Object> rules = new ArrayList<>(); //add rule for single line comments. rules.add(new EndOfLineRule("--", comment)); // Add rule for strings and character constants. rules.add(new SingleLineRule("\"", "\"", string, '\\')); rules.add(new SingleLineRule("'", "'", string, '\\')); //Add generic whitespace rule. rules.add(new WhitespaceRule(new EiffelWhitespaceDetector())); //Add word rule for keywords. WordRule wordRule = new WordRule(new EiffelWordDetector(), other); for (int i = 0; i < Parser.KEYWORDS.length; i++) { wordRule.addWord(Parser.KEYWORDS[i], keyword); rules.add(wordRule); IRule[] result = new IRule[rules.size()]; rules.toArray(result); setRules(result); } }
/** * Use the default Eclipse higlighting scheme. */ private void createRules() { Token keywordToken = new Token(keywordAttribute); Token commentToken = new Token(commentAttribute); Token docToken = new Token(docAttribute); Token stringToken = new Token(stringAttribute); Token numberToken = new Token(numberAttribute); Token normalToken = new Token(normalAttribute); setDefaultReturnToken(normalToken); setRules(new IRule[] { new EndOfLineRule("//", commentToken),//$NON-NLS-2$ new KeywordRule(keywordToken),//$NON-NLS-2$ new MultiLineRule("/**", "*/", docToken, (char) 0, false), //$NON-NLS-2$ new MultiLineRule("/*", "*/", commentToken, (char) 0, false), //$NON-NLS-2$ new SingleLineRule("\"", "\"", stringToken, '\\'), //$NON-NLS-2$ // Regexp new SingleLineRule("/", "/", stringToken, '\\'), //$NON-NLS-2$ new SingleLineRule("'", "'", stringToken, '\\'), //$NON-NLS-2$ new WhitespaceRule(new IWhitespaceDetector() { public boolean isWhitespace(char c) { return Character.isWhitespace(c); } }),//$NON-NLS-2$ new WordRule(new WordDetector(), normalToken),//$NON-NLS-2$ new NumberRule(numberToken) }); }
public XMLScanner( ColorManager manager) { IToken procInstr = new Token(new TextAttribute(manager.getColor(IXMLColorConstants.PROC_INSTR))); IToken docType = new Token(new TextAttribute(manager.getColor(IXMLColorConstants.DOCTYPE))); IRule[] rules = new IRule[3]; // Add rule for processing instructions and doctype rules[0] = new MultiLineRule("<?", "?>", procInstr); rules[1] = new MultiLineRule("<!DOCTYPE", ">", docType); // Add generic whitespace rule. rules[2] = new WhitespaceRule(new XMLWhitespaceDetector()); setRules(rules); }
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); }
/** * Creates a BibTeX document scanner * * @param provider The color provider for syntax highlighting */ public BibCodeScanner(BibColorProvider provider) { IToken keyword = new Token(new TextAttribute(provider .getColor(BibColorProvider.KEYWORD))); IToken comment = new Token(new TextAttribute(provider .getColor(BibColorProvider.SINGLE_LINE_COMMENT))); IToken other = new Token(new TextAttribute(provider .getColor(BibColorProvider.DEFAULT))); List rules = new ArrayList(); // Add rule for single line comments. rules.add(new EndOfLineRule("%", comment)); rules.add(new BibCommandRule(keyword)); // Add generic whitespace rule. rules.add(new WhitespaceRule(new WhitespaceDetector())); // Add word rule for keywords, types, and constants. WordRule wordRule = new WordRule(new BibWordDetector(), other); rules.add(wordRule); IRule[] result = new IRule[rules.size()]; rules.toArray(result); setRules(result); }
/** * A default constructor. * @param manager */ public TexCommentScanner(ColorManager manager) { List<IRule> rules = new ArrayList<IRule>(); rules.add(new WhitespaceRule(new WhitespaceDetector())); IRule[] result = new IRule[rules.size()]; rules.toArray(result); setRules(result); }
/** * A default constructor. * @param manager */ public TexScanner(ColorManager manager) { // A token that defines how to color numbers IToken numberToken = new Token(new TextAttribute(manager .getColor(ColorManager.TEX_NUMBER), null, manager.getStyle(ColorManager.TEX_NUMBER_STYLE))); // A token that defines how to color command words (\command_word) IToken commandToken = new Token(new TextAttribute(manager .getColor(ColorManager.COMMAND), null, manager.getStyle(ColorManager.COMMAND_STYLE))); IToken commentToken = new Token(new TextAttribute(manager .getColor(ColorManager.COMMENT), null, manager.getStyle(ColorManager.COMMENT_STYLE))); // A token that defines how to color special characters (\_, \&, \~ ...) IToken specialCharToken = new Token(new TextAttribute(manager .getColor(ColorManager.TEX_SPECIAL), null, manager.getStyle(ColorManager.TEX_SPECIAL_STYLE))); List<IRule> rules = new ArrayList<IRule>(); rules.add(new TexSpecialCharRule(specialCharToken)); rules.add(new WordRule(new TexWord(), commandToken)); rules.add(new NumberRule(numberToken)); rules.add(new EndOfLineRule("%", commentToken, '\\')); rules.add(new WhitespaceRule(new WhitespaceDetector())); IRule[] result = new IRule[rules.size()]; rules.toArray(result); setRules(result); }
public XMLScanner(ColorManager manager) { IToken procInstr = new Token(new TextAttribute(manager .getColor(IXMLColorConstants.PROC_INSTR))); IToken docType = new Token(new TextAttribute(manager .getColor(IXMLColorConstants.DOCTYPE))); IRule[] rules = new IRule[3]; // Add rule for processing instructions and doctype rules[0] = new MultiLineRule("<?", "?>", procInstr); rules[1] = new MultiLineRule("<!DOCTYPE", ">", docType); // Add generic whitespace rule. rules[2] = new WhitespaceRule(new NCLWhitespaceDetector()); setRules(rules); }
@Override protected List<IRule> createRules() { IToken matter = getToken(Prefs.EDITOR_FRONTMATTER_COLOR); List<IRule> rules = new ArrayList<IRule>(); rules.add(new FrontMatterRule("---", "---", matter, '\\')); rules.add(new WhitespaceRule(new WhitespaceDetector())); return rules; }
@Override protected List<IRule> createRules() { IToken code = getToken(Prefs.EDITOR_CODE_COLOR); IToken block = getToken(Prefs.EDITOR_CODEBLOCK_COLOR); List<IRule> rules = new ArrayList<IRule>(); rules.add(new MultiLineRule("```", "```", block, '\\', true)); rules.add(new MultiLineRule("~~~", "~~~", block, '\\', true)); rules.add(new SingleLineRule("`", "`", code, '\\', true)); rules.add(new WhitespaceRule(new WhitespaceDetector())); return rules; }
@Override protected List<IRule> createRules() { IToken hidden = getToken(Prefs.EDITOR_COMMENT_HIDDEN_COLOR); IToken visible = getToken(Prefs.EDITOR_COMMENT_VISIBLE_COLOR); List<IRule> rules = new ArrayList<IRule>(); rules.add(new MultiLineRule("<!---", "--->", hidden, '\\')); rules.add(new MultiLineRule("<!--", "-->", visible, '\\')); rules.add(new WhitespaceRule(new WhitespaceDetector())); return rules; }
@Override protected List<IRule> createRules() { IToken keywordToken = getToken(Prefs.EDITOR_DOT_KEYWORD_COLOR); IToken attribsToken = getToken(Prefs.EDITOR_DOT_ATTRIBS_COLOR); IToken symbolToken = getToken(Prefs.EDITOR_DOT_SYMBOL_COLOR); IToken stringToken = getToken(Prefs.EDITOR_DOT_STRING_COLOR); IToken commentToken = getToken(Prefs.EDITOR_DOT_COMMENT_COLOR); IToken defaultToken = getToken(Prefs.EDITOR_DEFAULT_COLOR); WordRule wordRule = new WordRule(new DotWordDetector(), defaultToken, true); for (String keyword : keywords) { wordRule.addWord(keyword, keywordToken); } WordRule attribRule = new WordRule(new DotWordDetector(), defaultToken, true); for (String attrib : attribs) { wordRule.addWord(attrib, attribsToken); } WordRule symbolRule = new WordRule(new DotSymbolDetector(), defaultToken, true); for (String symbol : symbols) { symbolRule.addWord(symbol, symbolToken); } List<IRule> rules = new ArrayList<IRule>(); rules.add(new MultiLineRule("/*", "*/", commentToken, '\\', true)); rules.add(new SingleLineRule("//", null, commentToken, '\\', true)); rules.add(new SingleLineRule("\"", "\"", stringToken, '\\', true)); rules.add(wordRule); rules.add(attribRule); rules.add(symbolRule); rules.add(new WhitespaceRule(new WhitespaceDetector())); return rules; }
@Override protected List<IRule> createRules() { IToken header = getToken(Prefs.EDITOR_HEADER_COLOR); IToken link = getToken(Prefs.EDITOR_LINK_COLOR); IToken list = getToken(Prefs.EDITOR_LIST_COLOR); IToken rule = getToken(Prefs.EDITOR_HRULE_COLOR); IToken bold = getToken(Prefs.EDITOR_BOLD_COLOR); IToken italic = getToken(Prefs.EDITOR_ITALIC_COLOR); IToken strikeout = getToken(Prefs.EDITOR_STRIKEOUT_COLOR); IToken code = getToken(Prefs.EDITOR_CODE_COLOR); List<IRule> rules = new ArrayList<IRule>(); rules.add(new HeaderUnderlineRule(header)); rules.add(new FirstColumnRule("#", header)); rules.add(new FirstColumnRule("---", rule)); rules.add(new FirstColumnRule("***", rule)); rules.add(new FirstColumnRule("___", rule)); rules.add(new LinkRule(link)); rules.add(new ListRule(list)); rules.add(new EmphasisRule("__", bold)); rules.add(new EmphasisRule("**", bold)); rules.add(new EmphasisRule("_", italic)); rules.add(new EmphasisRule("*", italic)); rules.add(new EmphasisRule("~~", strikeout)); rules.add(new EmphasisRule("``", code)); rules.add(new EmphasisRule("`", code)); rules.add(new WhitespaceRule(new WhitespaceDetector())); return rules; }
public VelocityCodeScanner(VelocityColorProvider manager) { List rules = new ArrayList(); // Add generic whitespace rule rules.add(new WhitespaceRule(new WhitespaceDetector())); // Add word rule for directives Token token = (Token) manager.getToken(IColorConstants.DIRECTIVE); WordRule wordRule = new WordRule(new DirectiveDetector(), token); token = (Token) manager.getToken(IColorConstants.DIRECTIVE); // System directives String[] directives = Directive.DIRECTIVES; for (int i = directives.length - 1; i >= 0; i--) { wordRule.addWord(directives[i], token); } // User directives Iterator userDirectives = VelocityEditorEnvironment.getParser().getUserDirectives().iterator(); while (userDirectives.hasNext()) { wordRule.addWord((String) userDirectives.next(), token); } rules.add(wordRule); // Add pattern rule for formal references token = (Token) manager.getToken(IColorConstants.REFERENCE); rules.add(new PatternRule("$!{", "}", token, (char) 0, true)); rules.add(new PatternRule("${", "}", token, (char) 0, true)); // Add pattern rule for shorthand references token = (Token) manager.getToken(IColorConstants.REFERENCE); rules.add(new WordPatternRule(new IdentifierDetector(), "$!", null, token)); rules.add(new WordPatternRule(new IdentifierDetector(), "$", null, token)); // token = new Token(new // TextAttribute(aProvider.getColor(IColorConstants.TAG), null, // SWT.BOLD)); // rules.add(new TagRule(token)); // token = new Token(new // TextAttribute(aProvider.getColor(IColorConstants.COMMENT))); IRule[] result = new IRule[rules.size()]; rules.toArray(result); setRules(result); }