public class ErrorParserManager extends OutputStream implements IConsoleParser, IWorkingDirectoryTracker
IErrorParser
s, assist in finding IResource
s, and
help create appropriate error/warning/info markers to be displayed
by the Problems view.Modifier and Type | Field and Description |
---|---|
static String |
BUILD_CONTEXT |
static char |
ERROR_PARSER_DELIMITER
Delimiter for error parsers presented in one string.
|
static String |
PREF_ERROR_PARSER
Deprecated.
since CDT 4.0.
|
Constructor and Description |
---|
ErrorParserManager(ACBuilder builder)
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.
|
ErrorParserManager(org.eclipse.core.resources.IProject project,
URI baseDirectoryURI,
IMarkerGenerator markerGenerator,
String[] parsersIDs)
URI based constructor.
|
Modifier and Type | Method and 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(org.eclipse.core.runtime.IPath path)
Find exact match in the workspace.
|
protected org.eclipse.core.resources.IFile |
findFileInWorkspace(URI uri)
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. As far as build is concerned
there is no difference between errors
IMarkerGenerator.SEVERITY_ERROR_RESOURCE and
IMarkerGenerator.SEVERITY_ERROR_BUILD |
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. This method is no longer reporting problems.
The problem markers are generated after processing each line.
|
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) |
write
@Deprecated public static final String PREF_ERROR_PARSER
public static final char ERROR_PARSER_DELIMITER
public static final String BUILD_CONTEXT
public ErrorParserManager(ACBuilder builder)
builder
- - project builder.public ErrorParserManager(org.eclipse.core.resources.IProject project, IMarkerGenerator markerGenerator)
project
- - project being built.markerGenerator
- - marker generator able to create markers.public ErrorParserManager(org.eclipse.core.resources.IProject project, IMarkerGenerator markerGenerator, String[] parsersIDs)
project
- - project being built.markerGenerator
- - marker generator able to create markers.parsersIDs
- - array of error parsers' IDs.@Deprecated public ErrorParserManager(org.eclipse.core.resources.IProject project, org.eclipse.core.runtime.IPath workingDirectory, IMarkerGenerator markerGenerator, String[] parsersIDs)
ErrorParserManager(IProject, URI, IMarkerGenerator, String[])
insteadproject
- - 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.public ErrorParserManager(org.eclipse.core.resources.IProject project, URI baseDirectoryURI, IMarkerGenerator markerGenerator, String[] parsersIDs)
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.public org.eclipse.core.resources.IProject getProject()
@Deprecated public org.eclipse.core.runtime.IPath getWorkingDirectory()
getWorkingDirectoryURI()
insteadpublic URI getWorkingDirectoryURI()
IWorkingDirectoryTracker
getWorkingDirectoryURI
in interface IWorkingDirectoryTracker
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".dir
- - another directory level to keep in stack -- corresponding to 'pushd'.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".dir
- - another directory level to keep in stack -- corresponding to 'pushd'.@Deprecated public org.eclipse.core.runtime.IPath popDirectory()
popDirectoryURI()
insteadpushDirectory(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".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".public int getDirectoryLevel()
@Deprecated protected void collectFiles(org.eclipse.core.resources.IProject parent, List<org.eclipse.core.resources.IResource> result)
findFileName(java.lang.String)
for searches.ResourceLookup
is used for search and not collection of files
kept by ErrorParserManager
.parent
- - project.result
- - resulting collection of files.public boolean processLine(String line)
processLine
in interface IConsoleParser
false - try other console parsers
public int getLineCounter()
public org.eclipse.core.resources.IFile findFileName(String partialLoc)
null
.
partialLoc
- - file name could be plain file name, absolute path or partial pathnull
.protected org.eclipse.core.resources.IFile findFileInWorkspace(org.eclipse.core.runtime.IPath path)
path
- - file path.null
if such a file doesn't existprotected org.eclipse.core.resources.IFile findFileInWorkspace(URI uri)
uri
- - absolute or relative URI to resolve.null
if such a file doesn't exist@Deprecated public boolean isConflictingName(String fileName)
findFileName(java.lang.String)
for searches.fileName
- - file name.true
if the project contains more than one file with the given name.@Deprecated public org.eclipse.core.resources.IFile findFilePath(String filePath)
findFileName(java.lang.String)
for searches.filePath
- - file path.public void generateMarker(org.eclipse.core.resources.IResource file, int lineNumber, String desc, int severity, String varName)
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.public void generateExternalMarker(org.eclipse.core.resources.IResource file, int lineNumber, String desc, int severity, String varName, org.eclipse.core.runtime.IPath externalPath)
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.public void addProblemMarker(ProblemMarkerInfo problemMarkerInfo)
problemMarkerInfo
- - The marker to be added.public String getPreviousLine()
public void setOutputStream(OutputStream os)
os
- - output streampublic OutputStream getOutputStream()
public void close() throws IOException
close
in interface Closeable
close
in interface AutoCloseable
close
in class OutputStream
IOException
Note: don't rely on this method to close underlying OutputStream,
close it explicitly
public void flush() throws IOException
flush
in interface Flushable
flush
in class OutputStream
IOException
OutputStream.flush()
public void write(int b) throws IOException
write
in class OutputStream
IOException
OutputStream.write(int)
public void write(byte[] b, int off, int len) throws IOException
write
in class OutputStream
IOException
@Deprecated public boolean reportProblems()
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
@Deprecated public String getScratchBuffer()
@Deprecated public void appendToScratchBuffer(String line)
line
- - input line.@Deprecated public void clearScratchBuffer()
@Deprecated public boolean hasErrors()
IMarkerGenerator.SEVERITY_ERROR_RESOURCE
and
IMarkerGenerator.SEVERITY_ERROR_BUILD
true
if errors attributed to resources detectedpublic static String[] getUserDefinedErrorParserIds()
public static void setUserDefinedErrorParsers(IErrorParserNamed[] errorParsers) throws org.eclipse.core.runtime.CoreException
errorParsers
- - array of user defined error parsersorg.eclipse.core.runtime.CoreException
- in case of problemspublic static String[] getErrorParserAvailableIds()
public static String[] getErrorParserAvailableIdsInContext(String context)
context
- - indicates the context in which an error parser can be used.public static String[] getErrorParserExtensionIds()
public static void setDefaultErrorParserIds(String[] ids) throws org.osgi.service.prefs.BackingStoreException
ids
- - default error parsers IDsorg.osgi.service.prefs.BackingStoreException
- in case of problem with storingpublic static String[] getDefaultErrorParserIds()
public static IErrorParserNamed getErrorParserCopy(String id)
id
- - ID of error parsernull
.
Note that ErrorParserNamedWrapper
returns shallow copy with the same instance
of underlying error parser.public static IErrorParserNamed getErrorParserExtensionCopy(String id)
id
- - ID of error parsernull
.public static String toDelimitedString(String[] ids)
ids
- - array of error parser IDspublic void shutdown()
IConsoleParser
shutdown
in interface IConsoleParser
public int getErrorCount()
public int getWarningCount()
public void deferDeDuplication()
deDuplicate()
is calledpublic void deDuplicate()
deferDeDuplication()
was called.Copyright (c) IBM Corp. and others 2004, 2020. All Rights Reserved.