2

I tried to implement the pattern matcher for tslint but it is going haywire. I am certain that regex is specified correctly, yet VSC keeps highlighting incorrect files. Here is my tasks.json file:

{
"version": "0.1.0",
"command": "gulp",
"isShellCommand": true,
"args": [

],
"tasks": [
    {
        "taskName": "build",
        "args": [],
        "isBuildCommand": true,
        "problemMatcher": [
            {
                "owner": "gulp",
                "fileLocation": ["absolute"],
                "pattern": {
                    "regexp": "^\\[[^>]* > ([^(]*)\\((\\d*),(\\d*)\\): (error) (.*)$",
                    "file": 1,
                    "line": 2,
                    "column": 3,
                    "severity": 4,
                    "message": 5
                }
            },
            {
                "owner": "gulp",
                "fileLocation": ["relative", "${workspaceRoot}/src/"],
                "pattern": {
                    "regexp": "^\\([a-z\\-]*\\) ([^\\[]*)\\[([\\d]*), ([\\d]*)\\]: (.*)$",
                    "file": 1,
                    "line": 2,
                    "column": 3,
                    "severity": 1,
                    "message": 4
                }
            }
        ]
    }
]
}
JasonMArcher
  • 14,195
  • 22
  • 56
  • 52
tomitrescak
  • 1,072
  • 12
  • 22
  • I am very interested in this as well. I had no idea VSC had the ability to do this. Has anyone who has setup code highlighting for vsc shed some light on this? – dss Jun 02 '15 at 17:42
  • It has been corrected in 0.2.0 and works normally now. Look on the vs code web page for the description on how to add a new matcher (under tasks). You also need to understand regular expressions to do it. – tomitrescak Jun 02 '15 at 23:14
  • been there, done that, but my matcher doesn't match anything... maybe you can help me? http://stackoverflow.com/questions/34055354/why-doesnt-this-problemmatcher-in-vs-code-work – santa Dec 09 '15 at 10:52

2 Answers2

0

Solved in version 0.2.0. It was a bug.

tomitrescak
  • 1,072
  • 12
  • 22
0

No only do you have to understand regular expressions, but you have to remember to escape for json too!

To get this working from the straight output from tslint rather than the gulp version, I had to use:

^(.*\.ts)\[(\d+), (\d+)\]: (.*)$

In the json this becomes:

  "problemMatcher": {
    "owner": "tslint",
    "fileLocation": [
      "absolute"
    ],
    "severity": "warning",
    "pattern": {
      "regexp": "^(.*\\.ts)\\[(\\d+), (\\d+)\\]: (.*)$",
      "file": 1,
      "line": 2,
      "column": 3,
      "message": 4
    }
  }
Tim
  • 7,746
  • 3
  • 49
  • 83