Package org.eclipse.cdt.core

# Class ErrorParserManager

java.lang.Object
java.io.OutputStream
org.eclipse.cdt.core.ErrorParserManager

All Implemented Interfaces:
  `Closeable`, `Flushable`, `AutoCloseable`, `IConsoleParser`, `IWorkingDirectoryTracker`

public class ErrorParserManager extends OutputStream implements IConsoleParser, IWorkingDirectoryTracker
The purpose of ErrorParserManager is to delegate the work of error parsing build output to `IErrorParser`s, assist in finding `IResource`s, and help create appropriate error/warning/info markers to be displayed by the Problems view.

Restriction:
  This class is not intended to be subclassed by clients.

## Field Summary

Fields
Modifier and Type
Field
Description
`static final String`
`BUILD_CONTEXT`
`static final char`
`ERROR_PARSER_DELIMITER`
Delimiter for error parsers presented in one string.
`static final String`
`PREF_ERROR_PARSER`
Deprecated.
since CDT 4.0.

## Constructor Summary

Constructors
Constructor
Description
`ErrorParserManager(ACBuilder builder)`
Constructor.
`ErrorParserManager(org.eclipse.core.resources.IProject project, URI baseDirectoryURI, IMarkerGenerator markerGenerator, String[] parsersIDs)`
URI based constructor.
`ErrorParserManager(org.eclipse.core.resources.IProject project, IMarkerGenerator markerGenerator)`
Constructor.
`ErrorParserManager(org.eclipse.core.resources.IProject project, IMarkerGenerator markerGenerator, String[] parsersIDs)`
Constructor.
`ErrorParserManager(org.eclipse.core.resources.IProject project, org.eclipse.core.runtime.IPath workingDirectory, IMarkerGenerator markerGenerator, String[] parsersIDs)`
Deprecated.
use `ErrorParserManager(IProject, URI, IMarkerGenerator, String[])` instead

## Method Summary

Modifier and Type
Method
Description
`void`
`addProblemMarker(ProblemMarkerInfo problemMarkerInfo)`
Add the given marker to the list of error markers.
`void`
`appendToScratchBuffer(String line)`
Deprecated.
Use IErrorParser2 interface to handle multiline messages rather than scratch buffer.
`void`
`clearScratchBuffer()`
Deprecated.
Use IErrorParser2 interface to handle multiline messages rather than scratch buffer.
`void`
`close()`
`protected void`
`collectFiles(org.eclipse.core.resources.IProject parent, List<org.eclipse.core.resources.IResource> result)`
Deprecated.
Use `findFileName(java.lang.String)` for searches.
`void`
`deDuplicate()`
De-duplicate error markers on resource that have had error markers added since `deferDeDuplication()` was called.
`void`
`deferDeDuplication()`
Flag the marker generator to defer the de-duplication of error markers until `deDuplicate()` is called
`protected org.eclipse.core.resources.IFile`
`findFileInWorkspace(URI uri)`
Find exact match in the workspace.
`protected org.eclipse.core.resources.IFile`
`findFileInWorkspace(org.eclipse.core.runtime.IPath path)`
Find exact match in the workspace.
`org.eclipse.core.resources.IFile`
`findFileName(String partialLoc)`
Returns the file with the given (partial) location if that file can be uniquely identified.
`org.eclipse.core.resources.IFile`
`findFilePath(String filePath)`
Deprecated.
Use `findFileName(java.lang.String)` for searches.
`void`
`flush()`
`void`
`generateExternalMarker(org.eclipse.core.resources.IResource file, int lineNumber, String desc, int severity, String varName, org.eclipse.core.runtime.IPath externalPath)`
Add marker to the list of error markers.
`void`
`generateMarker(org.eclipse.core.resources.IResource file, int lineNumber, String desc, int severity, String varName)`
Add marker to the list of error markers.
`static String[]`
`getDefaultErrorParserIds()`
`int`
`getDirectoryLevel()`
`int`
`getErrorCount()`
`static String[]`
`getErrorParserAvailableIds()`
`static String[]`
`getErrorParserAvailableIdsInContext(String context)`
`static IErrorParserNamed`
`getErrorParserCopy(String id)`
`static IErrorParserNamed`
`getErrorParserExtensionCopy(String id)`
`static String[]`
`getErrorParserExtensionIds()`
`int`
`getLineCounter()`
`OutputStream`
`getOutputStream()`
Method getOutputStream.
`String`
`getPreviousLine()`
Called by the error parsers.
`org.eclipse.core.resources.IProject`
`getProject()`
`String`
`getScratchBuffer()`
Deprecated.
Use IErrorParser2 interface to handle multiline messages rather than scratch buffer.
`static String[]`
`getUserDefinedErrorParserIds()`
`int`
`getWarningCount()`
`org.eclipse.core.runtime.IPath`
`getWorkingDirectory()`
Deprecated.
use `getWorkingDirectoryURI()` instead
`URI`
`getWorkingDirectoryURI()`
Returns current working directory for the current build command as determined from build output.
`boolean`
`hasErrors()`
Deprecated.
The semantics of this function is inconsistent.
`boolean`
`isConflictingName(String fileName)`
Deprecated.
Use `findFileName(java.lang.String)` for searches.
`org.eclipse.core.runtime.IPath`
`popDirectory()`
Deprecated.
use `popDirectoryURI()` instead
`URI`
`popDirectoryURI()`
`pushDirectoryURI(URI)` and `popDirectoryURI()` are used to change working directory from where file name is searched (see `findFileInWorkspace(IPath)`).
`boolean`
`processLine(String line)`
Parses one line of output and generates error or warning markers.
`void`
`pushDirectory(org.eclipse.core.runtime.IPath dir)`
`pushDirectory(org.eclipse.core.runtime.IPath)` and `popDirectory()` are used to change working directory from where file name is searched (see `findFileInWorkspace(org.eclipse.core.runtime.IPath)`).
`void`
`pushDirectoryURI(URI dir)`
`pushDirectoryURI(java.net.URI)` and `popDirectoryURI()` are used to change working directory from where file name is searched (see `findFileInWorkspace(org.eclipse.core.runtime.IPath)`).
`boolean`
`reportProblems()`
Deprecated.
as of 5.2.
`static void`
`setDefaultErrorParserIds(String[] ids)`
Set and store default error parsers IDs to be used if error parser list is empty.
`void`
`setOutputStream(OutputStream os)`
Method setOutputStream.
`static void`
`setUserDefinedErrorParsers(IErrorParserNamed[] errorParsers)`
Set and store in workspace area user defined error parsers.
`void`
`shutdown()`
Called to let the parser know that the end of the error stream has been reached.
`static String`
`toDelimitedString(String[] ids)`
`void`
`write(byte[] b, int off, int len)`
`void`
`write(int b)`

### Methods inherited from class java.io.OutputStream

`nullOutputStream, write`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Field Details

### PREF_ERROR_PARSER

@Deprecated public static final String PREF_ERROR_PARSER
Deprecated.
since CDT 4.0.
The list of error parsers stored in .project for 3.X projects as key/value pair with key="org.eclipse.cdt.core.errorOutputParser"

See Also:
  - Constant Field Values

### ERROR_PARSER_DELIMITER

public static final char ERROR_PARSER_DELIMITER
Delimiter for error parsers presented in one string.

Since:
  5.2
See Also:
  - Constant Field Values

### BUILD_CONTEXT

public static final String BUILD_CONTEXT

Since:
  5.4
See Also:
  - Constant Field Values

## Constructor Details

### ErrorParserManager

public ErrorParserManager(ACBuilder builder)
Constructor.

Parameters:
  `builder` - - project builder.

### ErrorParserManager

public ErrorParserManager(org.eclipse.core.resources.IProject project, IMarkerGenerator markerGenerator)
Constructor.

Parameters:
  `project` - - project being built.
  `markerGenerator` - - marker generator able to create markers.

### ErrorParserManager

public ErrorParserManager(org.eclipse.core.resources.IProject project, IMarkerGenerator markerGenerator, String[] parsersIDs)
Constructor.

Parameters:
  `project` - - project being built.
  `markerGenerator` - - marker generator able to create markers.
  `parsersIDs` - - array of error parsers' IDs.

### ErrorParserManager

@Deprecated public ErrorParserManager(org.eclipse.core.resources.IProject project, org.eclipse.core.runtime.IPath workingDirectory, IMarkerGenerator markerGenerator, String[] parsersIDs)
Deprecated.
use `ErrorParserManager(IProject, URI, IMarkerGenerator, String[])` instead
Constructor.

Parameters:
  `project` - - project being built.
  `workingDirectory` - - IPath location of the working directory of where the build is performed.
  `markerGenerator` - - marker generator able to create markers.
  `parsersIDs` - - array of error parsers' IDs.

### ErrorParserManager

public ErrorParserManager(org.eclipse.core.resources.IProject project, URI baseDirectoryURI, IMarkerGenerator markerGenerator, String[] parsersIDs)
URI based constructor.

Parameters:
  `project` - - project being built.
  `baseDirectoryURI` - - absolute location URI of working directory of where the build is performed.
  `markerGenerator` - - marker generator able to create markers.
  `parsersIDs` - - array of error parsers' IDs.
Since:
  5.1

## Method Details

### getProject

public org.eclipse.core.resources.IProject getProject()

Returns:
  current project.

### getWorkingDirectory

@Deprecated public org.eclipse.core.runtime.IPath getWorkingDirectory()
Deprecated.
use `getWorkingDirectoryURI()` instead

Returns:
  current working directory location where build is being performed.

### getWorkingDirectoryURI

public URI getWorkingDirectoryURI()
Description copied from interface: `IWorkingDirectoryTracker`
Returns current working directory for the current build command as determined from build output.

Specified by:
  `getWorkingDirectoryURI` in interface `IWorkingDirectoryTracker`
Returns:
  the current URI location where the build is being performed
Since:
  5.1

### pushDirectory

public void pushDirectory(org.eclipse.core.runtime.IPath dir)
`pushDirectory(org.eclipse.core.runtime.IPath)` and `popDirectory()` are used to change working directory from where file name is searched (see `findFileInWorkspace(org.eclipse.core.runtime.IPath)`). The intention is to handle make output of commands "pushd dir" and "popd".

Parameters:
  `dir` - - another directory level to keep in stack -- corresponding to 'pushd'.

### pushDirectoryURI

public void pushDirectoryURI(URI dir)
`pushDirectoryURI(java.net.URI)` and `popDirectoryURI()` are used to change working directory from where file name is searched (see `findFileInWorkspace(org.eclipse.core.runtime.IPath)`). The intention is to handle make output of commands "pushd dir" and "popd".

Parameters:
  `dir` - - another directory level to keep in stack -- corresponding to 'pushd'.
Since:
  5.1

### popDirectory

@Deprecated public org.eclipse.core.runtime.IPath popDirectory()
Deprecated.
use `popDirectoryURI()` instead
`pushDirectory(org.eclipse.core.runtime.IPath)` and `popDirectory()` are used to change working directory from where file name is searched (see `findFileInWorkspace(org.eclipse.core.runtime.IPath)`). The intention is to handle make output of commands "pushd" and "popd".

Returns:
  previous build directory location corresponding 'popd' command.

### popDirectoryURI

public URI popDirectoryURI()
`pushDirectoryURI(URI)` and `popDirectoryURI()` are used to change working directory from where file name is searched (see `findFileInWorkspace(IPath)`). The intention is to handle make output of commands "pushd" and "popd".

Returns:
  previous build directory location corresponding 'popd' command.
Since:
  5.1

### getDirectoryLevel

public int getDirectoryLevel()

Returns:
  number of directories in the stack.

### collectFiles

@Deprecated protected void collectFiles(org.eclipse.core.resources.IProject parent, List<org.eclipse.core.resources.IResource> result)
Deprecated.
Use `findFileName(java.lang.String)` for searches.
This function used to populate member fFilesInProject which is not necessary anymore. Now `ResourceLookup` is used for search and not collection of files kept by `ErrorParserManager`.

Parameters:
  `parent` - - project.
  `result` - - resulting collection of files.

### processLine

public boolean processLine(String line)
Parses one line of output and generates error or warning markers.

Specified by:
  `processLine` in interface `IConsoleParser`
Parameters:
  `line` -
Returns:
  true if line was successfully processed; skip other console parsers

  false - try other console parsers

Since:
  5.4

### getLineCounter

public int getLineCounter()

Returns:
  counter counting processed lines of output
Since:
  5.2

### findFileName

public org.eclipse.core.resources.IFile findFileName(String partialLoc)
Returns the file with the given (partial) location if that file can be uniquely identified. Otherwise returns `null`.
The passed in String 'partialLoc' is treated as a partial filesystem location for the resource. Resolution is attempted with the following precedence:
If partialLoc is an absolute fs location:
- Resolve it to an IFile in the Project
- Resolve it to an IFile in the Workspace
If partialLoc is a relative path:
- Resolve it relative to the Current Working Directory
- Resolve just the segments provided

Parameters:
  `partialLoc` - - file name could be plain file name, absolute path or partial path
Returns:
  - file in the workspace or `null`.

### findFileInWorkspace

protected org.eclipse.core.resources.IFile findFileInWorkspace(org.eclipse.core.runtime.IPath path)
Find exact match in the workspace. If path is not absolute search is done in working directory.

Parameters:
  `path` - - file path.
Returns:
  - file in the workspace or `null` if such a file doesn't exist

### findFileInWorkspace

protected org.eclipse.core.resources.IFile findFileInWorkspace(URI uri)
Find exact match in the workspace. If path is not absolute search is done in the current working directory.

Parameters:
  `uri` - - absolute or relative URI to resolve.
Returns:
  - file in the workspace or `null` if such a file doesn't exist
Since:
  5.1

### isConflictingName

@Deprecated public boolean isConflictingName(String fileName)
Deprecated.
Use `findFileName(java.lang.String)` for searches.

Parameters:
  `fileName` - - file name.
Returns:
  `true` if the project contains more than one file with the given name.

### findFilePath

@Deprecated public org.eclipse.core.resources.IFile findFilePath(String filePath)
Deprecated.
Use `findFileName(java.lang.String)` for searches.
Called by the error parsers to find an IFile for a given external filesystem 'location'

Parameters:
  `filePath` - - file path.
Returns:
  IFile representing the external location, or null if one couldn't be found.

### generateMarker

public void generateMarker(org.eclipse.core.resources.IResource file, int lineNumber, String desc, int severity, String varName)
Add marker to the list of error markers.

Parameters:
  `file` - - resource to add the new marker.
  `lineNumber` - - line number of the error.
  `desc` - - description of the error.
  `severity` - - severity of the error.
  `varName` - - variable name.

### generateExternalMarker

public void generateExternalMarker(org.eclipse.core.resources.IResource file, int lineNumber, String desc, int severity, String varName, org.eclipse.core.runtime.IPath externalPath)
Add marker to the list of error markers.

Parameters:
  `file` - - resource to add the new marker.
  `lineNumber` - - line number of the error.
  `desc` - - description of the error.
  `severity` - - severity of the error, one of
  `IMarkerGenerator.SEVERITY_INFO`,
  `IMarkerGenerator.SEVERITY_WARNING`,
  `IMarkerGenerator.SEVERITY_ERROR_RESOURCE`,
  `IMarkerGenerator.SEVERITY_ERROR_BUILD`
  `varName` - - variable name.
  `externalPath` - - external path pointing to a file outside the workspace.

### addProblemMarker

public void addProblemMarker(ProblemMarkerInfo problemMarkerInfo)
Add the given marker to the list of error markers.

Parameters:
  `problemMarkerInfo` - - The marker to be added.
Since:
  5.4

### getPreviousLine

public String getPreviousLine()
Called by the error parsers.

Returns:
  the previous line, save in the working buffer.

### setOutputStream

public void setOutputStream(OutputStream os)
Method setOutputStream. Note: you have to close this stream explicitly don't rely on ErrorParserManager.close().

Parameters:
  `os` - - output stream

### getOutputStream

public OutputStream getOutputStream()
Method getOutputStream. Note: you have to close this stream explicitly don't rely on ErrorParserManager.close().

Returns:
  OutputStream

### close

public void close() throws IOException

Specified by:
  `close` in interface `AutoCloseable`
Specified by:
  `close` in interface `Closeable`
Overrides:
  `close` in class `OutputStream`
Throws:
  `IOException`
See Also:
  - `Note: don't rely on this method to close underlying OutputStream, close it explicitly`

### flush

public void flush() throws IOException

Specified by:
  `flush` in interface `Flushable`
Overrides:
  `flush` in class `OutputStream`
Throws:
  `IOException`
See Also:
  - `OutputStream.flush()`

### write

public void write(int b) throws IOException

Specified by:
  `write` in class `OutputStream`
Throws:
  `IOException`
See Also:
  - `OutputStream.write(int)`

### write

public void write(byte[] b, int off, int len) throws IOException

Overrides:
  `write` in class `OutputStream`
Throws:
  `IOException`

### reportProblems

@Deprecated public boolean reportProblems()
Deprecated.
as of 5.2. This method is no longer reporting problems. The problem markers are generated after processing each line.

Returns:
  `true` if detected a problem indicating that build failed. The semantics of the return code is inconsistent. As far as build is concerned there is no difference between errors `IMarkerGenerator.SEVERITY_ERROR_RESOURCE` and `IMarkerGenerator.SEVERITY_ERROR_BUILD`

### getScratchBuffer

@Deprecated public String getScratchBuffer()
Deprecated.
Use IErrorParser2 interface to handle multiline messages rather than scratch buffer.

Returns:
  scratch buffer.

### appendToScratchBuffer

@Deprecated public void appendToScratchBuffer(String line)
Deprecated.
Use IErrorParser2 interface to handle multiline messages rather than scratch buffer.

Parameters:
  `line` - - input line.

### clearScratchBuffer

@Deprecated public void clearScratchBuffer()
Deprecated.
Use IErrorParser2 interface to handle multiline messages rather than scratch buffer.

### hasErrors

@Deprecated public boolean hasErrors()
Deprecated.
The semantics of this function is inconsistent. As far as build is concerned there is no difference between errors `IMarkerGenerator.SEVERITY_ERROR_RESOURCE` and `IMarkerGenerator.SEVERITY_ERROR_BUILD`

Returns:
  `true` if errors attributed to resources detected

### getUserDefinedErrorParserIds

public static String[] getUserDefinedErrorParserIds()

Returns:
  default error parsers IDs to be used if error parser list is empty.
Since:
  5.3

### setUserDefinedErrorParsers

public static void setUserDefinedErrorParsers(IErrorParserNamed[] errorParsers) throws org.eclipse.core.runtime.CoreException
Set and store in workspace area user defined error parsers.

Parameters:
  `errorParsers` - - array of user defined error parsers
Throws:
  `org.eclipse.core.runtime.CoreException` - in case of problems
Since:
  5.2

### getErrorParserAvailableIds

public static String[] getErrorParserAvailableIds()

Returns:
  available error parsers IDs which include contributed through extension + user defined ones from workspace
Since:
  5.2

### getErrorParserAvailableIdsInContext

public static String[] getErrorParserAvailableIdsInContext(String context)

Parameters:
  `context` - - indicates the context in which an error parser can be used.
Returns:
  available error parsers ID, which include contributed through extension and user- defined ones from workspace, that can be used in the given context.
Since:
  5.4

### getErrorParserExtensionIds

public static String[] getErrorParserExtensionIds()

Returns:
  IDs of error parsers contributed through error parser extension point.
Since:
  5.2

### setDefaultErrorParserIds

public static void setDefaultErrorParserIds(String[] ids) throws org.osgi.service.prefs.BackingStoreException
Set and store default error parsers IDs to be used if error parser list is empty.

Parameters:
  `ids` - - default error parsers IDs
Throws:
  `org.osgi.service.prefs.BackingStoreException` - in case of problem with storing
Since:
  5.2

### getDefaultErrorParserIds

public static String[] getDefaultErrorParserIds()

Returns:
  default error parsers IDs to be used if error parser list is empty.
Since:
  5.2

### getErrorParserCopy

public static IErrorParserNamed getErrorParserCopy(String id)

Parameters:
  `id` - - ID of error parser
Returns:
  cloned copy of error parser or `null`. Note that `ErrorParserNamedWrapper` returns shallow copy with the same instance of underlying error parser.
Since:
  5.2

### getErrorParserExtensionCopy

public static IErrorParserNamed getErrorParserExtensionCopy(String id)

Parameters:
  `id` - - ID of error parser
Returns:
  cloned copy of error parser as defined by its extension point or `null`.
Since:
  5.3

### toDelimitedString

public static String toDelimitedString(String[] ids)

Parameters:
  `ids` - - array of error parser IDs
Returns:
  error parser IDs delimited with error parser delimiter ";"
Since:
  5.2

### shutdown

public void shutdown()
Description copied from interface: `IConsoleParser`
Called to let the parser know that the end of the error stream has been reached. Can be used by the parser to flush its internal buffers.

Specified by:
  `shutdown` in interface `IConsoleParser`
Since:
  5.4

### getErrorCount

public int getErrorCount()

Since:
  6.5

### getWarningCount

public int getWarningCount()

Since:
  6.5

### deferDeDuplication

public void deferDeDuplication()
Flag the marker generator to defer the de-duplication of error markers until `deDuplicate()` is called

Since:
  6.3

### deDuplicate

public void deDuplicate()
De-duplicate error markers on resource that have had error markers added since `deferDeDuplication()` was called.

Since:
  6.3