Class ChangeCorrectionProposal
- java.lang.Object
-
- org.eclipse.jdt.core.manipulation.ChangeCorrectionProposalCore
-
- org.eclipse.jdt.ui.text.java.correction.ChangeCorrectionProposal
-
- All Implemented Interfaces:
ICommandAccess,IJavaCompletionProposal,ICompletionProposal,ICompletionProposalExtension5,ICompletionProposalExtension6
- Direct Known Subclasses:
CUCorrectionProposal
public class ChangeCorrectionProposal extends ChangeCorrectionProposalCore implements IJavaCompletionProposal, ICommandAccess, ICompletionProposalExtension5, ICompletionProposalExtension6
Implementation of a Java completion proposal to be used for quick fix and quick assist proposals that are based on aChange. The proposal offers additional proposal information (based on theChange).- Since:
- 3.8
-
-
Field Summary
-
Fields inherited from class org.eclipse.jdt.core.manipulation.ChangeCorrectionProposalCore
fChange, fName, fRelevance
-
Fields inherited from interface org.eclipse.jdt.ui.text.java.correction.ICommandAccess
ASSIST_SUFFIX, COMMAND_ID_PREFIX
-
-
Constructor Summary
Constructors Constructor Description ChangeCorrectionProposal(String name, Change change, int relevance)Constructs a change correction proposal.ChangeCorrectionProposal(String name, Change change, int relevance, Image image)Constructs a change correction proposal.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidapply(IDocument document)StringgetAdditionalProposalInfo()ChangegetChange()Returns the change that will be executed when the proposal is applied.StringgetCommandId()Returns the id of the command that should invoke this correction proposal.IContextInformationgetContextInformation()StringgetDisplayString()ImagegetImage()PointgetSelection(IDocument document)StyledStringgetStyledDisplayString()protected voidperformChange(IEditorPart activeEditor, IDocument document)Performs the change associated with this proposal.voidsetCommandId(String commandId)Set the proposal id to allow assigning a shortcut to the correction proposal.voidsetImage(Image image)Sets the proposal's image ornullif no image is desired.-
Methods inherited from class org.eclipse.jdt.core.manipulation.ChangeCorrectionProposalCore
apply, createChange, getAdditionalProposalInfo, getName, getRelevance, performChange, setDisplayName, setRelevance
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.eclipse.jface.text.contentassist.ICompletionProposalExtension5
getAdditionalProposalInfo
-
Methods inherited from interface org.eclipse.jdt.ui.text.java.IJavaCompletionProposal
getRelevance
-
-
-
-
Constructor Detail
-
ChangeCorrectionProposal
public ChangeCorrectionProposal(String name, Change change, int relevance, Image image)
Constructs a change correction proposal.- Parameters:
name- the name that is displayed in the proposal selection dialogchange- the change that is executed when the proposal is applied ornullif the change will be created by implementors ofChangeCorrectionProposalCore.createChange()relevance- the relevance of this proposalimage- the image that is displayed for this proposal ornullif no image is desired
-
ChangeCorrectionProposal
public ChangeCorrectionProposal(String name, Change change, int relevance)
Constructs a change correction proposal. Uses the default image for this proposal.- Parameters:
name- The name that is displayed in the proposal selection dialog.change- The change that is executed when the proposal is applied ornullif the change will be created by implementors ofChangeCorrectionProposalCore.createChange().relevance- The relevance of this proposal.
-
-
Method Detail
-
apply
public void apply(IDocument document)
- Specified by:
applyin interfaceICompletionProposal
-
performChange
protected void performChange(IEditorPart activeEditor, IDocument document) throws CoreException
Performs the change associated with this proposal.Subclasses may extend, but must call the super implementation.
- Parameters:
activeEditor- the editor currently active ornullif no editor is activedocument- the document of the editor currently active ornullif no editor is visible- Throws:
CoreException- when the invocation of the change failed
-
getAdditionalProposalInfo
public String getAdditionalProposalInfo()
- Specified by:
getAdditionalProposalInfoin interfaceICompletionProposal
-
getContextInformation
public IContextInformation getContextInformation()
- Specified by:
getContextInformationin interfaceICompletionProposal
-
getDisplayString
public String getDisplayString()
- Specified by:
getDisplayStringin interfaceICompletionProposal
-
getStyledDisplayString
public StyledString getStyledDisplayString()
- Specified by:
getStyledDisplayStringin interfaceICompletionProposalExtension6
-
getImage
public Image getImage()
- Specified by:
getImagein interfaceICompletionProposal
-
getSelection
public Point getSelection(IDocument document)
- Specified by:
getSelectionin interfaceICompletionProposal
-
setImage
public void setImage(Image image)
Sets the proposal's image ornullif no image is desired.- Parameters:
image- the desired image.
-
getChange
public final Change getChange() throws CoreException
Returns the change that will be executed when the proposal is applied. This method callsChangeCorrectionProposalCore.createChange()to compute the change.- Overrides:
getChangein classChangeCorrectionProposalCore- Returns:
- the change for this proposal, can be
nullin rare cases if creation of the change failed - Throws:
CoreException- when the change could not be created
-
getCommandId
public String getCommandId()
Description copied from interface:ICommandAccessReturns the id of the command that should invoke this correction proposal.- Specified by:
getCommandIdin interfaceICommandAccess- Returns:
- the id of the command or
nullif this proposal does not have a command. This id must start withICommandAccess.COMMAND_ID_PREFIXto be recognized as a correction command. In addition, the id must end withICommandAccess.ASSIST_SUFFIXto be recognized as a quick assist command.
-
setCommandId
public void setCommandId(String commandId)
Set the proposal id to allow assigning a shortcut to the correction proposal.- Parameters:
commandId- The proposal id for this proposal ornullif no command should be assigned to this proposal.
-
-