fix: NPE in go to definition
This commit is contained in:
parent
733f0b2622
commit
b4539c0aa9
2 changed files with 11 additions and 5 deletions
|
@ -58,6 +58,8 @@ public class LSPGotoDefinitionAction extends ShowImplementationsAction {
|
||||||
super.actionPerformed(e);
|
super.actionPerformed(e);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
manager.gotoDefinition(psiElement);
|
if (!manager.gotoDefinition(psiElement)) {
|
||||||
|
super.actionPerformed(e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1285,14 +1285,16 @@ public class EditorEventManager {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Tries to go to definition
|
// Tries to go to definition
|
||||||
public void gotoDefinition(PsiElement element) {
|
public boolean gotoDefinition(PsiElement element) {
|
||||||
if (editor.isDisposed()) {
|
if (editor.isDisposed()) {
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
val sourceOffset = element.getTextOffset();
|
val sourceOffset = element.getTextOffset();
|
||||||
val loc = requestDefinition(DocumentUtils.offsetToLSPPos(editor, sourceOffset));
|
val loc = requestDefinition(DocumentUtils.offsetToLSPPos(editor, sourceOffset));
|
||||||
|
if (loc == null)
|
||||||
|
return false;
|
||||||
|
|
||||||
gotoLocation(loc);
|
return gotoLocation(loc);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Tries to go to declaration / show usages based on the element which is
|
// Tries to go to declaration / show usages based on the element which is
|
||||||
|
@ -1327,7 +1329,7 @@ public class EditorEventManager {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void gotoLocation(Location loc) {
|
public boolean gotoLocation(Location loc) {
|
||||||
VirtualFile file = null;
|
VirtualFile file = null;
|
||||||
try {
|
try {
|
||||||
file = VfsUtil.findFileByURL(new URL(loc.getUri()));
|
file = VfsUtil.findFileByURL(new URL(loc.getUri()));
|
||||||
|
@ -1349,9 +1351,11 @@ public class EditorEventManager {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
return true;
|
||||||
} else {
|
} else {
|
||||||
LOG.warn("Empty file for " + loc.getUri());
|
LOG.warn("Empty file for " + loc.getUri());
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void requestAndShowCodeActions() {
|
public void requestAndShowCodeActions() {
|
||||||
|
|
Loading…
Add table
Reference in a new issue