【问题标题】:How to define a squiggle range for the problem matcher in tasks.json (VS Code)?如何在tasks.json(VS Code)中为问题匹配器定义曲线范围?
【发布时间】:2021-12-13 13:58:58
【问题描述】:

我在tasks.json 中写了一个problemMatcher,看起来像这样:

"problemMatcher": {
    "owner": "myFileExtension",
    "pattern": {
    "regexp": "myRegExp",
    "file": 1,
    "line": 2,
    "severity": 3,
    "message": 4,
    "location": 2
    }
}

在我运行构建任务后,我正在使用这个问题匹配器来扭曲有问题的行。但是,我想根据问题的实际出处来绘制一个特定的范围,而不是整条线。看了documentation之后,我仍然不确定如何做到这一点。

如何在tasks.json 中绘制范围?

【问题讨论】:

    标签: visual-studio-code vscode-tasks


    【解决方案1】:

    请参阅文档中的最后一个示例。

    位置可以是 () 中包含的 1、2 或 4 个数字

    • 1:(line)
    • 2:(line,char)
    • 4:(lineStart,charStart,lineEnd,charEnd)
    {
      "version": "2.0.0",
      "tasks": [
        {
          "label": "watch",
          "command": "tsc",
          "args": ["--watch"],
          "isBackground": true,
          "problemMatcher": {
            "owner": "typescript",
            "fileLocation": "relative",
            "pattern": {
              "regexp": "^([^\\s].*)\\((\\d+|\\d+,\\d+|\\d+,\\d+,\\d+,\\d+)\\):\\s+(error|warning|info)\\s+(TS\\d+)\\s*:\\s*(.*)$",
              "file": 1,
              "location": 2,
              "severity": 3,
              "code": 4,
              "message": 5
            },
            "background": {
              "activeOnStart": true,
              "beginsPattern": "^\\s*\\d{1,2}:\\d{1,2}:\\d{1,2}(?: AM| PM)? - File change detected\\. Starting incremental compilation\\.\\.\\.",
              "endsPattern": "^\\s*\\d{1,2}:\\d{1,2}:\\d{1,2}(?: AM| PM)? - Compilation complete\\. Watching for file changes\\."
            }
          }
        }
      ]
    }```
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-04-08
      • 1970-01-01
      • 1970-01-01
      • 2019-06-29
      相关资源
      最近更新 更多