org.eclipse.jface.text.rules.IPredicateRule Java Examples

The following examples show how to use org.eclipse.jface.text.rules.IPredicateRule. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: XMLPartitionScanner.java    From http4e with Apache License 2.0 6 votes vote down vote up
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);
   }
 
Example #2
Source File: BibPartitionScanner.java    From texlipse with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * 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);
}
 
Example #3
Source File: ModulaRuleBasedPartitionScanner.java    From xds-ide with Eclipse Public License 1.0 6 votes vote down vote up
public ModulaRuleBasedPartitionScanner() {
	super();
	
       // Create the list of rules that produce tokens
	inactiveCodeRule = new InactiveCodeRule();
	IPredicateRule[] rules = new IPredicateRule[] {
		inactiveCodeRule,
	    new EndOfLineRule("--", END_OF_LINE_COMMENT_TOKEN), //$NON-NLS-1$
	    new ModulaCommentRule(BLOCK_COMMENT_TOKEN),
                            
           new SingleLineRule("\"", "\"", DOUBLE_QUOTE_STRING_TOKEN), //$NON-NLS-1$ //$NON-NLS-2$
           new SingleLineRule("'", "'",   SINGLE_QUOTE_STRING_TOKEN), //$NON-NLS-1$ //$NON-NLS-2$

	    new MultiLineRule("<*", "*>", PRAGMA_TOKEN, (char)0, true) //$NON-NLS-1$ //$NON-NLS-2$
	};

	setPredicateRules(rules);
       setDefaultReturnToken(DEFAULT_TOKEN);
}
 
Example #4
Source File: LangPartitionScanner.java    From goclipse with Eclipse Public License 1.0 6 votes vote down vote up
/***
 * 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));
	}
	
}
 
Example #5
Source File: SamplePartitionScanner.java    From goclipse with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * 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()]));
}
 
Example #6
Source File: SQLPartitionScanner.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
/**
 *  
 */
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( )] ) );

}
 
Example #7
Source File: CompositePartitionScanner.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
/**
 * 
 */
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));
}
 
Example #8
Source File: GroovyExpressionPartitioner.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
private static IPartitionTokenScanner createDefaultScanner() {
    final IToken string = new Token(PatternExpressionViewer.GROOVY_EXPRESSION_CONTENT_TYPE);
    final RuleBasedPartitionScanner scanner = new RuleBasedPartitionScanner();
    scanner.setPredicateRules(new IPredicateRule[] {
            new MultiLineRule(GROOVY_START_TAG, GROOVY_END_TAG, string)
    });
    return scanner;
}
 
Example #9
Source File: HPartitionScanner.java    From http4e with Apache License 2.0 5 votes vote down vote up
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), });
}
 
Example #10
Source File: GoPartitionScanner.java    From goclipse with Eclipse Public License 1.0 5 votes vote down vote up
@Override
protected void initPredicateRules(ArrayList2<IPredicateRule> rules) {
	addStandardRules(rules, 
		LangPartitionTypes.LINE_COMMENT.getId(), 
		LangPartitionTypes.BLOCK_COMMENT.getId(), 
		null, 
		null, 
		null
	);
	
	rules.add(new SingleLineRule("'", "'", new Token(LangPartitionTypes.CHARACTER.getId()), '\\'));
	rules.add(new MultiLineRule("`", "`", new Token(LangPartitionTypes.MULTILINE_STRING.getId())));
	rules.add(new SingleLineRule("\"", "\"", new Token(LangPartitionTypes.STRING.getId()), '\\'));
}
 
Example #11
Source File: PartitionScanner.java    From textuml with Eclipse Public License 1.0 5 votes vote down vote up
public PartitionScanner() {
    super();
    final IToken comment = new Token(ContentTypes.COMMENT_CONTENT_TYPE);
    final IPredicateRule[] rules = new IPredicateRule[2];
    rules[0] = new MultiLineRule("/*", "*/", comment);
    rules[1] = new MultiLineRule("(*", "*)", comment);
    this.setPredicateRules(rules);
}
 
Example #12
Source File: CalcitePartitionScanner.java    From mat-calcite-plugin with Apache License 2.0 5 votes vote down vote up
public CalcitePartitionScanner() {
	IToken comment = new Token(SQL_COMMENT);
	IToken string = new Token(SQL_STRING);
	IToken quotedIdentifier = new Token(SQL_QUOTED_IDENTIFIER);

	setPredicateRules(new IPredicateRule[] {
			new EndOfLineRule("//", comment),
			new EndOfLineRule("--", comment),
			new MultiLineRule("/*", "*/", comment),
			new SingleLineRule("\"", "\"", quotedIdentifier),
			new MultiLineRule("'", "'", string),
	});
}
 
Example #13
Source File: EditorConfigPartitionScanner.java    From editorconfig-eclipse with Apache License 2.0 5 votes vote down vote up
/**
 * Creates the partitioner and sets up the appropriate rules.
 */
public EditorConfigPartitionScanner() {
	super();

	IToken comment = new Token(COMMENT);
	IToken sectionName = new Token(SECTION);
	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 sections.
	rules.add(new SingleLineRule("[", "]", sectionName, '\\', true, 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);
}
 
Example #14
Source File: JavaPartitionScanner.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * 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);
}
 
Example #15
Source File: PropertiesFilePartitionScanner.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * 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);
}
 
Example #16
Source File: CompositePartitionScanner.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
private static void resetRules(IPredicateRule[] rules) {
	for (IPredicateRule rule : rules) {
		if (rule instanceof IResumableRule) {
			((IResumableRule) rule).resetRule();
		}
	}
}
 
Example #17
Source File: TagBasedTLCOutputTokenScanner.java    From tlaplus with MIT License 5 votes vote down vote up
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()]));
}
 
Example #18
Source File: GWTPartitionScanner.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 5 votes vote down vote up
public GWTPartitionScanner() {
  IToken jsniMethod = new Token(GWTPartitions.JSNI_METHOD);
  MultiLineRule jsniRule = new MultiLineRule("/*-{", "}-*/", jsniMethod);

  IPredicateRule[] result = new IPredicateRule[] {jsniRule};
  setPredicateRules(result);
}
 
Example #19
Source File: CSSSourceConfiguration.java    From APICloud-Studio with GNU General Public License v3.0 4 votes vote down vote up
public IPredicateRule[] getPartitioningRules()
{
	return partitioningRules;
}
 
Example #20
Source File: RuleBasedPartitionScannerExt.java    From goclipse with Eclipse Public License 1.0 4 votes vote down vote up
public void setPredicateRules(IPredicateRule[] rules) {
	super.setRules(rules);
}
 
Example #21
Source File: RuleBasedPartitionScannerExt.java    From goclipse with Eclipse Public License 1.0 4 votes vote down vote up
@SuppressWarnings("unused")
protected void initPredicateRules(ArrayList2<IPredicateRule> rules) {
}
 
Example #22
Source File: RuleBasedPartitionScannerExt.java    From goclipse with Eclipse Public License 1.0 4 votes vote down vote up
public RuleBasedPartitionScannerExt() {
	ArrayList2<IPredicateRule> rules = new ArrayList2<>();
	initPredicateRules(rules);
	setPredicateRules(rules.toArray(IPredicateRule.class));
}
 
Example #23
Source File: SVGSourceConfiguration.java    From APICloud-Studio with GNU General Public License v3.0 4 votes vote down vote up
public IPredicateRule[] getPartitioningRules()
{
	return partitioningRules;
}
 
Example #24
Source File: XMLSourceConfiguration.java    From APICloud-Studio with GNU General Public License v3.0 4 votes vote down vote up
public IPredicateRule[] getPartitioningRules()
{
	return partitioningRules;
}
 
Example #25
Source File: JSPartitionScanner.java    From birt with Eclipse Public License 1.0 4 votes vote down vote up
private void setRuleList( List rules )
{
	IPredicateRule[] result = new IPredicateRule[rules.size( )];
	rules.toArray( result );
	setPredicateRules( result );
}
 
Example #26
Source File: JSSourceConfiguration.java    From APICloud-Studio with GNU General Public License v3.0 4 votes vote down vote up
public IPredicateRule[] getPartitioningRules()
{
	return partitioningRules;
}
 
Example #27
Source File: DTDSourceConfiguration.java    From APICloud-Studio with GNU General Public License v3.0 4 votes vote down vote up
public IPredicateRule[] getPartitioningRules() {
	return partitioningRules;
}
 
Example #28
Source File: CompositePartitionScanner.java    From APICloud-Studio with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void setPredicateRules(IPredicateRule[] rules) {
	throw new UnsupportedOperationException("unsupported method"); //$NON-NLS-1$
}
 
Example #29
Source File: HTMLSourceConfiguration.java    From APICloud-Studio with GNU General Public License v3.0 4 votes vote down vote up
public IPredicateRule[] getPartitioningRules()
{
	return partitioningRules;
}
 
Example #30
Source File: NullSubPartitionScanner.java    From APICloud-Studio with GNU General Public License v3.0 4 votes vote down vote up
public IPredicateRule[] getRules() {
	return EMPTY;
}