PowerShell / PowerShell/PowerShellEditorServices

Add an on snippet event to psEditor API

Đang mở
#439 1 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Area-psEditor Issue-Enhancement
Ngôn ngữ chính
C#
Star
767
Fork
266
Merge trung bình
3 ngày 16 giờ
Pull request đã merge (30 ngày)
1

Mô tả

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
#>

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Hướng nghiên cứu

Issue không nêu tên tệp, test hoặc các điểm vào của phần triển khai. Hãy bắt đầu bằng việc xác định psEditor API và luồng xử lý snippet hiện có, sau đó làm rõ mục tiêu là một event, snippets dựa trên command hay cả hai. Phần hoàn tất cần bao gồm một handler contract được định nghĩa cho snippet AST, biến và metadata, cùng với hành vi và test bao quát phạm vi đã chọn.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
csharp, powershell
Lĩnh vực
api, tooling
Loại issue
Tính năng
Độ khó
5/5
Thời gian dự kiến
Hơn một tuần
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Cần làm rõ
Mức phù hợp với người mới
25/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.