org.eclipse.mtl.ide.ui.editors.template.rules
Class KeywordRule

java.lang.Object
  extended by org.eclipse.mtl.ide.ui.editors.template.rules.KeywordRule
All Implemented Interfaces:
org.eclipse.jface.text.rules.IPredicateRule, org.eclipse.jface.text.rules.IRule, ISequenceRule

public class KeywordRule
extends java.lang.Object
implements ISequenceRule

A rule to detect MTL keywords.


Constructor Summary
KeywordRule(java.lang.String keyword)
          Constructor.
KeywordRule(java.lang.String keyword, boolean wholeWord, boolean isIgnoreCase, org.eclipse.jface.text.rules.IToken token)
          Constructor.
 
Method Summary
 org.eclipse.jface.text.rules.IToken evaluate(org.eclipse.jface.text.rules.ICharacterScanner scanner)
          
 org.eclipse.jface.text.rules.IToken evaluate(org.eclipse.jface.text.rules.ICharacterScanner scanner, boolean resume)
          
 org.eclipse.jface.text.rules.IToken getSuccessToken()
          
protected  boolean nextIsNotIdentifierPart(org.eclipse.jface.text.rules.ICharacterScanner scanner)
          Indicates if the character after the candidate isn't an identifier part.
protected  boolean previousIsNotIdentifierPart(org.eclipse.jface.text.rules.ICharacterScanner scanner)
          Indicates if the character before the candidate isn't an identifier part.
 int read(org.eclipse.jface.text.rules.ICharacterScanner scanner)
          Evaluates the rule by examining the characters available from the provided character scanner.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

KeywordRule

public KeywordRule(java.lang.String keyword)
Constructor.

Parameters:
keyword - is the keyword name to detect

KeywordRule

public KeywordRule(java.lang.String keyword,
                   boolean wholeWord,
                   boolean isIgnoreCase,
                   org.eclipse.jface.text.rules.IToken token)
Constructor.

Parameters:
keyword - is the keyword name
wholeWord - indicates if the whole word mode is enabled
isIgnoreCase - indicates if case is ignored
token - is the token to use for this rule
Method Detail

getSuccessToken

public org.eclipse.jface.text.rules.IToken getSuccessToken()

Specified by:
getSuccessToken in interface org.eclipse.jface.text.rules.IPredicateRule
See Also:
IPredicateRule.getSuccessToken()

evaluate

public org.eclipse.jface.text.rules.IToken evaluate(org.eclipse.jface.text.rules.ICharacterScanner scanner)

Specified by:
evaluate in interface org.eclipse.jface.text.rules.IRule
See Also:
IRule.evaluate(org.eclipse.jface.text.rules.ICharacterScanner)

read

public int read(org.eclipse.jface.text.rules.ICharacterScanner scanner)
Evaluates the rule by examining the characters available from the provided character scanner.

Specified by:
read in interface ISequenceRule
Parameters:
scanner - is the character scanner to be used by this rule
Returns:
the number of examined characters
See Also:
ISequenceRule.read(org.eclipse.jface.text.rules.ICharacterScanner)

previousIsNotIdentifierPart

protected boolean previousIsNotIdentifierPart(org.eclipse.jface.text.rules.ICharacterScanner scanner)
Indicates if the character before the candidate isn't an identifier part.

Parameters:
scanner - is the scanner
Returns:
true if the character before the candidate isn't an identifier part

nextIsNotIdentifierPart

protected boolean nextIsNotIdentifierPart(org.eclipse.jface.text.rules.ICharacterScanner scanner)
Indicates if the character after the candidate isn't an identifier part.

Parameters:
scanner - is the scanner
Returns:
true if the character after the candidate isn't an identifier part

evaluate

public org.eclipse.jface.text.rules.IToken evaluate(org.eclipse.jface.text.rules.ICharacterScanner scanner,
                                                    boolean resume)

Specified by:
evaluate in interface org.eclipse.jface.text.rules.IPredicateRule
See Also:
IPredicateRule.evaluate(org.eclipse.jface.text.rules.ICharacterScanner, boolean)

Copyright 2008 Obeo
All Rights Reserved.