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

项目:eclipse-batch-editor    文件:BatchDocumentPartitionScanner.java   
private void buildWordRules(List<IPredicateRule> rules, IToken token, DocumentKeyWord[] values) {
    for (DocumentKeyWord keyWord : values) {
        ExactWordPatternRule rule1 = new ExactWordPatternRule(onlyLettersWordDetector, createWordStart(keyWord), token,
                keyWord.isBreakingOnEof());
        rule1.setAllowedPrefix('@');
        rule1.setAllowedPostfix(':');
        rules.add(rule1);

        ExactWordPatternRule rule2 = new ExactWordPatternRule(onlyLettersWordDetector, keyWord.getText().toUpperCase(), token,
                keyWord.isBreakingOnEof());
        rule2.setAllowedPrefix('@');
        rule2.setAllowedPostfix(':');
        rules.add(rule2);

    }
}
项目: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);
}
项目: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);
}
项目:texlipse    文件:BibPartitionScanner.java   
/**
 * Creates the partitioner and sets up the appropriate rules.
 */
public BibPartitionScanner() {
    super();

    IToken bibEntry = new Token(BIB_ENTRY);

    List 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 rules for BibTeX entries
    //rules.add(new MultiLineRule("{", "}", bibEntry, (char) 0, false));
    rules.add(new BibBraceRule(true, bibEntry));;

    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    文件: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);
}
项目:GLSL-Eclipse    文件:GlslPartitionScanner.java   
public GlslPartitionScanner() {
    IToken preprocessorToken = new Token(GLSL_PREPROCESSOR);
    IToken uniformToken = new Token(GLSL_UNIFORM);
    IToken variableToken = new Token(GLSL_VARIABLE);
    IToken commentToken = new Token(GLSL_COMMENT);

    setPredicateRules(new IPredicateRule[] {
        new SingleLineRule("#", null, preprocessorToken, '\0', true, false),
        new SingleLineRule("//", null, commentToken, '\0', true, false),
        new SingleLineRule("/*", "*/", commentToken),
        new DeclarationRule(uniformToken, new DeclarationSection[] {
            new DeclarationSection(Glsl.QUALIFIERS),
            new DeclarationSection(Glsl.TYPES)
        }),
        new DeclarationRule(variableToken, new DeclarationSection[] {
            new DeclarationSection(Glsl.TYPES)
        }),
    });
}
项目:APICloud-Studio    文件:CompositePartitionScanner.java   
/**
 * 
 */
public CompositePartitionScanner(ISubPartitionScanner defaultPartitionScanner, ISubPartitionScanner primaryPartitionScanner,
        IPartitionerSwitchStrategy partitionerSwitchStrategy) {
    this.defaultPartitionScanner = defaultPartitionScanner;
    this.primaryPartitionScanner = primaryPartitionScanner;

    defaultPartitionScanner.initCharacterScanner(this, partitionerSwitchStrategy.getDefaultSwitchStrategy());
    primaryPartitionScanner.initCharacterScanner(this, partitionerSwitchStrategy.getPrimarySwitchStrategy());

    String[][] pairs = partitionerSwitchStrategy.getSwitchTagPairs();
    switchRules = new IPredicateRule[pairs.length][];
    for (int i = 0; i < pairs.length; ++i) {
        switchRules[i] = new IPredicateRule[] { new SingleTagRule(pairs[i][0], new Token(START_SWITCH_TAG)), new SingleTagRule(pairs[i][1], new Token(END_SWITCH_TAG)) };
    }

    currentPartitionScanner = defaultPartitionScanner;
    setDefaultReturnToken(new Token(IDocument.DEFAULT_CONTENT_TYPE));
}
项目: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);
}
项目:strutsclipse    文件:AbstractXmlParser.java   
private IDocumentPartitioner createAttrPartitioner(IDocument document,
        String[] attrs) {
    IPredicateRule[] attrRules = new IPredicateRule[attrs.length + 2];
    attrRules[0] = new SingleLineRule("\"", "\"", new Token(
            DOUBLE_QUOTES_TOKEN));
    attrRules[1] = new SingleLineRule("'", "'", new Token(
            SINGLE_QUOTES_TOKEN));

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

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

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

    return createConnectPartitioner(document, attrRules, types);
}
项目: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);
}
项目: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()]));
}
项目: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()]));
}
项目: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));
    }

}
项目:eclipse-jenkins-editor    文件:JenkinsDocumentPartitionScanner.java   
@Override
protected void addOtherRules(List<IPredicateRule> rules) {
    IToken jenkinsDefaultClosureKeywords = createToken(JENKINS_KEYWORD);
    IToken jenkinsVariables = createToken(JENKINS_VARIABLE);

    buildWordRules(rules, jenkinsDefaultClosureKeywords, JenkinsDefaultClosureKeyWords.values(),onlyLettersWordDetector);
    buildWordRules(rules, jenkinsVariables, JenkinsSpecialVariableKeyWords.values(),onlyLettersWordDetector);
}
项目:eclipse-batch-editor    文件:BatchDocumentPartitionScanner.java   
public BatchDocumentPartitionScanner() {
        IToken echoOutput = createToken(ECHO_OUTPUT);
        IToken parameters = createToken(PARAMETER);
        IToken comment = createToken(COMMENT);
        IToken doubleString = createToken(DOUBLE_STRING);

        IToken batchBuildIn = createToken(BATCH_KEYWORD);

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

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

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

        rules.add(new CommandParameterRule(parameters));

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

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

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

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

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

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

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

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

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

        rules.add(new CommandParameterRule(parameters));

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

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

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

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

    return new FastPartitioner(scanner, CONTENT_TYPES);
}
项目: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;
}
项目: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);
}
项目:egradle    文件:GradleDocumentPartitionScanner.java   
protected void addOtherRules(List<IPredicateRule> rules) {
    IToken gradleClosureKeywords = createToken(GRADLE_KEYWORD);
    IToken gradleVariable = createToken(GRADLE_VARIABLE);
    IToken gradleApplyKeyWord = createToken(GRADLE_APPLY_KEYWORD);
    IToken gradleTaskKeyWord = createToken(GRADLE_TASK_KEYWORD);


    buildWordRules(rules, gradleClosureKeywords, GradleDefaultClosureKeyWords.values(),onlyLettersWordDetector);
    buildWordRules(rules, gradleApplyKeyWord, GradleApplyKeyWords.values(),onlyLettersWordDetector);
    buildWordRules(rules, gradleTaskKeyWord, GradleTaskKeyWords.values(),onlyLettersWordDetector);
    buildWordRules(rules, gradleVariable, GradleSpecialVariableKeyWords.values(),onlyLettersWordDetector);
}
项目: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    文件:GradlePartitionScanner.java   
public GradlePartitionScanner() {
    IToken jsDocToken = new Token(GRADLEDOC);
    IToken multilineCommentToken = new Token(MULTILINE_COMMENT);

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

   setPredicateRules(new IPredicateRule[] { 
         new SingleLineRule(AssistConstants.PARAM_DELIM_EQ, null, propertyValue, '\\', true, true), 
         new SingleLineRule("#", null, comment, (char) 0, true, true), });
}
项目:tlaplus    文件:TagBasedTLCOutputTokenScanner.java   
public TagBasedTLCOutputTokenScanner()
{
    Vector<IPredicateRule> rules = new Vector<IPredicateRule>();

    rules.add(new TLCSingleLineRule(RULE_START, TAIL_DELIM + "\n", new Token(TAG_OPEN)));
    rules.add(new TLCSingleLineRule(RULE_END, TAIL_DELIM + "\n", new Token(TAG_CLOSED)));
    rules.add(new TLCMultiLineRule(new Token(DEFAULT_CONTENT_TYPE)));

    // add the rules
    setPredicateRules((IPredicateRule[]) rules.toArray(new IPredicateRule[rules.size()]));
}
项目: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);
}
项目:brainfuck    文件:BfPartitionScanner.java   
public BfPartitionScanner() {
    super();
    IPredicateRule bfCodeRule = new BfCodeRule();
    /*
     * MUST break on EOF, otherwise reparsing breaks when closing the comment section after being incomplete
     */
    IPredicateRule multiLineCommentRule = new CommentRule();
    IPredicateRule templateParametersRule = new TemplateParametersRule();

    this.setPredicateRules(new IPredicateRule[]{multiLineCommentRule, bfCodeRule, templateParametersRule});
}
项目: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));
}