microsoft / microsoft/vscode-cpptools

Add textmate scope for declarations and definitions

Abierto
#8,489 4 comentarios 3 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Feature Request Feature: Colorization Language Service
Lenguaje dominante
TypeScript
Estrellas
6.2k
Forks
1.7k
Merge medio
14 h 46 min
PR fusionados (30 d)
61

Descripción

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.

Guía de contribución

Abrir la guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Línea de trabajo

Empieza trazando cómo las declaraciones, definiciones de C++ y el tipo de token semántico variable con el modificador local se convierten en scopes de TextMate. Usa los ejemplos del issue como casos, incluidos los nombres de struct, las variables, las funciones y las declaraciones repetidas. Se considera terminado cuando meta.name-introduction.cpp rodea las introducciones sin coincidir también con los usos ordinarios.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
cpp
Área
tooling
Tipo de issue
Nueva funcionalidad
Dificultad
4/5
Tiempo estimado
3-5 días
Estado de actividad
Tranquilo
Claridad
Bastante claro
Aptitud para principiantes
52/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.