microsoft / microsoft/vscode-cpptools
Add textmate scope for declarations and definitions
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- TypeScript
- Sterne
- 6.2k
- Forks
- 1.7k
- Ø Merge
- 14 Std. 46 Min.
- Gemergte PRs (30 T.)
- 61
Beschreibung
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.cppmeta.function.definition.cppsource.cpp
And semantic token type variable with modifier local.
With my proposition, it would look like this:
meta.name-introduction.cppmeta.body.function.definition.cppmeta.function.definition.cppsource.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.
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Beginne damit nachzuverfolgen, wie C++-Deklarationen, -Definitionen und der Semantic-Token-Typ variable mit dem Modifier local zu TextMate-Scopes werden. Verwende die Beispiele im Issue als Fälle, einschließlich Struct-Namen, Variablen, Funktionen und wiederholten Deklarationen. Fertig ist die Aufgabe, wenn meta.name-introduction.cpp Einführungen umschließt, ohne zugleich gewöhnliche Verwendungen zu erfassen.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- cpp
- Bereich
- tooling
- Issue-Typ
- Feature
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Aktivitätsstatus
- Ruhig
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 52/100