@Override
      protected void addCompletions(@NotNull final CompletionParameters parameters,
                                    @NotNull ProcessingContext context,
                                    @NotNull final CompletionResultSet _result) {
        if (!parameters.isExtendedCompletion()) {
          return;
        }

        @NotNull final CompletionResultSet result = _result.caseInsensitive();
        final PsiElement e = parameters.getPosition();
        final Project project = e.getProject();

        final PsiReference psiReference = parameters.getPosition().getContainingFile().findReferenceAt(parameters.getOffset());

        final Pair<FileReference, Boolean> fileReferencePair = getReference(psiReference);
        if (fileReferencePair != null) {
          final FileReference first = fileReferencePair.getFirst();
          if (first == null) return;
          Boolean stopHere = fileReferencePair.getSecond();
          Set<PsiFile> variants = stopHere
                                  ? Collections.emptySet()
                                  : Arrays.stream(first.getVariants()).map(v -> v instanceof LookupElement ? ((LookupElement)v).getObject() : null).filter(o -> o instanceof PsiFile).map(o -> (PsiFile)o).collect(Collectors.toSet());

          final FileReferenceSet set = first.getFileReferenceSet();
          int end = parameters.getOffset() - set.getElement().getTextRange().getStartOffset() - set.getStartInElement();
          String pathString = set.getPathString();
          if (pathString.length() < end) return;

          final PsiFile originalFile = parameters.getOriginalFile();
          final VirtualFile contextFile = originalFile.getVirtualFile();

          String relativePrefix = getRelativePathPrefix(pathString);
          VirtualFile parent = null;
          if (relativePrefix != null && relativePrefix.length() <= end) {
            parent = VfsUtilCore.findRelativeFile(relativePrefix, contextFile.getParent());
            if (parent != null) {
              pathString = pathString.substring(relativePrefix.length());
              end -= relativePrefix.length();
            }
          }

          String prefix = pathString.substring(0, end);

          List<String> pathPrefixParts = null;
          int lastSlashIndex;
          if ((lastSlashIndex = prefix.lastIndexOf('/')) != -1) {
            pathPrefixParts = StringUtil.split(prefix.substring(0, lastSlashIndex), "/");
            prefix = prefix.substring(lastSlashIndex + 1);
          }

          final CompletionResultSet __result = result.withPrefixMatcher(prefix).caseInsensitive();


          if (contextFile != null) {
            Set<String> resultNames = new TreeSet<>();
            String finalPrefix = prefix;
            processAllNames(project, fileName -> {
              if (filenameMatchesPrefixOrType(fileName, finalPrefix, set.getSuitableFileTypes(),
                                              parameters.getInvocationCount())) {
                resultNames.add(fileName);
              }
              return true;
            });

            final ProjectFileIndex index = ProjectRootManager.getInstance(project).getFileIndex();

            final Module contextModule = index.getModuleForFile(contextFile);
            if (contextModule != null) {
              final List<FileReferenceHelper> helpers = FileReferenceHelperRegistrar.getHelpers(originalFile);

              final GlobalSearchScope scope = ProjectScope.getProjectScope(project);
              for (final String name : resultNames) {
                ProgressManager.checkCanceled();

                final PsiFile[] files = FilenameIndex.getFilesByName(project, name, scope);

                for (final PsiFile file : files) {
                  ProgressManager.checkCanceled();
                  if (variants.contains(file) && file.getName().startsWith(finalPrefix)) {
                    continue;
                  }

                  final VirtualFile virtualFile = file.getVirtualFile();
                  if (virtualFile == null ||
                      !virtualFile.isValid() ||
                      Comparing.equal(virtualFile, contextFile) ||
                      parent != null && !VfsUtilCore.isAncestor(parent, virtualFile, true)) {
                    continue;
                  }
                  List<FileReferenceHelper> helperList = new ArrayList<>();
                  for (FileReferenceHelper contextHelper : helpers) {
                    ProgressManager.checkCanceled();

                    if (contextHelper.isMine(project, virtualFile)) {
                      if (pathPrefixParts == null ||
                          fileMatchesPathPrefix(contextHelper.getPsiFileSystemItem(project, virtualFile), parent, pathPrefixParts)) {
                        helperList.add(contextHelper);
                      }
                    }
                  }
                  if (!helperList.isEmpty()) {
                    __result.addElement(new FilePathLookupItem(file, helperList));
                  }
                }
              }
            }
          }

          if (set.getSuitableFileTypes().length > 0 && parameters.getInvocationCount() == 1) {
            final String shortcut = KeymapUtil.getFirstKeyboardShortcutText(IdeActions.ACTION_CODE_COMPLETION);
            result.addLookupAdvertisement(CodeInsightBundle.message("class.completion.file.path.all.variants", shortcut));
          }

          if (stopHere) result.stopHere();
        }
      }
@Override
      protected void addCompletions(@NotNull final CompletionParameters parameters,
                                    @NotNull ProcessingContext context,
                                    @NotNull final CompletionResultSet _result)