Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[cdt-patch] Search: Function parameter matching & enumerator references

Core :
        Index
        Enumerator references
         - Added createEnumeratorFullyQualifiedName in AbstractIndexer
         - Added addEnumeratorReference in AbstractIndexer
         - implemented acceptEnumeratorReference in SourceIndexerRequestor

        Search
        pattern matching on function parameters:
         - modified scanForParameters in CSearchPattern
         - added getParamString in CSearchPattern
         - modified matchLevel in MethodDeclarationPattern
 
        Enumeration references
         - modified acceptEnumeratorReference in MatchLocator

core.tests:
        Modified resources/search/classDecl.cpp
         - to include more function declarations to test parameter 
matching
         - to include an enumerator reference to test enumerators
        Added testMethodDeclarationParameterMatching to 
FunctionMethodPatternTests.java
        Added testEnumeratorReferences to OtherPatternTests

-Andrew

Index: index/ChangeLog
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/index/ChangeLog,v
retrieving revision 1.16
diff -u -r1.16 ChangeLog
--- index/ChangeLog	8 Sep 2003 18:10:49 -0000	1.16
+++ index/ChangeLog	9 Sep 2003 14:20:02 -0000
@@ -1,3 +1,9 @@
+2003-09-09 Andrew Niefer
+	Enumerator references
+ 	 - Added createEnumeratorFullyQualifiedName in AbstractIndexer
+	 - Added addEnumeratorReference in AbstractIndexer
+	 - implemented acceptEnumeratorReference in SourceIndexerRequestor
+
 2003-09-08 Andrew Niefer
 	- Modified calls to ParserFactory to specify which language to use
 
Index: index/org/eclipse/cdt/internal/core/search/indexing/AbstractIndexer.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/search/indexing/AbstractIndexer.java,v
retrieving revision 1.15
diff -u -r1.15 AbstractIndexer.java
--- index/org/eclipse/cdt/internal/core/search/indexing/AbstractIndexer.java	5 Sep 2003 18:31:39 -0000	1.15
+++ index/org/eclipse/cdt/internal/core/search/indexing/AbstractIndexer.java	9 Sep 2003 14:20:03 -0000
@@ -71,25 +71,35 @@
 	public void addEnumerationSpecifier(IASTEnumerationSpecifier enumeration) {
 		this.output.addRef(encodeTypeEntry(enumeration.getFullyQualifiedName(), ENUM, ICSearchConstants.DECLARATIONS));
 		
-	Iterator i = enumeration.getEnumerators();
+		Iterator i = enumeration.getEnumerators();
 		while (i.hasNext())
 		{
 			IASTEnumerator en = (IASTEnumerator) i.next(); 	
-			String name = en.getName();
-			IASTEnumerationSpecifier parent = en.getOwnerEnumerationSpecifier();
-			String[] parentName = parent.getFullyQualifiedName();
-			
-			//See spec 7.2-10, the the scope of the enumerator is the same level as the enumeration
-			String[] enumeratorFullName = new String[ parentName.length ];
-			
-			System.arraycopy( parentName, 0, enumeratorFullName, 0, parentName.length);
-			enumeratorFullName[ parentName.length - 1 ] = name;
+			String[] enumeratorFullName =
+				createEnumeratorFullyQualifiedName(en);
 			
 			this.output.addRef(encodeEntry( enumeratorFullName, FIELD_DECL, FIELD_DECL_LENGTH ));
 
 		}
 	}
-	
+
+	protected String[] createEnumeratorFullyQualifiedName(IASTEnumerator en) {
+		String name = en.getName();
+		IASTEnumerationSpecifier parent = en.getOwnerEnumerationSpecifier();
+		String[] parentName = parent.getFullyQualifiedName();
+		
+		//See spec 7.2-10, the the scope of the enumerator is the same level as the enumeration
+		String[] enumeratorFullName = new String[ parentName.length ];
+		
+		System.arraycopy( parentName, 0, enumeratorFullName, 0, parentName.length);
+		enumeratorFullName[ parentName.length - 1 ] = name;
+		return enumeratorFullName;
+	}
+
+	public void addEnumeratorReference(IASTEnumerator enumerator) {
+		this.output.addRef(encodeEntry(createEnumeratorFullyQualifiedName(enumerator),FIELD_REF,FIELD_REF_LENGTH));	
+	}
+		
 	public void addMacro(IASTMacro macro) {
 		String[] macroName = new String[1];
 		macroName[0] = macro.getName();
@@ -574,6 +584,5 @@
 		
 		return bestPrefix( prefix,  (char)0, macroName, null, matchMode, isCaseSenstive );	
 	}
-
 }
 
Index: index/org/eclipse/cdt/internal/core/search/indexing/SourceIndexerRequestor.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/search/indexing/SourceIndexerRequestor.java,v
retrieving revision 1.14
diff -u -r1.14 SourceIndexerRequestor.java
--- index/org/eclipse/cdt/internal/core/search/indexing/SourceIndexerRequestor.java	8 Sep 2003 19:17:53 -0000	1.14
+++ index/org/eclipse/cdt/internal/core/search/indexing/SourceIndexerRequestor.java	9 Sep 2003 14:20:03 -0000
@@ -26,6 +26,7 @@
 import org.eclipse.cdt.core.parser.ast.IASTElaboratedTypeSpecifier;
 import org.eclipse.cdt.core.parser.ast.IASTEnumerationReference;
 import org.eclipse.cdt.core.parser.ast.IASTEnumerationSpecifier;
+import org.eclipse.cdt.core.parser.ast.IASTEnumerator;
 import org.eclipse.cdt.core.parser.ast.IASTEnumeratorReference;
 import org.eclipse.cdt.core.parser.ast.IASTField;
 import org.eclipse.cdt.core.parser.ast.IASTFieldReference;
@@ -38,7 +39,6 @@
 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.IASTScope;
 import org.eclipse.cdt.core.parser.ast.IASTTemplateDeclaration;
 import org.eclipse.cdt.core.parser.ast.IASTTemplateInstantiation;
 import org.eclipse.cdt.core.parser.ast.IASTTemplateSpecialization;
@@ -438,7 +438,8 @@
      */
     public void acceptEnumeratorReference(IASTEnumeratorReference reference)
     {
-        // TODO Auto-generated method stub
+     	if( reference.getReferencedElement() instanceof IASTEnumerator )
+     		indexer.addEnumeratorReference( (IASTEnumerator)reference.getReferencedElement() );
         
     }
 }
Index: search/ChangeLog
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/search/ChangeLog,v
retrieving revision 1.21
diff -u -r1.21 ChangeLog
--- search/ChangeLog	5 Sep 2003 18:31:39 -0000	1.21
+++ search/ChangeLog	9 Sep 2003 14:20:03 -0000
@@ -1,3 +1,12 @@
+2003-09-09 Andrew Niefer
+	pattern matching on function parameters:
+	 - modified scanForParameters in CSearchPattern
+	 - added getParamString in CSearchPattern
+	 - modified matchLevel in MethodDeclarationPattern
+	 
+	Enumeration references
+	 - modified acceptEnumeratorReference in MatchLocator
+
 2003-09-05 Andrew Niefer
 	- fix searching for enumerators
 
Index: search/org/eclipse/cdt/internal/core/search/matching/CSearchPattern.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/search/org/eclipse/cdt/internal/core/search/matching/CSearchPattern.java,v
retrieving revision 1.19
diff -u -r1.19 CSearchPattern.java
--- search/org/eclipse/cdt/internal/core/search/matching/CSearchPattern.java	8 Sep 2003 18:10:49 -0000	1.19
+++ search/org/eclipse/cdt/internal/core/search/matching/CSearchPattern.java	9 Sep 2003 14:20:04 -0000
@@ -15,9 +15,12 @@
 
 import java.io.IOException;
 import java.io.StringReader;
+import java.util.Iterator;
 import java.util.LinkedList;
 
 import org.eclipse.cdt.core.parser.EndOfFile;
+import org.eclipse.cdt.core.parser.IParser;
+import org.eclipse.cdt.core.parser.IQuickParseCallback;
 import org.eclipse.cdt.core.parser.IScanner;
 import org.eclipse.cdt.core.parser.IToken;
 import org.eclipse.cdt.core.parser.ParserLanguage;
@@ -25,6 +28,16 @@
 import org.eclipse.cdt.core.parser.ParserMode;
 import org.eclipse.cdt.core.parser.ScannerException;
 import org.eclipse.cdt.core.parser.ast.ASTClassKind;
+import org.eclipse.cdt.core.parser.ast.ASTNotImplementedException;
+import org.eclipse.cdt.core.parser.ast.ASTPointerOperator;
+import org.eclipse.cdt.core.parser.ast.IASTClassSpecifier;
+import org.eclipse.cdt.core.parser.ast.IASTCompilationUnit;
+import org.eclipse.cdt.core.parser.ast.IASTElaboratedTypeSpecifier;
+import org.eclipse.cdt.core.parser.ast.IASTEnumerationSpecifier;
+import org.eclipse.cdt.core.parser.ast.IASTFunction;
+import org.eclipse.cdt.core.parser.ast.IASTParameterDeclaration;
+import org.eclipse.cdt.core.parser.ast.IASTSimpleTypeSpecifier;
+import org.eclipse.cdt.core.parser.ast.IASTTypeSpecifier;
 import org.eclipse.cdt.core.search.ICSearchConstants;
 import org.eclipse.cdt.core.search.ICSearchPattern;
 import org.eclipse.cdt.core.search.ICSearchScope;
@@ -210,10 +223,8 @@
 		IScanner scanner = ParserFactory.createScanner( new StringReader( nameString ), "TEXT", new ScannerInfo(), ParserMode.QUICK_PARSE, ParserLanguage.CPP, null );
 		
 		LinkedList names = scanForNames( scanner, null );
-		
-		scanner = ParserFactory.createScanner( new StringReader( paramString ), "TEXT", new ScannerInfo(), ParserMode.QUICK_PARSE, ParserLanguage.CPP, null );
-		
-		LinkedList params = scanForParameters( scanner );
+
+		LinkedList params = scanForParameters( paramString );
 		
 		char [] name = (char [])names.removeLast();
 		char [][] qualifications = new char[0][];
@@ -298,53 +309,99 @@
 	 * @param object
 	 * @return
 	 */
-	private static LinkedList scanForParameters(IScanner scanner) {
+	private static LinkedList scanForParameters( String paramString ) {
 		LinkedList list = new LinkedList();
 		
-		String param = new String("");
+		if( paramString == null || paramString.equals("") )
+			return list;
 		
-		boolean lastTokenWasWild = false;
-		try{
-			IToken token = scanner.nextToken();
-			
-			tokenConsumption:
-			while( true ){
-				switch( token.getType() ){
-					case IToken.tCOMMA :
-						list.addLast( param.toCharArray() );
-						param = new String("");
-						break;
-						
-					case IToken.tLPAREN :
-						break;
-						
-					case IToken.tRPAREN :
-						list.addLast( param.toCharArray() );
-						break tokenConsumption;
-						
-					case IToken.tSTAR:
-					case IToken.tQUESTION:
-						lastTokenWasWild = true;
-						param += token.getImage();
-						break;
-						
-					default:
-						if( !lastTokenWasWild && param.length() > 0 )
-							param += " ";
-						param += token.getImage();
-						break;
-				}
+		String functionString = "void f " + paramString + ";";
 				
-				token = scanner.nextToken();
+		IScanner scanner = ParserFactory.createScanner( new StringReader( functionString ), "TEXT", new ScannerInfo(), ParserMode.QUICK_PARSE, ParserLanguage.CPP, null );
+		IQuickParseCallback callback = ParserFactory.createQuickParseCallback();			   
+		IParser parser = ParserFactory.createParser( scanner, callback, ParserMode.QUICK_PARSE, ParserLanguage.CPP ); 
+
+		if( parser.parse() ){
+			IASTCompilationUnit compUnit = callback.getCompilationUnit();
+			Iterator declarations = null;
+			try {
+				declarations = compUnit.getDeclarations();
+			} catch (ASTNotImplementedException e) {
+			}
+			
+			if( declarations == null || ! declarations.hasNext() )
+				return null;
+			IASTFunction function = (IASTFunction) declarations.next();
+			
+			Iterator parameters = function.getParameters();
+			char [] param = null;
+			while( parameters.hasNext() ){
+				param = getParamString( (IASTParameterDeclaration)parameters.next() );
+				list.add( param );
 			}
-		} catch ( EndOfFile e ){
-			list.addLast( param.toCharArray() );
-		} catch( ScannerException e ){
 		}
 		
 		return list;
 	}
 		
+	static public char [] getParamString( IASTParameterDeclaration param ){
+		if( param == null ) return null;
+		 
+		String signature = "";
+		
+		IASTTypeSpecifier typeSpec = param.getTypeSpecifier();
+		if( typeSpec instanceof IASTSimpleTypeSpecifier ){
+			IASTSimpleTypeSpecifier simple = (IASTSimpleTypeSpecifier)typeSpec;
+			signature += simple.getTypename();
+		} else if( typeSpec instanceof IASTElaboratedTypeSpecifier ){
+			IASTElaboratedTypeSpecifier elaborated = (IASTElaboratedTypeSpecifier)typeSpec;
+			if( elaborated.getClassKind() == ASTClassKind.CLASS ){
+				signature += "class ";
+			} else if( elaborated.getClassKind() == ASTClassKind.ENUM ) {
+				signature += "enum ";
+			} else if( elaborated.getClassKind() == ASTClassKind.STRUCT ) {
+				signature += "struct ";
+			} else if( elaborated.getClassKind() == ASTClassKind.UNION ) {
+				signature += "union";
+			}
+
+			signature += elaborated.getName();
+		} else if( typeSpec instanceof IASTClassSpecifier ){
+			IASTClassSpecifier classSpec = (IASTClassSpecifier)typeSpec;
+			signature += classSpec.getName();
+		} else if( typeSpec instanceof IASTEnumerationSpecifier ){
+			IASTEnumerationSpecifier enumSpec = (IASTEnumerationSpecifier)typeSpec;
+			signature += enumSpec.getName();
+		}
+		
+		signature += " ";
+		
+		if( param.isConst() ) signature += "const ";
+		if( param.isVolatile() ) signature += "volatile ";
+
+		Iterator ptrs = param.getPointerOperators();
+		while( ptrs.hasNext() ){
+			ASTPointerOperator ptrOp = (ASTPointerOperator) ptrs.next();
+			if( ptrOp == ASTPointerOperator.POINTER ){
+				signature += " * ";
+			} else if( ptrOp == ASTPointerOperator.REFERENCE ){
+				signature += " & ";
+			} else if( ptrOp == ASTPointerOperator.CONST_POINTER ){
+				signature += " const * ";
+			} else if( ptrOp == ASTPointerOperator.VOLATILE_POINTER ){
+				signature += " volatile * ";
+			}
+		}
+
+		Iterator arrayModifiers = param.getArrayModifiers();
+		while( arrayModifiers.hasNext() ){
+			arrayModifiers.next();
+			signature += " [] ";
+		}
+
+		return signature.toCharArray();
+	}
+	
 	static private LinkedList scanForNames( IScanner scanner, IToken unusedToken ){
 		LinkedList list = new LinkedList();
 		
Index: search/org/eclipse/cdt/internal/core/search/matching/MatchLocator.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/search/org/eclipse/cdt/internal/core/search/matching/MatchLocator.java,v
retrieving revision 1.24
diff -u -r1.24 MatchLocator.java
--- search/org/eclipse/cdt/internal/core/search/matching/MatchLocator.java	8 Sep 2003 19:17:53 -0000	1.24
+++ search/org/eclipse/cdt/internal/core/search/matching/MatchLocator.java	9 Sep 2003 14:20:04 -0000
@@ -126,7 +126,15 @@
 	public void exitTemplateSpecialization(IASTTemplateSpecialization specialization) 		{	}
 	public void exitTemplateExplicitInstantiation(IASTTemplateInstantiation instantiation) 	{	}
 	public void exitLinkageSpecification(IASTLinkageSpecification linkageSpec) 	{	}
+
+	public void enterCodeBlock(IASTCodeScope scope) {	}
+	public void exitCodeBlock(IASTCodeScope scope) 	{	}
+	
 	
+	public void acceptEnumeratorReference(IASTEnumeratorReference reference){
+		check( REFERENCES, reference );	
+	}
+		
 	public void acceptMacro(IASTMacro macro){
 		check( DECLARATIONS, macro );	
 	}
@@ -465,29 +473,5 @@
 	  System.out.println("(" + Thread.currentThread() + ") " + log); 
 	}
 
-	/* (non-Javadoc)
-	 * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#enterCodeBlock(org.eclipse.cdt.core.parser.ast.IASTScope)
-	 */
-	public void enterCodeBlock(IASTCodeScope scope) {
-		// TODO Auto-generated method stub
-		
-	}
-
-	/* (non-Javadoc)
-	 * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#exitCodeBlock(org.eclipse.cdt.core.parser.ast.IASTScope)
-	 */
-	public void exitCodeBlock(IASTCodeScope scope) {
-		// TODO Auto-generated method stub
-		
-	}
-
-    /* (non-Javadoc)
-     * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#acceptEnumeratorReference(org.eclipse.cdt.core.parser.ast.IASTEnumerationReference)
-     */
-    public void acceptEnumeratorReference(IASTEnumeratorReference reference)
-    {
-        // TODO Auto-generated method stub
-        
-    }
 
 }
Index: search/org/eclipse/cdt/internal/core/search/matching/MethodDeclarationPattern.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/search/org/eclipse/cdt/internal/core/search/matching/MethodDeclarationPattern.java,v
retrieving revision 1.8
diff -u -r1.8 MethodDeclarationPattern.java
--- search/org/eclipse/cdt/internal/core/search/matching/MethodDeclarationPattern.java	12 Aug 2003 20:20:04 -0000	1.8
+++ search/org/eclipse/cdt/internal/core/search/matching/MethodDeclarationPattern.java	9 Sep 2003 14:20:04 -0000
@@ -19,11 +19,8 @@
 import org.eclipse.cdt.core.parser.ISourceElementCallbackDelegate;
 import org.eclipse.cdt.core.parser.ast.IASTFunction;
 import org.eclipse.cdt.core.parser.ast.IASTMethod;
-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.IASTSimpleTypeSpecifier;
-import org.eclipse.cdt.core.parser.ast.IASTTypeSpecifier;
 import org.eclipse.cdt.core.search.ICSearchScope;
 import org.eclipse.cdt.internal.core.CharOperation;
 import org.eclipse.cdt.internal.core.index.IEntryResult;
@@ -96,8 +93,9 @@
 		
 		//parameters
 		if( parameterNames != null && parameterNames.length > 0  &&	parameterNames[0].length > 0 ){
+
 			Iterator params = function.getParameters();
-			
+				
 			for( int i = 0; i < parameterNames.length; i++ ){
 			
 				//if this function doesn't have this many parameters, it is not a match.
@@ -105,21 +103,14 @@
 				if( !params.hasNext() || parameterNames[ i ] == null )
 					return IMPOSSIBLE_MATCH;
 					
-				IASTParameterDeclaration param = (IASTParameterDeclaration) params.next();
-				IASTTypeSpecifier typeSpec = param.getTypeSpecifier();
-				String paramName = null;
-				if( typeSpec instanceof IASTSimpleTypeSpecifier ){
-					paramName = ((IASTSimpleTypeSpecifier)typeSpec).getTypename();
-				} else if( typeSpec instanceof IASTOffsetableNamedElement ){
-					paramName = ((IASTOffsetableNamedElement)typeSpec).getName();
-				} else {
-					//???
-					return IMPOSSIBLE_MATCH;
-				}
+				IASTParameterDeclaration parameter = (IASTParameterDeclaration) params.next();
+				char[] param = CSearchPattern.getParamString( parameter );
 				
-				if( !matchesName( parameterNames[i], paramName.toCharArray() ) )
+				//no wildcards in parameters strings
+				if( !CharOperation.equals( parameterNames[i], param, _caseSensitive ) )
 					return IMPOSSIBLE_MATCH;
 			}
+			
 			//if this function still has more parameters, it is not a match
 			if( params.hasNext() )
 				return IMPOSSIBLE_MATCH;
Index: ChangeLog
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core.tests/ChangeLog,v
retrieving revision 1.84
diff -u -r1.84 ChangeLog
--- ChangeLog	8 Sep 2003 19:17:45 -0000	1.84
+++ ChangeLog	9 Sep 2003 14:25:26 -0000
@@ -1,3 +1,10 @@
+2003-09-09 Andrew Niefer
+	Modified resources/search/classDecl.cpp
+	 - to include more function declarations to test parameter matching
+	 - to include an enumerator reference to test enumerators
+	Added testMethodDeclarationParameterMatching to FunctionMethodPatternTests.java
+	Added testEnumeratorReferences to OtherPatternTests
+	
 2003-09-08 John Camelon
 	Added CompleteParseASTTest::testThrowStatement(), testScoping(), testEnumeratorReferences().
 	Removed LineNumberTest source as it is obsolete.  
Index: resources/search/classDecl.cpp
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core.tests/resources/search/classDecl.cpp,v
retrieving revision 1.7
diff -u -r1.7 classDecl.cpp
--- resources/search/classDecl.cpp	5 Sep 2003 18:31:44 -0000	1.7
+++ resources/search/classDecl.cpp	9 Sep 2003 14:25:26 -0000
@@ -7,6 +7,9 @@
 class A {
 	class B {
 		void f( A );
+		void f( A & );
+		void f( A* );
+		void f( int &, const char [], A ** );
 	};
 };
 
@@ -15,6 +18,7 @@
 		struct a{};
 	}
 	class B: public A {
+	public:
 		struct AA {};
 		enum e {
 			One,
@@ -32,7 +36,7 @@
 
 namespace NS3{
 	class C : public NS::B {
-		e eE;
+		e eE = One;
 	};
 }
 
Index: search/org/eclipse/cdt/core/search/tests/ClassDeclarationPatternTests.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core.tests/search/org/eclipse/cdt/core/search/tests/ClassDeclarationPatternTests.java,v
retrieving revision 1.12
diff -u -r1.12 ClassDeclarationPatternTests.java
--- search/org/eclipse/cdt/core/search/tests/ClassDeclarationPatternTests.java	12 Aug 2003 20:19:47 -0000	1.12
+++ search/org/eclipse/cdt/core/search/tests/ClassDeclarationPatternTests.java	9 Sep 2003 14:25:26 -0000
@@ -198,7 +198,7 @@
 		search( workspace, pattern, scope, resultCollector );
 		
 		Set matches = resultCollector.getSearchResults();
-		assertEquals( matches.size(), 3 );
+		assertEquals( matches.size(), 6 );
 	}
 	
 	public void testClassReferenceInFieldType(){
@@ -255,6 +255,6 @@
 		
 		Set matches = resultCollector.getSearchResults();
 		
-		assertEquals( matches.size(), 4 );//TODO was 6, changed for bug 41445
+		assertEquals( matches.size(), 7 );
 	}
 }
Index: search/org/eclipse/cdt/core/search/tests/FunctionMethodPatternTests.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core.tests/search/org/eclipse/cdt/core/search/tests/FunctionMethodPatternTests.java,v
retrieving revision 1.6
diff -u -r1.6 FunctionMethodPatternTests.java
--- search/org/eclipse/cdt/core/search/tests/FunctionMethodPatternTests.java	12 Aug 2003 20:19:47 -0000	1.6
+++ search/org/eclipse/cdt/core/search/tests/FunctionMethodPatternTests.java	9 Sep 2003 14:25:26 -0000
@@ -73,7 +73,7 @@
 		
 		Set matches = resultCollector.getSearchResults();
 		
-		assertEquals( matches.size(), 1 );
+		assertEquals( matches.size(), 4 );
 	}
 	
 	public void testMethodDeclarationWithParams() {
@@ -83,5 +83,24 @@
 		
 		Set matches = resultCollector.getSearchResults();
 		
-		assertEquals( matches.size(), 1 );	}
+		assertEquals( matches.size(), 1 );	
+	}
+	
+	public void testMethodDeclarationParameterMatching(){
+		ICSearchPattern pattern = SearchEngine.createSearchPattern( "f( A & )", METHOD, DECLARATIONS, true );
+		
+		search( workspace, pattern, scope, resultCollector );
+		Set matches = resultCollector.getSearchResults();
+		assertEquals( matches.size(), 1 );
+		
+		pattern = SearchEngine.createSearchPattern( "f( A * )", METHOD, DECLARATIONS, true );
+		search( workspace, pattern, scope, resultCollector );
+		matches = resultCollector.getSearchResults();
+		assertEquals( matches.size(), 1 );
+		
+		pattern = SearchEngine.createSearchPattern( "f( int &, const char  [],  A** )", METHOD, DECLARATIONS, true );
+		search( workspace, pattern, scope, resultCollector );
+		matches = resultCollector.getSearchResults();
+		assertEquals( matches.size(), 1 );
+	}
 }
Index: search/org/eclipse/cdt/core/search/tests/OtherPatternTests.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core.tests/search/org/eclipse/cdt/core/search/tests/OtherPatternTests.java,v
retrieving revision 1.9
diff -u -r1.9 OtherPatternTests.java
--- search/org/eclipse/cdt/core/search/tests/OtherPatternTests.java	5 Sep 2003 18:31:44 -0000	1.9
+++ search/org/eclipse/cdt/core/search/tests/OtherPatternTests.java	9 Sep 2003 14:25:26 -0000
@@ -193,4 +193,13 @@
 		assertEquals( matches.size(), 1 );
 	}
 	
+	public void testEnumeratorReferences(){
+		ICSearchPattern pattern = SearchEngine.createSearchPattern( "One", FIELD, REFERENCES, true );
+		
+		search( workspace, pattern, scope, resultCollector );
+		
+		Set matches = resultCollector.getSearchResults();
+		assertEquals( matches.size(), 1 );
+	}
+	
 }

Back to the top