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?
Tasks in VS Code can be configured to run scripts and start processes so that many of these existing tools can be used from within VS Code without having to enter a command line or write new code. Workspace or folder specific tasks are configured from the tasks. json file in the . vscode folder for a workspace.
VS Code extensions support two main languages: JavaScript and TypeScript.
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"
}
]
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With