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

项目: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);
  }
项目: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);
}
项目: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);
}
项目: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;
}
项目: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);
}
项目: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;
}
项目: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);
}
项目: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()]));
}
项目: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    文件:SQLPartitionScanner.java   
/**
 *  
 */
public SQLPartitionScanner( )
{
    super( );
    IToken sqlComment = new Token( COMMENT );
    IToken sqlQuoteString = new Token( QUOTE_STRING );


    ArrayList rules = new ArrayList( );
    rules.add( new MultiLineRule( "\"", "\"", sqlQuoteString, '\\' ) ); //$NON-NLS-1$ //$NON-NLS-2$
    rules.add( new MultiLineRule( "\'", "\'", sqlQuoteString, '\\' ) ); //$NON-NLS-1$ //$NON-NLS-2$
    rules.add( new EndOfLineRule( "//", sqlComment ) ); //$NON-NLS-1$
    rules.add( new EndOfLineRule( "--", sqlComment ) ); //$NON-NLS-1$
    rules.add( new MultiLineRule( "/*", "*/", sqlComment ) ); //$NON-NLS-1$ //$NON-NLS-2$

    setPredicateRules( (IPredicateRule[]) 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()]));
}
项目: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    文件:RelBoundScanner.java   
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);
}
项目:Tarski    文件:ValidationPartitionScanner.java   
public ValidationPartitionScanner() {
  final IToken comment = new Token(VALIDATION_COMMENT);
  final IToken model = new Token(VALIDATION_MODEL);

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

  rules[0] = new MultiLineRule("/**", "**/", comment);
  rules[1] = new EndOfLineRule("--", comment);
  rules[2] = new ModelRule(model);

  this.setPredicateRules(rules);
}
项目: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);
}
项目: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$
    });
}
项目:texlipse    文件:BibCodeScanner.java   
/**
 * 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);
}
项目:texlipse    文件:TexScanner.java   
/**
 * 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);
}
项目:hybris-commerce-eclipse-plugin    文件:InstructionsRuleScanner.java   
public InstructionsRuleScanner(ColorProvider provider) {
    IToken stringToken = new Token(new TextAttribute(provider.getColor(PreferenceConverter.getColor(store, PreferenceConstants.P_STRING_COLOR))));
    IToken commentToken = new Token(new TextAttribute(provider.getColor(PreferenceConverter.getColor(store, PreferenceConstants.P_COMMENT_COLOR))));
    IToken instructToken = new Token(new TextAttribute(provider.getColor(PreferenceConverter.getColor(store, PreferenceConstants.P_INSTRUCT_COLOR)), null, Font.ITALIC));
    IToken definitionsToken = new Token(new TextAttribute(provider.getColor(PreferenceConverter.getColor(store, PreferenceConstants.P_DEF_COLOR)), null, Font.ITALIC));

    List<IRule> rules = Lists.newArrayList();
    // rule for Strings - may spanning multiple lines
    rules.add(new MultiLineRule("\"", "\"", stringToken));
    rules.add(new MultiLineRule("\'", "\'", stringToken));
    rules.add(new EndOfLineRule("#%", instructToken));
    // rule for comments - ended by a line delimiter
    rules.add(new EndOfLineRule("//", commentToken));

    WordRule wordRule = RuleFactory.buildRule(ImpexRules.KEYWORD, null);        
    // rule for instructions
    for (String word : Formatter.INSTRUCTION_CLASS_PROPOSALS) {
        wordRule.addWord(word, instructToken);
    }

    rules.add(wordRule);

    // rule for definitions
    wordRule = RuleFactory.buildRule(ImpexRules.VARIABLE, definitionsToken);
    rules.add(wordRule);
    IRule[] ruleArray = new IRule[rules.size()];
    setRules(rules.toArray(ruleArray));
}
项目: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);
    }
项目: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);
}
项目:eclipse-kernelsyntax    文件:KernelSyntaxLangC.java   
private MyCommentScanner() {
  IToken commentToken = new Token(new TextAttribute(KSC_COMMENT));
  IRule[] rules = new IRule[] {
    new MultiLineRule("/*","*/",commentToken),
    new EndOfLineRule("//",commentToken),
  };
  setRules(rules);
}
项目:eclipse-kernelsyntax    文件:KernelSyntaxLangC.java   
public void attachPartitionRule(List<IPredicateRule> rules) {
    IToken tokenComment = new Token(KSP_COMMENT);
    IToken tokenString = new Token(KSP_STRING);
    IToken tokenMacro = new Token(KSP_MACRO);
    rules.add(new EndOfLineRule("//", tokenComment));
    rules.add(new EndOfLineRule("#", tokenMacro));
    rules.add(new MultiLineRule("/*", "*/", tokenComment, (char)0, true));
    rules.add(new MultiLineRule("\"", "\"", tokenString, '\\', true));
    rules.add(new MultiLineRule("\'", "\'", tokenString, '\\', true));
}
项目:eclipse-kernelsyntax    文件:KernelSyntaxLangShell.java   
public void attachPartitionRule(List<IPredicateRule> rules) {
    IToken tokenComment = new Token(KSP_COMMENT);
    IToken tokenString = new Token(KSP_STRING);
    //rules.add(new EndOfLineRule("#!", tokenMetadata));
    EndOfLineRule commentRule = new EndOfLineRule("#", tokenComment);
    commentRule.setColumnConstraint(0);
    rules.add(commentRule);
    rules.add(new EndOfLineRule(" #", tokenComment));
    rules.add(new EndOfLineRule("\t#", tokenComment));
    rules.add(new MultiLineRule("\"", "\"", tokenString, '\\', true));
    rules.add(new MultiLineRule("\'", "\'", tokenString, '\\', true));
    rules.add(new MultiLineRule("`", "`", tokenString, '\\', true));
}
项目:eclipse-kernelsyntax    文件:KernelSyntaxLangPython.java   
public void attachPartitionRule(List<IPredicateRule> rules) {
    IToken tokenComment = new Token(KSP_COMMENT);
    IToken tokenString = new Token(KSP_STRING);
    IToken tokenMetadata = new Token(KSP_METADATA);
    rules.add(new EndOfLineRule("@", tokenMetadata));
    rules.add(new EndOfLineRule("#", tokenComment));
    rules.add(new MultiLineRule("\"", "\"", tokenString, '\\', true));
    rules.add(new MultiLineRule("\'", "\'", tokenString, '\\', true));
    rules.add(new MultiLineRule("\"\"\"", "\"\"\"", tokenString, '\\', true));
    rules.add(new MultiLineRule("\'\'\'", "\'\'\'", tokenString, '\\', true));
}
项目:eclipse-kernelsyntax    文件:KernelSyntaxLang.java   
public void attachPartitionRule(List<IPredicateRule> rules) {
    IToken tokenComment = new Token(KSP_COMMENT);
    IToken tokenString = new Token(KSP_STRING);
    IToken tokenMacro = new Token(KSP_MACRO);
    rules.add(new EndOfLineRule("//", tokenComment));
    rules.add(new EndOfLineRule("#", tokenMacro));
    rules.add(new MultiLineRule("/*", "*/", tokenComment, (char)0, true));
    rules.add(new MultiLineRule("\"", "\"", tokenString, '\\', true));
    rules.add(new MultiLineRule("\'", "\'", tokenString, '\\', true));
}
项目: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),
  });
}
项目: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);
}
项目:Eclipse-Postfix-Code-Completion    文件:JavaPartitionScanner.java   
/**
 * Creates the partitioner and sets up the appropriate rules.
 */
public JavaPartitionScanner() {
    super();

    IToken string= new Token(JAVA_STRING);
    IToken character= new Token(JAVA_CHARACTER);
    IToken javaDoc= new Token(JAVA_DOC);
    IToken multiLineComment= new Token(JAVA_MULTI_LINE_COMMENT);
    IToken singleLineComment= new Token(JAVA_SINGLE_LINE_COMMENT);

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

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

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

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

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

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

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