public class CUCorrectionProposal extends ChangeCorrectionProposal
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.
ASSIST_SUFFIX, COMMAND_ID_PREFIX| Modifier | Constructor and Description |
|---|---|
protected |
CUCorrectionProposal(String name,
ICompilationUnit cu,
int relevance,
Image image)
Constructs a correction proposal working on a compilation unit.
|
|
CUCorrectionProposal(String name,
ICompilationUnit cu,
TextChange change,
int relevance)
Constructs a correction proposal working on a compilation unit with a given text change.
|
|
CUCorrectionProposal(String name,
ICompilationUnit cu,
TextChange change,
int relevance,
Image image)
Constructs a correction proposal working on a compilation unit with a given text change.
|
| Modifier and Type | Method and Description |
|---|---|
protected void |
addEdits(IDocument document,
TextEdit editRoot)
Called when the
CompilationUnitChange is initialized. |
void |
apply(IDocument document) |
protected Change |
createChange()
Creates the change for this proposal.
|
protected TextChange |
createTextChange()
Creates the text change for this proposal.
|
protected boolean |
didOpenEditor()
Returns whether the changed compilation unit was not previously open in an editor.
|
Object |
getAdditionalProposalInfo(IProgressMonitor monitor) |
ICompilationUnit |
getCompilationUnit()
The compilation unit on which the change works.
|
String |
getPreviewContent()
Creates a preview of the content of the compilation unit after applying the change.
|
TextChange |
getTextChange()
Returns the text change that is invoked when the change is applied.
|
String |
toString() |
getAdditionalProposalInfo, getChange, getCommandId, getContextInformation, getDisplayString, getImage, getName, getRelevance, getSelection, getStyledDisplayString, performChange, setCommandId, setDisplayName, setImage, setRelevancepublic CUCorrectionProposal(String name, ICompilationUnit cu, TextChange change, int relevance, Image image)
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 or null
if implementors override addEdits(IDocument, TextEdit) to provide the
text edits or createTextChange() to provide a text changerelevance - the relevance of this proposalimage - the image that is displayed for this proposal or null if no image
is desiredpublic CUCorrectionProposal(String name, ICompilationUnit cu, TextChange change, int relevance)
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 or null
if implementors override addEdits(IDocument, TextEdit) to provide the
text edits or createTextChange() to provide a text change.relevance - the relevance of this proposalprotected CUCorrectionProposal(String name, ICompilationUnit cu, int relevance, Image image)
Users have to override addEdits(IDocument, TextEdit) to provide the text edits or
createTextChange() to provide a text change.
name - the name that is displayed in the proposal selection dialogcu - the compilation unit on that the change worksrelevance - the relevance of this proposalimage - the image that is displayed for this proposal or null if no image
is desiredprotected void addEdits(IDocument document, TextEdit editRoot) throws CoreException
CompilationUnitChange 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 call ChangeCorrectionProposal.getChange().
The default implementation does not add any edits
document - content of the underlying compilation unit. To be accessed read only.editRoot - The root edit to add all edits toCoreException - can be thrown if adding the edits is failing.public Object getAdditionalProposalInfo(IProgressMonitor monitor)
getAdditionalProposalInfo in interface ICompletionProposalExtension5getAdditionalProposalInfo in class ChangeCorrectionProposalpublic void apply(IDocument document)
apply in interface ICompletionProposalapply in class ChangeCorrectionProposalprotected TextChange createTextChange() throws CoreException
CUCorrectionProposal(String, ICompilationUnit, TextChange, int, Image).CoreException - if the creation of the text change failedprotected final Change createChange() throws CoreException
ChangeCorrectionProposalChangeCorrectionProposal.ChangeCorrectionProposal(String, Change, int, Image).
Subclasses may override.createChange in class ChangeCorrectionProposalCoreException - if the creation of the change failedpublic final TextChange getTextChange() throws CoreException
CoreException - if accessing the change failedpublic final ICompilationUnit getCompilationUnit()
public String getPreviewContent() throws CoreException
CoreException - if the creation of the change failedprotected boolean didOpenEditor()
true if the changed compilation unit was not previously open in an
editor, false if the changed compilation unit was already open in an
editor
Copyright (c) 2000, 2014 Eclipse Contributors and others. All rights reserved.Guidelines for using Eclipse APIs.