Class CUCorrectionProposalCore
java.lang.Object
org.eclipse.jdt.core.manipulation.ChangeCorrectionProposalCore
org.eclipse.jdt.core.manipulation.CUCorrectionProposalCore
- All Implemented Interfaces:
ICUCorrectionProposal
public class CUCorrectionProposalCore
extends ChangeCorrectionProposalCore
implements ICUCorrectionProposal
A proposal for quick fixes and quick assists that work on a single compilation unit. Either a
text change
is directly passed in the constructor or method
addEdits(IDocument, TextEdit)
is overridden to provide the text edits that are applied
to the document when the proposal is evaluated.
The proposal takes care of the preview of the changes as proposal information.
- Since:
- 1.11
-
Field Summary
Fields inherited from class org.eclipse.jdt.core.manipulation.ChangeCorrectionProposalCore
fChange, fName, fRelevance
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
CUCorrectionProposalCore
(String name, ICompilationUnit cu, int relevance) Constructs a correction proposal working on a compilation unit.CUCorrectionProposalCore
(String name, ICompilationUnit cu, TextChange change, int relevance) Constructs a correction proposal working on a compilation unit with a given text change.CUCorrectionProposalCore
(ICUCorrectionProposal proposal, String name, ICompilationUnit cu, TextChange change, int relevance) Constructs a correction proposal working on a compilation unit with a given text change. -
Method Summary
Modifier and TypeMethodDescriptionprotected void
Called when theCompilationUnitChange
is initialized.void
apply()
protected Change
Creates the change for this proposal.Creates the text change for this proposal.The compilation unit on which the change works.Creates a preview of the content of the compilation unit after applying the change.final TextChange
Returns the text change that is invoked when the change is applied.toString()
Methods inherited from class org.eclipse.jdt.core.manipulation.ChangeCorrectionProposalCore
getChange, getName, getRelevance, performChange, setDisplayName, setRelevance
-
Constructor Details
-
CUCorrectionProposalCore
public CUCorrectionProposalCore(ICUCorrectionProposal proposal, String name, ICompilationUnit cu, TextChange change, int relevance) Constructs a correction proposal working on a compilation unit with a given text change.- Parameters:
proposal
- ICUCorrectionProposal to usename
- the name that is displayed in the proposal selection dialogcu
- the compilation unit to which the change can be appliedchange
- the change that is executed when the proposal is applied ornull
if implementors overrideaddEdits(IDocument, TextEdit)
to provide the text edits orcreateTextChange()
to provide a text changerelevance
- the relevance of this proposal
-
CUCorrectionProposalCore
Constructs a correction proposal working on a compilation unit with a given text change.- Parameters:
name
- the name that is displayed in the proposal selection dialogcu
- the compilation unit to which the change can be appliedchange
- the change that is executed when the proposal is applied ornull
if implementors overrideaddEdits(IDocument, TextEdit)
to provide the text edits orcreateTextChange()
to provide a text changerelevance
- the relevance of this proposal
-
CUCorrectionProposalCore
Constructs a correction proposal working on a compilation unit.Users have to override
addEdits(IDocument, TextEdit)
to provide the text edits orcreateTextChange()
to provide a text change.- Parameters:
name
- the name that is displayed in the proposal selection dialogcu
- the compilation unit on that the change worksrelevance
- the relevance of this proposal
-
-
Method Details
-
addEdits
Called when theCompilationUnitChange
is initialized. Subclasses can override to add text edits to the root edit of the change. Implementors must not access the proposal, e.g. not callChangeCorrectionProposalCore.getChange()
.The default implementation does not add any edits
- Parameters:
document
- content of the underlying compilation unit. To be accessed read only.editRoot
- The root edit to add all edits to- Throws:
CoreException
- can be thrown if adding the edits is failing.
-
getAdditionalProposalInfo
- Overrides:
getAdditionalProposalInfo
in classChangeCorrectionProposalCore
-
apply
- Overrides:
apply
in classChangeCorrectionProposalCore
- Throws:
CoreException
-
getNewChange
-
createTextChange
Creates the text change for this proposal. This method is only called once and only when no text change has been passed in {see #CUCorrectionProposal(String, ICompilationUnit, TextChange, int, Image)}.- Returns:
- the created text change
- Throws:
CoreException
- if the creation of the text change failed
-
createChange
Description copied from class:ChangeCorrectionProposalCore
Creates the change for this proposal. This method is only called once and only when no change has been passed in {#ChangeCorrectionProposal(String, Change, int, Image)}. Subclasses may override.- Overrides:
createChange
in classChangeCorrectionProposalCore
- Returns:
- the created change
- Throws:
CoreException
- if the creation of the change failed
-
getTextChange
Returns the text change that is invoked when the change is applied.- Specified by:
getTextChange
in interfaceICUCorrectionProposal
- Returns:
- the text change that is invoked when the change is applied
- Throws:
CoreException
- if accessing the change failed
-
getCompilationUnit
The compilation unit on which the change works.- Returns:
- the compilation unit on which the change works
-
getPreviewContent
Creates a preview of the content of the compilation unit after applying the change.- Returns:
- the preview of the changed compilation unit
- Throws:
CoreException
- if the creation of the change failed- Restriction:
- This method is not intended to be referenced by clients.
-
toString
-