PsiClass (final Project project, final String className, final int lineNumber) { if (project == null) return null; final PsiManager psiManager = PsiManager.getInstance(project); PsiClass psiClass = JavaPsiFacade.getInstance(psiManager.getProject()).findClass(className, GlobalSearchScope.allScope(project)); PsiElement navElement = psiClass == null ? null : psiClass.getNavigationElement(); if (psiClass == null || navElement instanceof PsiCompiledElement) return null; final PsiFile psiFile = navElement.getContainingFile(); return PsiTreeUtil.getParentOfType(psiFile.findElementAt(offsetOfLine(psiFile, lineNumber)), PsiClass.class, false); }