microsoft / microsoft/TypeScript

[Proposal] Display all properties (inherited or not) of a given class (in TypeScript)

Aperta
#10,752 18 commenti 16 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Needs Proposal Suggestion VS Code Tracked
Lingua principale
Go
Stelle
111k
Fork
14.3k
Merge medio
2g 4h
PR unite (30g)
132

Descrizione

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, private should 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 super prefixes to distinguish each version in the inheritance hierarchy. For instance super.method() would refer to immediate method()'s parent, whereas super.super.method() would refer to method()'s grand-parent, and so on.
  • Method()'s parent should be displayed before the method() itself.
  • The same rules for method() apply to constructor().

Copied from original issue: Microsoft/vscode#11526

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Inizia con gli esempi animal.ts e bird.ts della proposta, quindi analizza il punto di ingresso del comando F1 in VS Code e il modo in cui vengono esposte le informazioni sull’ereditarietà di TypeScript. Il lavoro sarà considerato completato quando un comando potrà visualizzare proprietà, metodi, costruttori e membri astratti ereditati e locali nel formato informativo descritto.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
typescript, vscode
Ambito
developer-experience, tooling
Tipo di issue
Funzionalità
Difficoltà
5/5
Tempo stimato
Più di una settimana
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
28/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.