mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-23 14:42:11 +02:00
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)
This commit is contained in:
parent
ce9b0e9e66
commit
39fd1475ba
6 changed files with 71 additions and 1 deletions
|
@ -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 ) );
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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){
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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 ){
|
||||
|
|
|
@ -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 );
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue