Processor<WordOccurrence> (@NotNull CharSequence chars, @NotNull IdDataConsumer consumer) { final char[] charsArray = CharArrayUtil.fromSequenceWithoutCopying(chars); return new Processor<>() { @Override public boolean process(final WordOccurrence t) { if (charsArray != null && t.getBaseText() == chars) { consumer.addOccurrence(charsArray, t.getStart(), t.getEnd(), convertToMask(t.getKind())); } else { consumer.addOccurrence(t.getBaseText(), t.getStart(), t.getEnd(), convertToMask(t.getKind())); } return true; } private static int convertToMask(final WordOccurrence.Kind kind) { if (kind == null) { return UsageSearchContext.ANY; } if (kind == WordOccurrence.Kind.CODE) return UsageSearchContext.IN_CODE; if (kind == WordOccurrence.Kind.COMMENTS) return UsageSearchContext.IN_COMMENTS; if (kind == WordOccurrence.Kind.LITERALS) return UsageSearchContext.IN_STRINGS; if (kind == WordOccurrence.Kind.FOREIGN_LANGUAGE) return UsageSearchContext.IN_FOREIGN_LANGUAGES; return 0; } }; }