PowerShell / PowerShell/PSScriptAnalyzer

Format indention of multiline statements

未关闭
#1,315 12 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

Area - Formatter Issue - Enhancement
主要语言
C#
星标
2.2k
派生
414
平均合并
13 小时 1 分钟
30 天内合并 PR
2

描述

Summary of the new feature

Enhance formatting of continued (multiline) statements (command and expression), combining the PipeLineIndentionStyle with statement continuation.

There are a lot of means to continue command statements, including pipe lines. especially so with expressions. I, myself, prefer all continued statements to be indented, but currently the formatting only supports indenting when a brace or parenthesis is involved, or optionally with a pipe line.

Proposed technical implementation details (optional)

I actually think the details of pipe line continuation gets simpler when the entire statement's continuation is taken in to account.

I am not fully understanding of how the formatting mechanism works, so this is a fundamental concept to how I would think it would work.

If using PowerShell AST's, for each PipeLineAst/CommandExpressionAst/etc, add 1 indention level to subsequent lines, in addition to all other indenting even for the same PipeLineAst.

There might be a need to restrict the continuation indention of a PipeLine or CommandExpression if they are the sole contents of a ParenExpression, because in that case, the PipeLine or CommandExpression is fully captured in the indention of the ParenExpression, as technically only one expression should appear in such cases, unlike a scriptblock or statementblock where multiple statements or expressions could appear.

I need to gather some examples to better demonstrate my use case.

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

没有指定文件或测试。首先定位格式化机制以及针对 PipeLineAst 和 CommandExpressionAst 的 PowerShell AST 处理;收集缺失的多行示例,然后将补全定义为一致的续行缩进,其中包括所述的带括号表达式区别,并编写覆盖该行为的测试。

由索引模型根据 Issue 内容生成。

评估

技术栈
csharp, powershell
领域
tooling
Issue 类型
功能
难度
5/5
预计耗时
一周以上
活跃度
停滞
描述清晰度
需要澄清
新手友好度
25/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。