@Nullable private XSourcePosition findPosition() { XDebugSession debugSession = getSession(); if (debugSession == null) return null; XStackFrame stackFrame = debugSession.getCurrentStackFrame(); if (stackFrame == null) return null; Project project = debugSession.getProject(); XSourcePosition position = debugSession.getCurrentPosition(); Editor editor = ((FileEditorManagerImpl)FileEditorManager.getInstance(project)).getSelectedTextEditor(true); if (editor == null || position == null) return null; String name = myName.startsWith("&") ? myName.replaceFirst("\\&", "") : myName; PsiElement resolved = findTargetElement(project, position, editor, name); if (resolved == null) return null; VirtualFile virtualFile = resolved.getContainingFile().getVirtualFile(); return XDebuggerUtil.getInstance().createPositionByOffset(virtualFile, resolved.getTextOffset()); } });
@Nullable private XSourcePosition findPosition() { XDebugSession debugSession = myProcess.getSession(); if (debugSession == null) { return null; } XStackFrame stackFrame = debugSession.getCurrentStackFrame(); if (stackFrame == null) { return null; } Project project = debugSession.getProject(); XSourcePosition position = debugSession.getCurrentPosition(); Editor editor = ((FileEditorManagerImpl) FileEditorManager.getInstance(project)) .getSelectedTextEditor(true); if (editor == null || position == null) { return null; } String name = myName.startsWith("&") ? myName.replaceFirst("\\&", "") : myName; PsiElement resolved = findTargetElement(project, position, editor, name); if (resolved == null) { return null; } VirtualFile virtualFile = resolved.getContainingFile().getVirtualFile(); return XDebuggerUtil.getInstance().createPositionByOffset(virtualFile, resolved.getTextOffset()); } });
@Override public void computeTypeSourcePosition(@NotNull XNavigatable navigatable) { readActionInPooledThread(() -> { boolean isStructure = myVariable.isStructure(); boolean isPtr = myVariable.isPtr(); if (!isStructure && !isPtr) return; Project project = getProject(); if (project == null) return; String dlvType = myVariable.type; String fqn = dlvType.replaceFirst(isPtr ? "\\*struct " : "struct ", ""); List<String> split = StringUtil.split(fqn, "."); boolean noFqn = split.size() == 1; if (split.size() == 2 || noFqn) { String name = ContainerUtil.getLastItem(split); assert name != null; Collection<GoTypeSpec> types = GoTypesIndex.find(name, project, GlobalSearchScope.allScope(project), null); for (GoTypeSpec type : types) { if (noFqn || Comparing.equal(fqn, type.getQualifiedName())) { navigatable.setSourcePosition(XDebuggerUtil.getInstance().createPositionByOffset( type.getContainingFile().getVirtualFile(), type.getTextOffset())); return; } } } }); } }