visual-studio-codevscode-problem-matcher

vscode custom task problem matcher does not find text that matches regex


Here is my entire tasks.json file in the .vscode directory

{
    // See https://go.microsoft.com/fwlink/?LinkId=733558
    // for the documentation about the tasks.json format
    "version": "2.0.0",
    "tasks": [
        {
            "label": "make",
            "type": "shell",
            "command": "make",
            "args": [
                "all"
            ],
            "group": "build",
            "presentation": {
                "reveal": "always",
                "echo": true,
                "showReuseMessage": false,
                "clear": true
            },
            "problemMatcher": [
                {
                    "owner": "ld65-a",
                    "fileLocation": [
                        "relative",
                        "${workspaceFolder}"
                    ],
                    "severity": "error",
                    "pattern": {
                        "regexp": "^(Unresolved external)\\s+'(.*)'.*:\\s+(.*)\\((\\d.*)\\)$",
                        "file": 3,
                        "line": 4,
                        "message": 1,
                        "code": 2
                    }
                },
                {
                    "owner": "ld65-b",
                    "fileLocation": [
                        "relative",
                        "${workspaceFolder}"
                    ],
                    "pattern": {
                        "regexp": "^ld65:\\s+(warning|error|Warning|Error):(.*)\\((\\d.*)\\):\\s+(.*)$",
                        "file": 2,
                        "line": 3,
                        "severity": 1,
                        "message": 4
                    }
                },
                {
                    "owner": "ld65-c",
                    "fileLocation": "autoDetect",
                    "pattern": {
                        "regexp": "^ld65:\\s+(warning|error|Warning|Error): (\\d+.*)$",
                        "kind": "file",
                        "severity": 1,
                        "message": 2
                    }
                },
                {
                    "owner": "cc65",
                    "fileLocation": [
                        "relative",
                        "${workspaceFolder}"
                    ],
                    "pattern": {
                        "regexp": "^(.*)\\((\\d.*)\\):\\s+(warning|error|Warning|Error):\\s+(.*)$",
                        "file": 1,
                        "line": 2,
                        "severity": 3,
                        "message": 4
                    }
                }
            ]
        },
        {
            "label": "clean",
            "type": "shell",
            "command": "make",
            "args": [
                "clean"
            ],
            "group": "build",
            "presentation": {
                "reveal": "always",
                "echo": true,
                "showReuseMessage": false,
                "clear": true
            }
        }
    ]
}

Here is the end of my text output that is being processed:

cl65 -C src/cmn-src-atarixl-xex.cfg --start-addr 0x4000 -Ln build/bin/cfgame.lbl --ld-args --dbgfile,build/bin/cfgame.dbg --mapfile build/bin/cfgame.map -o build/bin/cfgame.xex build/cf_fileUtils.o build/cf_font.o build/cf_mapEditor.o build/cf_pixmapViewer.o build/cf_tileMap.o build/cf_types.o build/cf_utils.o build/gr7utils.o build/gr12utils.o build/main.o build/pmg.o build/splash.o C:/cc65/lib/atarixl.lib
ld65: Warning: atari/crt0.s(207): 'lowcode area' reaches into $4000..$7FFF bank memory window
Unresolved external '_displaySplashExit' referenced in:
  src/main.s(97)
Unresolved external '_selectAppSplash' referenced in:
  src/main.s(71)
ld65: Error: 2 unresolved external(s) found - cannot create output file
make: *** [makefile:95: cfgame] Error 1
The terminal process "C:\Program Files\Git\bin\bash.exe '-c', 'make all'" terminated with exit code: 2.

The problems that are detected come up earlier but it does also find the '2 unresolved external(s) found. It does not however find the specific information related to the Unresolved external text in the output. I tested my regex using regex101.com on this same output. I've tried a few variations on these - mostly some differences in the json defining the problem matcher.

The goal is to get the unresolved external items to be listed as individual problems referencing the actual symbol names.

I've read through other posts & answers related and tried different things, hence the reason the "owner" parameter has been set to strings 'ld65-a' etc.

I also tried changing the order the problem matchers are defined in, moving the unresolved external one to the first item in the array - this did not seem to matter.

I realize there are other ways to run the make task, but I needed to integrate with gnu make and this seemed a reasonable approach. Maybe there is a better idea here in terms of that - e.g. run gnu make on my vscode workspace from the app.


Solution

  • The Unresolved matcher is a multi-line problem matcher

            {
              "owner": "ld65-a",
              "fileLocation": ["relative", "${workspaceFolder}"
              ],
              "severity": "error",
              "pattern": [
                {
                  "regexp": "^(Unresolved external)\\s+'([^']+)'.*:$",
                  "message": 1,
                  "code": 2
                },
                {
                  "regexp": "^\\s+(.*)\\((\\d+)\\)$",
                  "file": 1,
                  "line": 2
                }
              ]
            },