2929import com .microsoft .java .debug .core .adapter .ISourceLookUpProvider ;
3030import com .microsoft .java .debug .core .adapter .IStackTraceProvider ;
3131import com .microsoft .java .debug .core .adapter .formatter .SimpleTypeFormatter ;
32+ import com .microsoft .java .debug .core .adapter .stacktrace .DecodedMethod ;
3233import com .microsoft .java .debug .core .adapter .variables .StackFrameReference ;
3334import com .microsoft .java .debug .core .protocol .Messages .Response ;
3435import com .microsoft .java .debug .core .protocol .Requests .Arguments ;
@@ -79,10 +80,10 @@ public CompletableFuture<Response> handle(Command command, Arguments arguments,
7980 StackFrameReference stackframe = new StackFrameReference (thread , i );
8081 int frameId = context .getRecyclableIdPool ().addObject (thread .uniqueID (), stackframe );
8182 IStackTraceProvider stackTraceProvider = context .getProvider (IStackTraceProvider .class );
82- Optional < String > formattedMethod = stackTraceProvider .formatMethod (thread .frame (i ).location ().method ());
83-
84- if (formattedMethod . isPresent ()) {
85- result .add (convertDebuggerStackFrameToClient (frames [i ], frameId , context , formattedMethod . get () ));
83+ DecodedMethod decodedMethod = stackTraceProvider .decode (thread .frame (i ).location ().method ());
84+
85+ if (! decodedMethod . isGenerated ()) {
86+ result .add (convertDebuggerStackFrameToClient (frames [i ], frameId , context , decodedMethod ));
8687 }
8788 }
8889 } catch (IncompatibleThreadStateException | IndexOutOfBoundsException | URISyntaxException
@@ -99,25 +100,18 @@ public CompletableFuture<Response> handle(Command command, Arguments arguments,
99100 return CompletableFuture .completedFuture (response );
100101 }
101102
102- private Types .StackFrame convertDebuggerStackFrameToClient (StackFrame stackFrame , int frameId , IDebugAdapterContext context ,String formattedName )
103+ private Types .StackFrame convertDebuggerStackFrameToClient (StackFrame stackFrame , int frameId , IDebugAdapterContext context , DecodedMethod decodedMethod )
103104 throws URISyntaxException , AbsentInformationException {
104105 Location location = stackFrame .location ();
105- Method method = location .method ();
106106 Types .Source clientSource = this .convertDebuggerSourceToClient (location , context );
107- // String methodName = formatMethodName(method, true, true,formattedName );
107+ String formattedName = decodedMethod . format ( );
108108 int lineNumber = AdapterUtils .convertLineNumber (location .lineNumber (), context .isDebuggerLinesStartAt1 (), context .isClientLinesStartAt1 ());
109109 // Line number returns -1 if the information is not available; specifically, always returns -1 for native methods.
110- if (lineNumber < 0 ) {
111- if (method .isNative ()) {
112- // For native method, display a tip text "native method" in the Call Stack View.
113- formattedName += "[native method]" ;
114- } else {
115- // For other unavailable method, such as lambda expression's built-in methods run/accept/apply,
116- // display "Unknown Source" in the Call Stack View.
117- clientSource = null ;
118- }
110+ if (lineNumber < 0 && !location .method ().isNative ()) {
111+ // For other unavailable method, such as lambda expression's built-in methods run/accept/apply,
112+ // display "Unknown Source" in the Call Stack View.
113+ clientSource = null ;
119114 }
120-
121115 return new Types .StackFrame (frameId , formattedName , clientSource , lineNumber , context .isClientColumnsStartAt1 () ? 1 : 0 );
122116 }
123117
@@ -175,21 +169,4 @@ public static Types.Source convertDebuggerSourceToClient(String fullyQualifiedNa
175169 }
176170 }
177171 }
178-
179- private String formatMethodName (Method method , boolean showContextClass , boolean showParameter ,String formattedNameString ) {
180- StringBuilder formattedName = new StringBuilder ();
181- /* if (showContextClass) {
182- // String fullyQualifiedClassName = method.declaringType().name();
183- formattedName.append(SimpleTypeFormatter.trimTypeName(formattedNameString));
184- formattedName.append(".");
185- }*/
186- formattedName .append (formattedNameString );
187- if (showParameter ) {
188- List <String > argumentTypeNames = method .argumentTypeNames ().stream ().map (SimpleTypeFormatter ::trimTypeName ).collect (Collectors .toList ());
189- formattedName .append ("(" );
190- formattedName .append (String .join ("," , argumentTypeNames ));
191- formattedName .append (")" );
192- }
193- return formattedName .toString ();
194- }
195172}
0 commit comments