【问题标题】:How to make vscode problem matcher match the IAR ARM compiler error?如何使 vscode 问题匹配器匹配 IAR ARM 编译器错误?
【发布时间】:2019-11-15 16:00:36
【问题描述】:

我正在尝试匹配 IAR ARM 编译器为 VSCode ProblemMatcher 生成的这种格式的错误...

"d:\test\helloWorld.c",646  Warning[Pe223]:
function "printf" declared implicitly

使用 regex101.com,我可以将第一行消息与此正则表达式匹配...

^"(.*)",(\d+)\s+((Warning|Error)\[Pe\d+\]):$

唉,当使用正确的转义斜杠放入我的 tasks.json 文件时。 vscode 在 task.json 中提示该错误。 error in task.json

"problemMatcher": {
   "owner": "cpp",
   "fileLocation": "absolute",
   "pattern": [
      // The regular expression for IAR ARM compiler. Example to match: 
      //   "d:\test\helloWorld.c",646  Warning[Pe223]:
      //   function "printf" declared implicitly
      {
         "regexp": "^"(.*)",(\\d+)\\s+((Warning|Error)\\[Pe\\d+\\]):$",
         // The first match group matches the file name which is relative.
         "file"    : 1,
         // The second match group matches the line on which the problem occurred.
         "location": 2,
         // The third match group matches the message
         "message" : 3,
         // The fourth match group matches the problem's severity. Can
         // be ignored. Then all problems are captured as errors.
         "severity": 4
      },
      {
         // The next line matches the message.
         "regexp": "^([^\\s].*)$",
         "message": 1               
      }
   ]
}

然后,我把“”去掉,变成了,

^(.*),(\\d+)\\s+((Warning|Error)\\[Pe\\d+\\]):$

最后,在运行将在 VSCode 终端中生成这些错误的任务后,我在问题选项卡中收到输出。警告信息和行号是正确的。但是文件不匹配,无法跳转到文件。

【问题讨论】:

    标签: visual-studio-code vscode-tasks


    【解决方案1】:

    好的,我从https://docs.microsoft.com/en-us/visualstudio/ide/using-regular-expressions-in-visual-studio找到了答案

    \"匹配双引号

    所以正确的正则表达式是,

    "regexp": "^\"(.+?)\",(\\d+)\\s+((Warning|Error)\\[Pe\\d+\\]):$",
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-03-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多