ClassMatcher (SearchId @NotNull [] internalIds) { List<InternalNameMatcher> nameMatchers = new SmartList<>(); IntSet anonymousIndices = null; for (SearchId internalId : internalIds) { if (internalId.getId() != -1) { if (anonymousIndices == null) { anonymousIndices = new IntOpenHashSet(); } anonymousIndices.add(internalId.getId()); } else { String internalName = internalId.getDeserializedName(); int curLast = internalName.length() - 1; while (true) { int lastIndex = internalName.lastIndexOf('$', curLast); if (lastIndex > -1 && lastIndex < internalName.length() - 1) { final int followingIndex = lastIndex + 1; final boolean digit = Character.isDigit(internalName.charAt(followingIndex)); if (digit) { if (curLast == internalName.length() - 1) { final int nextNonDigit = getNextNonDigitIndex(internalName, followingIndex); if (nextNonDigit != -1) { //declared inside method nameMatchers.add(new InternalNameMatcher.ByName(internalName.substring(nextNonDigit))); } else { throw new IllegalStateException(); } } else { //declared in anonymous nameMatchers.add(new InternalNameMatcher.ByName(StringUtil.getShortName(internalName, '$'))); break; } } } else { nameMatchers.add(new InternalNameMatcher.ByQualifiedName(StringUtil.replace(internalName, "$", "."))); break; } curLast = lastIndex - 1; } } } return new ClassMatcher(anonymousIndices, nameMatchers); }