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

项目: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));
}
项目:goclipse    文件:LangPartitionScanner.java   
/***
 * Add some partition rules common to C-style languages.
 * All rules are optional, if an id is null, the rule will not be added.
 */
protected static void addStandardRules(ArrayList2<IPredicateRule> rules, 
        String lineCommentId, String blockCommentId, 
        String docLineCommentId, String docBlockCommentId,
        String stringId) {
    if(docLineCommentId != null) {
        rules.add(new PatternRule("///", null, new Token(docLineCommentId), NO_ESCAPE_CHAR, true, true));
    }
    if(docBlockCommentId != null) {
        rules.add(new PatternRule("/**", "*/", new Token(docBlockCommentId), NO_ESCAPE_CHAR, false, true));
    }

    if(lineCommentId != null) {
        rules.add(new PatternRule("//", null, new Token(lineCommentId), NO_ESCAPE_CHAR, true, true));
    }
    if(blockCommentId != null) {
        rules.add(new PatternRule("/*", "*/", new Token(blockCommentId), NO_ESCAPE_CHAR, false, true));
    }

    if(stringId != null) {
        rules.add(new PatternRule("\"", "\"", new Token(stringId), '\\', false, true));
    }

}
项目:vertigo-chroma-kspplugin    文件:KspDocumentSetupParticipant.java   
private IPartitionTokenScanner createKspPartitionScanner() {
    RuleBasedPartitionScanner scanner = new RuleBasedPartitionScanner();
    scanner.setPredicateRules(new IPredicateRule[] {
    /* String entre double quote. */
    new PatternRule("\"", "\"", new Token(KspRegionType.STRING.getContentType()), '\\', false),
    /* Commentaire multi-lignes */
    new PatternRule("/*", "*/", new Token(KspRegionType.COMMENT.getContentType()), '\\', false),
    /* Commentaire fin de ligne */
    new EndOfLineRule("//", new Token(KspRegionType.COMMENT.getContentType())) });
    return scanner;
}
项目:vertigo-chroma-kspplugin    文件:KspCommentScanner.java   
private IRule[] extractRules() {
    IToken comment = new Token(new TextAttribute(new Color(Display.getCurrent(), commentColor), null, SWT.NORMAL));
    return new IRule[] {
    /* Commentaire multi-ligne */
    new PatternRule("/*", "*/", comment, NO_ESCAPE_CHAR, false),
    /* Commentaire à la fin d'une ligne */
    new EndOfLineRule("//", comment) };
}
项目:Tarski    文件:RelationModelPartitionScanner.java   
public RelationModelPartitionScanner() {
    final IToken commentPartition = new Token(RelationModelPartitionScanner.RELATION_MODEL_COMMENT);
    final IToken valuesPartition = new Token(RelationModelPartitionScanner.RELATION_MODEL_VALUES);

    final List<IRule> rules = new ArrayList<IRule>();
    rules.add(new MultiLineRule("/*", "*/", commentPartition));
    rules.add(new EndOfLineRule("//", commentPartition));
    rules.add(new PatternRule("\"", "\"", valuesPartition, (char) 0, true));

    final IPredicateRule[] result = new IPredicateRule[rules.size()];
    rules.toArray(result);
    this.setPredicateRules(result);
}
项目:velocity-edit    文件:VelocityCodeScanner.java   
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);
}
项目:velocity-edit    文件:HTMLTagScanner.java   
public HTMLTagScanner(VelocityColorProvider manager)
{
    fDefaultToken = manager.getToken(IColorConstants.HTML_ATTRIBUTE);
    fElementToken = manager.getToken(IColorConstants.HTML_TAG);
    fEndElementToken = manager.getToken(IColorConstants.HTML_ENDTAG);
    IToken string = manager.getToken(IColorConstants.HTML_String);
    Vector rules = new Vector();
    setDefaultReturnToken(fDefaultToken);
    fElementRule = new WordRule(new HTMLElementDetector(), fDefaultToken);
    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);
    }
    rules.add(wordRule);

    rules.add(new PatternRule("\"", "\"", string, '\0', true));
    rules.add(new PatternRule("'", "'", string, '\0', true));
    rules.add(new WhitespaceRule(new WhitespaceDetector()));
    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));
    IRule[] result = new IRule[rules.size()];
    rules.copyInto(result);
    setRules(result);
}
项目:BYONDclipse    文件:DMPartitionScanner.java   
public DMPartitionScanner()
{
    final IToken dmComment                                  = new Token(DM_COMMENT);
    final IToken dmString                                   = new Token(DM_STRING);

    final IPredicateRule[] rules                            = new IPredicateRule[5];

    rules[0]                                                = new MultiLineRule("/*", "*/", dmComment);
    rules[1]                                                = new EndOfLineRule("//", dmComment, '\\', true);
    rules[2]                                                = new MultiLineRule("{\"", "\"}", dmString);
    rules[3]                                                = new DMStringRule(dmString);
    rules[4]                                                = new PatternRule("'", "'", dmString, '\\', true, true, true);

    this.setPredicateRules(rules);
}
项目:WP3    文件:RelationModelPartitionScanner.java   
public RelationModelPartitionScanner() {
    final IToken commentPartition = new Token(RelationModelPartitionScanner.RELATION_MODEL_COMMENT);
    final IToken valuesPartition = new Token(RelationModelPartitionScanner.RELATION_MODEL_VALUES);

    final List<IRule> rules = new ArrayList<IRule>();
    rules.add(new MultiLineRule("/*", "*/", commentPartition));
    rules.add(new EndOfLineRule("//", commentPartition));
    rules.add(new PatternRule("\"", "\"", valuesPartition, (char) 0, true));

    final IPredicateRule[] result = new IPredicateRule[rules.size()];
    rules.toArray(result);
    this.setPredicateRules(result);
}
项目:dLabPro-Plugin    文件:CommonDocumentPartitionScanner.java   
/**
 * 
 * @return the list of rules to find document partitions
 */
protected List createRules()
{
  List rules = new ArrayList();
  rules.add(new EndOfLineRule("#", commentToken));

  for (int i = 0; i < IKeywordConstants.SINGLE_SEGMENT_KEYWORDS.length; i++)
    rules.add(new EolRule(IKeywordConstants.SINGLE_SEGMENT_KEYWORDS[i], syntaxOffEolToken));

  rules.add(new SingleLineRule("${", "}", preprocessorWithBracketsToken/* ,'\\' */));
  rules.add(new SingleLineRule("$[", "]", preprocessorWithBracketsToken/* ,'\\' */));
  rules.add(new PreprocessorWithLeadingDollarRule(preprocessorWithLeading$Token));

  rules.add(new PatternRule("\"", "\"", characterChainToken, '\\', true, true, true));
  // rules.add(new PatternRule("'", "'", characterChainToken, '\\', true, true, true));

  // rules.add(new FormularRule(formelInterpreterToken));

  // rules
  // .add(new SingleLineRule("${", "}", preprocessorWithBracketsToken/* ,'\\' */));
  // rules
  // .add(new SingleLineRule("$[", "]", preprocessorWithBracketsToken/* ,'\\' */));
  // rules.add(new PreprocessorWithLeadingDollarRule(
  // preprocessorWithLeading$Token));

  rules.add(new CodeRule(syntaxOffToken));
  for (int i = 0; i < IKeywordConstants.SYNTAX_OFF_SEGMENT_START_KEYWORDS.length; i++)
    if (IKeywordConstants.SYNTAX_OFF_SEGMENT_START_KEYWORDS[i].endsWith("CODE:")
        && !IKeywordConstants.SYNTAX_OFF_SEGMENT_START_KEYWORDS[i].equals("CODE:")) rules
        .add(new MultiLineRule(IKeywordConstants.SYNTAX_OFF_SEGMENT_START_KEYWORDS[i],
            "END_CODE", syntaxOffToken));

  // rules.add(new MultiLineRule("CODE:", "END_CODE", syntaxOffToken));
  rules.add(new MultiLineRule("MAN:", "END_MAN", syntaxOffToken));
  rules.add(new MultiLineRule("<%", "%>", syntaxOffToken));
  // rules.add(new StartOfLineRule(";",formelInterpreterToken));

  return rules;
}
项目:dLabPro-Plugin    文件:CharacterChainScanner.java   
/**
 * this method overrides createRules() from the superclass
 * 
 * @see AbstractScanner#createRules()
 */
protected List createRules()
{
  List list = new ArrayList();
  IToken characterChainToken = getToken(IPreferenceConstants.P_CLR_STRING);
  list.add(new PatternRule("\"", "\"", characterChainToken, '\\', true, true, true));
  // list.add(new PatternRule("'", "'", characterChainToken, '\\', true, true, true));
  setDefaultReturnToken(getToken(IPreferenceConstants.DEFAULT));
  return list;
}