microsoft / microsoft/vscode-cpptools

Add textmate scope for declarations and definitions

Aperta
#8,489 4 commenti 3 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Feature Request Feature: Colorization Language Service
Lingua principale
TypeScript
Stelle
6.2k
Fork
1.7k
Merge medio
14h 46m
PR unite (30g)
61

Descrizione

Type: Feature Request

I tried to create a color theme that all name introduction (like declarations and definitions) are bold. However, it's not possible to unambiguously select all of those.

For example, here's a struct definition and usage:

struct MyStruct {}; // 1

MyStruct myInstance; // 2

auto function() -> decltype(myInstance) { // 3
    MyStruct myVar; // 4
    return myVar;
}

I tried to make MyStruct in 1, myInstance in 2, function in 3, myVar in 4 all bold. However, any attempt to make them bold also resulted in MyStruct being bold in 2, but it's a usage of MyStruct, not it's definition. Then any attempt to make myInstance bold in 2 also resulted in myInstance being bold in 3, but it is also a usage of it, not it's declaration like in 2. Then, same thing at 4. Local variable are indistinguishable in declaration and uses.

A solution would be to introduce a new meta scope around all name introduction.

Today myVar at line 4 have those scopes:

  • meta.body.function.definition.cpp
  • meta.function.definition.cpp
  • source.cpp

And semantic token type variable with modifier local.

With my proposition, it would look like this:

  • meta.name-introduction.cpp
  • meta.body.function.definition.cpp
  • meta.function.definition.cpp
  • source.cpp

That meta scope would surround the name MyStruct in 1, the name myInstance in 2, the name function in 3 and the name myVar in 4.

That way, a color theme could highlight declaration and definition differently from uses of a name.

A name can be introduced multiple times. For example:

struct MyStruct;

struct MyStruct {
    auto fn() -> void;
};

auto MyStruct::fn() -> void {
   // ...
}

Here, both name have a declaration and a definition and no uses.

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 tracciando come le dichiarazioni, le definizioni C++ e il tipo di token semantico variable con il modificatore local diventano scope TextMate. Usa gli esempi nell’issue come casi, includendo i nomi delle struct, le variabili, le funzioni e le dichiarazioni ripetute. Il lavoro è completo quando meta.name-introduction.cpp racchiude le introduzioni senza corrispondere anche agli usi ordinari.

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

Valutazione

Stack tecnologico
cpp
Ambito
tooling
Tipo di issue
Funzionalità
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Tranquilla
Chiarezza
Abbastanza chiara
Idoneità per principianti
52/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.