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
IErrorParsers, assist in finding IResources, 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 -
Constructor Summary
ConstructorsConstructorDescriptionErrorParserManager(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 TypeMethodDescriptionvoidaddProblemMarker(ProblemMarkerInfo problemMarkerInfo) Add the given marker to the list of error markers.voidappendToScratchBuffer(String line) Deprecated.Use IErrorParser2 interface to handle multiline messages rather than scratch buffer.voidDeprecated.Use IErrorParser2 interface to handle multiline messages rather than scratch buffer.voidclose()protected voidcollectFiles(org.eclipse.core.resources.IProject parent, List<org.eclipse.core.resources.IResource> result) Deprecated.UsefindFileName(java.lang.String)for searches.voidDe-duplicate error markers on resource that have had error markers added sincedeferDeDuplication()was called.voidFlag the marker generator to defer the de-duplication of error markers untildeDuplicate()is calledprotected org.eclipse.core.resources.IFilefindFileInWorkspace(URI uri) Find exact match in the workspace.protected org.eclipse.core.resources.IFilefindFileInWorkspace(org.eclipse.core.runtime.IPath path) Find exact match in the workspace.org.eclipse.core.resources.IFilefindFileName(String partialLoc) Returns the file with the given (partial) location if that file can be uniquely identified.org.eclipse.core.resources.IFilefindFilePath(String filePath) Deprecated.UsefindFileName(java.lang.String)for searches.voidflush()voidgenerateExternalMarker(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.voidgenerateMarker(org.eclipse.core.resources.IResource file, int lineNumber, String desc, int severity, String varName) Add marker to the list of error markers.static String[]intintstatic String[]static String[]static IErrorParserNamedstatic IErrorParserNamedstatic String[]intMethod getOutputStream.Called by the error parsers.org.eclipse.core.resources.IProjectDeprecated.Use IErrorParser2 interface to handle multiline messages rather than scratch buffer.static String[]intorg.eclipse.core.runtime.IPathDeprecated.usegetWorkingDirectoryURI()insteadReturns current working directory for the current build command as determined from build output.booleanDeprecated.The semantics of this function is inconsistent.booleanisConflictingName(String fileName) Deprecated.UsefindFileName(java.lang.String)for searches.org.eclipse.core.runtime.IPathDeprecated.usepopDirectoryURI()insteadpushDirectoryURI(URI)andpopDirectoryURI()are used to change working directory from where file name is searched (seefindFileInWorkspace(IPath)).booleanprocessLine(String line) Parses one line of output and generates error or warning markers.voidpushDirectory(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)).voidpushDirectoryURI(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)).booleanDeprecated.as of 5.2.static voidsetDefaultErrorParserIds(String[] ids) Set and store default error parsers IDs to be used if error parser list is empty.voidMethod setOutputStream.static voidsetUserDefinedErrorParsers(IErrorParserNamed[] errorParsers) Set and store in workspace area user defined error parsers.voidshutdown()Called to let the parser know that the end of the error stream has been reached.static StringtoDelimitedString(String[] ids) voidwrite(byte[] b, int off, int len) voidwrite(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:IWorkingDirectoryTrackerReturns current working directory for the current build command as determined from build output.- Specified by:
getWorkingDirectoryURIin 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. NowResourceLookupis 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:
processLinein interfaceIConsoleParser- 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
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
nullif 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
nullif such a file doesn't exist - Since:
- 5.1
-
isConflictingName
Deprecated.UsefindFileName(java.lang.String)for searches.- Parameters:
fileName- - file name.- Returns:
trueif 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_BUILDvarName- - 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:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classOutputStream- Throws:
IOException- See Also:
-
flush
- Specified by:
flushin interfaceFlushable- Overrides:
flushin classOutputStream- Throws:
IOException- See Also:
-
write
- Specified by:
writein classOutputStream- Throws:
IOException- See Also:
-
write
- Overrides:
writein 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:
trueif 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_RESOURCEandIMarkerGenerator.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_RESOURCEandIMarkerGenerator.SEVERITY_ERROR_BUILD- Returns:
trueif 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 thatErrorParserNamedWrapperreturns 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:IConsoleParserCalled 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:
shutdownin 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
-