diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selectiontests/CPPSelectionTestsNoIndexer.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selectiontests/CPPSelectionTestsNoIndexer.java index 6f0994d3fe1..26397f43bcf 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selectiontests/CPPSelectionTestsNoIndexer.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selectiontests/CPPSelectionTestsNoIndexer.java @@ -957,4 +957,32 @@ public class CPPSelectionTestsNoIndexer extends TestCase { assertEquals(((ASTNode)decl).getOffset(), 128); assertEquals(((ASTNode)decl).getLength(), 3); } + + public void testBug95202() throws Exception { + StringBuffer buffer = new StringBuffer(); + buffer.append("struct A { }; // implicitlydeclared A::operator=\n"); //$NON-NLS-1$ + buffer.append("struct B : A {\n"); //$NON-NLS-1$ + buffer.append("B& operator=(const B &);\n"); //$NON-NLS-1$ + buffer.append("};\n"); //$NON-NLS-1$ + buffer.append("B& B::operator=(const B& s) {\n"); //$NON-NLS-1$ + buffer.append("this->B::operator=(s); // wellformed\n"); //$NON-NLS-1$ + buffer.append("return *this;\n"); //$NON-NLS-1$ + buffer.append("}\n"); //$NON-NLS-1$ + + String code = buffer.toString(); + IFile file = importFile("testBug95202.cpp", code); //$NON-NLS-1$ + + int offset = code.indexOf("s); // wellformed"); //$NON-NLS-1$ + IASTNode def = testF2(file, offset); + IASTNode decl = testF3(file, offset); + assertTrue(def instanceof IASTName); + assertTrue(decl instanceof IASTName); + assertEquals(((IASTName)decl).toString(), "s"); //$NON-NLS-1$ + assertEquals(((ASTNode)decl).getOffset(), 117); + assertEquals(((ASTNode)decl).getLength(), 1); + assertEquals(((IASTName)def).toString(), "s"); //$NON-NLS-1$ + assertEquals(((ASTNode)def).getOffset(), 117); + assertEquals(((ASTNode)def).getLength(), 1); + + } } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/OpenDeclarationsAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/OpenDeclarationsAction.java index c477dc60b0b..b5428ebdb0f 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/OpenDeclarationsAction.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/OpenDeclarationsAction.java @@ -24,6 +24,7 @@ import org.eclipse.cdt.core.model.ICElement; import org.eclipse.cdt.core.model.ICProject; import org.eclipse.cdt.core.parser.ParserLanguage; import org.eclipse.cdt.core.parser.ParserUtil; +import org.eclipse.cdt.core.parser.util.ArrayUtil; import org.eclipse.cdt.core.search.DOMSearchUtil; import org.eclipse.cdt.core.search.ICSearchConstants; import org.eclipse.cdt.core.search.IMatch; @@ -129,6 +130,18 @@ public class OpenDeclarationsAction extends SelectionParseAction implements IUpd IASTName searchName = selectedNames[0]; // step 2 starts here IASTName[] domNames = DOMSearchUtil.getNamesFromDOM(searchName, ICSearchConstants.DECLARATIONS); + + // make sure the names are clean (fix for 95202) + boolean modified=false; + for(int i=0; i 0 && domNames[0] != null) { String fileName=null; int start=0; diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/OpenDefinitionAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/OpenDefinitionAction.java index 7a7f758ad51..1a7230b93fd 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/OpenDefinitionAction.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/OpenDefinitionAction.java @@ -23,6 +23,7 @@ import org.eclipse.cdt.core.model.ICElement; import org.eclipse.cdt.core.model.ICProject; import org.eclipse.cdt.core.parser.ParserLanguage; import org.eclipse.cdt.core.parser.ParserUtil; +import org.eclipse.cdt.core.parser.util.ArrayUtil; import org.eclipse.cdt.core.search.DOMSearchUtil; import org.eclipse.cdt.core.search.ICSearchConstants; import org.eclipse.cdt.core.search.IMatch; @@ -142,6 +143,17 @@ public class OpenDefinitionAction extends SelectionParseAction implements // step 2 starts here IASTName[] domNames = DOMSearchUtil.getNamesFromDOM(searchName, ICSearchConstants.DEFINITIONS); + // make sure the names are clean (fix for 95202) + boolean modified=false; + for(int i=0; i 0 && domNames[0] != null) { String fileName=null; int start=0;