E5E7 format stackframe name with ClassName.MethodName(ParameterTypes) by testforstephen · Pull Request #73 · microsoft/java-debug · GitHub
[go: up one dir, main page]

Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

import org.apache.commons.lang3.StringUtils;

Expand All @@ -29,6 +30,7 @@
import com.microsoft.java.debug.core.adapter.Requests.StackTraceArguments;
import com.microsoft.java.debug.core.adapter.Responses;
import com.microsoft.java.debug.core.adapter.Types;
import com.microsoft.java.debug.core.adapter.formatter.SimpleTypeFormatter;
import com.microsoft.java.debug.core.adapter.variables.JdiObjectProxy;
import com.sun.jdi.AbsentInformationException;
import com.sun.jdi.IncompatibleThreadStateException;
Expand Down Expand Up @@ -90,7 +92,7 @@ private Types.StackFrame convertDebuggerStackFrameToClient(StackFrame stackFrame
Location location = stackFrame.location();
Method method = location.method();
Types.Source clientSource = this.convertDebuggerSourceToClient(location, context);
String methodName = method.name();
String methodName = formatMethodName(method, true, true);
int lineNumber = AdapterUtils.convertLineNumber(location.lineNumber(), context.isDebuggerLinesStartAt1(), context.isClientLinesStartAt1());
// Line number returns -1 if the information is not available; specifically, always returns -1 for native methods.
if (lineNumber < 0) {
Expand All @@ -103,6 +105,7 @@ private Types.StackFrame convertDebuggerStackFrameToClient(StackFrame stackFrame
clientSource = null;
}
}

return new Types.StackFrame(frameId, methodName, clientSource, lineNumber, 0);
}

Expand Down Expand Up @@ -152,4 +155,21 @@ private Types.Source convertDebuggerSourceToClient(Location location, IDebugAdap
}
}
}

private String formatMethodName(Method method, boolean showContextClass, boolean showParameter) {
StringBuilder formattedName = new StringBuilder();
if (showContextClass) {
String fullyQualifiedClassName = method.declaringType().name();
formattedName.append(SimpleTypeFormatter.trimTypeName(fullyQualifiedClassName));
formattedName.append(".");
}
formattedName.append(method.name());
if (showParameter) {
List<String> argumentTypeNames = method.argumentTypeNames().stream().map(SimpleTypeFormatter::trimTypeName).collect(Collectors.toList());
formattedName.append("(");
formattedName.append(String.join(",", argumentTypeNames));
formattedName.append(")");
}
return formattedName.toString();
}
}
0