diff --git a/core/org.eclipse.cdt.core.tests/search/org/eclipse/cdt/core/search/tests/OtherPatternTests.java b/core/org.eclipse.cdt.core.tests/search/org/eclipse/cdt/core/search/tests/OtherPatternTests.java index a55f869c678..9c8f2d6725a 100644 --- a/core/org.eclipse.cdt.core.tests/search/org/eclipse/cdt/core/search/tests/OtherPatternTests.java +++ b/core/org.eclipse.cdt.core.tests/search/org/eclipse/cdt/core/search/tests/OtherPatternTests.java @@ -163,6 +163,18 @@ public class OtherPatternTests extends BaseSearchTest { assertTrue( match.getParentName().equals( "" ) ); } + public void testParameterDeclaration(){ + ICSearchPattern pattern = SearchEngine.createSearchPattern( "index", VAR, DECLARATIONS, true ); + + search( workspace, pattern, scope, resultCollector ); + + Set matches = resultCollector.getSearchResults(); + assertEquals( matches.size(), 3 ); + + IMatch match = (IMatch) matches.iterator().next(); + assertTrue( match.getParentName().equals( "" ) ); + } + public void testOrPattern(){ OrPattern orPattern = new OrPattern(); orPattern.addPattern( SearchEngine.createSearchPattern( "::NS::B::e", ENUM, REFERENCES, true ) ); diff --git a/core/org.eclipse.cdt.core/index/ChangeLog b/core/org.eclipse.cdt.core/index/ChangeLog index 18d98eb4320..01b5240a4b3 100644 --- a/core/org.eclipse.cdt.core/index/ChangeLog +++ b/core/org.eclipse.cdt.core/index/ChangeLog @@ -1,3 +1,10 @@ +2004-06-25 Bogdan Gheorghe + Indirect fix for Bug 65551: [Search] Search for Variable references should not include parameters + Instead of excluding parameter references from searches, added parm declarations to the index (for + both functions and methods) + + * index/org/eclipse/cdt/internal/core/search/indexing/AbstractIndexer.java + 2004-06-22 Alain Magloire Part of PR 68246. diff --git a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/search/indexing/AbstractIndexer.java b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/search/indexing/AbstractIndexer.java index b52d6270d8d..8c0b3106315 100644 --- a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/search/indexing/AbstractIndexer.java +++ b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/search/indexing/AbstractIndexer.java @@ -224,6 +224,15 @@ public abstract class AbstractIndexer implements IIndexer, IIndexConstants, ICSe public void addMethodDeclaration(IASTMethod method) { this.output.addRef(encodeEntry(method.getFullyQualifiedName(),METHOD_DECL,METHOD_DECL_LENGTH)); + + Iterator i=method.getParameters(); + while (i.hasNext()){ + Object parm = i.next(); + if (parm instanceof IASTParameterDeclaration){ + IASTParameterDeclaration parmDecl = (IASTParameterDeclaration) parm; + this.output.addRef(encodeTypeEntry(new String[]{parmDecl.getName()}, VAR, ICSearchConstants.DECLARATIONS)); + } + } } public void addMethodReference(IASTMethod method) { @@ -261,6 +270,15 @@ public abstract class AbstractIndexer implements IIndexer, IIndexConstants, ICSe public void addFunctionDeclaration(IASTFunction function){ this.output.addRef(encodeEntry(function.getFullyQualifiedName(),FUNCTION_DECL,FUNCTION_DECL_LENGTH)); + + Iterator i=function.getParameters(); + while (i.hasNext()){ + Object parm = i.next(); + if (parm instanceof IASTParameterDeclaration){ + IASTParameterDeclaration parmDecl = (IASTParameterDeclaration) parm; + this.output.addRef(encodeTypeEntry(new String[]{parmDecl.getName()}, VAR, ICSearchConstants.DECLARATIONS)); + } + } } public void addFunctionReference(IASTFunction function){ diff --git a/core/org.eclipse.cdt.core/search/ChangeLog b/core/org.eclipse.cdt.core/search/ChangeLog index eacc378f16a..92d3a9bd9ad 100644 --- a/core/org.eclipse.cdt.core/search/ChangeLog +++ b/core/org.eclipse.cdt.core/search/ChangeLog @@ -1,3 +1,11 @@ +2004-06-25 Bogdan Gheorghe + Indirect fix for Bug 65551: [Search] Search for Variable references should not include parameters + Instead of excluding parameter references from searches, added parm declarations to the index (for + both functions and methods) + + * search/org/eclipse/cdt/core/search/BasicSearchResultCollector.java + * index/org/eclipse/cdt/internal/core/search/matching/MatchLocator.java + 2004-06-25 Bogdan Gheorghe Fix for 68550: [Indexer] Cannot restart indexer by touching .c/.cpp/.cc files diff --git a/core/org.eclipse.cdt.core/search/org/eclipse/cdt/core/search/BasicSearchResultCollector.java b/core/org.eclipse.cdt.core/search/org/eclipse/cdt/core/search/BasicSearchResultCollector.java index 02ccea46c08..8e839a8ce1e 100644 --- a/core/org.eclipse.cdt.core/search/org/eclipse/cdt/core/search/BasicSearchResultCollector.java +++ b/core/org.eclipse.cdt.core/search/org/eclipse/cdt/core/search/BasicSearchResultCollector.java @@ -32,6 +32,7 @@ import org.eclipse.cdt.core.parser.ast.IASTMethod; import org.eclipse.cdt.core.parser.ast.IASTNamespaceDefinition; import org.eclipse.cdt.core.parser.ast.IASTOffsetableElement; import org.eclipse.cdt.core.parser.ast.IASTOffsetableNamedElement; +import org.eclipse.cdt.core.parser.ast.IASTParameterDeclaration; import org.eclipse.cdt.core.parser.ast.IASTQualifiedNameElement; import org.eclipse.cdt.core.parser.ast.IASTReference; import org.eclipse.cdt.core.parser.ast.IASTTypedefDeclaration; @@ -106,7 +107,7 @@ public class BasicSearchResultCollector implements ICSearchResultCollector { names = enumerator.getOwnerEnumerationSpecifier().getFullyQualifiedName(); } else if( offsetable instanceof IASTQualifiedNameElement ) { names = ((IASTQualifiedNameElement) offsetable).getFullyQualifiedName(); - } + } if( names != null ){ for( int i = 0; i < names.length - 1; i++ ){ @@ -205,6 +206,9 @@ public class BasicSearchResultCollector implements ICSearchResultCollector { match.type = ICElement.C_VARIABLE; IASTVariable variable = (IASTVariable)node; match.isConst = variable.getAbstractDeclaration().isConst(); + } else if (node instanceof IASTParameterDeclaration){ + match.type = ICElement.C_VARIABLE; + match.isConst = ((IASTParameterDeclaration) node).isConst(); } else if ( node instanceof IASTEnumerator ){ match.type = ICElement.C_ENUMERATOR; } else if ( node instanceof IASTMethod ){ diff --git a/core/org.eclipse.cdt.core/search/org/eclipse/cdt/internal/core/search/matching/MatchLocator.java b/core/org.eclipse.cdt.core/search/org/eclipse/cdt/internal/core/search/matching/MatchLocator.java index 4977027db5f..60f262ba282 100644 --- a/core/org.eclipse.cdt.core/search/org/eclipse/cdt/internal/core/search/matching/MatchLocator.java +++ b/core/org.eclipse.cdt.core/search/org/eclipse/cdt/internal/core/search/matching/MatchLocator.java @@ -61,6 +61,7 @@ import org.eclipse.cdt.core.parser.ast.IASTMethodReference; import org.eclipse.cdt.core.parser.ast.IASTNamespaceDefinition; import org.eclipse.cdt.core.parser.ast.IASTNamespaceReference; import org.eclipse.cdt.core.parser.ast.IASTOffsetableNamedElement; +import org.eclipse.cdt.core.parser.ast.IASTParameterDeclaration; import org.eclipse.cdt.core.parser.ast.IASTParameterReference; import org.eclipse.cdt.core.parser.ast.IASTReference; import org.eclipse.cdt.core.parser.ast.IASTScope; @@ -251,6 +252,15 @@ public class MatchLocator implements IMatchLocator{ check( DECLARATIONS, function ); check( DEFINITIONS, function ); + + Iterator parms =function.getParameters(); + while (parms.hasNext()){ + Object tempParm = parms.next(); + if (tempParm instanceof IASTParameterDeclaration){ + check( DECLARATIONS, ((IASTParameterDeclaration)tempParm)); + } + } + pushScope( function ); } @@ -260,6 +270,17 @@ public class MatchLocator implements IMatchLocator{ check( DECLARATIONS, method ); check( DEFINITIONS, method ); + + + Iterator parms =method.getParameters(); + while (parms.hasNext()){ + Object tempParm = parms.next(); + if (tempParm instanceof IASTParameterDeclaration){ + check( DECLARATIONS, ((IASTParameterDeclaration)tempParm)); + } + } + + pushScope( method ); }