IssueParser

An IssueParser object is a streaming-style object capable of parsing Issue objects from the string output of a task (such as the standard output of a Process). This is accomplished by “pushing” lines of output into the parser, which processes that output using a series of predefined Issue Matcher rules defined in an extensions JSON manifest.

The IssueParser class is not subclassable.

An example of using an issue parser alongside a Process object to parse issues from the standard output of the process:

let p = new Process(path, {
    args: args
});

let parser = new IssueParser("my-issue-matcher");

p.onStdout((line) => {
    parser.pushLine(line);
});

p.onDidExit((code) => {
    let issues = parser.issues;
    
});

p.start();

In this example, an issue parser is created, and with each line of output from the process, the line is pushed onto the parser. Once the process exits, the issues are requested from the parser as an array of Issue objects.

Class Methods

constructor([matcherNames])

Creates a new IssueParser object with one or more issue matcher names. The matcherNames argument may be either a string, in which case a single matcher is used, or an array of strings, in which case multiple matchers are used.

Properties

issues

The array of Issue objects that have been successfully parsed from the provided output. If no issues are parsed, an empty array is returned.

This property is readonly.

Methods

pushLine(line)

Pushes a new line of output on to the parser, which causes immediate parsing of that line against the current set of matchers.

clear()

Removes all issues from the parser’s issues array and resets any in-progress matching. This can be used to “batch” issues after a known point within the output is reached.