Leverage AST and Java Runtime to resolve inline values#368
Merged
testforstephen merged 2 commits intomicrosoft:masterfrom Apr 21, 2021
Merged
Leverage AST and Java Runtime to resolve inline values#368testforstephen merged 2 commits intomicrosoft:masterfrom
testforstephen merged 2 commits intomicrosoft:masterfrom
Conversation
Contributor
Author
jdneo
reviewed
Apr 15, 2021
| } | ||
| } | ||
|
|
||
| private static IMethod findEnclosingMethod(ITypeRoot root, int stoppedOffset) throws JavaModelException { |
Member
There was a problem hiding this comment.
Is JDTUtils.findElementsAtSelection() suitable for this task?
Contributor
Author
There was a problem hiding this comment.
No, it doesn't apply to this task. The purpose of that helper is to find the definition element of the selection. For example, the offset is at the String▮, it returns the String.class element. But what we want is the enclosing method method.
void method() {
String▮ a = "test";
}
....debug.plugin/src/main/java/com/microsoft/java/debug/plugin/internal/InlineValueHandler.java
Outdated
Show resolved
Hide resolved
....debug.plugin/src/main/java/com/microsoft/java/debug/plugin/internal/InlineValueHandler.java
Outdated
Show resolved
Hide resolved
.../src/main/java/com/microsoft/java/debug/core/adapter/handler/InlineValuesRequestHanlder.java
Outdated
Show resolved
Hide resolved
.../src/main/java/com/microsoft/java/debug/core/adapter/handler/InlineValuesRequestHanlder.java
Outdated
Show resolved
Hide resolved
jdneo
approved these changes
Apr 21, 2021
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


The steps:
Visit AST tree to find the variable tokens in each lines.
ASTVisitor can identify if a node is a variable declaration and a simple name. And then based on resolveBinding, it's easy to tell if the name is a variable/field binding.
Resolve the values of the variable tokens.
Once the variable names in each lines are found, next step is to resolve values for these variables. Usually the variables come from four places, we can use different methods to get the values.
For the first two kinds, they are visible local variables of the current stack frame, and by default their values will be expanded by Variables View. So we're going to return them with VariableLookup kind to tell client to look them up in Variables View directly.
For the last two kinds, their values are hidden as properties of 'this' object and require additional evaluation to get their values. So we're going to return them with Evaluation kind, and then calling the debuggee runtime to evaluate their values.