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,26 @@ 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+ String file = new Path (source ).lastSegment ();
82+ if (file == null ) {
83+ file = source ;
84+ }
85+ final String suffix = '(' + file + ":" + line + ')' ; //$NON-NLS-1$
86+ if (!endsWith (label , suffix )) {
87+ label .append (' ' );
88+ label .append (suffix );
89+ }
90+ }
91+ } catch (final Exception ex ) {
92+ // Ignore - if we cannot get a line number, skip the suffix
93+ }
94+ }
7595 }
7696 if (element instanceof DSPDebugElement debugElement ) {
7797 if (debugElement .getErrorMessage () != null ) {
@@ -197,6 +217,20 @@ public void computeDetail(IValue value, IValueDetailListener listener) {
197217 }
198218 }
199219
220+ private static boolean endsWith (final StringBuilder sb , final String suffix ) {
221+ final int sbLen = sb .length ();
222+ final int suffixLen = suffix .length ();
223+ if (suffixLen > sbLen ) {
224+ return false ;
225+ }
226+ for (int i = 1 ; i <= suffixLen ; i ++) {
227+ if (sb .charAt (sbLen - i ) != suffix .charAt (suffixLen - i )) {
228+ return false ;
229+ }
230+ }
231+ return true ;
232+ }
233+
200234 public static Display getDisplay () {
201235 Display display ;
202236 display = Display .getCurrent ();
0 commit comments