Search in sources :

Example 6 with WordOccurrence

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();
    }
}
Also used : IElementType(com.intellij.psi.tree.IElementType) WordOccurrence(com.intellij.lang.cacheBuilder.WordOccurrence)

Aggregations

WordOccurrence (com.intellij.lang.cacheBuilder.WordOccurrence)6 IElementType (com.intellij.psi.tree.IElementType)2 FormEditingUtil (com.intellij.uiDesigner.FormEditingUtil)1 AlienFormFileException (com.intellij.uiDesigner.compiler.AlienFormFileException)1 UnexpectedFormElementException (com.intellij.uiDesigner.compiler.UnexpectedFormElementException)1 IComponent (com.intellij.uiDesigner.lw.IComponent)1 LwRootContainer (com.intellij.uiDesigner.lw.LwRootContainer)1 JDOMParseException (org.jdom.input.JDOMParseException)1 SmaliLexer (org.jf.smalidea.SmaliLexer)1