diff --git a/core/org.eclipse.cdt.core/ChangeLog b/core/org.eclipse.cdt.core/ChangeLog index 81e36218f4f..c5a148c8162 100644 --- a/core/org.eclipse.cdt.core/ChangeLog +++ b/core/org.eclipse.cdt.core/ChangeLog @@ -1,3 +1,10 @@ +2005-06-17 Vladimir Hirsl + Fix for 95174: [Search Engine][DOM AST Indexer] does not find definition of a method + + * index/org/eclipse/cdt/internal/core/index/cindexstorage/EntryResult.java + * index/org/eclipse/cdt/internal/core/index/domsourceindexer/IndexVisitorUtil.java + * search/org/eclipse/cdt/core/search/DOMSearchUtil.java + 2005-06-16 Vladimir Hirsl Fix for PR 99433: [Search] Return parms not part of qualification matching Function/methos parameters are now used as a part of search pattern. diff --git a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/cindexstorage/EntryResult.java b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/cindexstorage/EntryResult.java index 06a0e938a04..c6cb5f5a92d 100644 --- a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/cindexstorage/EntryResult.java +++ b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/cindexstorage/EntryResult.java @@ -206,7 +206,10 @@ public String getDisplayString() { int finishParam = longname.indexOf("/("); //$NON-NLS-1$ String functionName; - String arguments = longname.substring(startParam + 2, finishParam); + String arguments = ""; //$NON-NLS-1$ + if (startParam + 2 < finishParam) { + arguments = longname.substring(startParam + 2, finishParam); + } // TODO: flip arguments arguments = arguments.replace('/',','); @@ -219,7 +222,10 @@ public String getDisplayString() { return functionName + arguments ; } else { - String returnType = longname.substring(startReturn + 3, finishReturn); + String returnType = ""; + if (startReturn + 3 < finishReturn) { + returnType = longname.substring(startReturn + 3, finishReturn); + } functionName = longname.substring(0, startReturn -1); return functionName + arguments + ':' + returnType; } diff --git a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/domsourceindexer/IndexVisitorUtil.java b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/domsourceindexer/IndexVisitorUtil.java index 791020685c1..190d30f7dfb 100644 --- a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/domsourceindexer/IndexVisitorUtil.java +++ b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/domsourceindexer/IndexVisitorUtil.java @@ -26,6 +26,7 @@ import org.eclipse.cdt.core.dom.ast.IType; import org.eclipse.cdt.core.dom.ast.IVariable; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTDeclSpecifier; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionDeclarator; +import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName; import org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructor; import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction; import org.eclipse.cdt.core.dom.ast.cpp.ICPPMember; @@ -184,6 +185,9 @@ public class IndexVisitorUtil { */ public static char[][] getParameters(IASTName functionName) { IASTNode parent = functionName.getParent(); + if (parent instanceof ICPPASTQualifiedName) { + parent = parent.getParent(); + } if (parent instanceof IASTDeclarator) { IASTDeclarator declarator = (IASTDeclarator) parent; String[] parameters = ASTSignatureUtil.getParameterSignatureArray(declarator); diff --git a/core/org.eclipse.cdt.core/search/org/eclipse/cdt/core/search/DOMSearchUtil.java b/core/org.eclipse.cdt.core/search/org/eclipse/cdt/core/search/DOMSearchUtil.java index fcef59a2828..5f6a3830218 100644 --- a/core/org.eclipse.cdt.core/search/org/eclipse/cdt/core/search/DOMSearchUtil.java +++ b/core/org.eclipse.cdt.core/search/org/eclipse/cdt/core/search/DOMSearchUtil.java @@ -19,9 +19,9 @@ import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.ICLogConstants; import org.eclipse.cdt.core.dom.CDOM; import org.eclipse.cdt.core.dom.IASTServiceProvider; -import org.eclipse.cdt.core.dom.ast.ASTTypeUtil; import org.eclipse.cdt.core.dom.ast.ASTVisitor; import org.eclipse.cdt.core.dom.ast.DOMException; +import org.eclipse.cdt.core.dom.ast.IASTFunctionDeclarator; import org.eclipse.cdt.core.dom.ast.IASTName; import org.eclipse.cdt.core.dom.ast.IASTNode; import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit; @@ -30,15 +30,14 @@ import org.eclipse.cdt.core.dom.ast.ICompositeType; import org.eclipse.cdt.core.dom.ast.IEnumeration; import org.eclipse.cdt.core.dom.ast.IEnumerator; import org.eclipse.cdt.core.dom.ast.IFunction; -import org.eclipse.cdt.core.dom.ast.IFunctionType; import org.eclipse.cdt.core.dom.ast.IMacroBinding; -import org.eclipse.cdt.core.dom.ast.IType; +import org.eclipse.cdt.core.dom.ast.IProblemBinding; import org.eclipse.cdt.core.dom.ast.ITypedef; import org.eclipse.cdt.core.dom.ast.IVariable; import org.eclipse.cdt.core.dom.ast.c.CASTVisitor; -import org.eclipse.cdt.core.dom.ast.c.ICExternalBinding; import org.eclipse.cdt.core.dom.ast.cpp.CPPASTVisitor; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNamespaceDefinition; +import org.eclipse.cdt.core.dom.ast.cpp.ICPPBinding; import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassScope; import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType; import org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructor; @@ -53,6 +52,7 @@ import org.eclipse.cdt.core.search.ICSearchConstants.LimitTo; import org.eclipse.cdt.core.search.ICSearchConstants.SearchFor; import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTName; import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTQualifiedName; +import org.eclipse.cdt.internal.core.index.domsourceindexer.IndexVisitorUtil; import org.eclipse.cdt.internal.core.search.matching.CSearchPattern; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IProject; @@ -443,60 +443,72 @@ public class DOMSearchUtil { */ public static String getSearchPattern(IASTName name) { StringBuffer buffer = new StringBuffer(); - buffer.append("::"); //$NON-NLS-1$ - - String[] namespaces = null; - - IASTNode parent = name.getParent(); - while(!(parent instanceof IASTTranslationUnit) && parent != null) { - if (parent instanceof ICPPASTNamespaceDefinition) { - namespaces = (String[])ArrayUtil.append(String.class, namespaces, ((ICPPASTNamespaceDefinition)parent).getName().toString()); - } - parent = parent.getParent(); - } - - if (namespaces != null && namespaces.length > 0) { - for( int i=namespaces.length-1; i>=0; i-- ) { - if (namespaces[i] != null) { - buffer.append(namespaces[i]); - buffer.append("::"); //$NON-NLS-1$ - } - } - } - - if (name instanceof CPPASTName && name.getParent() instanceof CPPASTQualifiedName) { - IASTName[] names = ((CPPASTQualifiedName)name.getParent()).getNames(); - for(int i=0; i 0) { + for( int i=namespaces.length-1; i>=0; i-- ) { + if (namespaces[i] != null) { + buffer.append(namespaces[i]); + buffer.append("::"); //$NON-NLS-1$ + } + } + } + + if (name instanceof CPPASTName && name.getParent() instanceof CPPASTQualifiedName) { + IASTName[] names = ((CPPASTQualifiedName)name.getParent()).getNames(); + for(int i=0; i