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
-
Constructor Summary
ConstructorDescriptionErrorParserManager
(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. -
Method Summary
Modifier and TypeMethodDescriptionvoid
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
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.UsefindFileName(java.lang.String)
for searches.void
De-duplicate error markers on resource that have had error markers added sincedeferDeDuplication()
was called.void
Flag the marker generator to defer the de-duplication of error markers untildeDuplicate()
is calledprotected 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.UsefindFileName(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[]
int
int
static String[]
static String[]
static IErrorParserNamed
static IErrorParserNamed
static String[]
int
Method getOutputStream.Called by the error parsers.org.eclipse.core.resources.IProject
Deprecated.Use IErrorParser2 interface to handle multiline messages rather than scratch buffer.static String[]
int
org.eclipse.core.runtime.IPath
Deprecated.usegetWorkingDirectoryURI()
insteadReturns current working directory for the current build command as determined from build output.boolean
Deprecated.The semantics of this function is inconsistent.boolean
isConflictingName
(String fileName) Deprecated.UsefindFileName(java.lang.String)
for searches.org.eclipse.core.runtime.IPath
Deprecated.usepopDirectoryURI()
insteadpushDirectoryURI(URI)
andpopDirectoryURI()
are used to change working directory from where file name is searched (seefindFileInWorkspace(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)
andpopDirectory()
are used to change working directory from where file name is searched (seefindFileInWorkspace(org.eclipse.core.runtime.IPath)
).void
pushDirectoryURI
(URI dir) pushDirectoryURI(java.net.URI)
andpopDirectoryURI()
are used to change working directory from where file name is searched (seefindFileInWorkspace(org.eclipse.core.runtime.IPath)
).boolean
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
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
-
Field Details
-
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:
-
ERROR_PARSER_DELIMITER
public static final char ERROR_PARSER_DELIMITERDelimiter for error parsers presented in one string.- Since:
- 5.2
- See Also:
-
BUILD_CONTEXT
- Since:
- 5.4
- See Also:
-
-
Constructor Details
-
ErrorParserManager
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.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.usegetWorkingDirectoryURI()
instead- Returns:
- current working directory location where build is being performed.
-
getWorkingDirectoryURI
Description copied from interface:IWorkingDirectoryTracker
Returns current working directory for the current build command as determined from build output.- Specified by:
getWorkingDirectoryURI
in interfaceIWorkingDirectoryTracker
- 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)
andpopDirectory()
are used to change working directory from where file name is searched (seefindFileInWorkspace(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
pushDirectoryURI(java.net.URI)
andpopDirectoryURI()
are used to change working directory from where file name is searched (seefindFileInWorkspace(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.usepopDirectoryURI()
insteadpushDirectory(org.eclipse.core.runtime.IPath)
andpopDirectory()
are used to change working directory from where file name is searched (seefindFileInWorkspace(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
pushDirectoryURI(URI)
andpopDirectoryURI()
are used to change working directory from where file name is searched (seefindFileInWorkspace(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.UsefindFileName(java.lang.String)
for searches.This function used to populate member fFilesInProject which is not necessary anymore. NowResourceLookup
is used for search and not collection of files kept byErrorParserManager
.- Parameters:
parent
- - project.result
- - resulting collection of files.
-
processLine
Parses one line of output and generates error or warning markers.- Specified by:
processLine
in interfaceIConsoleParser
- 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
Returns the file with the given (partial) location if that file can be uniquely identified. Otherwise returnsnull
.
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
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.UsefindFileName(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.UsefindFileName(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 ofIMarkerGenerator.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
Add the given marker to the list of error markers.- Parameters:
problemMarkerInfo
- - The marker to be added.- Since:
- 5.4
-
getPreviousLine
Called by the error parsers.- Returns:
- the previous line, save in the working buffer.
-
setOutputStream
Method setOutputStream. Note: you have to close this stream explicitly don't rely on ErrorParserManager.close().- Parameters:
os
- - output stream
-
getOutputStream
Method getOutputStream. Note: you have to close this stream explicitly don't rely on ErrorParserManager.close().- Returns:
- OutputStream
-
close
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Overrides:
close
in classOutputStream
- Throws:
IOException
- See Also:
-
flush
- Specified by:
flush
in interfaceFlushable
- Overrides:
flush
in classOutputStream
- Throws:
IOException
- See Also:
-
write
- Specified by:
write
in classOutputStream
- Throws:
IOException
- See Also:
-
write
- Overrides:
write
in classOutputStream
- Throws:
IOException
-
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 errorsIMarkerGenerator.SEVERITY_ERROR_RESOURCE
andIMarkerGenerator.SEVERITY_ERROR_BUILD
-
getScratchBuffer
Deprecated.Use IErrorParser2 interface to handle multiline messages rather than scratch buffer.- Returns:
- scratch buffer.
-
appendToScratchBuffer
Deprecated.Use IErrorParser2 interface to handle multiline messages rather than scratch buffer.- Parameters:
line
- - input line.
-
clearScratchBuffer
Deprecated.Use IErrorParser2 interface to handle multiline messages rather than scratch buffer. -
hasErrors
Deprecated.The semantics of this function is inconsistent. As far as build is concerned there is no difference between errorsIMarkerGenerator.SEVERITY_ERROR_RESOURCE
andIMarkerGenerator.SEVERITY_ERROR_BUILD
- Returns:
true
if errors attributed to resources detected
-
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
- Returns:
- available error parsers IDs which include contributed through extension + user defined ones from workspace
- Since:
- 5.2
-
getErrorParserAvailableIdsInContext
- 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
- 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
- Returns:
- default error parsers IDs to be used if error parser list is empty.
- Since:
- 5.2
-
getErrorParserCopy
- Parameters:
id
- - ID of error parser- Returns:
- cloned copy of error parser or
null
. Note thatErrorParserNamedWrapper
returns shallow copy with the same instance of underlying error parser. - Since:
- 5.2
-
getErrorParserExtensionCopy
- Parameters:
id
- - ID of error parser- Returns:
- cloned copy of error parser as defined by its extension point or
null
. - Since:
- 5.3
-
toDelimitedString
- 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 interfaceIConsoleParser
- 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 untildeDuplicate()
is called- Since:
- 6.3
-
deDuplicate
public void deDuplicate()De-duplicate error markers on resource that have had error markers added sincedeferDeDuplication()
was called.- Since:
- 6.3
-