Add a command "Go To Definition/Declaration "

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

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

評価

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

調査の方向性

既存の editor.action.revealDeclaration と editor.action.revealDefinition コマンド、および issue にある F12/キーバインドの例を確認します。C/C++ 拡張機能のコマンドエントリポイントを追跡し、#include 行を含む現在のシンボルコンテキストがどのように対象を選択するかを特定します。1 つのネイティブコマンドが常に適切なアクションを選択すれば完了です。

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

説明

enhancement Feature: Go to Definition Language Service more votes needed
Feature Request

I would love to be able to apply "Go To Declaration" when I am requesting it on a definition, and "Go To Definition" when I am requesting it on a declaration.

I foolishly thought this was the standard F12 behaviour before finding out I need to bind both and use them contextually! I imagine its trivial to implement the context switching internally and apply the correct one given the context of the request.

i.e.
IF requested on a declaration -> Go To Definition
IF requested on a definition -> Go To Decleration

My workaround currently is binding the behaviour to the "when" field inside Keybinds.json based on file endings:

    {
        "key": "F12",
        "command": "editor.action.revealDeclaration",
        "when": "editorHasDeclarationProvider && editorTextFocus && !isInEmbeddedEditor && resourceExtname =~ /\\.(cpp|cxx|cc|c\\+\\+|c)$/"
    },
    {
        "key": "F12",
        "command": "editor.action.revealDefinition",
        "when": "editorHasDefinitionProvider && editorTextFocus && !isInEmbeddedEditor && resourceExtname =~ /\\.(hpp|hxx|hh|h\\+\\+|h|inl|ipp)$/"
    },

This fails in nuanced cases such as F12 on #include lines when in a source file, this will attempt "Go To Declaration" and fail but should be using "Go To Definition". Another reason a context based command would be useful!

A native command provided by the extension would be nice.

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

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

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

はじめの一歩

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

microsoft/vscode-cpptools のほかの issue

microsoft/vscode-cpptools の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

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

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