3333import org .eclipse .jface .viewers .LabelProvider ;
3434import org .eclipse .lsp4e .debug .DSPPlugin ;
3535import org .eclipse .lsp4e .debug .debugmodel .DSPDebugElement ;
36+ import org .eclipse .lsp4e .debug .debugmodel .DSPStackFrame ;
3637import org .eclipse .lsp4e .debug .debugmodel .DSPThread ;
3738import org .eclipse .osgi .util .NLS ;
3839import org .eclipse .swt .SWT ;
@@ -58,7 +59,6 @@ public String getText(Object element) {
5859 final var label = new StringBuilder ();
5960 if (element instanceof DSPThread thread ) {
6061 label .append (NLS .bind ("Thread #{0} [{1}]" , thread .getId (), thread .getName ()));
61-
6262 }
6363
6464 if (label .length () != 0 ) {
@@ -72,6 +72,28 @@ public String getText(Object element) {
7272 } else {
7373 // Use default TODO should the entire default be copied here?
7474 label .append (DebugUIPlugin .getDefaultLabelProvider ().getText (element ));
75+
76+ if (element instanceof DSPStackFrame frame ) {
77+ try {
78+ final int line = frame .getLineNumber ();
79+ if (line > 0 ) {
80+ final String source = frame .getSourceName ();
81+ if (source != null ) {
82+ String file = new Path (source ).lastSegment ();
83+ if (file == null ) {
84+ file = source ;
85+ }
86+ final String suffix = '(' + file + ":" + line + ')' ; //$NON-NLS-1$
87+ if (!endsWith (label , suffix )) {
88+ label .append (' ' );
89+ label .append (suffix );
90+ }
91+ }
92+ }
93+ } catch (final Exception ex ) {
94+ DSPPlugin .logWarning ("Failed to determine stack frame line number" , ex );
95+ }
96+ }
7597 }
7698 if (element instanceof DSPDebugElement debugElement ) {
7799 if (debugElement .getErrorMessage () != null ) {
@@ -197,6 +219,20 @@ public void computeDetail(IValue value, IValueDetailListener listener) {
197219 }
198220 }
199221
222+ private static boolean endsWith (final StringBuilder sb , final String suffix ) {
223+ final int sbLen = sb .length ();
224+ final int suffixLen = suffix .length ();
225+ if (suffixLen > sbLen ) {
226+ return false ;
227+ }
228+ for (int i = 1 ; i <= suffixLen ; i ++) {
229+ if (sb .charAt (sbLen - i ) != suffix .charAt (suffixLen - i )) {
230+ return false ;
231+ }
232+ }
233+ return true ;
234+ }
235+
200236 public static Display getDisplay () {
201237 Display display ;
202238 display = Display .getCurrent ();
0 commit comments