Search in sources :

Example 1 with SmaliLexer

use of org.jf.smalidea.SmaliLexer in project smali by JesusFreke.

the class SmaliWordScanner method processWords.

@Override
public void processWords(CharSequence fileText, Processor<WordOccurrence> processor) {
    SmaliLexer lexer = new SmaliLexer();
    lexer.start(fileText);
    IElementType type = lexer.getTokenType();
    while (type != null) {
        if (type == SmaliTokens.CLASS_DESCRIPTOR) {
            processClassDescriptor(fileText, lexer.getTokenStart(), lexer.getTokenEnd(), processor);
        } else if (MEMBER_NAME_TOKENS.contains(type)) {
            processor.process(new WordOccurrence(fileText, lexer.getTokenStart(), lexer.getTokenEnd(), Kind.CODE));
        } else if (type == SmaliTokens.PARAM_LIST_OR_ID_PRIMITIVE_TYPE) {
            int tokenStart = lexer.getTokenStart();
            while (type == SmaliTokens.PARAM_LIST_OR_ID_PRIMITIVE_TYPE) {
                lexer.advance();
                type = lexer.getTokenType();
            }
            int tokenEnd = lexer.getTokenStart();
            processor.process(new WordOccurrence(fileText, tokenStart, tokenEnd, Kind.CODE));
        }
        lexer.advance();
        type = lexer.getTokenType();
    }
}
Also used : IElementType(com.intellij.psi.tree.IElementType) WordOccurrence(com.intellij.lang.cacheBuilder.WordOccurrence) SmaliLexer(org.jf.smalidea.SmaliLexer)

Aggregations

WordOccurrence (com.intellij.lang.cacheBuilder.WordOccurrence)1 IElementType (com.intellij.psi.tree.IElementType)1 SmaliLexer (org.jf.smalidea.SmaliLexer)1