【发布时间】:2020-06-21 10:57:50
【问题描述】:
我目前正在为 Campbell Scientific 数据记录器使用的语言编写 vscode 扩展。我所做的部分扩展为编译器结果指定了一个自定义问题匹配器。
我遇到的问题是,当我使用 tasks.json 中的任务将 crbasic 程序 (test.cr300) 发送到编译器时,我无法匹配编译器结果顶部的文件名。
编辑:这是由于文件名和错误消息之间的空白行。我目前无法找到解决此问题的方法。即使在 https://regex101.com/ 上工作,将 \n 添加到模式也无法按预期工作。
编译器返回的文本示例:
test.cr300 -- Compile Failed!
line 12: Undeclared variable U1.
line 18: gmx600 not yet declared so cannot be aliased.
line 19: gmx600 not yet declared so cannot be aliased.
line 20: gmx600 not yet declared so cannot be aliased.
line 21: gmx600 not yet declared so cannot be aliased.
我的 package.json 中指定的模式:
"pattern": [
{
"regexp": "^(.*\\.cr300).*\\n$",
"file": 1
},
{
"regexp": "^line\\s(\\d+):\\s(.+)$",
"line": 1,
"message": 2,
"loop": true
}
]
这是我在调试中运行扩展时来自 tasks.json 的任务。
{
"label": "CRBasic: Compiler",
"type": "shell",
"group": {
"kind": "build",
"isDefault": true
},
"options": {
"shell": {
"executable": "powershell.exe"
}
},
"command": "${config:CRBasic.Path.Compiler path}\\cr300comp.exe",
"args": [
"${file}"
],
"problemMatcher": [
"$crbasicCompiler"
]
}
【问题讨论】: