microsoft / microsoft/TypeScript
[Proposal] Display all properties (inherited or not) of a given class (in TypeScript)
Chưa có ai nhận issue này.
- Ngôn ngữ chính
- Go
- Star
- 111k
- Fork
- 14.4k
- Merge trung bình
- 1 ngày 19 giờ
- Pull request đã merge (30 ngày)
- 117
Mô tả
From @yahiko00 on September 4, 2016 21:56
Visual Studio Code is a fantastic tool and I am really impressed by all its features despite being quite young.
There is a feature that does not still exists in VS Code which could be really convenient when we are forced to deal with big inheritance hierarchies.
This proposal is based on the TypeScript language, but I am quite sure this could apply to other OOP languages VS Code supports.
Overview of the Workflow
Let us assume we have a source file animal.ts like this:
// animal.ts
abstract class Animal {
private dna: number;
name: string;
constructor(name: string) {
this.dna = Math.random();
this.name = name;
}
abstract shout(): string;
}
This file could be open or not in VS Code, but it is part of the current project.
Let us assume we have another source file bird.ts like this:
// bird.ts
class Bird extends Animal {
constructor() {
super();
this.name = "Hector";
}
shout(): string {
return "Cuicui!"; // sorry it is in French... I do not know how a bird shouts in English ^_^
}
}
This file is open in VS Code.
What I would like to be able to do in VS Code is displaying all properties, inherited or not, available for the class Bird.
To do so, we could move the cursor on the Bird identifier, press F1 key, and run a new Display all inherited properties command.
This new command would open a new file in a new tab called Bird (all inherited properties).
In this example, the content of this file would be the following:
class Bird {
private dna: number;
name: string;
super.constructor(name: string) {
this.dna = Math.random();
this.name = name;
}
constructor() {
super();
this.name = "Hector";
}
shout(): string {
return "Cuicui!";
}
}
The content of Bird (all inherited properties) has nothing to do with valid syntax. Its purpose is only informational.
Some informal rules
- Attributes should be displayed first.
- Type anotations should be rendered unchanged.
- Access modifiers
public,protected,privateshould be rendered unchanged. - Abstract methods which are not overriden should be rendered.
- All versions of an overriden method should be rendered, with a concatenation of
superprefixes to distinguish each version in the inheritance hierarchy. For instancesuper.method()would refer to immediatemethod()'s parent, whereassuper.super.method()would refer tomethod()'s grand-parent, and so on. Method()'s parent should be displayed before themethod()itself.- The same rules for
method()apply toconstructor().
Copied from original issue: Microsoft/vscode#11526
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
Bắt đầu với các ví dụ animal.ts và bird.ts trong đề xuất, sau đó tìm hiểu điểm vào của lệnh F1 trong VS Code và cách thông tin kế thừa của TypeScript được cung cấp. Công việc được xem là hoàn tất khi một lệnh có thể hiển thị các thuộc tính, phương thức, hàm khởi tạo và thành viên trừu tượng được kế thừa và cục bộ theo định dạng thông tin đã mô tả.
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, vscode
- Lĩnh vực
- developer-experience, tooling
- Loại issue
- Tính năng
- Độ khó
- 5/5
- Thời gian dự kiến
- Hơn một tuần
- 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
- 28/100