# Class ASTRewriteCorrectionProposal

java.lang.Object
org.eclipse.jdt.core.manipulation.ChangeCorrectionProposalCore
org.eclipse.jdt.ui.text.java.correction.ChangeCorrectionProposal
org.eclipse.jdt.ui.text.java.correction.CUCorrectionProposal
org.eclipse.jdt.ui.text.java.correction.ASTRewriteCorrectionProposal

All Implemented Interfaces:
  `org.eclipse.core.runtime.IAdaptable, ICUCorrectionProposal, ICommandAccess, IJavaCompletionProposal, org.eclipse.jface.text.contentassist.ICompletionProposal, org.eclipse.jface.text.contentassist.ICompletionProposalExtension5, org.eclipse.jface.text.contentassist.ICompletionProposalExtension6`

public class ASTRewriteCorrectionProposal extends CUCorrectionProposal
A proposal for quick fixes and quick assists that works on an AST rewrite. Either a rewrite is directly passed in the constructor or the method `getRewrite()` is overridden to provide the AST rewrite that is evaluated on the document when the proposal is applied.

Since:
  3.8

## Field Summary

### Fields inherited from class ChangeCorrectionProposalCore

`fChange, fName, fRelevance`

### Fields inherited from interface ICommandAccess

`ASSIST_SUFFIX, COMMAND_ID_PREFIX`

## Constructor Summary

Constructors
Constructor
Description
`ASTRewriteCorrectionProposal(String name, ICompilationUnit cu, ASTRewrite rewrite, int relevance)`
Constructs an AST rewrite correction proposal.
`ASTRewriteCorrectionProposal(String name, ICompilationUnit cu, ASTRewrite rewrite, int relevance, org.eclipse.swt.graphics.Image image)`
Constructs an AST rewrite correction proposal.
`ASTRewriteCorrectionProposal(String name, ICompilationUnit cu, ASTRewrite rewrite, int relevance, org.eclipse.swt.graphics.Image image, org.eclipse.jdt.ui.text.java.correction.ASTRewriteCorrectionProposalCore delegate)`
Constructs an AST rewrite correction proposal.
`ASTRewriteCorrectionProposal(org.eclipse.jdt.ui.text.java.correction.ASTRewriteCorrectionProposalCore delegate, org.eclipse.swt.graphics.Image image)`
Constructs an AST rewrite correction proposal.

## Method Summary

Modifier and Type
Method
Description
`ImportRewrite`
`createImportRewrite(CompilationUnit astRoot)`
`ImportRewrite`
`getImportRewrite()`
Returns the import rewrite used for this compilation unit.
`protected ASTRewrite`
`getRewrite()`
`void`
`setImportRewrite(ImportRewrite rewrite)`
Sets the import rewrite used for this compilation unit.

### Methods inherited from class CUCorrectionProposal

`addEdits, apply, createChange, createTextChange, createTextChangeLocal, createTextChangeViaDelegate, didOpenEditor, getAdapter, getAdditionalProposalInfo, getCommandId, getCompilationUnit, getDelegate, getInitialCompilationUnit, getName, getPreviewContent, getTextChange, toString, useDelegateToCreateTextChange`

### Methods inherited from class ChangeCorrectionProposal

`getAdditionalProposalInfo, getChange, getContextInformation, getDisplayString, getImage, getSelection, getStyledDisplayString, performChange, setImage`

### Methods inherited from class ChangeCorrectionProposalCore

`apply, getCurrentChange, getRelevance, performChange, setCommandId, setDisplayName, setRelevance`

### Methods inherited from class Object

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

### Methods inherited from interface IJavaCompletionProposal

`getRelevance`

## Constructor Details

### ASTRewriteCorrectionProposal

public ASTRewriteCorrectionProposal(org.eclipse.jdt.ui.text.java.correction.ASTRewriteCorrectionProposalCore delegate, org.eclipse.swt.graphics.Image image)
Constructs an AST rewrite correction proposal.

Parameters:
  `delegate` - The delegate instance
  `image` - the image that is displayed for this proposal or `null` if no image is desired
Since:
  3.32

### ASTRewriteCorrectionProposal

public ASTRewriteCorrectionProposal(String name, ICompilationUnit cu, ASTRewrite rewrite, int relevance, org.eclipse.swt.graphics.Image image, org.eclipse.jdt.ui.text.java.correction.ASTRewriteCorrectionProposalCore delegate)
Constructs an AST rewrite correction proposal.

Parameters:
  `name` - the display name of the proposal
  `cu` - the compilation unit that is modified
  `rewrite` - the AST rewrite that is invoked when the proposal is applied or `null` if `getRewrite()` is overridden
  `relevance` - the relevance of this proposal
  `image` - the image that is displayed for this proposal or `null` if no image is desired
  `delegate` - The delegate instance
Since:
  3.31

### ASTRewriteCorrectionProposal

public ASTRewriteCorrectionProposal(String name, ICompilationUnit cu, ASTRewrite rewrite, int relevance, org.eclipse.swt.graphics.Image image)
Constructs an AST rewrite correction proposal.

Parameters:
  `name` - the display name of the proposal
  `cu` - the compilation unit that is modified
  `rewrite` - the AST rewrite that is invoked when the proposal is applied or `null` if `getRewrite()` is overridden
  `relevance` - the relevance of this proposal
  `image` - the image that is displayed for this proposal or `null` if no image is desired

### ASTRewriteCorrectionProposal

public ASTRewriteCorrectionProposal(String name, ICompilationUnit cu, ASTRewrite rewrite, int relevance)
Constructs an AST rewrite correction proposal. Uses the default image for this proposal.

Parameters:
  `name` - the display name of the proposal
  `cu` - the compilation unit that is modified
  `rewrite` - the AST rewrite that is invoked when the proposal is applied or `null` if `getRewrite()` is overridden
  `relevance` - The relevance of this proposal

## Method Details

### createImportRewrite

public ImportRewrite createImportRewrite(CompilationUnit astRoot)

### getRewrite

protected ASTRewrite getRewrite() throws org.eclipse.core.runtime.CoreException

Throws:
  `org.eclipse.core.runtime.CoreException`

### getImportRewrite

public ImportRewrite getImportRewrite()
Returns the import rewrite used for this compilation unit.

Returns:
  the import rewrite or `null` if no import rewrite has been set
Restriction:
  This method is not intended to be re-implemented or extended by clients.

### setImportRewrite

public void setImportRewrite(ImportRewrite rewrite)
Sets the import rewrite used for this compilation unit.

Parameters:
  `rewrite` - the import rewrite
Restriction:
  This method is not intended to be re-implemented or extended by clients.