PowerShell / PowerShell/PowerShellEditorServices

Add an on snippet event to psEditor API

オープン
#439 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

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

Area-psEditor Issue-Enhancement
主要言語
C#
スター
767
フォーク
266
平均マージ
3日 16時間
マージ済み PR(30日)
1

説明

It'd be nice to have an event we could hook into when a snippet is used. It would be great if the
the ast of the snippet, the variables, and maybe snippet metadata like name was passed to the handler.
Alternatively (or additionally) allow editor commands to act like snippets (e.g. set "variables" to
tab to, etc.) This would enable dynamic snippets that can expand or shape the snippet based on command
output.

A very simple mock up:

/* VSCode snippet example */
"Comment Help with PowerShell Output": {
    "prefix": "CommentHelp",
    "body": [
        "<#",
        ".SYNOPSIS",
        "    ${Short description}",
        ".DESCRIPTION",
        "    ${Long description}",
        ".NOTES",
        "    Date: ${PowerShell1:Get-Date -Format MM-dd-yyyy}",
        ".LINK",
        "    ${PowerShell2:Get-Command -Module \\$MyInvocation.MyCommand.Module.Name}",
        "#>"
    ]
}
# PowerShell event handler.
$eventHandler = {
    param($snippetVariables)
    foreach ($variable in $snippetVariables) {
        if ($variable.Name.StartsWith('PowerShell')) {
            $script = [scriptblock]::Create($variable.Value)
            $output = & $script
            $psEditor.GetEditorContext().CurrentFile.InsertText($output, $variable.Range)
        }
    }
}
<#
.SYNOPSIS
    Short description
.DESCRIPTION
    Long description
.NOTES
    Date: 04-12-2017
.LINK
    Get-Function1
    Get-Function2
    Get-Function3
#>

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

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

はじめの一歩

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

調査の方向性

Issue では、ファイル、テスト、実装のエントリポイントが指定されていません。まず psEditor API と既存の snippet 処理パスを特定し、次に目標がイベント、コマンドに基づく snippets、またはその両方のどれなのかを明確にしてください。完了条件には、snippet AST、変数、メタデータに対する定義済みの handler 契約と、選択したスコープをカバーする動作およびテストを含める必要があります。

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

評価

技術スタック
csharp, powershell
領域
api, tooling
issue の種類
機能追加
難易度
5/5
見積もり時間
1週間以上
活発さ
停滞
明瞭さ
説明が足りない
初心者へのやさしさ
25/100

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

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