Skip to content

Commit ed1376b

Browse files
committed
dlv debugger: navigate to type source (shift + f4) for pointers
1 parent 140ec3f commit ed1376b

File tree

2 files changed

+16
-6
lines changed

2 files changed

+16
-6
lines changed

src/com/goide/dlv/DlvXValue.java

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
import com.intellij.psi.util.PsiTreeUtil;
4242
import com.intellij.util.Consumer;
4343
import com.intellij.util.ThreeState;
44+
import com.intellij.util.containers.ContainerUtil;
4445
import com.intellij.xdebugger.XDebugSession;
4546
import com.intellij.xdebugger.XDebuggerUtil;
4647
import com.intellij.xdebugger.XSourcePosition;
@@ -223,21 +224,26 @@ public boolean canNavigateToSource() {
223224

224225
@Override
225226
public boolean canNavigateToTypeSource() {
226-
return myVariable.isStructure() && getProject() != null;
227+
return (myVariable.isStructure() || myVariable.isPtr()) && getProject() != null;
227228
}
228229

229230
@Override
230231
public void computeTypeSourcePosition(@NotNull XNavigatable navigatable) {
231-
if (!myVariable.isStructure()) return;
232+
boolean isStructure = myVariable.isStructure();
233+
boolean isPtr = myVariable.isPtr();
234+
if (!isStructure && !isPtr) return;
232235
Project project = getProject();
233236
if (project == null) return;
234-
String fqn = myVariable.type;
237+
String dlvType = myVariable.type;
238+
String fqn = isPtr ? dlvType.replaceFirst("\\*struct ", "") : dlvType;
235239
List<String> split = StringUtil.split(fqn, ".");
236-
if (split.size() == 2) {
237-
String name = split.get(1);
240+
boolean noFqn = split.size() == 1;
241+
if (split.size() == 2 || noFqn) {
242+
String name = ContainerUtil.getLastItem(split);
243+
assert name != null;
238244
Collection<GoTypeSpec> types = GoTypesIndex.find(name, project, GlobalSearchScope.allScope(project));
239245
for (GoTypeSpec type : types) {
240-
if (Comparing.equal(fqn, type.getQualifiedName())) {
246+
if (noFqn || Comparing.equal(fqn, type.getQualifiedName())) {
241247
navigatable.setSourcePosition(XDebuggerUtil.getInstance().createPositionByOffset(
242248
type.getContainingFile().getVirtualFile(), type.getTextOffset()));
243249
return;

src/com/goide/dlv/protocol/DlvApi.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,10 @@ private boolean isNumber() {
172172
public boolean isStructure() {
173173
return getKind() == Kind.Struct;
174174
}
175+
176+
public boolean isPtr() {
177+
return getKind() == Kind.Ptr;
178+
}
175179
}
176180

177181
// Goroutine represents the information relevant to Delve from the runtime's

0 commit comments

Comments
 (0)