Package org.eclipse.jdt.core
Class CorrectionEngine
java.lang.Object
org.eclipse.jdt.core.CorrectionEngine
This class is the entry point for source corrections.
This class is intended to be instantiated by clients.
- Since:
- 2.0
- Restriction:
- This class is not intended to be subclassed by clients.
-
Field Summary
Modifier and TypeFieldDescriptionprotected static final int
This field is not intended to be used by client.protected ICompilationUnit
This field is not intended to be used by client.protected CompletionRequestor
This field is not intended to be used by client.protected int
This field is not intended to be used by client.protected ICorrectionRequestor
This field is not intended to be used by client.protected int
This field is not intended to be used by client.protected static final int
This field is not intended to be used by client.protected int
This field is not intended to be used by client.protected static final int
This field is not intended to be used by client.protected static final int
This field is not intended to be used by client.protected static final int
This field is not intended to be used by client.protected static final int
This field is not intended to be used by client.protected int
This field is not intended to be used by client. -
Constructor Summary
ConstructorDescriptionCorrectionEngine
(Map setting) The CorrectionEngine is responsible for computing problem corrections. -
Method Summary
Modifier and TypeMethodDescriptionvoid
computeCorrections
(org.eclipse.core.resources.IMarker marker, ICompilationUnit targetUnit, int positionOffset, ICorrectionRequestor requestor) Performs code correction for the given marker, reporting results to the given correction requestor.void
computeCorrections
(IProblem problem, ICompilationUnit targetUnit, ICorrectionRequestor requestor) Performs code correction for the given IProblem, reporting results to the given correction requestor.static String[]
Return an array of strings which contains one entry per warning token accepted by the@SuppressWarnings
annotation.static String[]
getProblemArguments
(org.eclipse.core.resources.IMarker problemMarker) Helper method for decoding problem marker attributes.static String
getWarningToken
(int problemID) Returns a token which can be used to suppress a given warning using@SuppressWarnings
annotation, for a given problem ID (IProblem
).
-
Field Details
-
correctionStart
protected int correctionStartThis field is not intended to be used by client. -
correctionEnd
protected int correctionEndThis field is not intended to be used by client. -
prefixLength
protected int prefixLengthThis field is not intended to be used by client. -
compilationUnit
This field is not intended to be used by client. -
correctionRequestor
This field is not intended to be used by client. -
CLASSES
protected static final int CLASSESThis field is not intended to be used by client.- See Also:
-
INTERFACES
protected static final int INTERFACESThis field is not intended to be used by client.- See Also:
-
IMPORT
protected static final int IMPORTThis field is not intended to be used by client.- See Also:
-
METHOD
protected static final int METHODThis field is not intended to be used by client.- See Also:
-
FIELD
protected static final int FIELDThis field is not intended to be used by client.- See Also:
-
LOCAL
protected static final int LOCALThis field is not intended to be used by client.- See Also:
-
filter
protected int filterThis field is not intended to be used by client. -
completionRequestor
This field is not intended to be used by client.
-
-
Constructor Details
-
CorrectionEngine
The CorrectionEngine is responsible for computing problem corrections.- Parameters:
setting
- java.util.Map set of options used to configure the code correction engine. CURRENTLY THERE IS NO CORRECTION SPECIFIC SETTINGS.
-
-
Method Details
-
computeCorrections
public void computeCorrections(org.eclipse.core.resources.IMarker marker, ICompilationUnit targetUnit, int positionOffset, ICorrectionRequestor requestor) throws JavaModelException Performs code correction for the given marker, reporting results to the given correction requestor. Correction results are answered through a requestor.- Parameters:
marker
- the marker which describe the problem to correct.targetUnit
- replace the compilation unit given by the marker. Ignored if null.positionOffset
- the offset of position given by the marker.requestor
- the given correction requestor- Throws:
IllegalArgumentException
- ifrequestor
isnull
JavaModelException
- currently this exception is never thrown, but the opportunity to thrown an exception when the correction failed is kept for later.- Since:
- 2.0
-
computeCorrections
public void computeCorrections(IProblem problem, ICompilationUnit targetUnit, ICorrectionRequestor requestor) throws JavaModelException Performs code correction for the given IProblem, reporting results to the given correction requestor. Correction results are answered through a requestor.- Parameters:
problem
- the problem which describe the problem to correct.targetUnit
- denote the compilation unit in which correction occurs. Cannot be null.requestor
- the given correction requestor- Throws:
IllegalArgumentException
- iftargetUnit
orrequestor
isnull
JavaModelException
- currently this exception is never thrown, but the opportunity to thrown an exception when the correction failed is kept for later.- Since:
- 2.0
-
getAllWarningTokens
Return an array of strings which contains one entry per warning token accepted by the@SuppressWarnings
annotation. This array is neither null nor empty, it contains at least the Stringall
. It should not be modified by the caller (please take a copy if modifications are needed).
Note: The tokens returned are not necessarily standardized across Java compilers. If you were to use one of these tokens in a@SuppressWarnings
annotation in the Java source code, the effects (if any) may vary from compiler to compiler.- Returns:
- an array of strings which contains one entry per warning token
accepted by the
@SuppressWarnings
annotation. - Since:
- 3.2
-
getProblemArguments
Helper method for decoding problem marker attributes. Returns an array of String arguments extracted from the problem marker "arguments" attribute, ornull
if the marker "arguments" attribute is missing or ill-formed.- Parameters:
problemMarker
- the problem marker to decode arguments from.- Returns:
- an array of String arguments, or
null
if unable to extract arguments - Since:
- 2.1
-
getWarningToken
Returns a token which can be used to suppress a given warning using@SuppressWarnings
annotation, for a given problem ID (IProblem
). If a particular problem is not suppressable,null
will be returned.Note:
@SuppressWarnings
can only suppress warnings, which means that if some problems got promoted to ERROR using custom compiler settings (IJavaProject.setOption(String, String)
), the@SuppressWarnings
annotation will be ineffective.Note:
@SuppressWarnings
can be argumented with"all"
so as to suppress all possible warnings at once.Note: The tokens returned are not necessarily standardized across Java compilers. If you were to use one of these tokens in an @SuppressWarnings annotation in the Java source code, the effects (if any) may vary from compiler to compiler.
- Parameters:
problemID
- the ID of a given warning to suppress- Returns:
- a String which can be used in
@SuppressWarnings
annotation, ornull
if unable to suppress this warning. - Since:
- 3.1
-