Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support resolving stacktrace to uri #1584

Merged
merged 3 commits into from
Nov 3, 2020

Conversation

jdneo
Copy link
Contributor

@jdneo jdneo commented Oct 27, 2020

To resolve #1202

Other extensions can leverage the delegate command to get the source uri.

Signed-off-by: Sheng Chen [email protected]

}
Set<ISourceContainer> containers = new LinkedHashSet<>();
containers.addAll(Arrays.asList(
JavaRuntime.getSourceContainers(resolved.toArray(new IRuntimeClasspathEntry[0]))));
Copy link
Contributor

@rgrunber rgrunber Oct 30, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there may be an issue here when JavaSourceLookupUtil#translate(..) creates a PackageFragmentRootSourceContainer(..) for the archive entries. The PackageFragmentRootSourceContainer class doesn't seem to use the source attachment to figure the source location. It ends up just returning a reference in the classfile.

Update : Come to think of it, I could be wrong here. I mean if the stacktrace reference is meant to just resolve to the artifact that ran that code then I think this is fine.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, here we mean to resolve a uri for a given stack trace line, and the uri comes from the classfile's reference.

To resolve the content(source code) of the uri, we have a content provider to do this: https://github.com/eclipse/eclipse.jdt.ls/blob/master/org.eclipse.jdt.ls.core/src/org/eclipse/jdt/ls/core/internal/DisassemblerContentProvider.java#L52

@@ -79,6 +80,8 @@ public Object executeCommand(String commandId, List<Object> arguments, IProgress
case "java.project.import":
ProjectCommand.importProject(monitor);
return null;
case "java.project.resolveSourceUri":
return ResolveSourceMappingHandler.resolveSourceUri((String) arguments.get(0), (ArrayList<String>) arguments.get(1));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you make the second argument to be optional?

Signed-off-by: Sheng Chen <[email protected]>
@@ -79,6 +80,12 @@ public Object executeCommand(String commandId, List<Object> arguments, IProgress
case "java.project.import":
ProjectCommand.importProject(monitor);
return null;
case "java.project.resolveSourceUri":
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since the input is the stacktrace text, the command name such as java.project.resolveStackTraceLocation is more descriptive.

Copy link
Contributor

@testforstephen testforstephen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@testforstephen testforstephen merged commit 43d2add into eclipse-jdtls:master Nov 3, 2020
@jdneo jdneo deleted the cs/stacktrace branch November 3, 2020 02:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature Request] Provide method for converting callstack entry to location
3 participants