Class CUCorrectionProposal
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
- 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
- Direct Known Subclasses:
ASTRewriteCorrectionProposal
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:
- 3.8
-
Field Summary
Fields inherited from class org.eclipse.jdt.core.manipulation.ChangeCorrectionProposalCore
fChange, fName, fRelevanceFields inherited from interface org.eclipse.jdt.ui.text.java.correction.ICommandAccess
ASSIST_SUFFIX, COMMAND_ID_PREFIX -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedCUCorrectionProposal(String name, ICompilationUnit cu, int relevance, org.eclipse.swt.graphics.Image image) Constructs a correction proposal working on a compilation unit.CUCorrectionProposal(String name, ICompilationUnit cu, int relevance, org.eclipse.swt.graphics.Image image, CUCorrectionProposalCore delegate) Constructs a correction proposal working on a compilation unit.CUCorrectionProposal(String name, ICompilationUnit cu, org.eclipse.ltk.core.refactoring.TextChange change, int relevance) Constructs a correction proposal working on a compilation unit with a given text change.CUCorrectionProposal(String name, ICompilationUnit cu, org.eclipse.ltk.core.refactoring.TextChange change, int relevance, org.eclipse.swt.graphics.Image image) Constructs a correction proposal working on a compilation unit with a given text change.CUCorrectionProposal(String name, ICompilationUnit cu, org.eclipse.ltk.core.refactoring.TextChange change, int relevance, org.eclipse.swt.graphics.Image image, CUCorrectionProposalCore delegate) Constructs a correction proposal working on a compilation unit.CUCorrectionProposal(CUCorrectionProposalCore core, org.eclipse.swt.graphics.Image image) Constructs a correction proposal based on a core proposal and an image -
Method Summary
Modifier and TypeMethodDescriptionprotected voidaddEdits(org.eclipse.jface.text.IDocument document, org.eclipse.text.edits.TextEdit editRoot) Called when theCompilationUnitChangeis initialized.voidapply(org.eclipse.jface.text.IDocument document) protected final org.eclipse.ltk.core.refactoring.ChangeClients should not override this methodprotected org.eclipse.ltk.core.refactoring.TextChangeCreates the text change for this proposal.protected org.eclipse.ltk.core.refactoring.TextChangeprotected org.eclipse.ltk.core.refactoring.TextChangeprotected booleanReturns whether the changed compilation unit was not previously open in an editor.<T> TgetAdapter(Class<T> adapter) getAdditionalProposalInfo(org.eclipse.core.runtime.IProgressMonitor monitor) Returns the id of the command that should invoke this correction proposal.final ICompilationUnitThe compilation unit on which the change works.protected CUCorrectionProposalCoreprotected ICompilationUnitgetName()Returns the name of the proposal.final StringCreates a preview of the content of the compilation unit after applying the change.final org.eclipse.ltk.core.refactoring.TextChangeReturns the text change that is invoked when the change is applied.toString()protected booleanMethods inherited from class org.eclipse.jdt.ui.text.java.correction.ChangeCorrectionProposal
getAdditionalProposalInfo, getChange, getContextInformation, getDisplayString, getImage, getSelection, getStyledDisplayString, performChange, setImageMethods inherited from class org.eclipse.jdt.core.manipulation.ChangeCorrectionProposalCore
apply, getCurrentChange, getRelevance, performChange, setCommandId, setDisplayName, setRelevanceMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.eclipse.jdt.ui.text.java.IJavaCompletionProposal
getRelevance
-
Constructor Details
-
CUCorrectionProposal
public CUCorrectionProposal(String name, ICompilationUnit cu, org.eclipse.ltk.core.refactoring.TextChange change, int relevance, org.eclipse.swt.graphics.Image image) 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 ornullif implementors overrideaddEdits(IDocument, TextEdit)to provide the text edits orcreateTextChange()to provide a text changerelevance- the relevance of this proposalimage- the image that is displayed for this proposal ornullif no image is desired
-
CUCorrectionProposal
public CUCorrectionProposal(String name, ICompilationUnit cu, org.eclipse.ltk.core.refactoring.TextChange change, int relevance) Constructs a correction proposal working on a compilation unit with a given text change. Uses the default image for this proposal.- 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 ornullif implementors overrideaddEdits(IDocument, TextEdit)to provide the text edits orcreateTextChange()to provide a text change.relevance- the relevance of this proposal
-
CUCorrectionProposal
public CUCorrectionProposal(CUCorrectionProposalCore core, org.eclipse.swt.graphics.Image image) throws org.eclipse.core.runtime.CoreException Constructs a correction proposal based on a core proposal and an image- Parameters:
core- the core proposalimage- the image to use- Throws:
org.eclipse.core.runtime.CoreException- if obtaining text change has issue- Since:
- 3.34
-
CUCorrectionProposal
protected CUCorrectionProposal(String name, ICompilationUnit cu, int relevance, org.eclipse.swt.graphics.Image image) 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 proposalimage- the image that is displayed for this proposal ornullif no image is desired
-
CUCorrectionProposal
public CUCorrectionProposal(String name, ICompilationUnit cu, int relevance, org.eclipse.swt.graphics.Image image, CUCorrectionProposalCore delegate) 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 proposalimage- the image that is displayed for this proposal ornullif no image is desireddelegate- The delegate instance- Since:
- 3.31
-
CUCorrectionProposal
public CUCorrectionProposal(String name, ICompilationUnit cu, org.eclipse.ltk.core.refactoring.TextChange change, int relevance, org.eclipse.swt.graphics.Image image, CUCorrectionProposalCore delegate) 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 workschange- The text change to be appliedrelevance- the relevance of this proposalimage- the image that is displayed for this proposal ornullif no image is desireddelegate- The delegate proposal underlying this proposal- Since:
- 3.31
-
-
Method Details
-
getDelegate
- Returns:
- the delegate
- Since:
- 3.32
-
addEdits
protected void addEdits(org.eclipse.jface.text.IDocument document, org.eclipse.text.edits.TextEdit editRoot) throws org.eclipse.core.runtime.CoreException Called when theCompilationUnitChangeis initialized. Subclasses can override to add text edits to the root edit of the change. Implementors must not access the proposal, e.g. not callChangeCorrectionProposal.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:
org.eclipse.core.runtime.CoreException- can be thrown if adding the edits is failing.
-
getAdditionalProposalInfo
- Specified by:
getAdditionalProposalInfoin interfaceorg.eclipse.jface.text.contentassist.ICompletionProposalExtension5- Overrides:
getAdditionalProposalInfoin classChangeCorrectionProposalCore
-
getInitialCompilationUnit
- Returns:
- the compilation unit
- Since:
- 3.31
-
apply
public void apply(org.eclipse.jface.text.IDocument document) - Specified by:
applyin interfaceorg.eclipse.jface.text.contentassist.ICompletionProposal- Overrides:
applyin classChangeCorrectionProposal
-
createTextChange
protected org.eclipse.ltk.core.refactoring.TextChange createTextChange() throws org.eclipse.core.runtime.CoreExceptionCreates the text change for this proposal. This method is only called once and only when no text change has been passed inCUCorrectionProposal(String, ICompilationUnit, TextChange, int, Image).- Returns:
- the created text change
- Throws:
org.eclipse.core.runtime.CoreException- if the creation of the text change failed
-
useDelegateToCreateTextChange
protected boolean useDelegateToCreateTextChange()- Since:
- 3.31
-
createTextChangeLocal
protected org.eclipse.ltk.core.refactoring.TextChange createTextChangeLocal() throws org.eclipse.core.runtime.CoreException- Returns:
- the text change
- Throws:
org.eclipse.core.runtime.CoreException- Since:
- 3.31
-
createTextChangeViaDelegate
protected org.eclipse.ltk.core.refactoring.TextChange createTextChangeViaDelegate() throws org.eclipse.core.runtime.CoreException- Returns:
- a text change created via the delegate
- Throws:
org.eclipse.core.runtime.CoreException- Since:
- 3.31
-
createChange
protected final org.eclipse.ltk.core.refactoring.Change createChange() throws org.eclipse.core.runtime.CoreExceptionClients should not override this method- Overrides:
createChangein classChangeCorrectionProposalCore- Returns:
- the created change
- Throws:
org.eclipse.core.runtime.CoreException- if the creation of the change failed
-
getTextChange
public final org.eclipse.ltk.core.refactoring.TextChange getTextChange() throws org.eclipse.core.runtime.CoreExceptionReturns the text change that is invoked when the change is applied.- Specified by:
getTextChangein interfaceICUCorrectionProposal- Returns:
- the text change that is invoked when the change is applied
- Throws:
org.eclipse.core.runtime.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:
org.eclipse.core.runtime.CoreException- if the creation of the change failed- Restriction:
- This method is not intended to be referenced by clients.
-
getName
Description copied from class:ChangeCorrectionProposalCoreReturns the name of the proposal.- Overrides:
getNamein classChangeCorrectionProposalCore- Returns:
- the name of the proposal
-
getCommandId
Description copied from interface:ICommandAccessReturns the id of the command that should invoke this correction proposal.- Specified by:
getCommandIdin interfaceICommandAccess- Overrides:
getCommandIdin classChangeCorrectionProposalCore- Returns:
- the command id
-
toString
-
didOpenEditor
protected boolean didOpenEditor()Returns whether the changed compilation unit was not previously open in an editor.- Returns:
trueif the changed compilation unit was not previously open in an editor,falseif the changed compilation unit was already open in an editor- Restriction:
- This method is not intended to be referenced by clients.
-
getAdapter
- Specified by:
getAdapterin interfaceorg.eclipse.core.runtime.IAdaptable- Overrides:
getAdapterin classChangeCorrectionProposalCore- Since:
- 3.32
-