String (DebugProcessImpl debugProcess, @Nullable SourcePosition position) { if (position == null) { return null; } String res = ReadAction.compute(() -> { final PsiFile positionFile = position.getFile(); if (positionFile instanceof JspFile) { final PsiDirectory dir = positionFile.getContainingDirectory(); return dir != null ? dir.getVirtualFile().getPresentableUrl() : null; } final PsiClass psiClass = getClassAt(position); if (psiClass != null) { PsiClass toplevel = PsiUtil.getTopLevelClass(psiClass); if (toplevel != null) { String qName = toplevel.getQualifiedName(); if (qName != null) { int i = qName.lastIndexOf('.'); return i > 0 ? qName.substring(0, i) : ""; } } } if (positionFile instanceof PsiClassOwner) { String name = ((PsiClassOwner)positionFile).getPackageName(); if (!StringUtil.isEmpty(name)) { return name; } } return null; }); if (res == null && debugProcess != null && debugProcess.isAttached()) { List<ReferenceType> allClasses = debugProcess.getPositionManager().getAllClasses(position); if (!allClasses.isEmpty()) { final String className = allClasses.get(0).name(); int dotIndex = className.lastIndexOf('.'); if (dotIndex >= 0) { return className.substring(0, dotIndex); } } } return ""; }