Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarkus Schorn2009-05-15 08:05:24 +0000
committerMarkus Schorn2009-05-15 08:05:24 +0000
commit61f652966775ca83c5b322399f0cf54ac4dbe2d7 (patch)
tree5971ea8b1f3ec15b97f2a2cbc9343af20a7db1c9
parent47e2c99bdbf6974d1707329a3c8ec66b039719a3 (diff)
downloadorg.eclipse.cdt-61f652966775ca83c5b322399f0cf54ac4dbe2d7.tar.gz
org.eclipse.cdt-61f652966775ca83c5b322399f0cf54ac4dbe2d7.tar.xz
org.eclipse.cdt-61f652966775ca83c5b322399f0cf54ac4dbe2d7.zip
Renaming a virtual method, bug 63290.
-rw-r--r--core/org.eclipse.cdt.ui.tests/src/org/eclipse/cdt/ui/tests/DOMAST/DOMAST.java54
-rw-r--r--core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/BaseUITestCase.java7
-rw-r--r--core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/rename/RenameFunctionTests.java12
-rw-r--r--core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/rename/RenameRegressionTests.java31
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRefactory.java3
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameMethodProcessor.java44
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameProcessor.java14
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameProcessorDelegate.java9
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameRefactoringInputPage.java41
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/messages.properties3
10 files changed, 152 insertions, 66 deletions
diff --git a/core/org.eclipse.cdt.ui.tests/src/org/eclipse/cdt/ui/tests/DOMAST/DOMAST.java b/core/org.eclipse.cdt.ui.tests/src/org/eclipse/cdt/ui/tests/DOMAST/DOMAST.java
index 41d7615e354..4d8d13802cf 100644
--- a/core/org.eclipse.cdt.ui.tests/src/org/eclipse/cdt/ui/tests/DOMAST/DOMAST.java
+++ b/core/org.eclipse.cdt.ui.tests/src/org/eclipse/cdt/ui/tests/DOMAST/DOMAST.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2008 IBM Corporation and others.
+ * Copyright (c) 2005, 2009 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
@@ -256,6 +256,7 @@ public class DOMAST extends ViewPart {
/* (non-Javadoc)
* @see org.eclipse.core.runtime.jobs.Job#run(org.eclipse.core.runtime.IProgressMonitor)
*/
+ @Override
protected IStatus run(IProgressMonitor monitor) {
job.schedule();
@@ -342,7 +343,8 @@ public class DOMAST extends ViewPart {
/* (non-Javadoc)
* @see org.eclipse.jface.operation.IRunnableWithProgress#run(org.eclipse.core.runtime.IProgressMonitor)
*/
- protected IStatus run(IProgressMonitor monitor) {
+ @Override
+ protected IStatus run(IProgressMonitor monitor) {
long start=0;
long overallStart=System.currentTimeMillis();
@@ -463,6 +465,8 @@ public class DOMAST extends ViewPart {
*/
public void run() {
if (view == null) return;
+ if (view.getTree().isDisposed())
+ return;
view.refresh();
if (view.getTree().getItems().length > 0) {
@@ -552,12 +556,14 @@ public class DOMAST extends ViewPart {
private static final String BLANK_STRING = ""; //$NON-NLS-1$
- public String getText(Object obj) {
+ @Override
+ public String getText(Object obj) {
if (obj == null) return BLANK_STRING;
return obj.toString();
}
- public Image getImage(Object obj) {
+ @Override
+ public Image getImage(Object obj) {
String imageKey = DOMASTPluginImages.IMG_DEFAULT;
IASTNode node = null;
@@ -630,7 +636,8 @@ public class DOMAST extends ViewPart {
* This is a callback that will allow us to create the viewer and initialize
* it.
*/
- public void createPartControl(Composite parent) {
+ @Override
+public void createPartControl(Composite parent) {
if (part == null) {
part = getActiveEditor();
@@ -804,7 +811,8 @@ public class DOMAST extends ViewPart {
private void makeActions() {
loadActiveEditorAction = new Action() {
- public void run() {
+ @Override
+ public void run() {
// first make sure there is an open editor
IEditorPart editor = getActiveEditor();
if (editor != null) {
@@ -817,7 +825,8 @@ public class DOMAST extends ViewPart {
loadActiveEditorAction.setImageDescriptor(DOMASTPluginImages.DESC_RELOAD_VIEW);
refreshAction = new Action() {
- public void run() {
+ @Override
+ public void run() {
// take a snapshot of the tree expansion
Object[] expanded = viewer.getExpandedElements();
@@ -830,7 +839,8 @@ public class DOMAST extends ViewPart {
refreshAction.setImageDescriptor(DOMASTPluginImages.DESC_REFRESH_VIEW);
expandAllAction = new Action() {
- public void run() {
+ @Override
+ public void run() {
viewer.expandAll();
}
};
@@ -839,7 +849,8 @@ public class DOMAST extends ViewPart {
expandAllAction.setImageDescriptor(DOMASTPluginImages.DESC_EXPAND_ALL);
collapseAllAction = new Action() {
- public void run() {
+ @Override
+ public void run() {
viewer.collapseAll();
}
};
@@ -848,7 +859,8 @@ public class DOMAST extends ViewPart {
collapseAllAction.setImageDescriptor(DOMASTPluginImages.DESC_COLLAPSE_ALL);
clearAction = new Action() {
- public void run() {
+ @Override
+ public void run() {
viewer.setContentProvider(new ViewContentProvider(null));
viewer.refresh();
}
@@ -867,7 +879,8 @@ public class DOMAST extends ViewPart {
dialog.open();
}
- public void run() {
+ @Override
+ public void run() {
performSearch();
}
};
@@ -876,7 +889,8 @@ public class DOMAST extends ViewPart {
searchNamesAction.setImageDescriptor(DOMASTPluginImages.DESC_SEARCH_NAMES);
displayNodeTypeAction = new Action() {
- public void run() {
+ @Override
+ public void run() {
ISelection selection = viewer.getSelection();
if (selection instanceof IStructuredSelection &&
((IStructuredSelection)selection).getFirstElement() instanceof DOMASTNodeLeaf &&
@@ -889,7 +903,8 @@ public class DOMAST extends ViewPart {
.getImageDescriptor(ISharedImages.IMG_OBJS_INFO_TSK));
displayNodeSignatureAction = new Action() {
- public void run() {
+ @Override
+ public void run() {
ISelection selection = viewer.getSelection();
if (selection instanceof IStructuredSelection &&
((IStructuredSelection)selection).getFirstElement() instanceof DOMASTNodeLeaf &&
@@ -902,7 +917,8 @@ public class DOMAST extends ViewPart {
.getImageDescriptor(ISharedImages.IMG_OBJS_INFO_TSK));
displayExpressionAction = new Action() {
- public void run() {
+ @Override
+ public void run() {
ISelection selection = viewer.getSelection();
if (selection instanceof IStructuredSelection &&
((IStructuredSelection)selection).getFirstElement() instanceof DOMASTNodeLeaf &&
@@ -915,7 +931,8 @@ public class DOMAST extends ViewPart {
.getImageDescriptor(ISharedImages.IMG_OBJS_INFO_TSK));
displayInitializerAction = new Action() {
- public void run() {
+ @Override
+ public void run() {
ISelection selection = viewer.getSelection();
if (selection instanceof IStructuredSelection &&
((IStructuredSelection)selection).getFirstElement() instanceof DOMASTNodeLeaf &&
@@ -970,7 +987,8 @@ public class DOMAST extends ViewPart {
return true;
}
- public void run() {
+ @Override
+ public void run() {
ISelection selection = viewer.getSelection();
Object obj = ((IStructuredSelection) selection).getFirstElement();
if (obj instanceof DOMASTNodeLeaf) {
@@ -1034,7 +1052,8 @@ public class DOMAST extends ViewPart {
/**
* Passing the focus request to the viewer's control.
*/
- public void setFocus() {
+ @Override
+public void setFocus() {
if (viewer==null) return;
viewer.getControl().setFocus();
@@ -1072,6 +1091,7 @@ public class DOMAST extends ViewPart {
/* (non-Javadoc)
* @see org.eclipse.core.runtime.jobs.Job#run(org.eclipse.core.runtime.IProgressMonitor)
*/
+ @Override
protected IStatus run(IProgressMonitor monitor) {
try {
initializeASTViewJob.join();
diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/BaseUITestCase.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/BaseUITestCase.java
index 79b81346454..8cc5662b8ed 100644
--- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/BaseUITestCase.java
+++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/BaseUITestCase.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006, 2008 Wind River Systems, Inc. and others.
+ * Copyright (c) 2006, 2009 Wind River Systems, Inc. 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
@@ -72,6 +72,11 @@ public class BaseUITestCase extends BaseTestCase {
@Override
protected void setUp() throws Exception {
super.setUp();
+ final IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
+ IViewPart view= activePage.findView("org.eclipse.cdt.ui.tests.DOMAST.DOMAST");
+ if (view != null) {
+ activePage.hideView(view);
+ }
}
/* (non-Javadoc)
diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/rename/RenameFunctionTests.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/rename/RenameFunctionTests.java
index 565d363e755..c838322726c 100644
--- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/rename/RenameFunctionTests.java
+++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/rename/RenameFunctionTests.java
@@ -1,14 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2005, 2007 Wind River Systems, Inc.
+ * Copyright (c) 2005, 2009 Wind River Systems, Inc.
* 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:
- * Markus Schorn - initial API and implementation
+ * Markus Schorn - initial API and implementation
*******************************************************************************/
-
package org.eclipse.cdt.ui.tests.refactoring.rename;
import java.io.StringWriter;
@@ -20,9 +19,6 @@ import org.eclipse.core.resources.IFile;
import org.eclipse.ltk.core.refactoring.Change;
import org.eclipse.ltk.core.refactoring.RefactoringStatus;
-/**
- * @author markus.schorn@windriver.com
- */
public class RenameFunctionTests extends RenameTests {
public RenameFunctionTests(String name) {
@@ -813,7 +809,7 @@ public class RenameFunctionTests extends RenameTests {
IFile cpp= importFile("test.cpp", contents ); //$NON-NLS-1$
int offset = contents.indexOf("mthd") ; //$NON-NLS-1$
offset= contents.indexOf("mthd", offset+1) ; //$NON-NLS-1$
- RefactoringStatus status= checkConditions(cpp, offset, "xxx"); //$NON-NLS-1$
- assertRefactoringWarning(status, "Renaming a virtual method. Consider renaming the base and derived class methods (if any)."); //$NON-NLS-1$
+ Change changes = getRefactorChanges(cpp, offset, "z"); //$NON-NLS-1$
+ assertTotalChanges( 2, changes );
}
}
diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/rename/RenameRegressionTests.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/rename/RenameRegressionTests.java
index 8ba92733d5e..4e5bc0f7a80 100644
--- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/rename/RenameRegressionTests.java
+++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/rename/RenameRegressionTests.java
@@ -1,12 +1,12 @@
/*******************************************************************************
- * Copyright (c) 2004, 2008 IBM Corporation and others.
+ * Copyright (c) 2004, 2009 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
+ * Andrew Niefer (IBM Corporation) - initial API and implementation
* Wind River Systems Inc. - ported for new rename implementation
*******************************************************************************/
package org.eclipse.cdt.ui.tests.refactoring.rename;
@@ -25,9 +25,6 @@ import org.eclipse.ltk.core.refactoring.participants.RenameArguments;
import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.tests.FailingTest;
-/**
- * @author aniefer
- */
public class RenameRegressionTests extends RenameTests {
public RenameRegressionTests() {
@@ -607,10 +604,11 @@ public class RenameRegressionTests extends RenameTests {
IFile file = importFile( "t.cpp", contents ); //$NON-NLS-1$
//vp1 implicit virtual method
int offset = contents.indexOf( "v/*vp1*/" ) ; //$NON-NLS-1$
- String[] messages= getRefactorMessages( file, offset, "v2" ); //$NON-NLS-1$
- assertEquals(1, messages.length);
- assertEquals("Renaming a virtual method. Consider renaming the base and derived class methods (if any).", messages[0] ); //$NON-NLS-1$
-
+ Change changes = getRefactorChanges(file, offset, "v1" ); //$NON-NLS-1$
+ assertTotalChanges( 3, changes );
+ assertChange( changes, file, contents.indexOf("v()"), 1, "v1" ); //$NON-NLS-1$//$NON-NLS-2$
+ assertChange( changes, file, contents.indexOf("v/*vp1*/"), 1, "v1" ); //$NON-NLS-1$//$NON-NLS-2$
+ assertChange( changes, file, contents.indexOf("v(){"), 1, "v1" ); //$NON-NLS-1$//$NON-NLS-2$
}
public void testMethod_45() throws Exception {
StringWriter writer = new StringWriter();
@@ -627,15 +625,18 @@ public class RenameRegressionTests extends RenameTests {
writer.write( "}; \n" ); //$NON-NLS-1$
String contents = writer.toString();
IFile file = importFile( "t.cpp", contents ); //$NON-NLS-1$
+ waitForIndexer();
//vp1 implicit virtual method
int offset = contents.indexOf( "v/*vp1*/" ) ; //$NON-NLS-1$
- String[] messages= getRefactorMessages( file, offset, "v2" ); //$NON-NLS-1$
- assertEquals(1, messages.length);
- assertEquals("Renaming a virtual method. Consider renaming the base and derived class methods (if any).", messages[0] ); //$NON-NLS-1$
-
-
+ Change changes = getRefactorChanges(file, offset, "v1" ); //$NON-NLS-1$
+ assertTotalChanges( 4, changes );
+ assertChange( changes, file, contents.indexOf("v()"), 1, "v1" ); //$NON-NLS-1$//$NON-NLS-2$
+ assertChange( changes, file, contents.indexOf("v(){}"), 1, "v1" ); //$NON-NLS-1$//$NON-NLS-2$
+ assertChange( changes, file, contents.indexOf("v/*vp1*/"), 1, "v1" ); //$NON-NLS-1$//$NON-NLS-2$
+ assertChange( changes, file, contents.indexOf("v(){i"), 1, "v1" ); //$NON-NLS-1$//$NON-NLS-2$
}
- public void testStruct_46() throws Exception {
+
+ public void testStruct_46() throws Exception {
StringWriter writer = new StringWriter();
writer.write( "struct st1/*vp1*/{}; \n" ); //$NON-NLS-1$
writer.write( "class c1/*vp1*/{ \n" ); //$NON-NLS-1$
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRefactory.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRefactory.java
index 42c341c432f..d76afaa39ad 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRefactory.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRefactory.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2008 Wind River Systems, Inc. and others.
+ * Copyright (c) 2004, 2009 Wind River Systems, Inc. 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
@@ -43,6 +43,7 @@ public class CRefactory {
public static final int OPTION_IN_PREPROCESSOR_DIRECTIVE = 0x20;
public static final int OPTION_IN_INACTIVE_CODE = 0x40;
public static final int OPTION_IN_CODE = 0x80;
+ public static final int OPTION_DO_VIRTUAL = 0x100;
public static final int ARGUMENT_UNKNOWN = 0;
public static final int ARGUMENT_LOCAL_VAR = 1;
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameMethodProcessor.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameMethodProcessor.java
index 332a0a8a45f..7786851c6d0 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameMethodProcessor.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameMethodProcessor.java
@@ -1,15 +1,18 @@
/*******************************************************************************
- * Copyright (c) 2005, 2008 Wind River Systems, Inc. and others.
+ * Copyright (c) 2005, 2009 Wind River Systems, Inc. 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:
- * Markus Schorn - initial API and implementation
+ * Markus Schorn - initial API and implementation
******************************************************************************/
package org.eclipse.cdt.internal.ui.refactoring.rename;
+import java.util.ArrayList;
+import java.util.Arrays;
+
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.OperationCanceledException;
@@ -23,17 +26,20 @@ import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.IScope;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructor;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
import org.eclipse.cdt.internal.core.dom.parser.ASTInternal;
+import org.eclipse.cdt.internal.core.dom.parser.cpp.ClassTypeHelper;
/**
* Rename processor for methods.
*/
public class CRenameMethodProcessor extends CRenameGlobalProcessor {
-
- public CRenameMethodProcessor(CRenameProcessor processor, String kind) {
+ public CRenameMethodProcessor(CRenameProcessor processor, String kind, boolean isVirtual) {
super(processor, kind);
+ if (isVirtual)
+ setAvailableOptions(getAvailableOptions() | CRefactory.OPTION_DO_VIRTUAL);
}
@Override
@@ -83,11 +89,39 @@ public class CRenameMethodProcessor extends CRenameGlobalProcessor {
}
}
}
- if (argument.getArgumentKind() == CRefactory.ARGUMENT_VIRTUAL_METHOD) {
+ if (argument.getArgumentKind() == CRefactory.ARGUMENT_VIRTUAL_METHOD && (getSelectedOptions() & CRefactory.OPTION_DO_VIRTUAL) == 0) {
result.merge(RefactoringStatus.createWarningStatus(Messages.getString("CRenameMethodProcessor.warning.renameVirtual"))); //$NON-NLS-1$
}
result.merge(super.checkFinalConditions(monitor, context));
return result;
}
+
+ @Override
+ protected IBinding[] getBindingsToBeRenamed(RefactoringStatus status) {
+ if ((getSelectedOptions() & CRefactory.OPTION_DO_VIRTUAL) == 0) {
+ return super.getBindingsToBeRenamed(status);
+ }
+
+ CRefactoringArgument argument= getArgument();
+ IBinding binding= argument.getBinding();
+ ArrayList<IBinding> bindings= new ArrayList<IBinding>();
+ if (binding != null) {
+ bindings.add(binding);
+ }
+ if (binding instanceof ICPPMethod) {
+ ICPPMethod m= (ICPPMethod) binding;
+ try {
+ IBinding[] bs= ClassTypeHelper.findOverridden(m);
+ bindings.addAll(Arrays.asList(bs));
+ bs= ClassTypeHelper.findOverriders(getIndex(), m);
+ bindings.addAll(Arrays.asList(bs));
+ } catch (DOMException e) {
+ getAstManager().handleDOMException(argument.getTranslationUnit(), e, status);
+ } catch (CoreException e) {
+ status.addError(e.getMessage());
+ }
+ }
+ return bindings.toArray(new IBinding[bindings.size()]);
+ }
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameProcessor.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameProcessor.java
index 279dc2b6831..635dfafdbf8 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameProcessor.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameProcessor.java
@@ -1,16 +1,15 @@
/*******************************************************************************
- * Copyright (c) 2004, 2008 Wind River Systems, Inc. and others.
+ * Copyright (c) 2004, 2009 Wind River Systems, Inc. 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:
- * Markus Schorn - initial API and implementation
+ * Markus Schorn - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.internal.ui.refactoring.rename;
-import com.ibm.icu.text.MessageFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
@@ -31,8 +30,11 @@ import org.eclipse.ltk.core.refactoring.participants.RenameParticipant;
import org.eclipse.ltk.core.refactoring.participants.RenameProcessor;
import org.eclipse.ltk.core.refactoring.participants.SharableParticipants;
+import com.ibm.icu.text.MessageFormat;
+
import org.eclipse.cdt.core.CCProjectNature;
import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.core.CProjectNature;
import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.index.IIndex;
import org.eclipse.cdt.core.model.CoreModel;
@@ -159,9 +161,9 @@ public class CRenameProcessor extends RenameProcessor {
case CRefactory.ARGUMENT_GLOBAL_FUNCTION:
return new CRenameGlobalProcessor(this, Messages.getString("CRenameTopProcessor.globalFunction")); //$NON-NLS-1$
case CRefactory.ARGUMENT_VIRTUAL_METHOD:
- return new CRenameMethodProcessor(this, Messages.getString("CRenameTopProcessor.virtualMethod")); //$NON-NLS-1$
+ return new CRenameMethodProcessor(this, Messages.getString("CRenameTopProcessor.virtualMethod"), true); //$NON-NLS-1$
case CRefactory.ARGUMENT_NON_VIRTUAL_METHOD:
- return new CRenameMethodProcessor(this, Messages.getString("CRenameTopProcessor.method")); //$NON-NLS-1$
+ return new CRenameMethodProcessor(this, Messages.getString("CRenameTopProcessor.method"), false); //$NON-NLS-1$
case CRefactory.ARGUMENT_CLASS_TYPE:
return new CRenameClassProcessor(this, Messages.getString("CRenameTopProcessor.type")); //$NON-NLS-1$
case CRefactory.ARGUMENT_NAMESPACE:
@@ -198,7 +200,7 @@ public class CRenameProcessor extends RenameProcessor {
SharableParticipants sharedParticipants) throws CoreException {
RenameArguments arguments= new RenameArguments(getReplacementText(),
true);
- final String[] natures= {CCProjectNature.CC_NATURE_ID, CCProjectNature.C_NATURE_ID};
+ final String[] natures= {CCProjectNature.CC_NATURE_ID, CProjectNature.C_NATURE_ID};
List<RenameParticipant> result= new ArrayList<RenameParticipant>();
IBinding binding= getArgument().getBinding();
if (binding != null) {
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameProcessorDelegate.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameProcessorDelegate.java
index bcc9990fa8f..95d9158f8ef 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameProcessorDelegate.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameProcessorDelegate.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2008 Wind River Systems, Inc. and others.
+ * Copyright (c) 2004, 2009 Wind River Systems, Inc. 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
@@ -11,7 +11,6 @@
******************************************************************************/
package org.eclipse.cdt.internal.ui.refactoring.rename;
-import com.ibm.icu.text.MessageFormat;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
@@ -35,7 +34,10 @@ import org.eclipse.text.edits.MultiTextEdit;
import org.eclipse.text.edits.ReplaceEdit;
import org.eclipse.text.edits.TextEditGroup;
+import com.ibm.icu.text.MessageFormat;
+
import org.eclipse.cdt.core.dom.ast.IBinding;
+import org.eclipse.cdt.core.index.IIndex;
import org.eclipse.cdt.ui.refactoring.CTextFileChange;
@@ -90,6 +92,9 @@ public abstract class CRenameProcessorDelegate {
final public ASTManager getAstManager() {
return fTopProcessor.getAstManager();
}
+ final public IIndex getIndex() {
+ return fTopProcessor.getIndex();
+ }
final public String getProcessorName() {
String identifier= getArgument().getName();
if (identifier != null) {
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameRefactoringInputPage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameRefactoringInputPage.java
index fb968fe67af..f024f5f2010 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameRefactoringInputPage.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameRefactoringInputPage.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2004, 2008 Wind River Systems, Inc. and others.
+ * Copyright (c) 2004, 2009 Wind River Systems, Inc. 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:
- * Markus Schorn - initial API and implementation
- * Emanuel Graf (Institute for Software, HSR Hochschule fuer Technik)
+ * Markus Schorn - initial API and implementation
+ * Emanuel Graf (Institute for Software, HSR Hochschule fuer Technik)
******************************************************************************/
package org.eclipse.cdt.internal.ui.refactoring.rename;
@@ -44,6 +44,7 @@ public class CRenameRefactoringInputPage extends UserInputWizardPage {
public static final String PAGE_NAME = "RenameRefactoringPage"; //$NON-NLS-1$
+ private static final String KEY_IGNORE_VIRTUAL = "ignoreVirtual"; //$NON-NLS-1$
private static final String KEY_REFERENCES_INV = "references_inv"; //$NON-NLS-1$
private static final String KEY_COMMENT = "comment"; //$NON-NLS-1$
private static final String KEY_STRING = "string"; //$NON-NLS-1$
@@ -62,6 +63,7 @@ public class CRenameRefactoringInputPage extends UserInputWizardPage {
private int fEnableScopeOptions;
private Text fNewName;
+ private Button fDoVirtual;
private Button fWorkspace;
private Button fDependent;
private Button fInComment;
@@ -106,7 +108,7 @@ public class CRenameRefactoringInputPage extends UserInputWizardPage {
// new name
Composite group= top;
- GridData gd;
+ GridData gd; GridLayout gl;
Label l= new Label(group, SWT.NONE);
l.setText(Messages.getString("CRenameRefactoringInputPage.newIdentifier.label")); //$NON-NLS-1$
@@ -114,33 +116,42 @@ public class CRenameRefactoringInputPage extends UserInputWizardPage {
fNewName.setText(fSearchString);
fNewName.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
fNewName.selectAll();
+
+ if (hasOption(CRefactory.OPTION_DO_VIRTUAL)) {
+ fDoVirtual= new Button(group, SWT.CHECK);
+ fDoVirtual.setText(Messages.getString("CRenameRefactoringInputPage.renameBaseAndDerivedMethods")); //$NON-NLS-1$
+ fDoVirtual.setLayoutData(gd= new GridData());
+ gd.horizontalSpan= 2;
+ }
- boolean skippedLine= false;
// specify the scope
if (hasOption(CRefactory.OPTION_ASK_SCOPE)) {
skipLine(top);
new Label(top, SWT.NONE).setText(Messages.getString("CRenameRefactoringInputPage.label.scope")); //$NON-NLS-1$
- skippedLine= true;
group= new Composite(top, SWT.NONE);
group.setLayoutData(gd= new GridData(GridData.FILL_HORIZONTAL));
gd.horizontalSpan= 2;
- group.setLayout(new GridLayout(3, false));
+ group.setLayout(gl= new GridLayout(3, false));
+ gl.marginHeight= 0;
fWorkspace= new Button(group, SWT.RADIO);
fWorkspace.setText(Messages.getString("CRenameRefactoringInputPage.button.scope.workspace")); //$NON-NLS-1$
fWorkspace.setLayoutData(gd= new GridData());
- gd.horizontalSpan= 3;
fDependent= new Button(group, SWT.RADIO);
fDependent.setText(Messages.getString("CRenameRefactoringInputPage.button.scope.releatedprojects")); //$NON-NLS-1$
fDependent.setLayoutData(gd= new GridData());
- gd.horizontalSpan= 3;
fSingle= new Button(group, SWT.RADIO);
fSingle.setText(Messages.getString("CRenameRefactoringInputPage.button.singleProject")); //$NON-NLS-1$
fSingle.setLayoutData(gd= new GridData());
- gd.horizontalSpan= 3;
+
+ group= new Composite(top, SWT.NONE);
+ group.setLayoutData(gd= new GridData(GridData.FILL_HORIZONTAL));
+ gd.horizontalSpan= 2;
+ group.setLayout(gl= new GridLayout(3, false));
+ gl.marginHeight= 0;
fWorkingSet= new Button(group, SWT.RADIO);
fWorkingSet.setText(Messages.getString("CRenameRefactoringInputPage.button.workingSet")); //$NON-NLS-1$
@@ -152,6 +163,7 @@ public class CRenameRefactoringInputPage extends UserInputWizardPage {
setButtonLayoutData(fWorkingSetButton);
}
+ boolean skippedLine= false;
group= null;
if (hasOption(CRefactory.OPTION_IN_CODE)) {
group= createLabelAndGroup(group, skippedLine, top);
@@ -245,6 +257,7 @@ public class CRenameRefactoringInputPage extends UserInputWizardPage {
onSelectOption();
}
};
+ registerOptionListener(fDoVirtual, listenOption);
registerOptionListener(fReferences, listenOption);
registerOptionListener(fInComment, listenOption);
registerOptionListener(fInInactiveCode, listenOption);
@@ -331,6 +344,10 @@ public class CRenameRefactoringInputPage extends UserInputWizardPage {
processor.setWorkingSet(workingSet);
}
+ if (fDoVirtual != null) {
+ boolean val= !fDialogSettings.getBoolean(KEY_IGNORE_VIRTUAL);
+ fDoVirtual.setSelection(val);
+ }
if (fReferences != null) {
boolean val= !fDialogSettings.getBoolean(KEY_REFERENCES_INV);
fReferences.setSelection(val);
@@ -345,6 +362,7 @@ public class CRenameRefactoringInputPage extends UserInputWizardPage {
private int computeSelectedOptions() {
int options= 0;
+ options |= computeOption(fDoVirtual, CRefactory.OPTION_DO_VIRTUAL);
options |= computeOption(fReferences, CRefactory.OPTION_IN_CODE);
options |= computeOption(fInComment, CRefactory.OPTION_IN_COMMENT);
options |= computeOption(fInString, CRefactory.OPTION_IN_STRING_LITERAL);
@@ -395,6 +413,9 @@ public class CRenameRefactoringInputPage extends UserInputWizardPage {
fDialogSettings.put(KEY_SCOPE, choice);
fDialogSettings.put(KEY_WORKING_SET_NAME, fWorkingSetSpec.getText());
}
+ if (fDoVirtual != null) {
+ fDialogSettings.put(KEY_IGNORE_VIRTUAL, !fDoVirtual.getSelection());
+ }
if (fReferences != null) {
fDialogSettings.put(KEY_REFERENCES_INV, !fReferences.getSelection());
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/messages.properties b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/messages.properties
index d7c2b8f3225..9c4cf5a89d4 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/messages.properties
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/messages.properties
@@ -1,5 +1,5 @@
###############################################################################
-# Copyright (c) 2005, 2008 IBM Corporation and others.
+# Copyright (c) 2005, 2009 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
@@ -86,6 +86,7 @@ CRefactoringMatch.label.potentialOccurrence=Rename potential occurrence
CRenameMethodProcessor.warning.renameVirtual=Renaming a virtual method. Consider renaming the base and derived class methods (if any).
CRenameRefactoringInputPage.button.preprocessor=other preprocessor directives
CRenameRefactoringInputPage.label.updateWithin=Update within:
+CRenameRefactoringInputPage.renameBaseAndDerivedMethods=Rename virtual methods in base and derived classes, also (if any).
ASTManager.task.analyze=Analyzing source code
ASTManager.task.generateAst=Generating AST
ASTManager.subtask.analyzing=Analyzing {0} files

Back to the top