Search in sources :

Example 1 with WhiteSpaceDetector

use of org.eclipse.titan.designer.editors.WhiteSpaceDetector 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;
}
Also used : ArrayList(java.util.ArrayList) MultiLineRule(org.eclipse.jface.text.rules.MultiLineRule) StringDetectionPatternRule(org.eclipse.titan.designer.editors.StringDetectionPatternRule) WhitespaceRule(org.eclipse.jface.text.rules.WhitespaceRule) WordRule(org.eclipse.jface.text.rules.WordRule) IRule(org.eclipse.jface.text.rules.IRule) WhiteSpaceDetector(org.eclipse.titan.designer.editors.WhiteSpaceDetector) IToken(org.eclipse.jface.text.rules.IToken) EndOfLineRule(org.eclipse.jface.text.rules.EndOfLineRule)

Aggregations

ArrayList (java.util.ArrayList)1 EndOfLineRule (org.eclipse.jface.text.rules.EndOfLineRule)1 IRule (org.eclipse.jface.text.rules.IRule)1 IToken (org.eclipse.jface.text.rules.IToken)1 MultiLineRule (org.eclipse.jface.text.rules.MultiLineRule)1 WhitespaceRule (org.eclipse.jface.text.rules.WhitespaceRule)1 WordRule (org.eclipse.jface.text.rules.WordRule)1 StringDetectionPatternRule (org.eclipse.titan.designer.editors.StringDetectionPatternRule)1 WhiteSpaceDetector (org.eclipse.titan.designer.editors.WhiteSpaceDetector)1