microsoft / microsoft/TypeScript
Add Inline value provider api for debugging
Chưa có ai nhận issue này.
- Ngôn ngữ chính
- Go
- Star
- 111k
- Fork
- 14.3k
- Merge trung bình
- 2 ngày 4 giờ
- Pull request đã merge (30 ngày)
- 132
Mô tả
From https://github.com/microsoft/vscode/issues/119489
Background
The new inline value api for VS Code lets language extensions tell the debugger which values should be shown directly in a file while debugging. Without this API, VS Code uses a generic method for determining which values to show. This ends up showing many irrelevant values to the user
See https://github.com/microsoft/vscode/issues/119489 for an example of this
Feature Request
We'd like to use the TypeScript server's language smarts to implement the VS Code inline value api so that only relevant values are shown.
Here's a potential shape of the API based on the vscode inline value API
// For debugging, we request inline values at a specific location in a file
interface InlineValueRequestArgs extends FileLocationRequestArgs {}
interface InlineValueResponse extends Response {
body: InlineValue[];
}
// Support two types of inline values: simple ones that can be looked up by name, and more complex ones
// that require evaluating an expression
type InlineValue = InlineValueVariableLookup | InlineValueEvaluatableExpression;
// A value that can be looked up by name.
// This is mostly just an optimization for a common case of inline values
interface InlineValueVariableLookup {
// Span in code of the identifier
readonly span: TextSpan;
// Optional variable name to look up. If not specified, uses the name from `span`
// TODO: Is this needed for TS?
readonly variableName?: string;
}
// A value which is shown by evaluating a given expression
interface InlineValueEvaluatableExpression {
// Span in code of the expression
readonly span: TextSpan;
// Optional expression to evaluate. If not specified, uses the expression from `span`
// TODO: Is this needed for TS?
readonly expression?: string;
}
Behavior
Some notes on how the inline value provider should work (copied from @connor4312):
-
The debugger should handle source maps, so the provider should only have to worry about the requested file
-
Inline values should only be provided in the current and parent scopes
-
Declarations and assignments assignments should evaluate the declared or assigned expression,
barinbar = foo()orfooinfunction foo() {} -
Conditional expressions (ternary or
ifstatements) should evaluate the conditional and none of its children,!foo && barinif (!foo && bar) -
Property assignments should be evaluated,
foo()in{ x: foo() }
Here's a small example of some inline values:
function double(n: number) { // eval('double') -> double()
return n * 2;
}
let x = 1; // InlineValueVariableLookup for x here
if (x === 2) { // eval(x === 2) -> false
x *= 2; // this line should NOT be evaluated since it's not the scope or its parents
}
if (x === 1) { // eval(x === 1) -> true
x *= 2; // InlineValueVariableLookup for x here
const y = {
z: x ** 2, // eval(x ** 2) -> 16
};
console.log(x); // <-- paused here
}
@connor4312 Is handling this on the VS Code side and should be able to answer any questions regarding this API
/cc @weinand
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Hướng nghiên cứu
Không có tệp repository hoặc test nào được nêu tên. Hãy bắt đầu bằng cách xem xét các interface giá trị inline được đề xuất và inline value API được liên kết của VS Code, sau đó kiểm tra các điểm vào của máy chủ TypeScript cung cấp các yêu cầu của language service. Hoàn tất khi máy chủ cung cấp các giá trị inline cho scope hiện tại và các scope cha, đồng thời tuân theo hành vi được liệt kê đối với khai báo, phép gán, điều kiện và biểu thức thuộc tính.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- typescript
- Lĩnh vực
- devtools
- Loại issue
- Tính năng
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Khá rõ ràng
- Mức phù hợp với người mới
- 35/100