Java 类org.eclipse.jface.text.rules.SingleLineRule 实例源码

项目:egradle    文件:AbstractGroovyBasedDocumentPartitionScanner.java   
protected void addGroovyRules(List<IPredicateRule> rules) {
    IToken groovyAnnotation = createToken(ANNOTATION);
    IToken javaDocComment = createToken(GROOVY_DOC);
    IToken groovyComment = createToken(COMMENT);
    IToken groovySimpleString = createToken(STRING);
    IToken groovyGString = createToken(GSTRING);
    IToken groovyKeyWord = createToken(GROOVY_KEYWORD);
    IToken javaKeyWord = createToken(JAVA_KEYWORD);
    IToken javaLiteral = createToken(JAVA_LITERAL);

    rules.add(new MultiLineRule("/**", "*/", javaDocComment));
    rules.add(new MultiLineRule("/*", "*/", groovyComment));
    rules.add(new SingleLineRule("//", "", groovyComment));

    rules.add(new MultiLineRule("\"", "\"", groovyGString, '\\'));
    rules.add(new MultiLineRule("\'", "\'", groovySimpleString, '\\'));

    buildWordRules(rules, javaKeyWord, JavaKeyWords.values(), javaWordDetector);
    buildWordRules(rules, javaLiteral, JavaLiteralKeyWords.values(), javaWordDetector);

    buildWordRules(rules, groovyKeyWord, GroovyKeyWords.values(), javaWordDetector);

    buildAnnotationRules(rules, groovyAnnotation, onlyAnnotationWordDetector);
}
项目:LibertyEiffel-Eclipse-Plugin    文件:EiffelPartitionScanner.java   
public EiffelPartitionScanner() {
    super();

    IToken multilineComment = new Token(MULTILINE_COMMENT);
    IToken singlelineComment = new Token(SINGLELINE_COMMENT);
    IToken string = new Token(STRING);

    List<Object> rules = new ArrayList<>();

    //Add rule for single line comments.
    rules.add(new EndOfLineRule("--", singlelineComment));

    // Add rule for strings and character constants.
    rules.add(new SingleLineRule("\"", "\"", string, '\\'));
    rules.add(new SingleLineRule("'", "'", string, '\\'));

    //Add rules for multi-line comments and eiffeldocs
    rules.add(new MultiLineRule("--[[", "]]", multilineComment, (char) 0, true));

    IPredicateRule[] result = new IPredicateRule[rules.size()];
    rules.toArray(result);
    setPredicateRules(result);
}
项目:ftc    文件:SqlCommentPartitionScanner.java   
private SqlCommentPartitionScanner() {
    IToken commentToken = new Token(SQL_COMMENT);

    List<IPredicateRule> rules= new ArrayList<>();

    rules.add(new EndOfLineRule("--", commentToken, '\\'));
    rules.add(new MultiLineRule("/*", "*/", commentToken, '\\'));

    rules.add(new WordPredicateRule(commentToken));
    rules.add(new SingleLineRule("\"", "\"", Token.UNDEFINED, '\\')); 
    rules.add(new SingleLineRule("'", "'", Token.UNDEFINED, '\\'));

    IPredicateRule[] result= new IPredicateRule[rules.size()];
    rules.toArray(result);
    setPredicateRules(result);
}
项目:ncl30-eclipse    文件:XMLTagScanner.java   
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);
}
项目:fluentmark    文件:ScannerHtml.java   
@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;
}
项目:typescript.java    文件:JSXScanner.java   
@Override
protected List<IRule> createRules() {
    List<IRule> rules = new ArrayList<IRule>();

    Token tagBorder = getToken(IJSXColorConstants.TAG_BORDER);
    Token tagName = getToken(IJSXColorConstants.TAG_NAME);
    Token tagAttributeName = getToken(IJSXColorConstants.TAG_ATTRIBUTE_NAME);
    Token tagAttributeEquals = getToken(IJSXColorConstants.TAG_ATTRIBUTE_EQUALS);
    Token tagAttributeValue = getToken(IJSXColorConstants.TAG_ATTRIBUTE_VALUE);

    rules.add(new SingleLineRule("\"", "\"", tagAttributeValue, '\\'));
    rules.add(new SingleLineRule("'", "'", tagAttributeValue, '\\'));
    rules.add(new SingleLineRule("{", "}", tagAttributeValue, '\\'));
    rules.add(new JSXTagRule(tagName, tagBorder));
    rules.add(new WordRule(new NameDetector(), tagAttributeName));

    // setDefaultReturnToken(token);
    return rules;
}
项目:umple    文件:UmpleTagScanner.java   
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);
}
项目:velocity-edit    文件:XMLTagScanner.java   
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);
}
项目:PDFReporter-Studio    文件:XMLTagScanner.java   
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);
}
项目:GLSL-Eclipse    文件:GlslPartitionScanner.java   
public GlslPartitionScanner() {
    IToken preprocessorToken = new Token(GLSL_PREPROCESSOR);
    IToken uniformToken = new Token(GLSL_UNIFORM);
    IToken variableToken = new Token(GLSL_VARIABLE);
    IToken commentToken = new Token(GLSL_COMMENT);

    setPredicateRules(new IPredicateRule[] {
        new SingleLineRule("#", null, preprocessorToken, '\0', true, false),
        new SingleLineRule("//", null, commentToken, '\0', true, false),
        new SingleLineRule("/*", "*/", commentToken),
        new DeclarationRule(uniformToken, new DeclarationSection[] {
            new DeclarationSection(Glsl.QUALIFIERS),
            new DeclarationSection(Glsl.TYPES)
        }),
        new DeclarationRule(variableToken, new DeclarationSection[] {
            new DeclarationSection(Glsl.TYPES)
        }),
    });
}
项目:GLSL-Eclipse    文件:GlslScanners.java   
public static final RuleBasedScanner createPreprocessorScanner() {
    final TextAttribute attribute = new TextAttribute(
        Activator.getDefault().getColor(GlslEditor.PREPROCESSOR_COLOR), null, SWT.BOLD
    );
    final Token preprocessorToken = new Token(attribute);

    IRule[] rules = new IRule[Glsl.PREPROCESSORS.length];
    for (int i = 0; i < rules.length; i++) {
        rules[i] = new SingleLineRule(Glsl.PREPROCESSORS[i], null, preprocessorToken, '\0',
                true, false);
    }

    RuleBasedScanner scanner = new RuleBasedScanner();
    scanner.setRules(rules);
    return scanner;
}
项目:APICloud-Studio    文件:JSDocScanner.java   
/**
 * Create a new javadoc scanner for the given color provider.
 */
public JSDocScanner()
{
    super();

    List<IRule> list = new ArrayList<IRule>();

    // Add rule for tags.
    list.add(new SingleLineRule("<", ">", getToken("text.html.basic"))); //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-1$

    // Add rule for links.
    list.add(new SingleLineRule("{", "}", getToken("markup.underline.link"))); //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-1$

    // Add word rule for keywords.
    IToken keyword = getToken("meta.tag.documentation.js"); //$NON-NLS-1$
    WordRule wordRule = new WordRule(new JSDocWordDetector());
    for (String word : KEYWORDS)
    {
        wordRule.addWord(word, keyword);
    }
    list.add(wordRule);

    setDefaultReturnToken(getToken("comment.block.documentation.js")); //$NON-NLS-1$
    setRules(list.toArray(new IRule[list.size()]));
}
项目:strutsclipse    文件:AbstractXmlParser.java   
private IDocumentPartitioner createAttrPartitioner(IDocument document,
        String[] attrs) {
    IPredicateRule[] attrRules = new IPredicateRule[attrs.length + 2];
    attrRules[0] = new SingleLineRule("\"", "\"", new Token(
            DOUBLE_QUOTES_TOKEN));
    attrRules[1] = new SingleLineRule("'", "'", new Token(
            SINGLE_QUOTES_TOKEN));

    String[] types = new String[attrs.length + 2];
    types[0] = DOUBLE_QUOTES_TOKEN;
    types[1] = SINGLE_QUOTES_TOKEN;

    for (int i = 0; i < attrs.length; i++) {
        attrRules[i + 2] = new WordPatternRule(new AttributeDetector(),
                attrs[i], "=", new Token(attrs[i]));

        types[i + 2] = attrs[i];
    }

    return createConnectPartitioner(document, attrRules, types);
}
项目:syncope    文件:JavaScriptScanner.java   
/**
 * Creates the list of <code>IRule</code>.
 * If you have to customize rules, override this method.
 *
 * @return the list of <code>IRule</code>
 */
protected List<IRule> createRules() {
    IToken normal  = new Token(new TextAttribute(new Color(Display.getCurrent(),
            IHTMLColorConstants.FOREGROUND)));
    IToken string  = new Token(new TextAttribute(new Color(Display.getCurrent(),
            IHTMLColorConstants.JAVA_STRING)));
    IToken comment = new Token(new TextAttribute(new Color(Display.getCurrent(),
            IHTMLColorConstants.JAVA_COMMENT)));
    IToken keyword = new Token(new TextAttribute(new Color(Display.getCurrent(),
            IHTMLColorConstants.JAVA_KEYWORD)));
    List<IRule> rules = new ArrayList<IRule>();
    rules.add(new SingleLineRule("\"", "\"", string, '\\'));
    rules.add(new SingleLineRule("'", "'", string, '\\'));
    rules.add(new SingleLineRule("\\//", null, normal));
    rules.add(new EndOfLineRule("//", comment));
    WordRule wordRule = new WordRule(new JavaWordDetector(), normal);
    for (int i = 0; i < KEYWORDS.length; i++) {
        wordRule.addWord(KEYWORDS[i], keyword);
    }
    rules.add(wordRule);
    return rules;
}
项目:idecore    文件:ApexPartitionScanner.java   
/**
 * Creates the partitioner and sets up the appropriate rules.
 */
public ApexPartitionScanner() {
    super();

    IToken comment = new Token(APEX_MULTILINE_COMMENT);

    List<IPredicateRule> rules = new ArrayList<>();

    // Add rule for single line comments.
    rules.add(new EndOfLineRule("//", Token.UNDEFINED));

    // Add rule for strings and character constants.
    rules.add(new SingleLineRule("\"", "\"", Token.UNDEFINED, '\\'));
    rules.add(new SingleLineRule("'", "'", Token.UNDEFINED, '\\'));

    // Add special case word rule.
    rules.add(new WordPredicateRule(comment));

    // Add rules for multi-line comments.
    rules.add(new MultiLineRule("/*", "*/", comment, (char) 0, true));

    IPredicateRule[] result = new IPredicateRule[rules.size()];
    rules.toArray(result);
    setPredicateRules(result);
}
项目:ant-ivyde    文件:XMLTagScanner.java   
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);
}
项目:rustyeclipse    文件:RustPartitionScanner.java   
/**
 * Creates the partitioner and sets up the appropriate rules.
 */
public RustPartitionScanner() {
    super();

    IToken javaDoc= new Token(HOT_DOC);
    IToken comment= new Token(RUST_MULTILINE_COMMENT);
    IToken other= new Token(RUST_OTHER);

    List<IPredicateRule> rules= new ArrayList<>();

    // Add rule for single line comments.
    rules.add(new EndOfLineRule("//", other)); //$NON-NLS-1$

    // Add rule for strings and character constants.
    rules.add(new SingleLineRule("\"", "\"", other, '\\')); //$NON-NLS-2$ //$NON-NLS-1$

    // Add special case word rule.
    rules.add(new WordPredicateRule(comment));

    // Add rules for multi-line comments and javadoc.
    rules.add(new MultiLineRule("/**", "*/", javaDoc, (char) 0, true)); //$NON-NLS-1$ //$NON-NLS-2$
    rules.add(new MultiLineRule("/*", "*/", comment, (char) 0, true)); //$NON-NLS-1$ //$NON-NLS-2$

    setPredicateRules(rules.toArray(new IPredicateRule[rules.size()]));
}
项目:goclipse    文件:SamplePartitionScanner.java   
/**
 * Creates the partitioner and sets up the appropriate rules.
 */
public SamplePartitionScanner() {
    IToken tkString = new Token(LANG_STRING);
    IToken tkRawString = new Token(LANG_RAW_STRING);
    IToken tkCharacter = new Token(LANG_CHARACTER);
    IToken tkSingleComment = new Token(LANG_SINGLE_COMMENT);
    IToken tkMultiComment = new Token(LANG_MULTI_COMMENT);

    List<IPredicateRule> rules = new ArrayList<IPredicateRule>();

    rules.add(new MultiLineRule("`", "`", tkRawString, NO_ESCAPE, true));
    rules.add(new MultiLineRule("\"", "\"", tkString, '\\', true));
    rules.add(new SingleLineRule("'", "'", tkCharacter, '\\', true));

    rules.add(new EndOfLineRule("//", tkSingleComment, NO_ESCAPE));

    rules.add(new MultiLineRule("/*", "*/", tkMultiComment, NO_ESCAPE, true));


    setPredicateRules(rules.toArray(new IPredicateRule[rules.size()]));
}
项目:eclipse-batch-editor    文件:BatchDocumentPartitionScanner.java   
public BatchDocumentPartitionScanner() {
        IToken echoOutput = createToken(ECHO_OUTPUT);
        IToken parameters = createToken(PARAMETER);
        IToken comment = createToken(COMMENT);
        IToken doubleString = createToken(DOUBLE_STRING);

        IToken batchBuildIn = createToken(BATCH_KEYWORD);

        IToken knownVariables = createToken(KNOWN_VARIABLES);
        IToken variables = createToken(VARIABLES);
        IToken batchExternalCommands = createToken(BATCH_COMMAND);

        List<IPredicateRule> rules = new ArrayList<>();
        rules.add(new AfterEchoDocumentRule(echoOutput)); 
        rules.add(new BatchVariableRule(variables));
        rules.add(new SingleLineRule("rem", "", comment, (char) -1, true));
        rules.add(new SingleLineRule("REM", "", comment, (char) -1, true));
        rules.add(new SingleLineRule("::", "", comment, (char) -1, true));

        rules.add(new BatchStringRule("\"", "\"", doubleString));

        rules.add(new CommandParameterRule(parameters));

        buildWordRules(rules, batchBuildIn, BatchBuildInKeywords.values());
        buildWordRules(rules, batchExternalCommands, BatchExternalKeyWords.values());

        buildWordRules(rules, knownVariables, BatchSpecialVariableKeyWords.values());

        /* TODO ATR: 24.11.2017: remove the next linecomplete or support variable setup like in bash editor*/
//      buildVarDefRules(rules, knownVariables, BatchSpecialVariableKeyWords.values());

        setPredicateRules(rules.toArray(new IPredicateRule[rules.size()]));
    }
项目:convertigo-eclipse    文件:XMLTagScanner.java   
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);
}
项目:eclipse-bash-editor    文件:BashDocumentPartitionScanner.java   
public BashDocumentPartitionScanner() {
        IToken hereDocument = createToken(HERE_DOCUMENT);
        IToken hereString = createToken(HERE_STRING);
        IToken parameters = createToken(PARAMETER);
        IToken comment = createToken(COMMENT);
        IToken simpleString = createToken(SINGLE_STRING);
        IToken doubleString = createToken(DOUBLE_STRING);
        IToken backtickString = createToken(BACKTICK_STRING);

        IToken systemKeyword = createToken(BASH_SYSTEM_KEYWORD);
        IToken bashKeyword = createToken(BASH_KEYWORD);

        IToken knownVariables = createToken(KNOWN_VARIABLES);
        IToken variables = createToken(VARIABLES);
        IToken includeKeyword = createToken(INCLUDE_KEYWORD);
        IToken bashCommand = createToken(BASH_COMMAND);

        List<IPredicateRule> rules = new ArrayList<>();
        rules.add(new HereStringRule(hereString));
        rules.add(new HereDocumentRule(hereDocument));

        buildWordRules(rules, systemKeyword, BashSystemKeyWords.values());
        rules.add(new BashVariableRule(variables));
        rules.add(new SingleLineRule("#", "", comment, (char) -1, true));

        rules.add(new BashStringRule("\"", "\"", doubleString));
        rules.add(new BashStringRule("\'", "\'", simpleString));
        rules.add(new BashStringRule("`", "`", backtickString));

        rules.add(new CommandParameterRule(parameters));

        buildWordRules(rules, includeKeyword, BashIncludeKeyWords.values());
        buildWordRules(rules, bashKeyword, BashLanguageKeyWords.values());
        buildWordRules(rules, bashCommand, BashGnuCommandKeyWords.values());

//      buildVarDefRules(rules, knownVariables, BashSpecialVariableKeyWords.values());
        buildWordRules(rules, knownVariables, BashSpecialVariableKeyWords.values());

        setPredicateRules(rules.toArray(new IPredicateRule[rules.size()]));
    }
项目:pgcodekeeper    文件:SQLEditorCommonDocumentProvider.java   
IDocumentPartitioner createRecipePartitioner() {
    IPredicateRule[] rules = {
            new SingleLineRule("--", null, new Token(SQL_SINGLE_COMMENT), (char) 0, true, false), //$NON-NLS-1$
            new MultiLineRule("/*", "*/", new Token(SQL_MULTI_COMMENT), (char) 0, true),  //$NON-NLS-1$ //$NON-NLS-2$
            new MultiLineRule( "'", "'", new Token(SQL_CHARACTER_STRING_LITERAL), (char) 0 , true) //$NON-NLS-1$ //$NON-NLS-2$
    };

    RuleBasedPartitionScanner scanner = new RuleBasedPartitionScanner();
    scanner.setPredicateRules(rules);

    return new FastPartitioner(scanner, CONTENT_TYPES);
}
项目:LibertyEiffel-Eclipse-Plugin    文件:EiffelCodeScanner.java   
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);
    }
}
项目:LibertyEiffel-Eclipse-Plugin    文件:EiffelPartitionScanner.java   
public EiffelPartitionScanner() {
    super();

    IToken multilineComment = new Token(MULTILINE_COMMENT);
    IToken singlelineComment = new Token(SINGLELINE_COMMENT);
    IToken string = new Token(STRING);
    IToken multilinestring = new Token(MULTILINE_STRING);

    List<Object> rules = new ArrayList<>();

    //Add rules for multi-line comments
    rules.add(new MultiLineRule("--[[", "]]", multilineComment));

    //Add rule for single line comments.
    rules.add(new EndOfLineRule("--", singlelineComment));

    // Add rule for strings and character constants.
    rules.add(new SingleLineRule("\"", "\"", string, '\\'));
    rules.add(new SingleLineRule("'", "'", string, '\\'));

    //Add rules for multi-line comments and eiffeldocs
    rules.add(new MultiLineRule("[[", "]]", multilinestring));

    IPredicateRule[] result = new IPredicateRule[rules.size()];
    rules.toArray(result);
    setPredicateRules(result);
}
项目:LibertyEiffel-Eclipse-Plugin    文件:EiffelCodeScanner.java   
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);
    }
}
项目:GradleEditor    文件:GradleCodeScanner.java   
/**
 * 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) });
}
项目:GradleEditor    文件:GradlePartitionScanner.java   
public GradlePartitionScanner() {
    IToken jsDocToken = new Token(GRADLEDOC);
    IToken multilineCommentToken = new Token(MULTILINE_COMMENT);

    setPredicateRules(new IPredicateRule[] { new EndOfLineRule("//", Token.UNDEFINED), //$NON-NLS-1$
            new SingleLineRule("\"", "\"", Token.UNDEFINED, '\\'), //$NON-NLS-2$ //$NON-NLS-1$
            new SingleLineRule("'", "'", Token.UNDEFINED, '\\'), //$NON-NLS-2$ //$NON-NLS-1$
            new EmptyCommentPredicateRule(multilineCommentToken), new MultiLineRule("/**", "*/", jsDocToken, (char) 0, true), //$NON-NLS-1$ //$NON-NLS-2$
            new MultiLineRule("/*", "*/", multilineCommentToken, (char) 0, true) //$NON-NLS-1$ //$NON-NLS-2$
    });
}
项目:http4e    文件:HPartitionScanner.java   
public HPartitionScanner() {
   // IToken key= new Token(IDocument.DEFAULT_CONTENT_TYPE);
   IToken comment = new Token(COMMENT);
   IToken propertyValue = new Token(PROPERTY_VALUE);

   setPredicateRules(new IPredicateRule[] { 
         new SingleLineRule(AssistConstants.PARAM_DELIM_EQ, null, propertyValue, '\\', true, true), 
         new SingleLineRule("#", null, comment, (char) 0, true, true), });
}
项目:http4e    文件:XMLTagScanner.java   
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);
}
项目:fluentmark    文件:ScannerCode.java   
@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;
}
项目:fluentmark    文件:ScannerDot.java   
@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;
}
项目:velocity-edit    文件:VelocityPartitionScanner.java   
/**
     * Creates the partitioner and sets up the appropriate rules.
     */
    public VelocityPartitionScanner()
    {
        cp = new VelocityColorProvider();
        List rules = new ArrayList();
        org.eclipse.jface.text.rules.IToken comment = cp.getToken(MULTI_LINE_COMMENT, true);
        org.eclipse.jface.text.rules.IToken proc_inst = cp.getToken(PROC_PARTITION, true);
        org.eclipse.jface.text.rules.IToken script = cp.getToken(SCRIPT_PARTITION, true);
        org.eclipse.jface.text.rules.IToken cdata = cp.getToken(CDATA_PARTITION, true);
        org.eclipse.jface.text.rules.IToken tag = cp.getToken(TAG_PARTITION, true);
        // org.eclipse.jface.text.rules.IToken text = cp.getToken(TEXT, true);
        rules.add(new MultiLineRule("<!--", "-->", comment));
//        rules.add(new MultiLineRule("<?", "?>", proc_inst));
//        rules.add(new MultiLineRule("<%", "%>", proc_inst));
//        rules.add(new MultiLineRule("<#", "#>", proc_inst));
        rules.add(new MultiLineRule("<![CDATA[", "]]>", proc_inst));
        rules.add(new MultiLineRule("<![", "]>", proc_inst));
        rules.add(new IgnoreCasePatternRule("<script", "</script>", script, '\0', false, false));
        rules.add(new IgnoreCasePatternRule("<pre>", "</pre>", cdata, '\0', false, false));
        rules.add(new HTMLTagRule("<", ">", tag, '\0', true));
        // Add rule for single line comments
        rules.add(new EndOfLineRule("##", cp.getToken(SINGLE_LINE_COMMENT, true)));
        // Add rule for strings
        rules.add(new SingleLineRule("\"", "\"", cp.getToken(PARSED_STRING, true), '\\'));
        // Add rule for character constants.
        rules.add(new SingleLineRule("'", "'", cp.getToken(UNPARSED_STRING, true), '\\'));
        // Add rules for multi-line comments and doc comments
        rules.add(new MultiLineRule("#**", "*#", cp.getToken(DOC_COMMENT, true)));
        rules.add(new MultiLineRule("#*", "*#", cp.getToken(MULTI_LINE_COMMENT, true)));
        // Add special empty comment word rules
        rules.add(new WordPatternRule(new EmptyCommentDetector(), "#***#", null, cp.getToken(DOC_COMMENT, true)));
        rules.add(new WordPatternRule(new EmptyCommentDetector(), "#**#", null, cp.getToken(MULTI_LINE_COMMENT, true)));
        IPredicateRule[] result = new IPredicateRule[rules.size()];
        rules.toArray(result);
        setPredicateRules(result);
    }
项目:velocity-edit    文件:PartitionScanner.java   
public PartitionScanner() {
    IPredicateRule[] predicateRules = new IPredicateRule[] {
        new MultiLineRule("#*", "*#", new Token(COMMENT_PARTITION)),
        new SingleLineRule("##", "\n", new Token(COMMENT_PARTITION)),
        new DirectiveRule(new Token(FOREACH_PARTITION), "foreach"),
        new DirectiveRule(new Token(SET_PARTITION), "set"),
        new DirectiveRule(new Token(TEXT_PARTITION), "txt"),
        new DirectiveRule(new Token(IF_PARTITION), "if"),
        new DirectiveRule(new Token(MACRO_PARTITION), "macro"),
        new DirectiveRule(new Token(INCLUDE_PARTITION), "include"),
        new DirectiveRule(new Token(PARSE_PARTITION), "parse"),
        new EndRule(new Token(FOREACH_END_PARTITION), "foreach"),
        new EndRule(new Token(IF_END_PARTITION), "if"),
        new EndRule(new Token(MACRO_END_PARTITION), "macro"),
        new WordPatternRule(new DirectiveDetector(), "#end", "", new Token(END_PARTITION)),
        new DirectiveRule(new Token(ELSE_IF_PARTITION), "elseif"),
        new WordPatternRule(new DirectiveDetector(), "#else", "", new Token(ELSE_PARTITION)),
        new VariableRule(new Token(VARIABLE_PARTITION), "!$"),
        new VariableRule(new Token(VARIABLE_PARTITION), "$"),
        new SingleLineRule("#stop", null, new Token(STOP_PARTITION)),
        new MacroInstanceRule(new Token(MACRO_INSTANCE_PARTITION)),

        new MultiLineRule("<!--", "-->", new Token(XML_COMMENT)),
        new TagRule(new Token(XML_TAG))
    };

    setPredicateRules(predicateRules);
}
项目:velocity-edit    文件:Scanner.java   
public Scanner(ColorManager manager) {
    IToken procInstr =
        new Token(
            new TextAttribute(
                manager.getColor(ColorManager.COLOR_PROC_INSTR)));

    IRule[] rules = new IRule[2];
    //Add rule for processing instructions
    rules[0] = new SingleLineRule("<?", "?>", procInstr);
    // Add generic whitespace rule.
    rules[1] = new WhitespaceRule(new WhitespaceDetector());

    setRules(rules);
}
项目:BYONDclipse    文件:DMStringScanner.java   
public DMStringScanner(final ColorManager manager)
{
    final IToken opToken                            = new Token(new TextAttribute(manager.getColor(IDMColorConstants.STRINGOP)));

    final IRule[] rules                             = new IRule[2];
    // Add generic whitespace rule.
    rules[0]                                        = new WhitespaceRule(new DMWhitespaceDetector());
    // Add keyword detection
    rules[1]                                        = new SingleLineRule("[", "]", opToken);

    this.setRules(rules);
}
项目:GLSL-Eclipse    文件:GlslScanner.java   
public GlslScanner() {
    Activator plugin = Activator.getDefault();
    final WordRule wordRule = GlslScanners.createWordRule();

    final Token keywordToken = new Token(new TextAttribute(plugin.getColor(GlslEditor.KEYWORD_COLOR), null, SWT.BOLD));
    final Token typeToken = new Token(new TextAttribute(plugin.getColor(GlslEditor.TYPE_COLOR)));
    final Token qualifierToken = new Token(new TextAttribute(plugin.getColor(GlslEditor.QUALIFIER_COLOR), null, SWT.BOLD));
    final Token functionToken = new Token(new TextAttribute(plugin.getColor(GlslEditor.FUNCTION_COLOR)));
    final Token builtInVariableToken = new Token(new TextAttribute(plugin.getColor(GlslEditor.BUILT_IN_VARIABLES_COLOR)));
    final Token commentToken = new Token(new TextAttribute(plugin.getColor(GlslEditor.COMMENTS_COLOR)));

    List<IRule> rules = new ArrayList<>();

    // Rules which affect entire lines at once
    rules.add(new SingleLineRule("//", null, commentToken, '\0', true, false));

    // Rules which don't affect entire lines
    rules.add(new SingleLineRule("/*", "*/", commentToken));
    rules.add(wordRule);

    GlslScanners.addToWordRule(wordRule, Glsl.KEYWORDS, keywordToken);
    GlslScanners.addToWordRule(wordRule, Glsl.TYPES, typeToken);
    GlslScanners.addToWordRule(wordRule, Glsl.QUALIFIERS, qualifierToken);
    GlslScanners.addToWordRule(wordRule, Glsl.FUNCTIONS, functionToken);
    GlslScanners.addToWordRule(wordRule, Glsl.VARIABLES, builtInVariableToken);

    rules.add(new WhitespaceRule(new IWhitespaceDetector() {
        @Override
        public boolean isWhitespace(char c) {
           return Character.isWhitespace(c);
        }
       }));

    IRule[] rulesArray = new IRule[rules.size()];
    for (int i = 0; i < rulesArray.length; i++) {
        rulesArray[i] = rules.get(i);
    }

    setRules(rulesArray);
}
项目:chromedevtools    文件:JsPartitionScanner.java   
public JsPartitionScanner() {
  IToken jsDocToken= new Token(JSDOC);
  IToken multilineCommentToken= new Token(MULTILINE_COMMENT);

  setPredicateRules(new IPredicateRule[] {
      new EndOfLineRule("//", Token.UNDEFINED), //$NON-NLS-1$
      new SingleLineRule("\"", "\"", Token.UNDEFINED, '\\'), //$NON-NLS-2$ //$NON-NLS-1$
      new SingleLineRule("'", "'", Token.UNDEFINED, '\\'), //$NON-NLS-2$ //$NON-NLS-1$
      new EmptyCommentPredicateRule(multilineCommentToken),
      new MultiLineRule("/**", "*/", jsDocToken, (char) 0, true),  //$NON-NLS-1$ //$NON-NLS-2$
      new MultiLineRule("/*", "*/", multilineCommentToken, (char) 0, true) //$NON-NLS-1$ //$NON-NLS-2$
  });
}
项目:chromedevtools    文件:JsCodeScanner.java   
/**
 * Use the default Eclipse higlighting scheme.
 */
private void createRules() {
  Token keywordToken = new Token(
      new TextAttribute(EditorColors.getColor(new RGB(127, 0, 85)), null, SWT.BOLD));

  commentToken = new Token(commentAttribute);

  Token jsDocToken = new Token(jsDocAttribute);

  Token stringToken = new Token(
      new TextAttribute(EditorColors.getColor(new RGB(42, 0, 255)), null, SWT.NORMAL));

  RGB blackRgb = new RGB(0, 0, 0);

  Token numberToken = new Token(
      new TextAttribute(EditorColors.getColor(blackRgb), null, SWT.NORMAL));

  Token normalToken = new Token(
      new TextAttribute(EditorColors.getColor(blackRgb), null, SWT.NORMAL));
  setDefaultReturnToken(normalToken);

  setRules(new IRule[] {
      new EndOfLineRule("//", commentToken), //$NON-NLS-1$
      new KeywordRule(keywordToken),
      new MultiLineRule("/**", "*/", jsDocToken, (char) 0, false),  //$NON-NLS-1$ //$NON-NLS-2$
      new MultiLineRule("/*", "*/", commentToken, (char) 0, false),  //$NON-NLS-1$ //$NON-NLS-2$
      new SingleLineRule("\"", "\"", stringToken, '\\'), //$NON-NLS-1$ //$NON-NLS-2$
      // Regexp
      new SingleLineRule("/", "/", stringToken, '\\'), //$NON-NLS-1$ //$NON-NLS-2$
      new SingleLineRule("'", "'", stringToken, '\\'), //$NON-NLS-1$ //$NON-NLS-2$
      new WhitespaceRule(new IWhitespaceDetector() {
        public boolean isWhitespace(char c) {
          return Character.isWhitespace(c);
        }
      }),

      new WordRule(new WordDetector(), normalToken),
      new NumberRule(numberToken),
  });
}
项目:APICloud-Studio    文件:CSSTokenScanner.java   
/**
 * createStringRules
 * 
 * @return
 */
private List<IRule> createStringRules()
{
    List<IRule> rules = new ArrayList<IRule>();

    rules.add(new SingleLineRule("\"", "\"", createToken(CSSTokenType.DOUBLE_QUOTED_STRING), '\\'));
    rules.add(new SingleLineRule("\'", "\'", createToken(CSSTokenType.SINGLE_QUOTED_STRING), '\\'));

    return rules;
}
项目:Eclipse-Postfix-Code-Completion    文件:PropertiesFilePartitionScanner.java   
/**
 * Creates the partitioner and sets up the appropriate rules.
 */
public PropertiesFilePartitionScanner() {
    super();

    IToken comment= new Token(COMMENT);
    IToken propertyValue= new Token(PROPERTY_VALUE);
    IToken key= new Token(IDocument.DEFAULT_CONTENT_TYPE);

    List<IPredicateRule> rules= new ArrayList<IPredicateRule>();

    // Add rule for leading white space.
    rules.add(new LeadingWhitespacePredicateRule(key, "\t")); //$NON-NLS-1$
    rules.add(new LeadingWhitespacePredicateRule(key, " ")); //$NON-NLS-1$

    // Add rules for comments.
    rules.add(new EndOfLineRule("#", comment, (char) 0, true)); //$NON-NLS-1$
    rules.add(new EndOfLineRule("!", comment, (char) 0, true)); //$NON-NLS-1$

    // Add rules for property values.
    rules.add(new SingleLineRule("=", null, propertyValue, '\\', true, true)); //$NON-NLS-1$
    rules.add(new SingleLineRule(":", null, propertyValue, '\\', true, true)); //$NON-NLS-1$
    rules.add(new SingleLineRule(" ", null, propertyValue, '\\', true, true)); //$NON-NLS-1$
    rules.add(new SingleLineRule("\t", null, propertyValue, '\\', true, true)); //$NON-NLS-1$

    // Add special case word rule.
    EmptyCommentRule wordRule= new EmptyCommentRule(comment);
    rules.add(wordRule);

    IPredicateRule[] result= new IPredicateRule[rules.size()];
    rules.toArray(result);
    setPredicateRules(result);
}