Use Visual Studio Code for your Particle development needs

Hrm, what I wrote above no longer seems to work. The thing I mentioned there, that the string “workspace” was oddly prepended to console lines, does not seem to happen anymore.

I am not sure if I changed something in my environment or shell, or maybe it was part of an update to VSCode or the particle-cli or backend build system since then.

So now, using the following tasks.json file, the warning & error parser should work:

{ 
"version": "0.1.0", 
"command": "particle", 
"isShellCommand": true, 
"args": [], 
"showOutput": "always", 
"echoCommand": true, 
"tasks": [ 
    { 
        "taskName": "compile", 
        "suppressTaskName": false, 
        "isBuildCommand": true,             
        "args": ["electron","${workspaceRoot}", "--saveTo", "${workspaceRoot}/firmware.bin"],
        // Use the standard less compilation problem matcher.
            "problemMatcher": {
                "owner": "cpp",
                "fileLocation": ["relative", "${workspaceRoot}"],
                "pattern": {
                    "regexp": "^(.*?):(\\d+):(\\d+):\\s+(warning|error|fatal error):\\s+(.*)$",
                    "file": 1,
                    "line": 2,
                    "column": 3,
                    "severity": 4,
                    "message": 5
                },
                "severity":"error"
            }
    }, 
    { 
        "taskName": "flash",             
        "suppressTaskName": false, 
        "isTestCommand": true, 
        "args": ["--usb", "firmware.bin"] 
    }    
]     
} 

This is almost exactly the same as this SO response for Makefiles, and the binding for F8 is also useful: https://stackoverflow.com/questions/30269449/how-do-i-set-up-vscode-to-compile-c-code

Here’s a screenshot of how the problems should be picked up by the problem matcher when running the build task: