From e425b0ea7bb3f101f757d3e59ea34d9343d87fea Mon Sep 17 00:00:00 2001 From: Hoda Amer Date: Wed, 16 Jun 2004 19:29:36 +0000 Subject: [PATCH] Bug Fixing --- core/org.eclipse.cdt.ui/ChangeLog | 3 +++ .../corext/refactoring/refactoring.properties | 2 ++ .../rename/RenameElementProcessor.java | 25 ++++++++++++++----- 3 files changed, 24 insertions(+), 6 deletions(-) diff --git a/core/org.eclipse.cdt.ui/ChangeLog b/core/org.eclipse.cdt.ui/ChangeLog index 6ff656a8799..2363eeb9eb8 100644 --- a/core/org.eclipse.cdt.ui/ChangeLog +++ b/core/org.eclipse.cdt.ui/ChangeLog @@ -1,3 +1,6 @@ +2004-06-16 Hoda Amer + Fix for PR 66730: [Refactoring] Renaming a class does not change .cpp file. + 2004-06-15 Bogdan Gheorghe Fix for Bug 60490: "Selected resource" option should only be enabled/disabled based on selections in the Navigator and C/C++ Projects views - search now diff --git a/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/corext/refactoring/refactoring.properties b/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/corext/refactoring/refactoring.properties index 9b6e673f6ec..5f0e4cdb9e0 100644 --- a/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/corext/refactoring/refactoring.properties +++ b/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/corext/refactoring/refactoring.properties @@ -346,6 +346,8 @@ RenameTypeRefactoring.member_type=Member Type declared inside ''{0}'' is named { RenameTypeRefactoring.another_type=Another type named ''{0} is referenced in ''{1}'' RenameTypeRefactoring.wrong_element=Rename refactoring does not handle this type of element. RenameTypeRefactoring.virtual_method=Renaming a virtual method. Consider renaming the base and derived class methods (if any). +RenameTypeRefactoring.no_files=No files are found. + TextMatchFinder.comment=text reference update in a comment TextMatchFinder.string=text reference update in a string literal diff --git a/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/corext/refactoring/rename/RenameElementProcessor.java b/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/corext/refactoring/rename/RenameElementProcessor.java index 03b96181a48..85d603eedf0 100644 --- a/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/corext/refactoring/rename/RenameElementProcessor.java +++ b/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/corext/refactoring/rename/RenameElementProcessor.java @@ -131,7 +131,7 @@ public class RenameElementProcessor extends RenameProcessor implements IReferenc return name; } - public int getCurrentElementNameLength() { + private int getCurrentElementNameLength() { if(fCElement == null) return 0; String name = fCElement.getElementName(); @@ -142,7 +142,7 @@ public class RenameElementProcessor extends RenameProcessor implements IReferenc return name.length(); } - public int getCurrentElementNameStartPos() { + private int getCurrentElementNameStartPos() { if(fCElement == null) return 0; String name = fCElement.getElementName(); @@ -152,15 +152,24 @@ public class RenameElementProcessor extends RenameProcessor implements IReferenc return ((CElement)fCElement).getIdStartPos(); } - public String getElementQualifiedName(ICElement element) throws CModelException{ + private String getElementQualifiedName(ICElement element) throws CModelException{ if(!eligibleForRefactoring(element)){ return ""; } else { StringBuffer name = new StringBuffer(); if(element instanceof IFunctionDeclaration){ - // add the whole signature IFunctionDeclaration function = (IFunctionDeclaration)element; + if((element instanceof IMethodDeclaration) && ( ((IMethodDeclaration)element).isFriend() )){ + // go up until you hit a namespace or a translation unit. + ICElement parent = (ICElement) element.getParent(); + while (!(parent instanceof INamespace) && (!(parent instanceof ITranslationUnit) )){ + parent = parent.getParent(); + } + name.append(getElementQualifiedName(parent)); + }else { + // add the whole signature name.append(getElementQualifiedName(element.getParent())); + } name.append("::"); name.append(function.getSignature()); } else { @@ -308,7 +317,11 @@ public class RenameElementProcessor extends RenameProcessor implements IReferenc pm.setTaskName(RefactoringCoreMessages.getString("RenameTypeRefactoring.checking")); //$NON-NLS-1$ if (pm.isCanceled()) throw new OperationCanceledException(); - + + if (fReferences.length == 0){ + result.addFatalError(RefactoringCoreMessages.getString("RenameTypeRefactoring.no_files")); + } + if (result.hasFatalError()) return result; // more checks go here @@ -562,7 +575,7 @@ public class RenameElementProcessor extends RenameProcessor implements IReferenc private static ICElement findEnclosingElements(ICElement element, String newName) { ICElement enclosing= element.getParent(); - while (enclosing != null){ + while ((enclosing != null) && (!(enclosing instanceof ITranslationUnit))){ if (newName.equals(enclosing.getElementName())) return enclosing; else