ErrorParser
Identifier:
org.eclipse.cdt.core.ErrorParser
Since:
CDT 1.2
Description:
This extension point is used to contribute a new Error Parser. A Error Parser is used to parse errors/warnings/info from build output and populate Problems View with them.
Configuration Markup:
<!ELEMENT extension (errorparser)>
<!ATTLIST extension
id CDATA #REQUIRED
name CDATA #REQUIRED
point CDATA #REQUIRED>
- id - ID of the extension point (Simple ID)
- name - Name of the extension point
<!ELEMENT errorparser (pattern* , context*)>
<!ATTLIST errorparser
id IDREF #IMPLIED
name CDATA #IMPLIED
class CDATA "org.eclipse.cdt.core.errorparsers.RegexErrorParser">
- id - ID of the error parser. If attribute is missing error parser ID is constructed appending Simple ID of extension to plugin ID.
- name - Name of the error parser. If this attribute is missing extension name is taken.
- class - a fully qualified name of the Java class that implements org.eclipse.cdt.core.IErrorParser
<!ELEMENT pattern EMPTY>
<!ATTLIST pattern
severity (Error|Warning|Info|Ignore)
regex CDATA "(.*)"
file-expr CDATA #IMPLIED
line-expr CDATA #IMPLIED
description-expr CDATA "$1"
variable-expr CDATA #IMPLIED
eat-processed-line (true | false) >
Use element "pattern" to configure RegexErrorParser.
- severity - This attribute specifies which severity should be used to display the marker in Problems View. There are 3 levels of severity, "Error", "Warning" and "Info". The forth option, "Ignore" tells the system to stop checking the line against the other patterns without causing it to show up in the Problems View.
- regex - Java regular expression which defines capturing groups for file-expr, line-expr and description-expr.
- file-expr - "Replacement" expression composed from capturing groups defined in regex to define the file.
- line-expr - "Replacement" expression composed from capturing groups defined in regex to define the line in file.
- description-expr - "Replacement" expression composed from capturing groups defined in regex to define the description (i.e. "$1: $2"). It is possible to specify more than one capturing group in such expression.
- variable-expr - "Replacement" expression composed from capturing groups defined in regex to define variable. The value will be assigned to marker attributes but is not used by CDT currently.
- eat-processed-line - The attribute defines if a line matched by the pattern is prevented or allowed to be processed by the rest of the patterns. "false" allows several patterns to evaluate the same line.
<!ELEMENT context EMPTY>
<!ATTLIST context
type CDATA #REQUIRED>
Use this element to specify the context where an error parser can be used. If none is specified, the default context type will be "build".
An example of a context type is "build". Only error parsers in this context are used to parse build output. You can see these error parsers in the "C/C++" > "Build" > "Settings" preference page.
An error parser can be assigned to more than one context type. Clients contributing error parsers are free to define their own context types.
- type - The type of context where an error parser can be used.
Examples:
package org.eclipse.cdt.example.errorparser;
import org.eclipse.cdt.core.IMarkerGenerator;
import org.eclipse.cdt.core.errorparsers.AbstractErrorParser;
import org.eclipse.cdt.core.errorparsers.ErrorPattern;
/**
* Simple error parser parsing lines of kind "FILE,LINE:error DESCRIPTION"
* Enable the errorparser in project Properties->C/C++ Build->Settings->Error Parsers
*/
public class SampleErrorParser extends AbstractErrorParser {
private static final ErrorPattern[] patterns = {
new ErrorPattern("(.*),(.*):error (.*)", 1, 2, 3, 0, IMarkerGenerator.SEVERITY_ERROR_RESOURCE),
new ErrorPattern("(.*),(.*):warning (.*)", 1, 2, 3, 0, IMarkerGenerator.SEVERITY_WARNING),
new ErrorPattern("(.*),(.*):info (.*)", 1, 2, 3, 0, IMarkerGenerator.SEVERITY_INFO),
};
/**
* Constructor to set the error pattern.
*/
public SampleErrorParser() {
super(patterns);
}
}
API Information:
Plug-ins that want to extend this extension point must implement org.eclipse.cdt.core.IErrorParser interface.
For most cases it is sufficient to configure RegexErrorParser which is provided by default.
Another good choice is to extend org.eclipse.cdt.core.errorparsers.AbstractErrorParser as done in the example.
ErrorParsers dealing with multi-line messages should implement org.eclipse.cdt.core.IErrorParser2 interface.
Supplied Implementation:
For another example of implementation see org.eclipse.cdt.internal.errorparsers.GCCErrorParser
Copyright (c) 2005, 2009 Andrew Gvozdev (Quoin Inc.) and others.
This program and the accompanying materials
are made available under the terms of the Eclipse Public License 2.0
which accompanies this distribution, and is available at
https://www.eclipse.org/legal/epl-2.0/
SPDX-License-Identifier: EPL-2.0