@Override
    public void visitElement(@NotNull PsiElement element) {
      ProgressManager.checkCanceled();
      final RefManagerExtension<?> extension = getExtension(element.getLanguage());
      if (extension != null) {
        extension.visitElement(element);
      }
      else if (processExternalElements) {
        PsiFile file = element.getContainingFile();
        if (file != null) {
          RefManagerExtension<?> externalFileManagerExtension =
            ContainerUtil.find(myExtensions.values(), ex -> ex.shouldProcessExternalFile(file));
          if (externalFileManagerExtension == null) {
            if (element instanceof PsiFile) {
              VirtualFile virtualFile = PsiUtilCore.getVirtualFile(element);
              if (virtualFile instanceof VirtualFileWithId) {
                registerUnprocessed(virtualFile);
              }
            }
          } else {
            RefElement refFile = getReference(file);
            LOG.assertTrue(refFile != null, file);
            for (PsiReference reference : element.getReferences()) {
              PsiElement resolve = reference.resolve();
              if (resolve != null) {
                fireNodeMarkedReferenced(resolve, file);
                RefElement refWhat = getReference(resolve);
                if (refWhat == null) {
                  PsiFile targetContainingFile = resolve.getContainingFile();
                  //no logic to distinguish different elements in the file anyway
                  if (file == targetContainingFile) continue;
                  refWhat = getReference(targetContainingFile);
                }

                if (refWhat != null) {
                  ((WritableRefElement)refWhat).addInReference(refFile);
                  ((WritableRefElement)refFile).addOutReference(refWhat);
                }
              }
            }

            Stream<? extends PsiElement> implicitRefs = externalFileManagerExtension.extractExternalFileImplicitReferences(file);
            implicitRefs.forEach(e -> {
              RefElement superClassReference = getReference(e);
              if (superClassReference != null) {
                //in case of implicit inheritance, e.g. GroovyObject
                //= no explicit reference is provided, dependency on groovy library could be treated as redundant though it is not
                //inReference is not important in this case
                ((RefElementImpl)refFile).addOutReference(superClassReference);
              }
            });

            if (element instanceof PsiFile) {
              externalFileManagerExtension.markExternalReferencesProcessed(refFile);
            }
          }
        }
      }
      for (PsiElement aChildren : element.getChildren()) {
        aChildren.accept(this);
      }
    }
@Override
    public void visitElement(@NotNull PsiElement element)