本文整理匯總了Java中org.eclipse.jface.text.rules.IToken類的典型用法代碼示例。如果您正苦於以下問題:Java IToken類的具體用法?Java IToken怎麽用?Java IToken使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
IToken類屬於org.eclipse.jface.text.rules包,在下文中一共展示了IToken類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: nextToken
import org.eclipse.jface.text.rules.IToken; //導入依賴的package包/類
@Override
public IToken nextToken() {
if (currentTemplateTextToken != null) {
if (currentTemplateTextToken.hasNext())
return currentTemplateTextToken.nextToken();
else
currentTemplateTextToken = null;
}
if (!getIterator().hasNext())
return Token.EOF;
ILexerTokenRegion next = getIterator().next();
int tokenType = next.getLexerTokenType();
switch (tokenType) {
case RULE_TEMPLATE_HEAD:
case RULE_TEMPLATE_MIDDLE: {
currentTemplateTextToken = createTemplateToken(tokenType, next);
return currentTemplateTextToken.nextToken();
}
default:
setCurrentToken(next);
return createToken(next);
}
}
示例2: buildWordRules
import org.eclipse.jface.text.rules.IToken; //導入依賴的package包/類
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);
}
}
示例3: evaluate
import org.eclipse.jface.text.rules.IToken; //導入依賴的package包/類
@Override
public IToken evaluate(ICharacterScanner scanner1, boolean resume) {
if (!(scanner1 instanceof BatchDocumentPartitionScanner)){
return Token.UNDEFINED;
}
BatchDocumentPartitionScanner scanner = (BatchDocumentPartitionScanner)scanner1;
if (scanner.getOffset()<ECHO.length()){
/* would be a problem on start on going back...*/
return Token.UNDEFINED;
}
scanner.unread(); // go to character before
int charBeforeAsInt = scanner.read(); // get character, moves to origin pos again
/* fast guard closing:*/
if (charBeforeAsInt!='o' && charBeforeAsInt!='O'){ // echo ECHO <- last character must be an o other wise guard close...
return Token.UNDEFINED;
}
ICharacterScannerCodePosSupport codePosSupport = new ICharacterScannerCodePosSupport(scanner);
if (parserSupport.isAfterEchoHandled(codePosSupport)){
return getSuccessToken();
}
codePosSupport.resetToStartPos();
return Token.UNDEFINED;
}
示例4: evaluate
import org.eclipse.jface.text.rules.IToken; //導入依賴的package包/類
@Override
public IToken evaluate(ICharacterScanner scanner, boolean resume) {
int r = scanner.read();
scanner.unread();
/* fast guard closing:*/
if (ICharacterScanner.EOF==r || r!='<'){
return Token.UNDEFINED;
}
ICharacterScannerCodePosSupport codePosSupport = new ICharacterScannerCodePosSupport(scanner);
if (hereStringSupport.isHereStringStateHandled(codePosSupport)){
return getSuccessToken();
}
codePosSupport.resetToStartPos();
return Token.UNDEFINED;
}
示例5: evaluate
import org.eclipse.jface.text.rules.IToken; //導入依賴的package包/類
@Override
public IToken evaluate(ICharacterScanner scanner, boolean resume) {
int r = scanner.read();
scanner.unread();
/* fast guard closing:*/
if (ICharacterScanner.EOF==r || r!='<'){
return Token.UNDEFINED;
}
ICharacterScannerCodePosSupport codePosSupport = new ICharacterScannerCodePosSupport(scanner);
if (hereDocSupport.isHereDocStateHandled(codePosSupport)){
return getSuccessToken();
}
codePosSupport.resetToStartPos();
return Token.UNDEFINED;
}
示例6: RelationModelPartitionScanner
import org.eclipse.jface.text.rules.IToken; //導入依賴的package包/類
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);
}
示例7: doEvaluate
import org.eclipse.jface.text.rules.IToken; //導入依賴的package包/類
@Override
protected IToken doEvaluate(final ICharacterScanner scanner, final boolean resume) {
if (resume) {
if (this.endSequenceDetected(scanner)) {
return this.fToken;
}
} else {
final int c = scanner.read();
if (c == this.fStartSequence[0]) {
if (this.sequenceDetected(scanner, this.fStartSequence, false)) {
if (this.endSequenceDetected(scanner)) {
return this.fToken;
}
}
}
}
scanner.unread();
return Token.UNDEFINED;
}
示例8: ModelScanner
import org.eclipse.jface.text.rules.IToken; //導入依賴的package包/類
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);
}
示例9: evaluate
import org.eclipse.jface.text.rules.IToken; //導入依賴的package包/類
public IToken evaluate(ICharacterScanner scanner) {
buffer.setLength(0);
int c = read(scanner);
if (c == '&') {
int i = 0;
do {
c = read(scanner);
i++;
if (c == '<' || c == ']') {
for (int j = i - 1; j > 0; j--)
scanner.unread();
return Token.UNDEFINED;
}
} while (c != ';');
return fToken;
}
scanner.unread();
return Token.UNDEFINED;
}
示例10: addGroovyRules
import org.eclipse.jface.text.rules.IToken; //導入依賴的package包/類
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);
}
示例11: EiffelPartitionScanner
import org.eclipse.jface.text.rules.IToken; //導入依賴的package包/類
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);
}
示例12: createRules
import org.eclipse.jface.text.rules.IToken; //導入依賴的package包/類
@Override
protected List<IRule> createRules() {
IToken keywordToken = getToken(Prefs.EDITOR_MATH_KEYWORD_COLOR);
IToken symbolToken = getToken(Prefs.EDITOR_MATH_SYMBOL_COLOR);
IToken commentToken = getToken(Prefs.EDITOR_MATH_COMMENT_COLOR);
// IToken defaultToken = getToken(Prefs.EDITOR_DEFAULT_COLOR);
WordRule wordRule = new WordRule(new MathWordDetector(), keywordToken, true);
WordRule symbolRule = new WordRule(new MathSymbolDetector(), symbolToken, true);
List<IRule> rules = new ArrayList<IRule>();
rules.add(wordRule);
rules.add(symbolRule);
rules.add(new EndOfLineRule("%", commentToken));
rules.add(new WhitespaceRule(new WhitespaceDetector()));
return rules;
}
示例13: scan
import org.eclipse.jface.text.rules.IToken; //導入依賴的package包/類
protected de.darwinspl.preferences.resource.dwprofile.ui.IDwprofileTokenScanner scan(EObject object, ITokenScannerConstraint constraint) {
IDocument document = getSourceViewer().getDocument();
de.darwinspl.preferences.resource.dwprofile.IDwprofileLocationMap locationMap = textResource.getLocationMap();
de.darwinspl.preferences.resource.dwprofile.ui.IDwprofileTokenScanner tokenScanner = createTokenScanner();
int offset = locationMap.getCharStart(object);
int length = getLength(locationMap, object);
tokenScanner.setRange(document, offset, length);
IToken token = tokenScanner.nextToken();
while (!token.isEOF()) {
if (constraint.mustStop(tokenScanner)) {
return tokenScanner;
}
token = tokenScanner.nextToken();
}
return null;
}
示例14: scan
import org.eclipse.jface.text.rules.IToken; //導入依賴的package包/類
protected eu.hyvar.context.contextValidity.resource.hyvalidityformula.ui.IHyvalidityformulaTokenScanner scan(EObject object, ITokenScannerConstraint constraint) {
IDocument document = getSourceViewer().getDocument();
eu.hyvar.context.contextValidity.resource.hyvalidityformula.IHyvalidityformulaLocationMap locationMap = textResource.getLocationMap();
eu.hyvar.context.contextValidity.resource.hyvalidityformula.ui.IHyvalidityformulaTokenScanner tokenScanner = createTokenScanner();
int offset = locationMap.getCharStart(object);
int length = getLength(locationMap, object);
tokenScanner.setRange(document, offset, length);
IToken token = tokenScanner.nextToken();
while (!token.isEOF()) {
if (constraint.mustStop(tokenScanner)) {
return tokenScanner;
}
token = tokenScanner.nextToken();
}
return null;
}
示例15: XMLTagScanner
import org.eclipse.jface.text.rules.IToken; //導入依賴的package包/類
public XMLTagScanner(ColorManager manager) {
IToken string = new Token(new TextAttribute(manager
.getColor(IXMLColorConstants.STRING)));
IToken attrValue = new Token(XML_ATTR_VALUE);
IRule[] rules = new IRule[3];
// Add rule for double quotes
rules[0] = new SingleLineRule("\"", "\"", string, '\\');
// Add a rule for single quotes
rules[1] = new SingleLineRule("'", "'", string, '\\');
// Add generic whitespace rule.
rules[2] = new WhitespaceRule(new NCLWhitespaceDetector());
setRules(rules);
}