Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 201456 Details for
Bug 287136
[quick fix][api] Make ASTRewriteCorrectionProposal and parents public API
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
first draft
ProposalsAPI.txt (text/plain), 25.57 KB, created by
Deepak Azad
on 2011-08-13 03:37:08 EDT
(
hide
)
Description:
first draft
Filename:
MIME Type:
Creator:
Deepak Azad
Created:
2011-08-13 03:37:08 EDT
Size:
25.57 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.ui >Index: ui/org/eclipse/jdt/internal/ui/text/correction/LocalCorrectionsSubProcessor.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/LocalCorrectionsSubProcessor.java,v >retrieving revision 1.236 >diff -u -r1.236 LocalCorrectionsSubProcessor.java >--- ui/org/eclipse/jdt/internal/ui/text/correction/LocalCorrectionsSubProcessor.java 10 Aug 2011 12:09:02 -0000 1.236 >+++ ui/org/eclipse/jdt/internal/ui/text/correction/LocalCorrectionsSubProcessor.java 13 Aug 2011 07:25:37 -0000 >@@ -101,7 +101,6 @@ > import org.eclipse.jdt.core.dom.rewrite.ImportRewrite; > import org.eclipse.jdt.core.dom.rewrite.ImportRewrite.ImportRewriteContext; > import org.eclipse.jdt.core.dom.rewrite.ListRewrite; >-import org.eclipse.jdt.core.refactoring.CompilationUnitChange; > > import org.eclipse.jdt.internal.corext.codemanipulation.CodeGenerationSettings; > import org.eclipse.jdt.internal.corext.codemanipulation.ContextSensitiveImportRewriteContext; >@@ -160,6 +159,7 @@ > import org.eclipse.jdt.internal.ui.text.correction.proposals.LinkedNamesAssistProposal; > import org.eclipse.jdt.internal.ui.text.correction.proposals.MissingAnnotationAttributesProposal; > import org.eclipse.jdt.internal.ui.text.correction.proposals.NewVariableCorrectionProposal; >+import org.eclipse.jdt.internal.ui.text.correction.proposals.RefactoringCorrectionProposal; > import org.eclipse.jdt.internal.ui.text.correction.proposals.ReplaceCorrectionProposal; > import org.eclipse.jdt.internal.ui.viewsupport.BasicElementLabels; > >@@ -206,7 +206,7 @@ > if (refactoring.checkActivationBasics(astRoot).isOK()) { > String label= CorrectionMessages.LocalCorrectionsSubProcessor_surroundwith_trycatch_description; > Image image= JavaPluginImages.get(JavaPluginImages.IMG_OBJS_EXCEPTION); >- CUCorrectionProposal proposal= new CUCorrectionProposal(label, cu, (CompilationUnitChange) refactoring.createChange(null), 6, image); >+ RefactoringCorrectionProposal proposal= new RefactoringCorrectionProposal(label, cu, refactoring, 6, image); > proposal.setLinkedProposalModel(refactoring.getLinkedProposalModel()); > proposals.add(proposal); > } >@@ -220,7 +220,7 @@ > if (refactoring.checkActivationBasics(astRoot).isOK()) { > String label= CorrectionMessages.LocalCorrectionsSubProcessor_surroundwith_trymulticatch_description; > Image image= JavaPluginImages.get(JavaPluginImages.IMG_OBJS_EXCEPTION); >- CUCorrectionProposal proposal= new CUCorrectionProposal(label, cu, (CompilationUnitChange) refactoring.createChange(null), 7, image); >+ RefactoringCorrectionProposal proposal= new RefactoringCorrectionProposal(label, cu, refactoring, 7, image); > proposal.setLinkedProposalModel(refactoring.getLinkedProposalModel()); > proposals.add(proposal); > } >Index: ui/org/eclipse/jdt/internal/ui/text/correction/QuickAssistProcessor.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/QuickAssistProcessor.java,v >retrieving revision 1.172 >diff -u -r1.172 QuickAssistProcessor.java >--- ui/org/eclipse/jdt/internal/ui/text/correction/QuickAssistProcessor.java 28 Jul 2011 17:39:58 -0000 1.172 >+++ ui/org/eclipse/jdt/internal/ui/text/correction/QuickAssistProcessor.java 13 Aug 2011 07:25:37 -0000 >@@ -25,19 +25,13 @@ > import org.eclipse.swt.graphics.Image; > > import org.eclipse.core.runtime.CoreException; >-import org.eclipse.core.runtime.IProgressMonitor; > import org.eclipse.core.runtime.NullProgressMonitor; > >-import org.eclipse.core.resources.IFile; > >-import org.eclipse.text.edits.InsertEdit; > > import org.eclipse.ui.IEditorPart; > > import org.eclipse.ltk.core.refactoring.Refactoring; >-import org.eclipse.ltk.core.refactoring.RefactoringStatus; >-import org.eclipse.ltk.core.refactoring.TextChange; >-import org.eclipse.ltk.core.refactoring.TextFileChange; > > import org.eclipse.jdt.core.Flags; > import org.eclipse.jdt.core.IBuffer; >@@ -149,12 +143,12 @@ > import org.eclipse.jdt.internal.ui.javaeditor.JavaEditor; > import org.eclipse.jdt.internal.ui.text.correction.proposals.ASTRewriteCorrectionProposal; > import org.eclipse.jdt.internal.ui.text.correction.proposals.AssignToVariableAssistProposal; >-import org.eclipse.jdt.internal.ui.text.correction.proposals.CUCorrectionProposal; > import org.eclipse.jdt.internal.ui.text.correction.proposals.ChangeCorrectionProposal; > import org.eclipse.jdt.internal.ui.text.correction.proposals.FixCorrectionProposal; > import org.eclipse.jdt.internal.ui.text.correction.proposals.LinkedCorrectionProposal; > import org.eclipse.jdt.internal.ui.text.correction.proposals.LinkedNamesAssistProposal; > import org.eclipse.jdt.internal.ui.text.correction.proposals.NewDefiningMethodProposal; >+import org.eclipse.jdt.internal.ui.text.correction.proposals.RefactoringCorrectionProposal; > import org.eclipse.jdt.internal.ui.text.correction.proposals.RenameRefactoringProposal; > import org.eclipse.jdt.internal.ui.viewsupport.BasicElementLabels; > import org.eclipse.jdt.internal.ui.viewsupport.JavaElementImageProvider; >@@ -2384,48 +2378,4 @@ > } > return true; > } >- >- private static class RefactoringCorrectionProposal extends CUCorrectionProposal { >- private final Refactoring fRefactoring; >- private RefactoringStatus fRefactoringStatus; >- >- public RefactoringCorrectionProposal(String name, ICompilationUnit cu, Refactoring refactoring, int relevance, Image image) { >- super(name, cu, null, relevance, image); >- fRefactoring= refactoring; >- } >- >- /** >- * Can be overridden by clients to perform expensive initializations of the refactoring >- * >- * @param refactoring the refactoring >- * @throws CoreException if something goes wrong during init >- */ >- protected void init(Refactoring refactoring) throws CoreException { >- // empty default implementation >- } >- >- @Override >- protected TextChange createTextChange() throws CoreException { >- init(fRefactoring); >- fRefactoringStatus= fRefactoring.checkFinalConditions(new NullProgressMonitor()); >- if (fRefactoringStatus.hasFatalError()) { >- TextFileChange dummyChange= new TextFileChange("fatal error", (IFile) getCompilationUnit().getResource()); //$NON-NLS-1$ >- dummyChange.setEdit(new InsertEdit(0, "")); //$NON-NLS-1$ >- return dummyChange; >- } >- return (TextChange) fRefactoring.createChange(new NullProgressMonitor()); >- } >- >- /* >- * @see org.eclipse.jdt.internal.ui.text.correction.proposals.CUCorrectionProposal#getAdditionalProposalInfo(org.eclipse.core.runtime.IProgressMonitor) >- * @since 3.6 >- */ >- @Override >- public Object getAdditionalProposalInfo(IProgressMonitor monitor) { >- if (fRefactoringStatus != null && fRefactoringStatus.hasFatalError()) { >- return fRefactoringStatus.getEntryWithHighestSeverity().getMessage(); >- } >- return super.getAdditionalProposalInfo(monitor); >- } >- } > } >Index: ui/org/eclipse/jdt/internal/ui/text/correction/proposals/CUCorrectionProposal.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/proposals/CUCorrectionProposal.java,v >retrieving revision 1.9 >diff -u -r1.9 CUCorrectionProposal.java >--- ui/org/eclipse/jdt/internal/ui/text/correction/proposals/CUCorrectionProposal.java 2 Mar 2011 20:32:57 -0000 1.9 >+++ ui/org/eclipse/jdt/internal/ui/text/correction/proposals/CUCorrectionProposal.java 13 Aug 2011 07:25:37 -0000 >@@ -34,13 +34,10 @@ > import org.eclipse.jface.text.Document; > import org.eclipse.jface.text.IDocument; > import org.eclipse.jface.text.IRegion; >-import org.eclipse.jface.text.ITextViewer; > > import org.eclipse.ui.IEditorPart; > import org.eclipse.ui.IWorkbenchPage; > >-import org.eclipse.ui.texteditor.ITextEditor; >- > import org.eclipse.ltk.core.refactoring.Change; > import org.eclipse.ltk.core.refactoring.DocumentChange; > import org.eclipse.ltk.core.refactoring.TextChange; >@@ -51,20 +48,15 @@ > import org.eclipse.jdt.core.refactoring.CompilationUnitChange; > > import org.eclipse.jdt.internal.corext.codemanipulation.StubUtility; >-import org.eclipse.jdt.internal.corext.fix.LinkedProposalModel; >-import org.eclipse.jdt.internal.corext.fix.LinkedProposalPositionGroup; > import org.eclipse.jdt.internal.corext.util.Resources; > import org.eclipse.jdt.internal.corext.util.Strings; > > import org.eclipse.jdt.ui.JavaUI; > > import org.eclipse.jdt.internal.ui.JavaPlugin; >-import org.eclipse.jdt.internal.ui.JavaUIStatus; > import org.eclipse.jdt.internal.ui.javaeditor.EditorUtility; >-import org.eclipse.jdt.internal.ui.javaeditor.JavaEditor; > import org.eclipse.jdt.internal.ui.text.correction.CorrectionMessages; > import org.eclipse.jdt.internal.ui.util.ExceptionHandler; >-import org.eclipse.jdt.internal.ui.viewsupport.LinkedProposalModelPresenter; > > /** > * A proposal for quick fixes and quick assist that work on a single compilation unit. >@@ -79,7 +71,6 @@ > public class CUCorrectionProposal extends ChangeCorrectionProposal { > > private ICompilationUnit fCompilationUnit; >- private LinkedProposalModel fLinkedProposalModel; > private boolean fSwitchedEditor; > > >@@ -101,7 +92,6 @@ > throw new IllegalArgumentException("Compilation unit must not be null"); //$NON-NLS-1$ > } > fCompilationUnit= cu; >- fLinkedProposalModel= null; > } > > /** >@@ -133,17 +123,6 @@ > protected void addEdits(IDocument document, TextEdit editRoot) throws CoreException { > } > >- protected LinkedProposalModel getLinkedProposalModel() { >- if (fLinkedProposalModel == null) { >- fLinkedProposalModel= new LinkedProposalModel(); >- } >- return fLinkedProposalModel; >- } >- >- public void setLinkedProposalModel(LinkedProposalModel model) { >- fLinkedProposalModel= model; >- } >- > @Override > public Object getAdditionalProposalInfo(IProgressMonitor monitor) { > >@@ -330,28 +309,9 @@ > */ > @Override > protected void performChange(IEditorPart part, IDocument document) throws CoreException { >- try { >- super.performChange(part, document); >- if (part == null) { >- return; >- } >- >- if (fLinkedProposalModel != null) { >- if (fLinkedProposalModel.hasLinkedPositions() && part instanceof JavaEditor) { >- // enter linked mode >- ITextViewer viewer= ((JavaEditor) part).getViewer(); >- new LinkedProposalModelPresenter().enterLinkedMode(viewer, part, fSwitchedEditor, fLinkedProposalModel); >- } else if (part instanceof ITextEditor) { >- LinkedProposalPositionGroup.PositionInformation endPosition= fLinkedProposalModel.getEndPosition(); >- if (endPosition != null) { >- // select a result >- int pos= endPosition.getOffset() + endPosition.getLength(); >- ((ITextEditor) part).selectAndReveal(pos, 0); >- } >- } >- } >- } catch (BadLocationException e) { >- throw new CoreException(JavaUIStatus.createError(IStatus.ERROR, e)); >+ super.performChange(part, document); >+ if (part == null) { >+ return; > } > } > >@@ -441,4 +401,8 @@ > } > return super.toString(); > } >+ >+ protected boolean isSwitchedEditor() { >+ return fSwitchedEditor; >+ } > } >Index: ui/org/eclipse/jdt/internal/ui/text/correction/proposals/CULinkedCorrectionProposal.java >=================================================================== >RCS file: ui/org/eclipse/jdt/internal/ui/text/correction/proposals/CULinkedCorrectionProposal.java >diff -N ui/org/eclipse/jdt/internal/ui/text/correction/proposals/CULinkedCorrectionProposal.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ ui/org/eclipse/jdt/internal/ui/text/correction/proposals/CULinkedCorrectionProposal.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,130 @@ >+/******************************************************************************* >+ * Copyright (c) 2000, 2011 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+ >+package org.eclipse.jdt.internal.ui.text.correction.proposals; >+ >+import org.eclipse.swt.graphics.Image; >+ >+import org.eclipse.core.runtime.CoreException; >+import org.eclipse.core.runtime.IStatus; >+ >+import org.eclipse.text.edits.TextEdit; >+ >+import org.eclipse.jface.text.BadLocationException; >+import org.eclipse.jface.text.IDocument; >+import org.eclipse.jface.text.ITextViewer; >+ >+import org.eclipse.ui.IEditorPart; >+ >+import org.eclipse.ui.texteditor.ITextEditor; >+ >+import org.eclipse.ltk.core.refactoring.TextChange; >+ >+import org.eclipse.jdt.core.ICompilationUnit; >+ >+import org.eclipse.jdt.internal.corext.fix.LinkedProposalModel; >+import org.eclipse.jdt.internal.corext.fix.LinkedProposalPositionGroup; >+ >+import org.eclipse.jdt.internal.ui.JavaUIStatus; >+import org.eclipse.jdt.internal.ui.javaeditor.JavaEditor; >+import org.eclipse.jdt.internal.ui.viewsupport.LinkedProposalModelPresenter; >+ >+/** >+ * A proposal for quick fixes and quick assist that work on a single compilation unit. >+ * Either a {@link TextChange text change} is directly passed in the constructor or method >+ * {@link #addEdits(IDocument, TextEdit)} is overridden to provide the text edits that are >+ * applied to the document when the proposal is evaluated. >+ * <p> >+ * The proposal takes care of the preview of the changes as proposal information. >+ * </p> >+ * @since 3.2 >+ */ >+public class CULinkedCorrectionProposal extends CUCorrectionProposal { >+ >+ private LinkedProposalModel fLinkedProposalModel; >+ >+ >+ /** >+ * Constructs a correction proposal working on a compilation unit with a given text change >+ * >+ * @param name the name that is displayed in the proposal selection dialog. >+ * @param cu the compilation unit on that the change works. >+ * @param change the change that is executed when the proposal is applied or <code>null</code> >+ * if implementors override {@link #addEdits(IDocument, TextEdit)} to provide >+ * the text edits or {@link #createTextChange()} to provide a text change. >+ * @param relevance the relevance of this proposal. >+ * @param image the image that is displayed for this proposal or <code>null</code> if no >+ * image is desired. >+ */ >+ public CULinkedCorrectionProposal(String name, ICompilationUnit cu, TextChange change, int relevance, Image image) { >+ super(name, cu, change, relevance, image); >+ fLinkedProposalModel= null; >+ } >+ >+ /** >+ * Constructs a correction proposal working on a compilation unit. >+ * <p>Users have to override {@link #addEdits(IDocument, TextEdit)} to provide >+ * the text edits or {@link #createTextChange()} to provide a text change. >+ * </p> >+ * >+ * @param name The name that is displayed in the proposal selection dialog. >+ * @param cu The compilation unit on that the change works. >+ * @param relevance The relevance of this proposal. >+ * @param image The image that is displayed for this proposal or <code>null</code> if no >+ * image is desired. >+ */ >+ protected CULinkedCorrectionProposal(String name, ICompilationUnit cu, int relevance, Image image) { >+ this(name, cu, null, relevance, image); >+ } >+ >+ protected LinkedProposalModel getLinkedProposalModel() { >+ if (fLinkedProposalModel == null) { >+ fLinkedProposalModel= new LinkedProposalModel(); >+ } >+ return fLinkedProposalModel; >+ } >+ >+ public void setLinkedProposalModel(LinkedProposalModel model) { >+ fLinkedProposalModel= model; >+ } >+ >+ /* >+ * (non-Javadoc) >+ * @see org.eclipse.jdt.internal.ui.text.correction.proposals.CUCorrectionProposal#performChange(org.eclipse.ui.IEditorPart, org.eclipse.jface.text.IDocument) >+ */ >+ @Override >+ protected void performChange(IEditorPart part, IDocument document) throws CoreException { >+ try { >+ super.performChange(part, document); >+ if (part == null) { >+ return; >+ } >+ >+ if (fLinkedProposalModel != null) { >+ if (fLinkedProposalModel.hasLinkedPositions() && part instanceof JavaEditor) { >+ // enter linked mode >+ ITextViewer viewer= ((JavaEditor) part).getViewer(); >+ new LinkedProposalModelPresenter().enterLinkedMode(viewer, part, isSwitchedEditor(), fLinkedProposalModel); >+ } else if (part instanceof ITextEditor) { >+ LinkedProposalPositionGroup.PositionInformation endPosition= fLinkedProposalModel.getEndPosition(); >+ if (endPosition != null) { >+ // select a result >+ int pos= endPosition.getOffset() + endPosition.getLength(); >+ ((ITextEditor) part).selectAndReveal(pos, 0); >+ } >+ } >+ } >+ } catch (BadLocationException e) { >+ throw new CoreException(JavaUIStatus.createError(IStatus.ERROR, e)); >+ } >+ } >+ >+} >Index: ui/org/eclipse/jdt/internal/ui/text/correction/proposals/FixCorrectionProposal.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/proposals/FixCorrectionProposal.java,v >retrieving revision 1.16 >diff -u -r1.16 FixCorrectionProposal.java >--- ui/org/eclipse/jdt/internal/ui/text/correction/proposals/FixCorrectionProposal.java 27 Apr 2011 07:43:18 -0000 1.16 >+++ ui/org/eclipse/jdt/internal/ui/text/correction/proposals/FixCorrectionProposal.java 13 Aug 2011 07:25:39 -0000 >@@ -42,9 +42,9 @@ > import org.eclipse.jdt.core.refactoring.CompilationUnitChange; > > import org.eclipse.jdt.internal.corext.fix.CleanUpRefactoring; >+import org.eclipse.jdt.internal.corext.fix.CleanUpRefactoring.MultiFixTarget; > import org.eclipse.jdt.internal.corext.fix.ILinkedFix; > import org.eclipse.jdt.internal.corext.fix.IProposableFix; >-import org.eclipse.jdt.internal.corext.fix.CleanUpRefactoring.MultiFixTarget; > import org.eclipse.jdt.internal.corext.util.Messages; > > import org.eclipse.jdt.ui.JavaElementImageDescriptor; >@@ -66,7 +66,7 @@ > * fix a problem. A fix correction proposal may have an {@link ICleanUp} > * attached which can be executed instead of the provided IFix. > */ >-public class FixCorrectionProposal extends CUCorrectionProposal implements ICompletionProposalExtension2, IStatusLineProposal { >+public class FixCorrectionProposal extends CULinkedCorrectionProposal implements ICompletionProposalExtension2, IStatusLineProposal { > > private final IProposableFix fFix; > private final ICleanUp fCleanUp; >Index: ui/org/eclipse/jdt/internal/ui/text/correction/proposals/LinkedCorrectionProposal.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/proposals/LinkedCorrectionProposal.java,v >retrieving revision 1.1 >diff -u -r1.1 LinkedCorrectionProposal.java >--- ui/org/eclipse/jdt/internal/ui/text/correction/proposals/LinkedCorrectionProposal.java 4 Sep 2007 08:40:22 -0000 1.1 >+++ ui/org/eclipse/jdt/internal/ui/text/correction/proposals/LinkedCorrectionProposal.java 13 Aug 2011 07:25:39 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2007 IBM Corporation and others. >+ * Copyright (c) 2000, 2011 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -12,11 +12,29 @@ > > import org.eclipse.swt.graphics.Image; > >+import org.eclipse.core.runtime.CoreException; >+import org.eclipse.core.runtime.IStatus; >+ >+import org.eclipse.jface.text.BadLocationException; >+import org.eclipse.jface.text.IDocument; >+import org.eclipse.jface.text.ITextViewer; >+ >+import org.eclipse.ui.IEditorPart; >+ >+import org.eclipse.ui.texteditor.ITextEditor; >+ > import org.eclipse.jdt.core.ICompilationUnit; > import org.eclipse.jdt.core.dom.ITypeBinding; > import org.eclipse.jdt.core.dom.rewrite.ASTRewrite; > import org.eclipse.jdt.core.dom.rewrite.ITrackedNodePosition; > >+import org.eclipse.jdt.internal.corext.fix.LinkedProposalModel; >+import org.eclipse.jdt.internal.corext.fix.LinkedProposalPositionGroup; >+ >+import org.eclipse.jdt.internal.ui.JavaUIStatus; >+import org.eclipse.jdt.internal.ui.javaeditor.JavaEditor; >+import org.eclipse.jdt.internal.ui.viewsupport.LinkedProposalModelPresenter; >+ > > /** > * A proposal for quick fixes and quick assists that works on a AST rewriter and enters the >@@ -28,6 +46,8 @@ > */ > public class LinkedCorrectionProposal extends ASTRewriteCorrectionProposal { > >+ private LinkedProposalModel fLinkedProposalModel; >+ > /** > * Constructs a linked correction proposal. > * @param name The display name of the proposal. >@@ -40,6 +60,18 @@ > */ > public LinkedCorrectionProposal(String name, ICompilationUnit cu, ASTRewrite rewrite, int relevance, Image image) { > super(name, cu, rewrite, relevance, image); >+ fLinkedProposalModel= null; >+ } >+ >+ protected LinkedProposalModel getLinkedProposalModel() { >+ if (fLinkedProposalModel == null) { >+ fLinkedProposalModel= new LinkedProposalModel(); >+ } >+ return fLinkedProposalModel; >+ } >+ >+ public void setLinkedProposalModel(LinkedProposalModel model) { >+ fLinkedProposalModel= model; > } > > /** >@@ -94,4 +126,34 @@ > public void addLinkedPositionProposal(String groupID, ITypeBinding type) { > getLinkedProposalModel().getPositionGroup(groupID, true).addProposal(type, getCompilationUnit(), 10); > } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jdt.internal.ui.text.correction.ChangeCorrectionProposal#performChange(org.eclipse.jface.text.IDocument, org.eclipse.ui.IEditorPart) >+ */ >+ @Override >+ protected void performChange(IEditorPart part, IDocument document) throws CoreException { >+ try { >+ super.performChange(part, document); >+ if (part == null) { >+ return; >+ } >+ >+ if (fLinkedProposalModel != null) { >+ if (fLinkedProposalModel.hasLinkedPositions() && part instanceof JavaEditor) { >+ // enter linked mode >+ ITextViewer viewer= ((JavaEditor) part).getViewer(); >+ new LinkedProposalModelPresenter().enterLinkedMode(viewer, part, isSwitchedEditor(), fLinkedProposalModel); >+ } else if (part instanceof ITextEditor) { >+ LinkedProposalPositionGroup.PositionInformation endPosition= fLinkedProposalModel.getEndPosition(); >+ if (endPosition != null) { >+ // select a result >+ int pos= endPosition.getOffset() + endPosition.getLength(); >+ ((ITextEditor) part).selectAndReveal(pos, 0); >+ } >+ } >+ } >+ } catch (BadLocationException e) { >+ throw new CoreException(JavaUIStatus.createError(IStatus.ERROR, e)); >+ } >+ } > } >Index: ui/org/eclipse/jdt/internal/ui/text/correction/proposals/RefactoringCorrectionProposal.java >=================================================================== >RCS file: ui/org/eclipse/jdt/internal/ui/text/correction/proposals/RefactoringCorrectionProposal.java >diff -N ui/org/eclipse/jdt/internal/ui/text/correction/proposals/RefactoringCorrectionProposal.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ ui/org/eclipse/jdt/internal/ui/text/correction/proposals/RefactoringCorrectionProposal.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,63 @@ >+package org.eclipse.jdt.internal.ui.text.correction.proposals; >+ >+import org.eclipse.swt.graphics.Image; >+ >+import org.eclipse.core.runtime.CoreException; >+import org.eclipse.core.runtime.IProgressMonitor; >+import org.eclipse.core.runtime.NullProgressMonitor; >+ >+import org.eclipse.core.resources.IFile; >+ >+import org.eclipse.text.edits.InsertEdit; >+ >+import org.eclipse.ltk.core.refactoring.Refactoring; >+import org.eclipse.ltk.core.refactoring.RefactoringStatus; >+import org.eclipse.ltk.core.refactoring.TextChange; >+import org.eclipse.ltk.core.refactoring.TextFileChange; >+ >+import org.eclipse.jdt.core.ICompilationUnit; >+ >+ >+public class RefactoringCorrectionProposal extends CULinkedCorrectionProposal { >+ private final Refactoring fRefactoring; >+ private RefactoringStatus fRefactoringStatus; >+ >+ public RefactoringCorrectionProposal(String name, ICompilationUnit cu, Refactoring refactoring, int relevance, Image image) { >+ super(name, cu, null, relevance, image); >+ fRefactoring= refactoring; >+ } >+ >+ /** >+ * Can be overridden by clients to perform expensive initializations of the refactoring >+ * >+ * @param refactoring the refactoring >+ * @throws CoreException if something goes wrong during init >+ */ >+ protected void init(Refactoring refactoring) throws CoreException { >+ // empty default implementation >+ } >+ >+ @Override >+ protected TextChange createTextChange() throws CoreException { >+ init(fRefactoring); >+ fRefactoringStatus= fRefactoring.checkFinalConditions(new NullProgressMonitor()); >+ if (fRefactoringStatus.hasFatalError()) { >+ TextFileChange dummyChange= new TextFileChange("fatal error", (IFile) getCompilationUnit().getResource()); //$NON-NLS-1$ >+ dummyChange.setEdit(new InsertEdit(0, "")); //$NON-NLS-1$ >+ return dummyChange; >+ } >+ return (TextChange) fRefactoring.createChange(new NullProgressMonitor()); >+ } >+ >+ /* >+ * @see org.eclipse.jdt.internal.ui.text.correction.proposals.CUCorrectionProposal#getAdditionalProposalInfo(org.eclipse.core.runtime.IProgressMonitor) >+ * @since 3.6 >+ */ >+ @Override >+ public Object getAdditionalProposalInfo(IProgressMonitor monitor) { >+ if (fRefactoringStatus != null && fRefactoringStatus.hasFatalError()) { >+ return fRefactoringStatus.getEntryWithHighestSeverity().getMessage(); >+ } >+ return super.getAdditionalProposalInfo(monitor); >+ } >+} >\ No newline at end of file
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 287136
:
201456