@NotNull
  private static List<PsiElement> compileByAllPrefixes(@NotNull Project project,
                                                       @NotNull MatchOptions options,
                                                       @NotNull CompiledPattern pattern,
                                                       @NotNull CompileContext context,
                                                       String @NotNull [] applicablePrefixes,
                                                       boolean checkForErrors) throws MalformedPatternException {
    if (applicablePrefixes.length == 0) {
      return Collections.emptyList();
    }

    final List<PsiElement> elements =
      doCompile(project, options, pattern, new ConstantPrefixProvider(applicablePrefixes[0]), context, checkForErrors);
    if (elements.isEmpty()) {
      return elements;
    }

    final PsiFile file = elements.get(0).getContainingFile();
    if (file == null) {
      return elements;
    }

    final PsiElement last = elements.get(elements.size() - 1);
    final Pattern[] patterns = new Pattern[applicablePrefixes.length];

    for (int i = 0; i < applicablePrefixes.length; i++) {
      patterns[i] = Pattern.compile(MatchUtil.shieldRegExpMetaChars(applicablePrefixes[i]) + "\\w+\\b");
    }

    final int[] varEndOffsets = findAllTypedVarOffsets(file, patterns);

    final int patternEndOffset = last.getTextRange().getEndOffset();
    if (elements.isEmpty() || checkErrorElements(file, patternEndOffset, patternEndOffset, varEndOffsets, true) != Boolean.TRUE) {
      return elements;
    }

    final int varCount = varEndOffsets.length;
    final String[] prefixSequence = new String[varCount];

    Arrays.fill(prefixSequence, applicablePrefixes[0]);

    final List<PsiElement> finalElements =
      compileByPrefixes(project, options, pattern, context, applicablePrefixes, patterns, prefixSequence, 0, checkForErrors);
    return finalElements != null
           ? finalElements
           : doCompile(project, options, pattern, new ConstantPrefixProvider(applicablePrefixes[0]), context, checkForErrors);
  }
@NotNull
  private static List<PsiElement> compileByAllPrefixes(@NotNull Project project,
                                                       @NotNull MatchOptions options,
                                                       @NotNull CompiledPattern pattern,
                                                       @NotNull CompileContext context,
                                                       String @NotNull [] applicablePrefixes,
                                                       boolean checkForErrors)