private static @Nullable PsiType getElementType(@NotNull PsiElement element) {
    if (DumbService.isDumb(element.getProject())) return null;
    if (element instanceof PsiExpression) {
      return ((PsiExpression)element).getType();
    }
    if (element instanceof PsiVariable) {
      return ((PsiVariable)element).getType();
    }
    return null;
  }
private static @Nullable PsiType getElementType(@NotNull PsiElement element)