From ac6a9d985265a58344f003c3b32b8921d6e39fdf Mon Sep 17 00:00:00 2001 From: Markus Schorn Date: Wed, 7 Sep 2011 10:12:48 +0200 Subject: [PATCH] Bug 356272: Renaming fields of anonymous structs. --- .../ui/refactoring/rename/ASTManager.java | 22 ++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/ASTManager.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/ASTManager.java index af94f751362..4c5afdbf40f 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/ASTManager.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/ASTManager.java @@ -98,6 +98,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespaceScope; import org.eclipse.cdt.core.dom.ast.cpp.ICPPReferenceType; import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateTypeParameter; import org.eclipse.cdt.core.index.IIndex; +import org.eclipse.cdt.core.index.IIndexBinding; import org.eclipse.cdt.core.index.IIndexName; import org.eclipse.cdt.core.model.CoreModel; import org.eclipse.cdt.core.model.ICElement; @@ -183,13 +184,26 @@ public class ASTManager implements IDisposable { * Returns TRUE, FALSE or UNKNOWN. * @throws DOMException */ - public static int isSameBinding(IBinding b1, IBinding b2) throws DOMException { + public static int isSameBinding(IIndex index, IBinding b1, IBinding b2) throws DOMException { if (b1 == null || b2 == null) { return UNKNOWN; } if (b1.equals(b2)) { return TRUE; } + if (b1 instanceof IIndexBinding || b2 instanceof IIndexBinding) { + if (index != null) { + IIndexBinding b11 = index.adaptBinding(b1); + if (b11 != null) + b1= b11; + IIndexBinding b21 = index.adaptBinding(b2); + if (b21 != null) + b2= b21; + if (b1.equals(b2)) + return TRUE; + } + } + String n1= b1.getName(); String n2= b2.getName(); if (n1 == null || n2 == null) { @@ -1191,9 +1205,11 @@ public class ASTManager implements IDisposable { if (problemInQualifier) { cmp= UNKNOWN; } else { + final IASTTranslationUnit tu = name.getTranslationUnit(); + final IIndex index= tu != null ? tu.getIndex() : null; for (IBinding renameBinding : fValidBindings) { try { - int cmp0= isSameBinding(binding, renameBinding); + int cmp0= isSameBinding(index, binding, renameBinding); if (cmp0 != FALSE) { cmp= cmp0; } @@ -1486,7 +1502,7 @@ public class ASTManager implements IDisposable { for (int i = 0; !isAboveOrEqual && i