org.eclipse.wst.jsdt.core

## Class CorrectionEngine

- java.lang.Object
- - org.eclipse.wst.jsdt.core.CorrectionEngine

All Implemented Interfaces:
  org.eclipse.wst.jsdt.internal.compiler.lookup.ProblemReasons

    public class CorrectionEngine
    extends java.lang.Object
    implements org.eclipse.wst.jsdt.internal.compiler.lookup.ProblemReasons

This class is the entry point for source corrections. This class is not intended to be subclassed by clients. This class is intended to be instantiated by clients. Provisional API: This class/interface is part of an interim API that is still under development and expected to change significantly before reaching stability. It is being made available at this early stage to solicit feedback from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken (repeatedly) as the API evolves.

### Field Summary

Fields
`protected static int` `CLASSES` This field is not intended to be used by client.
`protected IJavaScriptUnit` `compilationUnit` This field is not intended to be used by client.
`protected CompletionRequestor` `completionRequestor` This field is not intended to be used by client.
`protected int` `correctionEnd` This field is not intended to be used by client.
`protected ICorrectionRequestor` `correctionRequestor` This field is not intended to be used by client.
`protected int` `correctionStart` This field is not intended to be used by client.
`protected static int` `FIELD` This field is not intended to be used by client.
`protected int` `filter` This field is not intended to be used by client.
`protected static int` `IMPORT` This field is not intended to be used by client.
`protected static int` `LOCAL` This field is not intended to be used by client.
`protected static int` `METHOD` This field is not intended to be used by client.
`protected int` `prefixLength` This field is not intended to be used by client.

### Fields inherited from interface org.eclipse.wst.jsdt.internal.compiler.lookup.ProblemReasons

`Ambiguous, IllegalSuperTypeVariable, InheritedNameHidesEnclosingName, InternalNameProvided, NoError, NonStaticReferenceInConstructorInvocation, NonStaticReferenceInStaticContext, NotAFunction, NotFound, NotVisible, ReceiverTypeNotVisible`

### Constructor Summary

Constructors
Constructor and Description
`CorrectionEngine(java.util.Map setting)` The CorrectionEngine is responsible for computing problem corrections.

### Method Summary

All Methods Static Methods Instance Methods Concrete Methods
`void` `computeCorrections(IMarker marker, IJavaScriptUnit targetUnit, int positionOffset, ICorrectionRequestor requestor)` Performs code correction for the given marker, reporting results to the given correction requestor.
`void` `computeCorrections(IProblem problem, IJavaScriptUnit targetUnit, ICorrectionRequestor requestor)` Performs code correction for the given IProblem, reporting results to the given correction requestor.
`static java.lang.String[]` `getAllWarningTokens()` Return an array of strings which contains one entry per warning token accepted by the `@SuppressWarnings` annotation.
`static java.lang.String[]` `getProblemArguments(IMarker problemMarker)` Helper method for decoding problem marker attributes.
`static java.lang.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`).

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Field Detail

#### correctionStart

    protected int correctionStart

This field is not intended to be used by client.

#### correctionEnd

    protected int correctionEnd

This field is not intended to be used by client.

#### prefixLength

    protected int prefixLength

This field is not intended to be used by client.

#### compilationUnit

    protected IJavaScriptUnit compilationUnit

This field is not intended to be used by client.

#### correctionRequestor

    protected ICorrectionRequestor correctionRequestor

This field is not intended to be used by client.

#### CLASSES

    protected static final int CLASSES

This field is not intended to be used by client.

See Also:
  Constant Field Values

#### IMPORT

    protected static final int IMPORT

This field is not intended to be used by client.

See Also:
  Constant Field Values

#### METHOD

    protected static final int METHOD

This field is not intended to be used by client.

See Also:
  Constant Field Values

#### FIELD

    protected static final int FIELD

This field is not intended to be used by client.

See Also:
  Constant Field Values

#### LOCAL

    protected static final int LOCAL

This field is not intended to be used by client.

See Also:
  Constant Field Values

#### filter

    protected int filter

This field is not intended to be used by client.

#### completionRequestor

    protected CompletionRequestor completionRequestor

This field is not intended to be used by client.

### Constructor Detail

#### CorrectionEngine

    public CorrectionEngine(java.util.Map setting)

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 Detail

#### computeCorrections

    public void computeCorrections(IMarker marker,
                                   IJavaScriptUnit targetUnit,
                                   int positionOffset,
                                   ICorrectionRequestor requestor)
                            throws JavaScriptModelException

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:
  `java.lang.IllegalArgumentException` - if `requestor` is `null`
  `JavaScriptModelException` - currently this exception is never thrown, but the opportunity to thrown an exception when the correction failed is kept for later.

#### computeCorrections

    public void computeCorrections(IProblem problem,
                                   IJavaScriptUnit targetUnit,
                                   ICorrectionRequestor requestor)
                            throws JavaScriptModelException

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:
  `java.lang.IllegalArgumentException` - if `targetUnit` or `requestor` is `null`
  `JavaScriptModelException` - currently this exception is never thrown, but the opportunity to thrown an exception when the correction failed is kept for later.

#### getAllWarningTokens

    public static java.lang.String[] 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 String `all`. 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 JavaScript validators. If you were to use one of these tokens in a `@SuppressWarnings` annotation in the JavaScript source code, the effects (if any) may vary from validator to validator.

Returns:
  an array of strings which contains one entry per warning token accepted by the `@SuppressWarnings` annotation.

#### getProblemArguments

    public static java.lang.String[] getProblemArguments(IMarker problemMarker)

Helper method for decoding problem marker attributes. Returns an array of String arguments extracted from the problem marker "arguments" attribute, or `null` 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

#### getWarningToken

    public static java.lang.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`). 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 (`IJavaScriptProject.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 JavaScript validators. If you were to use one of these tokens in an @SuppressWarnings annotation in the JavaScript source code, the effects (if any) may vary from validator to validator.

Parameters:
  `problemID` - the ID of a given warning to suppress
Returns:
  a String which can be used in `@SuppressWarnings` annotation, or `null` if unable to suppress this warning.