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

项目: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);
  }
项目: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);
}
项目:http4e    文件:XMLPartitionScanner.java   
public XMLPartitionScanner() {

      IToken xmlComment = new Token(XML_COMMENT);
      IToken xmlPI = new Token(XML_PI);
      IToken startTag = new Token(XML_START_TAG);
      IToken endTag = new Token(XML_END_TAG);
      IToken docType = new Token(XML_DOCTYPE);
      IToken text = new Token(XML_TEXT);

      IPredicateRule[] rules = new IPredicateRule[7];

      rules[0] = new NonMatchingRule();
      rules[1] = new MultiLineRule("<!--", "-->", xmlComment);
      rules[2] = new MultiLineRule("<?", "?>", xmlPI);
      rules[3] = new MultiLineRule("</", ">", endTag);
      rules[4] = new StartTagRule(startTag);
      rules[5] = new MultiLineRule("<!DOCTYPE", ">", docType);
      rules[6] = new XMLTextPredicateRule(text);

      setPredicateRules(rules);
   }
项目: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    文件:XMLPartitionScanner.java   
public XMLPartitionScanner() {

        IToken xmlComment = new Token(XML_COMMENT);
        IToken xmlPI = new Token(XML_PI);
        IToken startTag = new Token(XML_START_TAG);
        IToken endTag = new Token(XML_END_TAG);
        IToken docType = new Token(XML_DOCTYPE);
        // IToken text = new Token(XML_TEXT);
        // IToken tag = new Token(XML_TAG);

        IPredicateRule[] rules = new IPredicateRule[6];

        rules[0] = new NonMatchingRule();
        rules[1] = new MultiLineRule("<!--", "-->", xmlComment, '\\', true);
        rules[2] = new MultiLineRule("<?", "?>", xmlPI);
        rules[3] = new MultiLineRule("</", ">", endTag);
        rules[4] = new StartTagRule(startTag);
        rules[5] = new MultiLineRule("<!DOCTYPE", ">", docType);

        // rules[6] = new XMLTextPredicateRule(text);
        // rules[7] = new TagRule(tag);

        setPredicateRules(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));
}
项目: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    文件:XMLPartitionScanner.java   
public XMLPartitionScanner()
{

    IToken xmlComment = new Token(XML_COMMENT);
    IToken xmlPI = new Token(XML_PI);
    IToken startTag = new Token(XML_START_TAG);
    IToken endTag = new Token(XML_END_TAG);
    IToken docType = new Token(XML_DOCTYPE);
    IToken text = new Token(XML_TEXT);

    IPredicateRule[] rules = new IPredicateRule[7];

    rules[0] = new NonMatchingRule();
    rules[1] = new MultiLineRule("<!--", "-->", xmlComment);
    rules[2] = new MultiLineRule("<?", "?>", xmlPI);
    rules[3] = new MultiLineRule("</", ">", endTag);
    rules[4] = new StartTagRule(startTag);
    rules[5] = new MultiLineRule("<!DOCTYPE", ">", docType);
    rules[6] = new XMLTextPredicateRule(text);

    setPredicateRules(rules);
}
项目: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);
}
项目:strutsclipse    文件:AbstractXmlParser.java   
protected IDocumentPartitioner createTagPartitioner(IDocument document,
        String[] tags) {
    IPredicateRule[] tagRules = new IPredicateRule[tags.length];
    for (int i = 0; i < tags.length; i++) {
        if (CLOSE_TAG_TOKEN.equals(tags[i])) {
            tagRules[i] = new MultiLineRule("</", ">", new Token(tags[i]));
        } else if (COMMENT_TOKEN.equals(tags[i])) {
            tagRules[i] = new MultiLineRule("<!--", "-->", new Token(
                    tags[i]));
        } else {
            tagRules[i] = new MultiLineRule("<" + tags[i], ">", new Token(
                    tags[i]));
        }
    }
    return createConnectPartitioner(document, tagRules, tags);
}
项目: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);
  }
项目: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);
}
项目: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);
         }
      }),
   });
}
项目: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()]));
}
项目: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( )] ) );

}
项目:wt-studio    文件:JsonScanner.java   
private void initScanner() {
    IToken string = new Token(new TextAttribute(getPreferenceColor(JsonPreferenceStore.STRING_COLOR)));
    IToken value = new Token(new TextAttribute(getPreferenceColor(JsonPreferenceStore.VALUE_COLOR)));
    IToken defaultText = new Token(new TextAttribute(getPreferenceColor(JsonPreferenceStore.DEFAULT_COLOR)));
    IToken nullValue = new Token(new TextAttribute(getPreferenceColor(JsonPreferenceStore.NULL_COLOR)));

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

    rules.add(new MultiLineRule(":\"", "\"", value, '\\'));
    rules.add(new MultiLineRule("\"", "\"", string, '\\')); //$NON-NLS-2$ //$NON-NLS-1$
    WordRule wordRule= new WordRule(new JsonWordDetector(), defaultText);
    wordRule.addWord("null", nullValue);
    rules.add(wordRule);
    rules.add(new WhitespaceRule(new JsonWhitespaceDetector()));

    IRule[] result= new IRule[rules.size()];
    rules.toArray(result);
    setRules(result);
}
项目: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()]));
}
项目: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);
}
项目: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    文件: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);
}
项目: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    文件: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);
}
项目: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));
}
项目:ncl30-eclipse    文件: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 NCLWhitespaceDetector());

    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    文件:ScannerComment.java   
@Override
protected List<IRule> createRules() {
    IToken hidden = getToken(Prefs.EDITOR_COMMENT_HIDDEN_COLOR);
    IToken visible = getToken(Prefs.EDITOR_COMMENT_VISIBLE_COLOR);

    List<IRule> rules = new ArrayList<IRule>();
    rules.add(new MultiLineRule("<!---", "--->", hidden, '\\'));
    rules.add(new MultiLineRule("<!--", "-->", visible, '\\'));
    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;
}
项目:gwt-eclipse-plugin    文件:GWTPartitionScanner.java   
public GWTPartitionScanner() {
  IToken jsniMethod = new Token(GWTPartitions.JSNI_METHOD);
  MultiLineRule jsniRule = new MultiLineRule("/*-{", "}-*/", jsniMethod);

  IPredicateRule[] result = new IPredicateRule[] {jsniRule};
  setPredicateRules(result);
}
项目: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);
}
项目: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));
}