2015-05-12 49 views
2

我試圖爲tslint實現模式匹配器,但它會失靈。我確信正則表達式正確,但VSC不斷突出顯示不正確的文件。這裏是我的tasks.json文件:Visual Studio代碼 - tslint - 模式匹配器

{ 
"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 
       } 
      } 
     ] 
    } 
] 
} 
+0

我很感興趣在這也是如此。我不知道VSC有能力做到這一點。有沒有人爲vsc設置了代碼突出顯示了這一點? – dss

+0

已在0.2.0中更正,現在正常工作。查看vs代碼網頁,瞭解如何添加新匹配器(在任務下)。您還需要了解正則表達式才能做到這一點。 – tomitrescak

+0

在那裏,做到了,但我的匹配器不匹配任何東西......也許你可以幫助我? http://stackoverflow.com/questions/34055354/why-doesnt-this-problemmatcher-in-vs-code-work – santa

回答

0

在版本0.2.0中解決。這是一個錯誤。

0

你不僅要理解正則表達式,還必須記住要爲json逃跑!

tslint而非一飲而盡版本得到直輸出這個工作,我不得不使用:

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

在此變成了JSON:

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