use of com.intellij.lang.cacheBuilder.WordOccurrence in project intellij-community by JetBrains.
the class GroovyWordsScanner method processWords.
@Override
public void processWords(CharSequence fileText, Processor<WordOccurrence> processor) {
myLexer.start(fileText);
// shared occurrence
WordOccurrence occurrence = null;
while (myLexer.getTokenType() != null) {
final IElementType type = myLexer.getTokenType();
if (type == GroovyTokenTypes.mIDENT || TokenSets.KEYWORDS.contains(type)) {
if (occurrence == null)
occurrence = new WordOccurrence(fileText, myLexer.getTokenStart(), myLexer.getTokenEnd(), WordOccurrence.Kind.CODE);
else
occurrence.init(fileText, myLexer.getTokenStart(), myLexer.getTokenEnd(), WordOccurrence.Kind.CODE);
if (!processor.process(occurrence))
return;
} else if (TokenSets.COMMENT_SET.contains(type)) {
if (!stripWords(processor, fileText, myLexer.getTokenStart(), myLexer.getTokenEnd(), WordOccurrence.Kind.COMMENTS, occurrence))
return;
} else if (TokenSets.STRING_LITERALS.contains(type)) {
if (!stripWords(processor, fileText, myLexer.getTokenStart(), myLexer.getTokenEnd(), WordOccurrence.Kind.LITERALS, occurrence)) {
return;
}
if (type == GroovyTokenTypes.mSTRING_LITERAL) {
if (!stripWords(processor, fileText, myLexer.getTokenStart(), myLexer.getTokenEnd(), WordOccurrence.Kind.CODE, occurrence))
return;
}
} else {
if (!stripWords(processor, fileText, myLexer.getTokenStart(), myLexer.getTokenEnd(), null, occurrence)) {
return;
}
}
myLexer.advance();
}
}
Aggregations