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

项目:Tarski    文件:RelationModelPartitionScanner.java   
public RelationModelPartitionScanner() {
  final IToken commentPartition = new Token(RelationModelPartitionScanner.RELATION_MODEL_COMMENT);
  final IToken optionPartition = new Token(RelationModelPartitionScanner.RELATION_MODEL_OPTION);
  final IToken universePartition =
      new Token(RelationModelPartitionScanner.RELATION_MODEL_UNIVERSE);
  final IToken relBoundPartition =
      new Token(RelationModelPartitionScanner.RELATION_MODEL_REL_BOUND);

  final List<IRule> rules = new ArrayList<IRule>();
  rules.add(new MultiLineRule("/**", "**/", commentPartition));
  rules.add(new EndOfLineRule("--", commentPartition));
  // rules.add(new EndOfLineRule("//", commentPartition));
  rules.add(new MultiLineRule("options {", "}", optionPartition));
  rules.add(new MultiLineRule("universe {", "}", universePartition));
  rules.add(new MultiLineRule("universe [", "]", universePartition));
  rules.add(new RelationBoundsRule("relations", "}", relBoundPartition));

  final IPredicateRule[] result = new IPredicateRule[rules.size()];
  rules.toArray(result);
  this.setPredicateRules(result);
}
项目:Tarski    文件:ModelScanner.java   
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);
  }
项目:http4e    文件:XMLTextScanner.java   
public XMLTextScanner( ColorManager colorManager) {

      ESCAPED_CHAR = new Token(new TextAttribute(colorManager.getColor(IXMLColorConstants.ESCAPED_CHAR)));
      CDATA_START = new Token(new TextAttribute(colorManager.getColor(IXMLColorConstants.CDATA)));
      CDATA_END = new Token(new TextAttribute(colorManager.getColor(IXMLColorConstants.CDATA)));
      CDATA_TEXT = new Token(new TextAttribute(colorManager.getColor(IXMLColorConstants.CDATA_TEXT)));
      IRule[] rules = new IRule[2];

      // Add rule to pick up escaped chars
      // Add rule to pick up start of CDATA section
      rules[0] = new CDataRule(CDATA_START, true);
      // Add a rule to pick up end of CDATA sections
      rules[1] = new CDataRule(CDATA_END, false);
      setRules(rules);

   }
项目:texlipse    文件:TexArgScanner.java   
/**
 * 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);
}
项目:texlipse    文件:TexOptArgScanner.java   
/**
 * 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);
}
项目:ncl30-eclipse    文件:XMLTextScanner.java   
public XMLTextScanner(ColorManager colorManager) {

        ESCAPED_CHAR = new Token(new TextAttribute(colorManager
                .getColor(IXMLColorConstants.ESCAPED_CHAR)));
        CDATA_START = new Token(new TextAttribute(colorManager
                .getColor(IXMLColorConstants.CDATA)));
        CDATA_END = new Token(new TextAttribute(colorManager
                .getColor(IXMLColorConstants.CDATA)));
        CDATA_TEXT = new Token(new TextAttribute(colorManager
                .getColor(IXMLColorConstants.CDATA_TEXT)));
        IRule[] rules = new IRule[2];

        // Add rule to pick up escaped chars
        // Add rule to pick up start of CDATA section
        //rules[0] = new CDataRule(CDATA_START, true);
        // Add a rule to pick up end of CDATA sections
        //rules[1] = new CDataRule(CDATA_END, false);
        setRules(rules);

    }
项目: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;
}
项目:fluentmark    文件:ScannerMath.java   
@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;
}
项目:fluentmark    文件:PartitionScanner.java   
public PartitionScanner() {
    super();

    IToken matter = new Token(Partitions.FRONT_MATTER);
    IToken comment = new Token(Partitions.COMMENT);
    IToken codeblock = new Token(Partitions.CODEBLOCK);
    IToken htmlblock = new Token(Partitions.HTMLBLOCK);
    IToken dotblock = new Token(Partitions.DOTBLOCK);
    IToken mathblock = new Token(Partitions.MATHBLOCK);

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

    rules.add(new FrontMatterRule("---", "---", matter, '\\'));
    rules.add(new MatchRule("\\$\\S", "\\S\\$", mathblock, '\\', false));
    rules.add(new MultiLineRule("$$", "$$", mathblock, '\\'));
    rules.add(new MultiLineRule("<!--", "-->", comment, '\\'));
    rules.add(new HtmlCodeRule(htmlblock));
    rules.add(new DotCodeRule(dotblock));
    rules.add(new MultiLineRule("~~~", "~~~", codeblock, '\\'));
    rules.add(new MultiLineRule("```", "```", codeblock, '\\'));
    rules.add(new IndentedCodeRule(codeblock));

    IPredicateRule[] rule = new IPredicateRule[rules.size()];
    setPredicateRules(rules.toArray(rule));
}
项目: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;
}
项目:LogViewer    文件:DynamicRuleBasedScanner.java   
public IToken nextToken() {
IToken token;
tokenOffset = offset;
column = UNDEFINED;
Iterator<?> ruleIterator = rules.iterator();
while(ruleIterator.hasNext()) {
    IRule rule = (IRule)ruleIterator.next();
    token = rule.evaluate(this);
    if(!token.isUndefined()) {
        return token;
    }
    if(ruleIterator.hasNext()) {
        offset = tokenOffset;
    }
}
if(rules.size() <= 0) {
    read();
}
if (read() == EOF) {
    return Token.EOF;
} else {
    unread();
    return defaultToken;
}
  }
项目: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    文件:VelocityStringScanner.java   
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));
}
项目: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);
}
项目:BYONDclipse    文件:DMScanner.java   
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);
}
项目:PDFReporter-Studio    文件:XMLScanner.java   
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);
}
项目:PDFReporter-Studio    文件:XMLTextScanner.java   
public XMLTextScanner(ColorManager colorManager) {

        ESCAPED_CHAR = new Token(new TextAttribute(colorManager.getColor(IXMLColorConstants.ESCAPED_CHAR)));
        CDATA_START = new Token(new TextAttribute(colorManager.getColor(IXMLColorConstants.CDATA)));
        CDATA_END = new Token(new TextAttribute(colorManager.getColor(IXMLColorConstants.CDATA)));
        CDATA_TEXT = new Token(new TextAttribute(colorManager.getColor(IXMLColorConstants.CDATA_TEXT)));
        IRule[] rules = new IRule[2];

        // Add rule to pick up escaped chars
        // Add rule to pick up start of CDATA section
        rules[0] = new CDataRule(CDATA_START, true);
        // Add a rule to pick up end of CDATA sections
        rules[1] = new CDataRule(CDATA_END, false);
        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);
}
项目:eclipse-kernelsyntax    文件:KernelSyntaxLangC.java   
public void attachWordRule(List<IRule> rules) {
IToken tokenDefault = new Token(new TextAttribute(KSC_DEFAULT));
IToken tokenKeyword = new Token(new TextAttribute(KSC_KEYWORD));
IToken tokenNumber = new Token(new TextAttribute(KSC_NUMBER));
IToken tokenOperator = new Token(new TextAttribute(KSC_OPERATOR));

WordRule wordRule = new WordRule(new KernelSyntaxWordDetector(), tokenDefault, true);
for (String keyword : KSL_KEYWORD) {
    wordRule.addWord(keyword, tokenKeyword);
}
rules.add(wordRule);

KernelSyntaxNumberRule numberRule = new KernelSyntaxNumberRule(tokenNumber);
rules.add(numberRule);

KernelSyntaxOperatorRule opRule = new KernelSyntaxOperatorRule(tokenOperator);
rules.add(opRule);
}
项目:eclipse-kernelsyntax    文件:KernelSyntaxLangPython.java   
public void attachWordRule(List<IRule> rules) {
IToken tokenDefault = new Token(new TextAttribute(KSC_DEFAULT));
IToken tokenKeyword = new Token(new TextAttribute(KSC_KEYWORD));
IToken tokenNumber = new Token(new TextAttribute(KSC_NUMBER));
IToken tokenOperator = new Token(new TextAttribute(KSC_OPERATOR));

WordRule wordRule = new WordRule(new KernelSyntaxWordDetector(), tokenDefault, true);
for (String keyword : KSL_KEYWORD) {
    wordRule.addWord(keyword, tokenKeyword);
}
rules.add(wordRule);

KernelSyntaxNumberRule numberRule = new KernelSyntaxNumberRule(tokenNumber);
rules.add(numberRule);

KernelSyntaxOperatorRule opRule = new KernelSyntaxOperatorRule(tokenOperator);
rules.add(opRule);
}
项目:eclipse-kernelsyntax    文件:KernelSyntaxLang.java   
public void attachWordRule(List<IRule> rules) {
IToken tokenDefault = new Token(new TextAttribute(KSC_DEFAULT));
IToken tokenKeyword = new Token(new TextAttribute(KSC_KEYWORD));
IToken tokenNumber = new Token(new TextAttribute(KSC_NUMBER));
IToken tokenOperator = new Token(new TextAttribute(KSC_OPERATOR));

WordRule wordRule = new WordRule(new KernelSyntaxWordDetector(), tokenDefault, true);
for (String keyword : KSL_KEYWORD) {
    wordRule.addWord(keyword, tokenKeyword);
}
rules.add(wordRule);

KernelSyntaxNumberRule numberRule = new KernelSyntaxNumberRule(tokenNumber);
rules.add(numberRule);

KernelSyntaxOperatorRule opRule = new KernelSyntaxOperatorRule(tokenOperator);
rules.add(opRule);
}
项目: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;
}
项目:vTM-eclipse    文件:StringScanner.java   
/**
 * 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
 * change.
 */
/* Override */
protected void update()
{
   LinkedList<IRule> rules = new LinkedList<IRule>();      
   this.setDefaultReturnToken( getTokenForPreference( Preference.COLOUR_STRING ) );

   // Add the escape character rule (e.g. \n \123)
   rules.add( new EscapeCharacterRule( 
      getTokenForPreference( Preference.COLOUR_ESCAPE ),
      isQuoteString()
   ) );

   // Set the rules
   this.setRules( rules.toArray( new IRule[rules.size()] ) );   
}
项目:vTM-eclipse    文件:CommentScanner.java   
/**
 * 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()] ) );   
}
项目:APICloud-Studio    文件:XMLTokenScanner.java   
/**
 * 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);
}
项目: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()]));
}
项目:APICloud-Studio    文件:CSSCodeScannerRuleBased.java   
/**
 * createScannerSpecificRules
 * 
 * @return
 */
protected Collection<? extends IRule> createScannerSpecificRules()
{
    List<IRule> rules = new ArrayList<IRule>();
    WordRule wordRule = new WordRule(new KeywordIdentifierDetector(), Token.UNDEFINED);
    wordRule.addWord("em", createToken(CSSTokenType.EMS));
    wordRule.addWord("ex", createToken(CSSTokenType.EXS));
    wordRule.addWord("px", createToken(CSSTokenType.LENGTH));
    wordRule.addWord("cm", createToken(CSSTokenType.LENGTH));
    wordRule.addWord("mm", createToken(CSSTokenType.LENGTH));
    wordRule.addWord("in", createToken(CSSTokenType.LENGTH));
    wordRule.addWord("pt", createToken(CSSTokenType.LENGTH));
    wordRule.addWord("pc", createToken(CSSTokenType.LENGTH));
    wordRule.addWord("deg", createToken(CSSTokenType.ANGLE));
    wordRule.addWord("rad", createToken(CSSTokenType.ANGLE));
    wordRule.addWord("grad", createToken(CSSTokenType.ANGLE));
    wordRule.addWord("ms", createToken(CSSTokenType.TIME));
    wordRule.addWord("s", createToken(CSSTokenType.TIME));
    wordRule.addWord("hz", createToken(CSSTokenType.FREQUENCY));
    wordRule.addWord("khz", createToken(CSSTokenType.FREQUENCY));
    wordRule.addWord("Hz", createToken(CSSTokenType.FREQUENCY));
    wordRule.addWord("kHz", createToken(CSSTokenType.FREQUENCY));
    addWordsToRule(wordRule, FUNCTIONS, CSSTokenType.FUNCTION);
    rules.add(wordRule);
    return rules;
}
项目:APICloud-Studio    文件:CSSTokenScanner.java   
/**
 * createUnitRules
 * 
 * @return
 */
protected List<IRule> createUnitRules()
{
    List<IRule> rules = new ArrayList<IRule>();

    // FIXME These are all really just numbers followed by measurements. Can't we modify scanner/parser to grab
    // number and then a measurement
    // XXX: The number and the units have to be connected without intermediate whitespace. Alternately, we could
    // make the parser changes as suggested but we would need to make sure the validators point out the error
    // condition

    rules.add(createUnitRule("em", CSSTokenType.EMS));
    rules.add(createUnitRule("px|cm|mm|in|pt|pc", CSSTokenType.LENGTH));
    rules.add(createUnitRule("%", CSSTokenType.PERCENTAGE));
    rules.add(createUnitRule("deg|rad|grad", CSSTokenType.ANGLE));
    rules.add(createUnitRule("ex", CSSTokenType.EXS));
    rules.add(createUnitRule("k?[Hh]z", CSSTokenType.FREQUENCY));
    rules.add(createUnitRule("m?s", CSSTokenType.TIME));

    return rules;
}
项目:Eclipse-Postfix-Code-Completion    文件:PropertyValueScanner.java   
@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;
}
项目:Eclipse-Postfix-Code-Completion    文件:JavaCommentScanner.java   
@Override
protected List<IRule> createRules() {
    List<IRule> list= new ArrayList<IRule>();
    Token defaultToken= getToken(fDefaultTokenProperty);

    List<WordMatcher> matchers= createMatchers();
    if (matchers.size() > 0) {
        CombinedWordRule combinedWordRule= new CombinedWordRule(new AtJavaIdentifierDetector(), defaultToken);
        for (int i= 0, n= matchers.size(); i < n; i++)
            combinedWordRule.addWordMatcher(matchers.get(i));
        list.add(combinedWordRule);
    }

    setDefaultReturnToken(defaultToken);

    return list;
}
项目:WP3    文件:RelationModelPartitionScanner.java   
public RelationModelPartitionScanner() {
  final IToken commentPartition = new Token(RelationModelPartitionScanner.RELATION_MODEL_COMMENT);
  final IToken optionPartition = new Token(RelationModelPartitionScanner.RELATION_MODEL_OPTION);
  final IToken universePartition =
      new Token(RelationModelPartitionScanner.RELATION_MODEL_UNIVERSE);
  final IToken relBoundPartition =
      new Token(RelationModelPartitionScanner.RELATION_MODEL_REL_BOUND);

  final List<IRule> rules = new ArrayList<IRule>();
  rules.add(new MultiLineRule("/**", "**/", commentPartition));
  rules.add(new EndOfLineRule("--", commentPartition));
  // rules.add(new EndOfLineRule("//", commentPartition));
  rules.add(new MultiLineRule("options {", "}", optionPartition));
  rules.add(new MultiLineRule("universe {", "}", universePartition));
  rules.add(new MultiLineRule("universe [", "]", universePartition));
  rules.add(new RelationBoundsRule("relations", "}", relBoundPartition));

  final IPredicateRule[] result = new IPredicateRule[rules.size()];
  rules.toArray(result);
  this.setPredicateRules(result);
}
项目:WP3    文件:ModelScanner.java   
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);
  }
项目: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;
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:PropertyValueScanner.java   
@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;
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:JavaCommentScanner.java   
@Override
protected List<IRule> createRules() {
    List<IRule> list= new ArrayList<IRule>();
    Token defaultToken= getToken(fDefaultTokenProperty);

    List<WordMatcher> matchers= createMatchers();
    if (matchers.size() > 0) {
        CombinedWordRule combinedWordRule= new CombinedWordRule(new AtJavaIdentifierDetector(), defaultToken);
        for (int i= 0, n= matchers.size(); i < n; i++)
            combinedWordRule.addWordMatcher(matchers.get(i));
        list.add(combinedWordRule);
    }

    setDefaultReturnToken(defaultToken);

    return list;
}
项目:Eclipse-Markdown-Editor-Plugin    文件:MDScanner.java   
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);
         }
      }),
   });
}
项目: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);
}
项目:eclipse-gn    文件:GnCodeScanner.java   
@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;
}
项目:birt    文件:SQLKeywordScanner.java   
/**
 *  
 */
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 ))));
}