Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion org.eclipse.lsp4e.debug/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Bundle-ManifestVersion: 2
Bundle-Name: Debug Adapter client for Eclipse IDE (Incubation)
Bundle-SymbolicName: org.eclipse.lsp4e.debug;singleton:=true
Bundle-Vendor: Eclipse LSP4E
Bundle-Version: 0.15.16.qualifier
Bundle-Version: 0.15.17.qualifier
Bundle-Activator: org.eclipse.lsp4e.debug.DSPPlugin
Require-Bundle: org.eclipse.ui,
org.eclipse.core.runtime,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,9 @@ public int getCharEnd() throws DebugException {
return -1;
}

public String getSourceName() {
return stackFrame.getSource().getPath();
public @Nullable String getSourceName() {
final var source = stackFrame.getSource();
return source == null ? null : source.getPath();
}

public Integer getFrameId() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.lsp4e.debug.DSPPlugin;
import org.eclipse.lsp4e.debug.debugmodel.DSPDebugElement;
import org.eclipse.lsp4e.debug.debugmodel.DSPStackFrame;
import org.eclipse.lsp4e.debug.debugmodel.DSPThread;
import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.SWT;
Expand All @@ -58,7 +59,6 @@ public String getText(Object element) {
final var label = new StringBuilder();
if (element instanceof DSPThread thread) {
label.append(NLS.bind("Thread #{0} [{1}]", thread.getId(), thread.getName()));

}

if (label.length() != 0) {
Expand All @@ -72,6 +72,28 @@ public String getText(Object element) {
} else {
// Use default TODO should the entire default be copied here?
label.append(DebugUIPlugin.getDefaultLabelProvider().getText(element));

if (element instanceof DSPStackFrame frame) {
try {
final int line = frame.getLineNumber();
if (line > 0) {
final String source = frame.getSourceName();
Comment thread
sebthom marked this conversation as resolved.
if (source != null) {
String file = new Path(source).lastSegment();
if (file == null) {
file = source;
}
final String suffix = '(' + file + ":" + line + ')'; //$NON-NLS-1$
if (!endsWith(label, suffix)) {
label.append(' ');
label.append(suffix);
}
}
}
} catch (final Exception ex) {
DSPPlugin.logWarning("Failed to determine stack frame line number", ex);
}
}
}
if (element instanceof DSPDebugElement debugElement) {
if (debugElement.getErrorMessage() != null) {
Expand Down Expand Up @@ -197,6 +219,20 @@ public void computeDetail(IValue value, IValueDetailListener listener) {
}
}

private static boolean endsWith(final StringBuilder sb, final String suffix) {
final int sbLen = sb.length();
final int suffixLen = suffix.length();
if (suffixLen > sbLen) {
return false;
}
for (int i = 1; i <= suffixLen; i++) {
if (sb.charAt(sbLen - i) != suffix.charAt(suffixLen - i)) {
return false;
}
}
return true;
}

public static Display getDisplay() {
Display display;
display = Display.getCurrent();
Expand Down