SourcePosition (AnActionEvent event) { final DataContext dataContext = event.getDataContext(); final Project project = event.getData(CommonDataKeys.PROJECT); if (project == null) { return null; } if (ActionPlaces.PROJECT_VIEW_POPUP.equals(event.getPlace()) || ActionPlaces.STRUCTURE_VIEW_POPUP.equals(event.getPlace()) || ActionPlaces.BOOKMARKS_VIEW_POPUP.equals(event.getPlace())) { final PsiElement psiElement = event.getData(CommonDataKeys.PSI_ELEMENT); if (psiElement instanceof PsiField) { return SourcePosition.createFromElement(psiElement); } return null; } XValue value = XDebuggerTreeActionBase.getSelectedValue(dataContext); if (value instanceof NodeDescriptorProvider) { NodeDescriptorImpl descriptor = ((NodeDescriptorProvider)value).getDescriptor(); if (descriptor instanceof FieldDescriptorImpl) { final DebuggerContextImpl debuggerContext = DebuggerAction.getDebuggerContext(dataContext); final DebugProcessImpl debugProcess = debuggerContext.getDebugProcess(); if (debugProcess != null) { // if there is an active debug session final Ref<SourcePosition> positionRef = new Ref<>(null); debugProcess.getManagerThread().invokeAndWait(new DebuggerContextCommandImpl(debuggerContext) { @Override public Priority getPriority() { return Priority.HIGH; } @Override public void threadAction(@NotNull SuspendContextImpl suspendContext) { ApplicationManager.getApplication().runReadAction( () -> positionRef.set(SourcePositionProvider.getSourcePosition(descriptor, project, debuggerContext))); } }); final SourcePosition sourcePosition = positionRef.get(); if (sourcePosition != null) { return sourcePosition; } } } } Editor editor = ToggleMethodBreakpointAction.getEditor(event); if (editor != null) { final Document document = editor.getDocument(); PsiFile file = PsiDocumentManager.getInstance(project).getPsiFile(document); if (file != null) { final VirtualFile virtualFile = file.getVirtualFile(); FileType fileType = virtualFile != null ? virtualFile.getFileType() : null; if (JavaFileType.INSTANCE == fileType || JavaClassFileType.INSTANCE == fileType) { final PsiField field = FieldBreakpoint.findField(project, document, editor.getCaretModel().getOffset()); if (field != null) { return SourcePosition.createFromElement(field); } } } } return null; }