@Nullable
 private static String getQuickNavigateInfo(PsiElement element) {
   final String name =
       ElementDescriptionUtil.getElementDescription(element, UsageViewShortNameLocation.INSTANCE);
   if (StringUtil.isEmpty(name)) return null;
   final String typeName =
       ElementDescriptionUtil.getElementDescription(element, UsageViewTypeLocation.INSTANCE);
   final PsiFile file = element.getContainingFile();
   final StringBuilder sb = new StringBuilder();
   if (StringUtil.isNotEmpty(typeName)) sb.append(typeName).append(" ");
   sb.append("\"").append(name).append("\"");
   if (file != null && file.isPhysical()) {
     sb.append(" [").append(file.getName()).append("]");
   }
   return sb.toString();
 }
  @Nullable
  private Info getInfoAt(final Editor editor, PsiFile file, int offset, BrowseMode browseMode) {
    PsiElement targetElement = null;

    if (browseMode == BrowseMode.TypeDeclaration) {
      try {
        targetElement = GotoTypeDeclarationAction.findSymbolType(editor, offset);
      } catch (IndexNotReadyException e) {
        showDumbModeNotification(myProject);
      }
    } else if (browseMode == BrowseMode.Declaration) {
      final PsiReference ref = TargetElementUtilBase.findReference(editor, offset);
      final List<PsiElement> resolvedElements =
          ref != null ? resolve(ref) : Collections.<PsiElement>emptyList();
      final PsiElement resolvedElement =
          resolvedElements.size() == 1 ? resolvedElements.get(0) : null;

      final PsiElement[] targetElements =
          GotoDeclarationAction.findTargetElementsNoVS(myProject, editor, offset);
      final PsiElement elementAtPointer = file.findElementAt(offset);

      if (targetElements != null) {
        if (targetElements.length == 0) {
          return null;
        } else if (targetElements.length == 1) {
          if (targetElements[0] != resolvedElement
              && elementAtPointer != null
              && targetElements[0].isPhysical()) {
            return new InfoSingle(elementAtPointer, targetElements[0]);
          }
        } else {
          return elementAtPointer != null ? new InfoMultiple(elementAtPointer) : null;
        }
      }

      if (resolvedElements.size() == 1) {
        return new InfoSingle(ref, resolvedElements.get(0));
      } else if (resolvedElements.size() > 1) {
        return new InfoMultiple(elementAtPointer);
      }
    } else if (browseMode == BrowseMode.Implementation) {
      final PsiElement element =
          TargetElementUtilBase.getInstance()
              .findTargetElement(editor, ImplementationSearcher.getFlags(), offset);
      PsiElement[] targetElements =
          new ImplementationSearcher() {
            @NotNull
            protected PsiElement[] searchDefinitions(final PsiElement element) {
              final List<PsiElement> found = new ArrayList<PsiElement>(2);
              DefinitionsSearch.search(element)
                  .forEach(
                      new Processor<PsiElement>() {
                        public boolean process(final PsiElement psiElement) {
                          found.add(psiElement);
                          return found.size() != 2;
                        }
                      });
              return PsiUtilBase.toPsiElementArray(found);
            }
          }.searchImplementations(editor, element, offset);
      if (targetElements.length > 1) {
        PsiElement elementAtPointer = file.findElementAt(offset);
        if (elementAtPointer != null) {
          return new InfoMultiple(elementAtPointer);
        }
        return null;
      }
      if (targetElements.length == 1) {
        Navigatable descriptor = EditSourceUtil.getDescriptor(targetElements[0]);
        if (descriptor == null || !descriptor.canNavigate()) {
          return null;
        }
        targetElement = targetElements[0];
      }
    }

    if (targetElement != null && targetElement.isPhysical()) {
      PsiElement elementAtPointer = file.findElementAt(offset);
      if (elementAtPointer != null) {
        return new InfoSingle(elementAtPointer, targetElement);
      }
    }

    return null;
  }