-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[lldb-dap] Emit declarations along with variables #74865
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1101,6 +1101,29 @@ std::string CreateUniqueVariableNameForDisplay(lldb::SBValue v, | |
// can use this optional information to present the | ||
// children in a paged UI and fetch them in chunks." | ||
// } | ||
// "declaration": { | ||
// "type": "object | undefined", | ||
// "description": "Extension to the protocol that indicates the source | ||
// location where the variable was declared. This value | ||
// might not be present if no declaration is available.", | ||
// "properties": { | ||
// "path": { | ||
// "type": "string | undefined", | ||
// "description": "The source file path where the variable was | ||
// declared." | ||
// }, | ||
// "line": { | ||
// "type": "number | undefined", | ||
// "description": "The 1-indexed source line where the variable was | ||
// declared." | ||
// }, | ||
// "column": { | ||
// "type": "number | undefined", | ||
// "description": "The 1-indexed source column where the variable was | ||
// declared." | ||
// } | ||
// } | ||
// } | ||
Comment on lines
+1104
to
+1126
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we document that is is an extension if it actually isn't part of the DAP protocol from the Microsoft website? |
||
// }, | ||
// "required": [ "name", "value", "variablesReference" ] | ||
// } | ||
|
@@ -1165,6 +1188,24 @@ llvm::json::Value CreateVariable(lldb::SBValue v, int64_t variablesReference, | |
const char *evaluateName = evaluateStream.GetData(); | ||
if (evaluateName && evaluateName[0]) | ||
EmplaceSafeString(object, "evaluateName", std::string(evaluateName)); | ||
|
||
if (lldb::SBDeclaration decl = v.GetDeclaration(); decl.IsValid()) { | ||
llvm::json::Object decl_obj; | ||
if (lldb::SBFileSpec file = decl.GetFileSpec(); file.IsValid()) { | ||
char path[PATH_MAX] = ""; | ||
if (file.GetPath(path, sizeof(path)) && | ||
lldb::SBFileSpec::ResolvePath(path, path, PATH_MAX)) { | ||
decl_obj.try_emplace("path", std::string(path)); | ||
} | ||
} | ||
|
||
if (int line = decl.GetLine()) | ||
decl_obj.try_emplace("line", line); | ||
if (int column = decl.GetColumn()) | ||
decl_obj.try_emplace("column", column); | ||
|
||
object.try_emplace("declaration", std::move(decl_obj)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So above we might or might not get any of the info, do we want to only emplace this into "declaration" if we at least have both a valid path and a valid line? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This one makes sense. I'll make that fix. |
||
} | ||
return llvm::json::Value(std::move(object)); | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is "type"? I also don't see you setting it in the diff below this one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this "type" is a JSON schema attribute, not an actual thing being returned