I have project that uses custom problemMatcher
. But I would like to extract it into an extension making it configurable. So eventually it could be used in tasks.json
like
{
"problemMatcher": "$myCustomProblemMatcher"
}
How to do that?
I have project that uses custom problemMatcher
. But I would like to extract it into an extension making it configurable. So eventually it could be used in tasks.json
like
{
"problemMatcher": "$myCustomProblemMatcher"
}
How to do that?
As of VSCode 1.11.0 (March 2017), extensions can contribute problem matchers via package.json
:
{
"contributes": {
"problemMatchers": [
{
"name": "gcc",
"owner": "cpp",
"fileLocation": [
"relative",
"${workspaceRoot}"
],
"pattern": {
"regexp": "^(.*):(\\d+):(\\d+):\\s+(warning|error):\\s+(.*)$",
"file": 1,
"line": 2,
"column": 3,
"severity": 4,
"message": 5
}
}
]
}
}
Tasks can then reference it with "problemMatcher": ["$name"]
($gcc
in the case of this example).
Instead of defining a matcher's pattern
inline, it can also contributed in problemPatterns
so it's reusable (for instance if you want to use it in multiple matchers):
{
"contributes": {
"problemPatterns": [
{
"name": "gcc",
"regexp": "^(.*):(\\d+):(\\d+):\\s+(warning|error):\\s+(.*)$",
"file": 1,
"line": 2,
"column": 3,
"severity": 4,
"message": 5
}
],
"problemMatchers": [
{
"name": "gcc",
"owner": "cpp",
"fileLocation": [
"relative",
"${workspaceRoot}"
],
"pattern": "$gcc"
}
]
}
}
© 2022 - 2024 — McMap. All rights reserved.