microsoft / microsoft/vscode-cpptools

Add textmate scope for declarations and definitions

オープン
#8,489 コメント 4 件 リアクション 3 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

Feature Request Feature: Colorization Language Service
主要言語
TypeScript
スター
6.2k
フォーク
1.7k
平均マージ
14時間 46分
マージ済み PR(30日)
61

説明

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.

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

まず、C++ の宣言、定義、および modifier local を持つ semantic token type variable が、どのように TextMate scopes になるかを追跡します。issue の例をケースとして使用し、struct 名、変数、関数、繰り返される宣言を含めます。meta.name-introduction.cpp が導入部分を囲み、通常の使用にも同時にマッチしなければ完了です。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
cpp
領域
tooling
issue の種類
機能追加
難易度
4/5
見積もり時間
3〜5日
活発さ
静か
明瞭さ
おおむね明確
初心者へのやさしさ
52/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。