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, fRelevance
Fields inherited from interface org.eclipse.jdt.ui.text.java.correction.ICommandAccess
ASSIST_SUFFIX, COMMAND_ID_PREFIX
-
Constructor Summary
ModifierConstructorDescriptionprotected
CUCorrectionProposal
(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. -
Method Summary
Modifier and TypeMethodDescriptionprotected void
addEdits
(org.eclipse.jface.text.IDocument document, org.eclipse.text.edits.TextEdit editRoot) Called when theCompilationUnitChange
is initialized.void
apply
(org.eclipse.jface.text.IDocument document) protected final org.eclipse.ltk.core.refactoring.Change
Clients should not override this methodprotected org.eclipse.ltk.core.refactoring.TextChange
Creates the text change for this proposal.protected org.eclipse.ltk.core.refactoring.TextChange
protected org.eclipse.ltk.core.refactoring.TextChange
protected boolean
Returns whether the changed compilation unit was not previously open in an editor.<T> T
getAdapter
(Class<T> adapter) getAdditionalProposalInfo
(org.eclipse.core.runtime.IProgressMonitor monitor) Returns the id of the command that should invoke this correction proposal.final ICompilationUnit
The compilation unit on which the change works.protected CUCorrectionProposalCore
protected ICompilationUnit
getName()
Returns the name of the proposal.final String
Creates a preview of the content of the compilation unit after applying the change.final org.eclipse.ltk.core.refactoring.TextChange
Returns the text change that is invoked when the change is applied.toString()
protected boolean
Methods inherited from class org.eclipse.jdt.ui.text.java.correction.ChangeCorrectionProposal
getAdditionalProposalInfo, getChange, getContextInformation, getDisplayString, getImage, getSelection, getStyledDisplayString, performChange, setImage
Methods inherited from class org.eclipse.jdt.core.manipulation.ChangeCorrectionProposalCore
apply, getCurrentChange, getRelevance, performChange, setCommandId, setDisplayName, setRelevance
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods 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 ornull
if 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 ornull
if 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 ornull
if implementors overrideaddEdits(IDocument, TextEdit)
to provide the text edits orcreateTextChange()
to provide a text change.relevance
- the relevance of this proposal
-
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 ornull
if 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 ornull
if 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 ornull
if 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 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 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:
getAdditionalProposalInfo
in interfaceorg.eclipse.jface.text.contentassist.ICompletionProposalExtension5
- Overrides:
getAdditionalProposalInfo
in classChangeCorrectionProposalCore
-
getInitialCompilationUnit
- Returns:
- the compilation unit
- Since:
- 3.31
-
apply
public void apply(org.eclipse.jface.text.IDocument document) - Specified by:
apply
in interfaceorg.eclipse.jface.text.contentassist.ICompletionProposal
- Overrides:
apply
in 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:
createChange
in 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:
getTextChange
in 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:ChangeCorrectionProposalCore
Returns the name of the proposal.- Overrides:
getName
in classChangeCorrectionProposalCore
- Returns:
- the name of the proposal
-
getCommandId
Description copied from interface:ICommandAccess
Returns the id of the command that should invoke this correction proposal.- Specified by:
getCommandId
in interfaceICommandAccess
- Overrides:
getCommandId
in classChangeCorrectionProposalCore
- Returns:
- the command id
-
toString
-
didOpenEditor
protected boolean didOpenEditor()Returns whether the changed compilation unit was not previously open in an editor.- Returns:
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- Restriction:
- This method is not intended to be referenced by clients.
-
getAdapter
- Specified by:
getAdapter
in interfaceorg.eclipse.core.runtime.IAdaptable
- Overrides:
getAdapter
in classChangeCorrectionProposalCore
- Since:
- 3.32
-