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 toIErrorParsers, assist in findingIResources, 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 StringBUILD_CONTEXTstatic charERROR_PARSER_DELIMITERDelimiter for error parsers presented in one string.static StringPREF_ERROR_PARSERDeprecated.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.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidaddProblemMarker(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.voidclearScratchBuffer()Deprecated.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.voiddeDuplicate()De-duplicate error markers on resource that have had error markers added sincedeferDeDuplication()was called.voiddeferDeDuplication()Flag 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[]getDefaultErrorParserIds()intgetDirectoryLevel()intgetErrorCount()static String[]getErrorParserAvailableIds()static String[]getErrorParserAvailableIdsInContext(String context)static IErrorParserNamedgetErrorParserCopy(String id)static IErrorParserNamedgetErrorParserExtensionCopy(String id)static String[]getErrorParserExtensionIds()intgetLineCounter()OutputStreamgetOutputStream()Method getOutputStream.StringgetPreviousLine()Called by the error parsers.org.eclipse.core.resources.IProjectgetProject()StringgetScratchBuffer()Deprecated.Use IErrorParser2 interface to handle multiline messages rather than scratch buffer.static String[]getUserDefinedErrorParserIds()intgetWarningCount()org.eclipse.core.runtime.IPathgetWorkingDirectory()Deprecated.usegetWorkingDirectoryURI()insteadURIgetWorkingDirectoryURI()Returns current working directory for the current build command as determined from build output.booleanhasErrors()Deprecated.The semantics of this function is inconsistent.booleanisConflictingName(String fileName)Deprecated.UsefindFileName(java.lang.String)for searches.org.eclipse.core.runtime.IPathpopDirectory()Deprecated.usepopDirectoryURI()insteadURIpopDirectoryURI()pushDirectoryURI(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)).booleanreportProblems()Deprecated.as of 5.2.static voidsetDefaultErrorParserIds(String[] ids)Set and store default error parsers IDs to be used if error parser list is empty.voidsetOutputStream(OutputStream os)Method 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 Detail
-
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 Detail
-
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.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 Detail
-
getProject
public org.eclipse.core.resources.IProject getProject()
- Returns:
- current project.
-
getWorkingDirectory
@Deprecated public org.eclipse.core.runtime.IPath getWorkingDirectory()
Deprecated.usegetWorkingDirectoryURI()instead- Returns:
- current working directory location where build is being performed.
-
getWorkingDirectoryURI
public URI 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
public 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)). 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.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
public URI 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
public boolean processLine(String line)
Parses one line of output and generates error or warning markers.- Specified by:
processLinein 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
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 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
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
nullif such a file doesn't exist - Since:
- 5.1
-
isConflictingName
@Deprecated public boolean isConflictingName(String fileName)
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 public org.eclipse.core.resources.IFile findFilePath(String filePath)
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
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:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classOutputStream- 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:
flushin interfaceFlushable- Overrides:
flushin classOutputStream- Throws:
IOException- See Also:
OutputStream.flush()
-
write
public void write(int b) throws IOException- Specified by:
writein classOutputStream- Throws:
IOException- See Also:
OutputStream.write(int)
-
write
public void write(byte[] b, int off, int len) throws IOException- Overrides:
writein classOutputStream- 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:
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 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 errorsIMarkerGenerator.SEVERITY_ERROR_RESOURCEandIMarkerGenerator.SEVERITY_ERROR_BUILD- Returns:
trueif 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 thatErrorParserNamedWrapperreturns 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: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
-
-