Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[cdt-patch] Search/Indexer work

This patch is for Search.  It has:

Core:
- modifications to the Indexer to better support qualified names
- functions to create Index entry prefixes for the different Search 
Patterns
- all of the search patterns are now being created and all do at least 
some matching
- all of the parser callbacks for declarations, definitions, and 
references are now being handled, though the patterns and indexer both 
need some work here

Core.tests:
- new BaseSearchTest which creates a project and uses the indexer
- new test class FunctionMethodPatternTests to test aspects of the 
Function & Method patterns
- new test class OtherPatternTests to test the other (Namespace, Field & 
variable) patterns
- new tests to test index prefixes for the patterns

UI:
- handle more varied search results and display more icons

-Andrew

Index: ChangeLog
===================================================================
RCS file: /home/tools/org.eclipse.cdt.ui/ChangeLog,v
retrieving revision 1.125
diff -u -r1.125 ChangeLog
--- ChangeLog	22 Jul 2003 00:44:14 -0000	1.125
+++ ChangeLog	23 Jul 2003 20:19:35 -0000
@@ -1,3 +1,7 @@
+2003-07-23 Andrew Niefer
+	-Modified CSearchResultCollector to handle icons for more items
+	-Modified CSearchResultCollector to reflect interface changes.
+
 2003-07-21	Bogdan Gheorghe
 	Update to CSearchResultLabelProvider to ensure that search labels
 	show up on subsequent runs.
Index: src/org/eclipse/cdt/internal/ui/search/CSearchResultCollector.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchResultCollector.java,v
retrieving revision 1.5
diff -u -r1.5 CSearchResultCollector.java
--- src/org/eclipse/cdt/internal/ui/search/CSearchResultCollector.java	21 Jul 2003 21:14:10 -0000	1.5
+++ src/org/eclipse/cdt/internal/ui/search/CSearchResultCollector.java	23 Jul 2003 20:19:35 -0000
@@ -18,28 +18,21 @@
 import java.util.HashSet;
 import java.util.Set;
 
-import org.eclipse.cdt.core.parser.ast.ASTClassKind;
-import org.eclipse.cdt.core.parser.ast.IASTClassSpecifier;
-import org.eclipse.cdt.core.parser.ast.IASTEnumerationSpecifier;
-import org.eclipse.cdt.core.parser.ast.IASTNamespaceDefinition;
-import org.eclipse.cdt.core.parser.ast.IASTOffsetableNamedElement;
-import org.eclipse.cdt.core.parser.ast.IASTQualifiedNameElement;
-import org.eclipse.cdt.core.parser.ast.IASTScope;
+import org.eclipse.cdt.core.parser.ISourceElementCallbackDelegate;
+import org.eclipse.cdt.core.parser.ast.*;
 import org.eclipse.cdt.core.search.ICSearchResultCollector;
 import org.eclipse.cdt.core.search.IMatch;
 import org.eclipse.cdt.internal.ui.CPluginImages;
-import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.cdt.ui.CElementImageDescriptor;
 import org.eclipse.core.resources.IMarker;
 import org.eclipse.core.resources.IResource;
 import org.eclipse.core.runtime.CoreException;
 import org.eclipse.core.runtime.IPath;
 import org.eclipse.core.runtime.IProgressMonitor;
 import org.eclipse.jface.resource.ImageDescriptor;
-//import org.eclipse.search.ui.IActionGroupFactory;
 import org.eclipse.search.ui.ISearchResultView;
 import org.eclipse.search.ui.SearchUI;
-import org.eclipse.swt.graphics.Image;
-//import org.eclipse.ui.actions.ActionGroup;
+import org.eclipse.swt.graphics.Point;
 
 /**
  * @author aniefer
@@ -50,21 +43,28 @@
 public class CSearchResultCollector implements ICSearchResultCollector {
 	
 	public static final String IMATCH = "IMatchObject";
+	private static final Point SMALL_SIZE= new Point(16, 16);
 	
 	/**
 	 * 
 	 */
 	public CSearchResultCollector() {
 		super();
-		// TODO Auto-generated constructor stub
+	}
+	
+	public CSearchResultCollector( boolean maintain ){
+		this();
+		_maintainOwnCollection = maintain;
 	}
 
 	/* (non-Javadoc)
 	 * @see org.eclipse.cdt.core.search.ICSearchResultCollector#aboutToStart()
 	 */
 	public void aboutToStart() {
-		_view = SearchUI.getSearchResultView();
 		_matchCount = 0;
+		
+		_view = SearchUI.getSearchResultView();
+		
 		if( _view != null ){
 			_view.searchStarted(
 				null,//new ActionGroupFactory(),
@@ -78,9 +78,14 @@
 				_operation
 			);
 		}
-		if( !getProgressMonitor().isCanceled() ){
+		
+		if( getProgressMonitor() != null && !getProgressMonitor().isCanceled() ){
 			getProgressMonitor().subTask( SEARCHING );
 		}
+		
+		if( _maintainOwnCollection ){
+			_matches = new HashSet();
+		}
 	}
 
 	/* (non-Javadoc)
@@ -109,7 +114,12 @@
 		
 		marker.setAttributes( markerAttributes );
 		
-		_view.addMatch( match.name, groupKey, resource, marker );
+		if( _view != null )
+			_view.addMatch( match.name, groupKey, resource, marker );
+		
+		if( _maintainOwnCollection ){
+			_matches.add( enclosingObject );
+		}
 		_matchCount++;
 	}
 
@@ -121,21 +131,19 @@
 		int accuracy)
 		throws CoreException 
 	{
-		if( _matches == null ){
-			_matches = new HashSet();
-		}
-		
-		_matches.add( match );
+		if( _maintainOwnCollection )
+			_matches.add( match );
 	}
 
 
 	/* (non-Javadoc)
 	 * @see org.eclipse.cdt.core.search.ICSearchResultCollector#createMatch(org.eclipse.cdt.core.parser.ast.IASTOffsetableNamedElement)
 	 */
-	public IMatch createMatch(IASTOffsetableNamedElement node, IASTScope parent ) {
-		String name = node.getName();
-		
+	public IMatch createMatch(ISourceElementCallbackDelegate node, IASTScope parent ) {
+		String name = null;
 		String parentName = "";
+		IASTOffsetableNamedElement offsetable = null;
+		
 		if( parent instanceof IASTQualifiedNameElement ){
 			String [] names = ((IASTQualifiedNameElement)parent).getFullyQualifiedName();
 			for( int i = 0; i < names.length; i++ ){
@@ -146,6 +154,24 @@
 			}
 		}
 		
+		if( node instanceof IASTReference ){
+			offsetable = (IASTOffsetableNamedElement) ((IASTReference)node).getReferencedElement();
+			name = ((IASTReference)node).getName();
+		} else if( node instanceof IASTOffsetableNamedElement ){
+			offsetable = (IASTOffsetableNamedElement)node;
+			name = offsetable.getName(); 
+		} else {
+			return null;
+		}
+		
+		ImageDescriptor image = getImageDescriptor( offsetable );
+		int adornmentFlags = computeAdornmentFlags( offsetable );
+		IMatch match = new Match(name, parentName, image );//, node.getNameOffset(), name.length() );
+		
+		return match;
+	}
+	
+	private ImageDescriptor getImageDescriptor( IASTOffsetableElement node ){
 		ImageDescriptor imageDescriptor = null;
 		if( node instanceof IASTClassSpecifier ){
 			ASTClassKind kind = ((IASTClassSpecifier)node).getClassKind();
@@ -160,12 +186,55 @@
 			imageDescriptor = CPluginImages.DESC_OBJS_CONTAINER;
 		} else if ( node instanceof IASTEnumerationSpecifier ){
 			imageDescriptor = CPluginImages.DESC_OBJS_ENUMERATION;
+		} else if ( node instanceof IASTField ){
+			IASTField  field = (IASTField)node;
+			ASTAccessVisibility visibility = field.getVisiblity();
+			if( visibility == ASTAccessVisibility.PUBLIC ){
+				imageDescriptor = CPluginImages.DESC_OBJS_PUBLIC_FIELD;
+			} else if ( visibility == ASTAccessVisibility.PROTECTED) {
+				imageDescriptor = CPluginImages.DESC_OBJS_PROTECTED_FIELD;
+			} else if ( visibility == ASTAccessVisibility.PRIVATE ) {
+				imageDescriptor = CPluginImages.DESC_OBJS_PRIVATE_FIELD;
+			}
+		} else if ( node instanceof IASTVariable ){
+			imageDescriptor = CPluginImages.DESC_OBJS_FIELD;
+		} else if ( node instanceof IASTEnumerator ){
+			imageDescriptor = CPluginImages.DESC_OBJS_ENUMERATOR;
+		} else if ( node instanceof IASTMethod ){
+			IASTMethod method = (IASTMethod) node;
+			ASTAccessVisibility visibility = method.getVisiblity();
+			if( visibility == ASTAccessVisibility.PUBLIC ){
+				imageDescriptor = CPluginImages.DESC_OBJS_PUBLIC_METHOD;
+			} else if ( visibility == ASTAccessVisibility.PROTECTED) {
+				imageDescriptor = CPluginImages.DESC_OBJS_PROTECTED_METHOD;
+			} else if ( visibility == ASTAccessVisibility.PRIVATE ) {
+				imageDescriptor = CPluginImages.DESC_OBJS_PRIVATE_METHOD;
+			}
+		} else if ( node instanceof IASTFunction ){
+			imageDescriptor = CPluginImages.DESC_OBJS_FUNCTION;
 		}
 		
-		Image image = CUIPlugin.getImageDescriptorRegistry().get( imageDescriptor );
-		IMatch match = new Match(name, parentName, image, node.getNameOffset(), name.length() );
+		if( imageDescriptor != null) {
+			int adornmentFlags = computeAdornmentFlags( node );
+			return new CElementImageDescriptor( imageDescriptor, adornmentFlags, SMALL_SIZE );
+		}
+		return imageDescriptor;		
+	}
+	
+	private int computeAdornmentFlags(IASTOffsetableElement element ) {
+		int flags = 0;
+			
+		if( element instanceof IASTVariable ){
+			flags |= ((IASTVariable) element).isStatic() ? 0 : CElementImageDescriptor.STATIC;
+		} else if ( element instanceof IASTMethod ){
+			flags |= ((IASTMethod) element).isStatic()   ? 0 : CElementImageDescriptor.STATIC;
+			flags |= ((IASTMethod) element).isConst()    ? 0 : CElementImageDescriptor.CONSTANT;
+			flags |= ((IASTMethod) element).isVolatile() ? 0 : CElementImageDescriptor.VOLATILE;
+		} else if( element instanceof IASTFunction ){
+			flags |= ((IASTFunction) element).isStatic() ? 0 : CElementImageDescriptor.STATIC;
+		}
 		
-		return match;
+		return flags;
 	}
 		
 	/* (non-Javadoc)
@@ -210,34 +279,15 @@
 		return _matches;
 	}
 	
-	//private class ActionGroupFactory implements IActionGroupFactory {
-	//	public ActionGroup createActionGroup( ISearchResultView part ){
-	//		return new CSearchViewActionGroup( part );
-	//	}
-	//}
-	
-	/*public static class Match impl{
-		public Match( String path, int start, int end ){
-			this.path = path;
-			this.start = start;
-			this.end = end;
-		}
-	
-		public String path;
-		public int start;
-		public int end;
-	}
-	*/	
 	private static final String SEARCHING = CSearchMessages.getString("CSearchResultCollector.searching"); //$NON-NLS-1$
 	private static final String MATCH     = CSearchMessages.getString("CSearchResultCollector.match"); //$NON-NLS-1$
 	private static final String MATCHES   = CSearchMessages.getString("CSearchResultCollector.matches"); //$NON-NLS-1$
 	private static final String DONE      = CSearchMessages.getString("CSearchResultCollector.done"); //$NON-NLS-1$
-
-		
 	
 	private IProgressMonitor 	_monitor;
 	private CSearchOperation 	_operation;
 	private ISearchResultView 	_view;
 	private int					_matchCount;
 	private Set					_matches;
+	private boolean 			_maintainOwnCollection = false;
 }
Index: src/org/eclipse/cdt/internal/ui/search/CSearchResultLabelProvider.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchResultLabelProvider.java,v
retrieving revision 1.3
diff -u -r1.3 CSearchResultLabelProvider.java
--- src/org/eclipse/cdt/internal/ui/search/CSearchResultLabelProvider.java	21 Jul 2003 21:14:10 -0000	1.3
+++ src/org/eclipse/cdt/internal/ui/search/CSearchResultLabelProvider.java	23 Jul 2003 20:19:35 -0000
@@ -15,9 +15,11 @@
 
 import org.eclipse.cdt.internal.ui.CElementImageProvider;
 import org.eclipse.cdt.ui.CElementLabelProvider;
+import org.eclipse.cdt.ui.CUIPlugin;
 import org.eclipse.core.resources.IMarker;
 import org.eclipse.core.resources.IResource;
 import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jface.resource.ImageDescriptor;
 import org.eclipse.jface.viewers.LabelProvider;
 import org.eclipse.search.ui.ISearchResultViewEntry;
 import org.eclipse.swt.graphics.Image;
@@ -61,7 +63,11 @@
 			return null;
 		}
 	
-		return match.image;
+		ImageDescriptor imageDescriptor = match.imageDesc;
+			
+		Image image = CUIPlugin.getImageDescriptorRegistry().get( imageDescriptor );
+				
+		return image;
 	}
 	
 	public String getText( Object element ) {
Index: src/org/eclipse/cdt/internal/ui/search/Match.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/Match.java,v
retrieving revision 1.1
diff -u -r1.1 Match.java
--- src/org/eclipse/cdt/internal/ui/search/Match.java	15 Jul 2003 14:43:48 -0000	1.1
+++ src/org/eclipse/cdt/internal/ui/search/Match.java	23 Jul 2003 20:19:35 -0000
@@ -14,7 +14,7 @@
 package org.eclipse.cdt.internal.ui.search;
 
 import org.eclipse.cdt.core.search.IMatch;
-import org.eclipse.swt.graphics.Image;
+import org.eclipse.jface.resource.ImageDescriptor;
 
 /**
  * @author aniefer
@@ -26,14 +26,18 @@
 
 	public String name;
 	public String parent;
-	public Image  image;
+	public ImageDescriptor imageDesc;
 	public int 	  start;
 	public int    end;
 	
-	public Match( String name, String parent, Image image, int start, int end ){
+	public Match( String name, String parent, ImageDescriptor image ){
 		this.name = name;
 		this.parent = parent;
-		this.image = image;
+		this.imageDesc = image;
+	}
+	
+	public Match( String name, String parent, ImageDescriptor image, int start, int end ){
+		this( name, parent, image );
 		this.start = start;
 		this.end = end;
 	}
Index: ChangeLog
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core.tests/ChangeLog,v
retrieving revision 1.29
diff -u -r1.29 ChangeLog
--- ChangeLog	22 Jul 2003 22:02:24 -0000	1.29
+++ ChangeLog	23 Jul 2003 20:28:31 -0000
@@ -1,3 +1,11 @@
+2003-07-23 Andrew Niefer
+	-Created search/BaseSearchTest to handle creating projects and setting them up to use the indexer
+	-removed ClassSpecifierSearchTests, its functionality is now in BaseSearchTest
+	-modified ClassDeclarationPatternTests to extend BaseSearchTest
+	-added FunctionMethodPatternTests
+	-added OtherPatternTests
+	-modified indexer/IndexManagerTests.testIndexContents
+
 2003-07-22 John Camelon
 	Updated CompleteParseASTTests.
 
Index: indexer/org/eclipse/cdt/core/indexer/tests/IndexManagerTests.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core.tests/indexer/org/eclipse/cdt/core/indexer/tests/IndexManagerTests.java,v
retrieving revision 1.4
diff -u -r1.4 IndexManagerTests.java
--- indexer/org/eclipse/cdt/core/indexer/tests/IndexManagerTests.java	22 Jul 2003 18:51:41 -0000	1.4
+++ indexer/org/eclipse/cdt/core/indexer/tests/IndexManagerTests.java	23 Jul 2003 20:28:31 -0000
@@ -276,7 +276,7 @@
 		IIndex ind = indexManager.getIndex(testProjectPath,true,true);
 		assertTrue("Index exists for project",ind != null);
 	
-		String [] typeDeclEntryResultModel ={"EntryResult: word=typeDecl/C/Mail/Z/X/Y, refs={ 1 }","EntryResult: word=typeDecl/C/Unknown/Z/X/Y, refs={ 1 }","EntryResult: word=typeDecl/C/container/Z/X/Y, refs={ 1 }","EntryResult: word=typeDecl/C/first_class/Z/X/Y, refs={ 1 }","EntryResult: word=typeDecl/C/postcard/Z/X/Y, refs={ 1 }","EntryResult: word=typeDecl/E/test/Z/X/Y, refs={ 1 }","EntryResult: word=typeDecl/V/x/Z, refs={ 1 }"};
+		String [] typeDeclEntryResultModel ={"EntryResult: word=typeDecl/C/Mail/Y/X/Z, refs={ 1 }","EntryResult: word=typeDecl/C/Unknown/Y/X/Z, refs={ 1 }","EntryResult: word=typeDecl/C/container/Y/X/Z, refs={ 1 }","EntryResult: word=typeDecl/C/first_class/Y/X/Z, refs={ 1 }","EntryResult: word=typeDecl/C/postcard/Y/X/Z, refs={ 1 }","EntryResult: word=typeDecl/E/test/Y/X/Z, refs={ 1 }","EntryResult: word=typeDecl/V/x/Z, refs={ 1 }"};
 		IEntryResult[] typedeclresults =ind.queryEntries(IIndexConstants.TYPE_DECL);
 
 		if (typedeclresults.length != typeDeclEntryResultModel.length)
@@ -298,7 +298,7 @@
 		 assertEquals(typeDefEntryResultModel[i],typedefresults[i].toString());
 		}
 				
-		String [] namespaceResultModel = {"EntryResult: word=namespaceDecl/X/Z, refs={ 1 }", "EntryResult: word=namespaceDecl/Y/Z/X, refs={ 1 }", "EntryResult: word=namespaceDecl/Z, refs={ 1 }"};
+		String [] namespaceResultModel = {"EntryResult: word=namespaceDecl/X/Z, refs={ 1 }", "EntryResult: word=namespaceDecl/Y/X/Z, refs={ 1 }", "EntryResult: word=namespaceDecl/Z, refs={ 1 }"};
 		IEntryResult[] namespaceresults =ind.queryEntries(IIndexConstants.NAMESPACE_DECL);
 		
 		if (namespaceresults.length != namespaceResultModel.length)
@@ -309,7 +309,7 @@
 			assertEquals(namespaceResultModel[i],namespaceresults[i].toString());
 		}
 				
-		String [] fieldResultModel = {"EntryResult: word=fieldDecl/array/Z/X/Y/container, refs={ 1 }", "EntryResult: word=fieldDecl/bye/Z/X/Y/test, refs={ 1 }", "EntryResult: word=fieldDecl/cool/Z/X/Y/test, refs={ 1 }", "EntryResult: word=fieldDecl/hi/Z/X/Y/test, refs={ 1 }", "EntryResult: word=fieldDecl/index/Z/X/Y/container, refs={ 1 }", "EntryResult: word=fieldDecl/postage/Z/X/Y/Mail, refs={ 1 }", "EntryResult: word=fieldDecl/sz/Z/X/Y/container, refs={ 1 }", "EntryResult: word=fieldDecl/type/Z/X/Y/Mail, refs={ 1 }", "EntryResult: word=fieldDecl/why/Z/X/Y/test, refs={ 1 }"};
+		String [] fieldResultModel = {"EntryResult: word=fieldDecl/array/container/Y/X/Z, refs={ 1 }", "EntryResult: word=fieldDecl/bye/test/Y/X/Z, refs={ 1 }", "EntryResult: word=fieldDecl/cool/test/Y/X/Z, refs={ 1 }", "EntryResult: word=fieldDecl/hi/test/Y/X/Z, refs={ 1 }", "EntryResult: word=fieldDecl/index/container/Y/X/Z, refs={ 1 }", "EntryResult: word=fieldDecl/postage/Mail/Y/X/Z, refs={ 1 }", "EntryResult: word=fieldDecl/sz/container/Y/X/Z, refs={ 1 }", "EntryResult: word=fieldDecl/type/Mail/Y/X/Z, refs={ 1 }", "EntryResult: word=fieldDecl/why/test/Y/X/Z, refs={ 1 }"};
 		IEntryResult[] fieldresults =ind.queryEntries(IIndexConstants.FIELD_DECL);
 	
 		if (fieldresults.length != fieldResultModel.length)
@@ -331,7 +331,7 @@
 			assertEquals(functionResultModel[i],functionresults[i].toString());
 		}
 		
-		String [] methodResultModel = {"EntryResult: word=methodDecl/operator<</Z/X/Y/Mail, refs={ 1 }","EntryResult: word=methodDecl/operator=/Z/X/Y/container, refs={ 1 }","EntryResult: word=methodDecl/operator[]/Z/X/Y/container, refs={ 1 }","EntryResult: word=methodDecl/print/Z/X/Y/Mail, refs={ 1 }"};	
+		String [] methodResultModel = {"EntryResult: word=methodDecl/operator<</Mail/Y/X/Z, refs={ 1 }","EntryResult: word=methodDecl/operator=/container/Y/X/Z, refs={ 1 }","EntryResult: word=methodDecl/operator[]/container/Y/X/Z, refs={ 1 }","EntryResult: word=methodDecl/print/Mail/Y/X/Z, refs={ 1 }"};	
 		IEntryResult[] methodresults =ind.queryEntries(IIndexConstants.METHOD_DECL);
 		
 		if (methodresults.length != methodResultModel.length)
Index: search/org/eclipse/cdt/core/search/tests/BaseSearchTest.java
===================================================================
RCS file: search/org/eclipse/cdt/core/search/tests/BaseSearchTest.java
diff -N search/org/eclipse/cdt/core/search/tests/BaseSearchTest.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ search/org/eclipse/cdt/core/search/tests/BaseSearchTest.java	23 Jul 2003 20:28:32 -0000
@@ -0,0 +1,167 @@
+/*******************************************************************************
+ * Copyright (c) 2003 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials 
+ * are made available under the terms of the Common Public License v0.5 
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v05.html
+ * 
+ * Contributors:
+ *     IBM Corp. - Rational Software - initial implementation
+ ******************************************************************************/
+/*
+ * Created on Jul 22, 2003
+ */
+package org.eclipse.cdt.core.search.tests;
+
+import java.io.FileInputStream;
+
+import junit.framework.TestCase;
+
+import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.core.CProjectNature;
+import org.eclipse.cdt.core.search.ICSearchConstants;
+import org.eclipse.cdt.core.search.ICSearchPattern;
+import org.eclipse.cdt.core.search.ICSearchResultCollector;
+import org.eclipse.cdt.core.search.ICSearchScope;
+import org.eclipse.cdt.core.search.SearchEngine;
+import org.eclipse.cdt.internal.core.index.impl.IFileDocument;
+import org.eclipse.cdt.internal.core.search.indexing.IndexManager;
+import org.eclipse.cdt.internal.ui.search.CSearchResultCollector;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IProjectDescription;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IWorkspace;
+import org.eclipse.core.resources.IWorkspaceRoot;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Platform;
+
+/**
+ * @author aniefer
+ *
+ * To change the template for this generated type comment go to
+ * Window>Preferences>Java>Code Generation>Code and Comments
+ */
+public class BaseSearchTest extends TestCase implements ICSearchConstants {
+
+	ICSearchScope 			scope;
+	IFile 					file;
+	IFileDocument 			fileDoc;
+	IProject 				testProject;
+	NullProgressMonitor		monitor;
+	IWorkspace 				workspace;
+	CSearchResultCollector	resultCollector;
+	SearchEngine			searchEngine;
+
+	public BaseSearchTest(String name) {
+		super(name);
+	}
+
+	protected void setUp() throws Exception {
+		super.setUp();
+
+		monitor = new NullProgressMonitor();
+		
+		workspace = ResourcesPlugin.getWorkspace();
+		
+		//Create temp project
+		testProject = createProject("SearchTestProject");
+
+		if (testProject == null)
+			fail("Unable to create project");
+
+		//Add a file to the project
+		importFile("mail.cpp", "resources/indexer/mail.cpp");
+		importFile("classDecl.cpp", "resources/search/classDecl.cpp");
+
+		scope = SearchEngine.createWorkspaceScope();
+		
+		IndexManager indexManager = CCorePlugin.getDefault().getCoreModel().getIndexManager();
+		indexManager.setEnabled(testProject,true);
+		
+		resultCollector = new CSearchResultCollector( true );
+		resultCollector.setProgressMonitor( monitor );
+		
+		searchEngine = new SearchEngine();
+	}
+
+	protected void tearDown() throws Exception {
+		super.tearDown();
+		//Delete project
+		if (testProject.exists()){
+			testProject.delete( true, monitor );
+		}
+	}
+	
+	private IProject createProject(String projectName) throws CoreException {
+		IWorkspaceRoot root = workspace.getRoot();
+		IProject project = root.getProject(projectName);
+		
+		if( !project.exists() ) {
+			project.create( null );
+		} else {
+			project.refreshLocal(IResource.DEPTH_INFINITE, null);
+		}
+		
+		if( !project.isOpen() ) {
+			project.open( null );
+		}
+
+		//Fill out a project description
+		IPath defaultPath = Platform.getLocation();
+		IPath newPath = project.getFullPath();
+		
+		if (defaultPath.equals(newPath))
+			newPath = null;
+		
+		IProjectDescription description = workspace.newProjectDescription(project.getName());
+		
+		description.setLocation(newPath);
+		
+		//Create the project
+		IProject cproject = CCorePlugin.getDefault().createCProject( description,
+																	 project,
+																	 monitor,
+																	 CCorePlugin.PLUGIN_ID + ".make");
+
+		if( !project.hasNature(CProjectNature.C_NATURE_ID) ){
+			addNatureToProject(project, CProjectNature.C_NATURE_ID, null);
+		}
+
+		return cproject;
+	}
+
+	private void importFile(String fileName, String resourceLocation)throws Exception{
+		//Obtain file handle
+		file = testProject.getProject().getFile(fileName); 
+		String pluginRoot=org.eclipse.core.runtime.Platform.getPlugin("org.eclipse.cdt.core.tests").find(new Path("/")).getFile();
+		//Create file input stream
+		
+		if (!file.exists()){
+			file.create(new FileInputStream(pluginRoot + resourceLocation),false,monitor);
+		}
+		fileDoc = new IFileDocument(file);
+	}
+	
+	private void addNatureToProject(IProject proj, String natureId, IProgressMonitor monitor) throws CoreException {
+		IProjectDescription description = proj.getDescription();
+		
+		String[] prevNatures = description.getNatureIds();
+		String[] newNatures = new String[ prevNatures.length + 1 ];
+		
+		System.arraycopy( prevNatures, 0, newNatures, 0, prevNatures.length );
+		newNatures[ prevNatures.length ] = natureId;
+		description.setNatureIds( newNatures );
+		proj.setDescription( description, monitor );
+	}
+	
+	protected void search(IWorkspace workspace, ICSearchPattern pattern, ICSearchScope scope, ICSearchResultCollector collector) {
+		resultCollector.setProgressMonitor( monitor );
+		searchEngine.search( workspace, pattern, scope, collector );
+	}
+}
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.5
diff -u -r1.5 ClassDeclarationPatternTests.java
--- search/org/eclipse/cdt/core/search/tests/ClassDeclarationPatternTests.java	17 Jul 2003 20:15:03 -0000	1.5
+++ search/org/eclipse/cdt/core/search/tests/ClassDeclarationPatternTests.java	23 Jul 2003 20:28:32 -0000
@@ -22,11 +22,8 @@
 import org.eclipse.cdt.internal.core.search.CharOperation;
 import org.eclipse.cdt.internal.core.search.matching.ClassDeclarationPattern;
 import org.eclipse.cdt.internal.core.search.matching.MatchLocator;
-import org.eclipse.cdt.internal.ui.search.CSearchResultCollector;
 import org.eclipse.cdt.internal.ui.search.Match;
-import org.eclipse.core.runtime.Path;
 
-import junit.framework.TestCase;
 
 /**
  * @author aniefer
@@ -34,32 +31,22 @@
  * To change the template for this generated type comment go to
  * Window>Preferences>Java>Code Generation>Code and Comments
  */
-public class ClassDeclarationPatternTests extends TestCase implements ICSearchConstants {
+public class ClassDeclarationPatternTests extends BaseSearchTest implements ICSearchConstants {
 
 	private MatchLocator matchLocator;
-	private CSearchResultCollector resultCollector;
+	
 	private String cppPath;
 	
 	public ClassDeclarationPatternTests(String name) {
 		super(name);
 	}
 	
-	private void initialize( ICSearchPattern pattern ){
-		cppPath = org.eclipse.core.runtime.Platform.getPlugin("org.eclipse.cdt.core.tests").find(new Path("/")).getFile();
-		cppPath += "resources/search/classDecl.cpp";
-		
-		resultCollector = new CSearchResultCollector();
-		matchLocator = new MatchLocator( pattern, resultCollector, null, null );
-	}
-	
 	public void testMatchSimpleDeclaration(){
 		ICSearchPattern pattern = SearchEngine.createSearchPattern( "A", TYPE, DECLARATIONS, true );
-
-		assertTrue( pattern instanceof ClassDeclarationPattern );
 		
-		initialize( pattern );
+		assertTrue( pattern instanceof ClassDeclarationPattern );
 		
-		matchLocator.locateMatches( new String [] { cppPath }, null, null );		
+		search( workspace, pattern, scope, resultCollector );
 		
 		Set matches = resultCollector.getMatches();
 		assertEquals( matches.size(), 2 );
@@ -76,9 +63,7 @@
 		assertTrue( clsPattern.getContainingTypes().length == 1 );
 		assertTrue( CharOperation.equals( new char[] { 'N', 'S' }, clsPattern.getContainingTypes()[0] ) );
 		
-		initialize( pattern );
-		
-		matchLocator.locateMatches( new String [] { cppPath }, null, null );
+		search( workspace, pattern, scope, resultCollector );
 		
 		Set matches = resultCollector.getMatches();
 		assertEquals( matches.size(), 1 );
@@ -87,22 +72,22 @@
 	public void testBug39652() {
 		ICSearchPattern pattern = SearchEngine.createSearchPattern( "A::B", TYPE, DECLARATIONS, true );
 		
-		initialize( pattern );
-		matchLocator.locateMatches( new String[] { cppPath }, null, null );
+		search( workspace, pattern, scope, resultCollector );
 		Set matches = resultCollector.getMatches();
+		
 		/* Test should find 1 match */
 		assertTrue( matches != null );
 		assertTrue( matches.size() == 1 );
 				
 		pattern = SearchEngine.createSearchPattern( "NS::NS2::a", TYPE, DECLARATIONS, true );
-		initialize( pattern );
-		matchLocator.locateMatches( new String[] { cppPath }, null, null );
+		search( workspace, pattern, scope, resultCollector );
+
 		matches = resultCollector.getMatches();
 		assertTrue( matches != null );
 		
 		pattern = SearchEngine.createSearchPattern( "NS::B::A", TYPE, DECLARATIONS, true );
-		initialize( pattern );
-		matchLocator.locateMatches( new String[] { cppPath }, null, null );
+		search( workspace, pattern, scope, resultCollector );
+
 		matches = resultCollector.getMatches();
 		assertTrue( matches != null );
 	}
@@ -112,19 +97,13 @@
 		
 		assertTrue( pattern instanceof ClassDeclarationPattern );
 		
-		ClassDeclarationPattern clsPattern = (ClassDeclarationPattern) pattern;
-		
-		initialize( pattern );
-		
-		matchLocator.locateMatches( new String[] { cppPath }, null, null );
+		search( workspace, pattern, scope, resultCollector );
 		
 		Set matches = resultCollector.getMatches();
 		assertEquals( matches.size(), 1 );
 		
 		pattern = SearchEngine.createSearchPattern( "NS::B::A", TYPE, DECLARATIONS, true );
-		
-		initialize( pattern );
-		matchLocator.locateMatches( new String[] { cppPath }, null, null );
+		search( workspace, pattern, scope, resultCollector );
 		
 		Set matches2 = resultCollector.getMatches();
 		assertTrue( matches2 != null );
@@ -143,15 +122,13 @@
 	
 	public void testWildcardQualification() {
 		ICSearchPattern pattern = SearchEngine.createSearchPattern( "::*::A", TYPE, DECLARATIONS, true );
-		initialize( pattern );
-		matchLocator.locateMatches( new String [] { cppPath }, null, null );
+		search( workspace, pattern, scope, resultCollector );
 		
 		Set matches = resultCollector.getMatches();
-		assertEquals( matches, null );
+		assertEquals( matches.size(), 0 );
 		
 		pattern = SearchEngine.createSearchPattern( "NS::*::A", TYPE, DECLARATIONS, false );
-		initialize( pattern );
-		matchLocator.locateMatches( new String [] { cppPath }, null, null );
+		search( workspace, pattern, scope, resultCollector );
 		
 		matches = resultCollector.getMatches();
 		assertEquals( matches.size(), 2 );
@@ -159,22 +136,39 @@
 	
 	public void testElaboratedType(){
 		ICSearchPattern pattern = SearchEngine.createSearchPattern( "struct A", TYPE, DECLARATIONS, true );
-		initialize( pattern );
-		matchLocator.locateMatches( new String [] { cppPath }, null, null );
+		search( workspace, pattern, scope, resultCollector );
+
 		Set matches = resultCollector.getMatches();
 		assertEquals( matches.size(), 1 );
 		
 		pattern = SearchEngine.createSearchPattern( "union u", TYPE, DECLARATIONS, true );
-		initialize( pattern );
-		matchLocator.locateMatches( new String [] { cppPath }, null, null );
+		search( workspace, pattern, scope, resultCollector );
+
 		matches = resultCollector.getMatches();
 		assertEquals( matches.size(), 2 );
 
 		pattern = SearchEngine.createSearchPattern( "union ::*::u", TYPE, DECLARATIONS, true );
-		initialize( pattern );
-		matchLocator.locateMatches( new String [] { cppPath }, null, null );
+		search( workspace, pattern, scope, resultCollector );
+
 		matches = resultCollector.getMatches();
 		assertEquals( matches.size(), 1 );
+	}
+	
+	public void testClassIndexPrefix(){
+		ICSearchPattern pattern = SearchEngine.createSearchPattern( "struct A::B::*::c", TYPE, DECLARATIONS, true );
+		assertTrue( pattern instanceof ClassDeclarationPattern );
+		
+		ClassDeclarationPattern clsPattern = (ClassDeclarationPattern)pattern;
+		assertEquals( CharOperation.compareWith( "typeDecl/S/c/".toCharArray(), clsPattern.indexEntryPrefix() ), 0);
+		
+		clsPattern = (ClassDeclarationPattern) SearchEngine.createSearchPattern( "class ::*::A::B::c", TYPE, DECLARATIONS, true );
+		assertEquals( CharOperation.compareWith( "typeDecl/C/c/B/A/".toCharArray(), clsPattern.indexEntryPrefix() ), 0);
+				
+		clsPattern = (ClassDeclarationPattern) SearchEngine.createSearchPattern( "enum ::RT*::c", TYPE, REFERENCES, true );
+		assertEquals( CharOperation.compareWith( "typeRef/E/c/RT".toCharArray(), clsPattern.indexEntryPrefix() ), 0);
+				
+		clsPattern = (ClassDeclarationPattern) SearchEngine.createSearchPattern( "union A::B::c", TYPE, REFERENCES, false );
+		assertEquals( CharOperation.compareWith( "typeRef/U/".toCharArray(), clsPattern.indexEntryPrefix() ), 0);
 	}
 	
 }
Index: search/org/eclipse/cdt/core/search/tests/ClassSpecifierSearchTests.java
===================================================================
RCS file: search/org/eclipse/cdt/core/search/tests/ClassSpecifierSearchTests.java
diff -N search/org/eclipse/cdt/core/search/tests/ClassSpecifierSearchTests.java
--- search/org/eclipse/cdt/core/search/tests/ClassSpecifierSearchTests.java	17 Jul 2003 20:15:03 -0000	1.2
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,153 +0,0 @@
-/*
- * Created on Jul 11, 2003
- */
-package org.eclipse.cdt.core.search.tests;
-
-import java.io.FileInputStream;
-
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-import org.eclipse.cdt.core.CCorePlugin;
-import org.eclipse.cdt.core.CProjectNature;
-import org.eclipse.cdt.core.search.ICSearchPattern;
-import org.eclipse.cdt.core.search.ICSearchResultCollector;
-import org.eclipse.cdt.internal.core.index.impl.IFileDocument;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IProjectDescription;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IWorkspace;
-import org.eclipse.core.resources.IWorkspaceRoot;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.core.runtime.Platform;
-
-/**
- * @author bgheorgh
- */
-public class ClassSpecifierSearchTests extends TestCase {
-	IFile file;
-	IFileDocument fileDoc;
-	IProject testProject;
-	NullProgressMonitor monitor;
-	
-
-	/**
-	 * @param name
-	 */
-	public ClassSpecifierSearchTests(String name) {
-		super(name);
-		// TODO Auto-generated constructor stub
-	}
-	
-	public static Test suite() { 
-			return new TestSuite(ClassSpecifierSearchTests.class);
-	}
-	
-	protected void setUp() throws Exception {
-			super.setUp();
-			//Create temp project
-			testProject = createProject("IndexerTestProject");
-			if (testProject==null)
-				fail("Unable to create project");
-			//Add a file to the project
-			importFile("mail.cpp","resources/indexer/mail.cpp");	
-	}
-	/*
-	 * @see TestCase#tearDown()
-	 */
-	protected void tearDown() throws Exception {
-		super.tearDown();
-		//Delete project
-		if (testProject.exists()){
-			testProject.delete(true,monitor);
-		}
-	}
-	/*
-	 * Utils
-	 */
-	private IProject createProject(String projectName) throws CoreException
-	{
-	   IWorkspaceRoot root= ResourcesPlugin.getWorkspace().getRoot();
-	   IProject project= root.getProject(projectName);
-	   if (!project.exists()) {
-		 project.create(null);
-	   } else {
-		 project.refreshLocal(IResource.DEPTH_INFINITE, null);
-	   }
-	   if (!project.isOpen()) {
-		 project.open(null);
-	   }  
-	  
-	   //Fill out a project description
-	   IPath defaultPath = Platform.getLocation();
-	   IPath newPath = project.getFullPath();
-	   if (defaultPath.equals(newPath))
-		 newPath = null;
-	   IWorkspace workspace = ResourcesPlugin.getWorkspace();
-	   IProjectDescription description = workspace.newProjectDescription(project.getName());
-	   description.setLocation(newPath);
-	   //Create the project
-	   IProject cproject = CCorePlugin.getDefault().createCProject(description,project,monitor,CCorePlugin.PLUGIN_ID + ".make"); //.getCoreModel().create(project);
-   
-	   if (!project.hasNature(CProjectNature.C_NATURE_ID)) {
-				 addNatureToProject(project, CProjectNature.C_NATURE_ID, null);
-		}
-			 
-	   return cproject; 
-	}
-
-	/**
-	 * @param project
-	 * @param string
-	 * @param object
-	 */
-	private void addNatureToProject(IProject project, String string, Object object) {
-		// TODO Auto-generated method stub
-		
-	}
-
-	private void importFile(String fileName, String resourceLocation)throws Exception{
-	   //Obtain file handle
-	   file = testProject.getProject().getFile(fileName); 
-	   String pluginRoot=org.eclipse.core.runtime.Platform.getPlugin("org.eclipse.cdt.core.tests").find(new Path("/")).getFile();
-	   //Create file input stream
-	   monitor = new NullProgressMonitor();
-	   if (!file.exists()){
-		 file.create(new FileInputStream(pluginRoot + resourceLocation),false,monitor);
-	   }
-	   fileDoc = new IFileDocument(file);
-	}
-
-	private void addNatureToProject(IProject proj, String natureId, IProgressMonitor monitor) throws CoreException {
-		   IProjectDescription description = proj.getDescription();
-		   String[] prevNatures= description.getNatureIds();
-		   String[] newNatures= new String[prevNatures.length + 1];
-		   System.arraycopy(prevNatures, 0, newNatures, 0, prevNatures.length);
-		   newNatures[prevNatures.length]= natureId;
-		   description.setNatureIds(newNatures);
-		   proj.setDescription(description, monitor);
-	 }
-	 
-	 public void search(ICSearchPattern pattern, ICSearchResultCollector collector){
-	
-	 }
-	/*
-	 * Start of tests
-	 */ 
-	public void testSearchSimpleName() throws Exception {
-		//ICSearchPattern pattern = SearchEngine.createSearchPattern( "Mail", ICSearchConstants.TYPE, ICSearchConstants.DECLARATIONS , false );
-		//Create a new result collector
-		//CSearchResultCollector collector= new CSearchResultCollector();
-		
-			
-	}
-	
-	
-}
Index: search/org/eclipse/cdt/core/search/tests/FunctionMethodPatternTests.java
===================================================================
RCS file: search/org/eclipse/cdt/core/search/tests/FunctionMethodPatternTests.java
diff -N search/org/eclipse/cdt/core/search/tests/FunctionMethodPatternTests.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ search/org/eclipse/cdt/core/search/tests/FunctionMethodPatternTests.java	23 Jul 2003 20:28:32 -0000
@@ -0,0 +1,68 @@
+/*******************************************************************************
+ * Copyright (c) 2003 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials 
+ * are made available under the terms of the Common Public License v0.5 
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v05.html
+ * 
+ * Contributors:
+ *     IBM Corp. - Rational Software - initial implementation
+ ******************************************************************************/
+/*
+ * Created on Jul 23, 2003
+ */
+package org.eclipse.cdt.core.search.tests;
+
+import org.eclipse.cdt.core.search.ICSearchPattern;
+import org.eclipse.cdt.core.search.SearchEngine;
+import org.eclipse.cdt.internal.core.search.CharOperation;
+import org.eclipse.cdt.internal.core.search.matching.FunctionDeclarationPattern;
+import org.eclipse.cdt.internal.core.search.matching.MethodDeclarationPattern;
+
+/**
+ * @author aniefer
+ *
+ * To change the template for this generated type comment go to
+ * Window>Preferences>Java>Code Generation>Code and Comments
+ */
+public class FunctionMethodPatternTests extends BaseSearchTest {
+
+	/**
+	 * @param name
+	 */
+	public FunctionMethodPatternTests(String name) {
+		super(name);
+		// TODO Auto-generated constructor stub
+	}
+
+	public void testFunctionIndexPrefix(){
+		ICSearchPattern pattern = SearchEngine.createSearchPattern( "c()", FUNCTION, DECLARATIONS, true );
+		assertTrue( pattern instanceof FunctionDeclarationPattern );
+		
+		FunctionDeclarationPattern functionPattern = (FunctionDeclarationPattern)pattern;
+		assertEquals( CharOperation.compareWith( "functionDecl/c".toCharArray(), functionPattern.indexEntryPrefix() ), 0);
+		
+		functionPattern = (FunctionDeclarationPattern) SearchEngine.createSearchPattern( "rt*()", FUNCTION, DECLARATIONS, true );
+		assertEquals( CharOperation.compareWith( "functionDecl/rt".toCharArray(), functionPattern.indexEntryPrefix() ), 0);
+				
+		functionPattern = (FunctionDeclarationPattern) SearchEngine.createSearchPattern( "Ac", FUNCTION, REFERENCES, false );
+		assertEquals( CharOperation.compareWith( "functionRef/".toCharArray(), functionPattern.indexEntryPrefix() ), 0);
+	}
+	
+	public void testMethodIndexPrefix(){
+		ICSearchPattern pattern = SearchEngine.createSearchPattern( "A::B::c", METHOD, DECLARATIONS, true );
+		assertTrue( pattern instanceof MethodDeclarationPattern );
+		
+		MethodDeclarationPattern methodPattern = (MethodDeclarationPattern)pattern;
+		assertEquals( CharOperation.compareWith( "methodDecl/c/B/A".toCharArray(), methodPattern.indexEntryPrefix() ), 0);
+		
+		methodPattern = (MethodDeclarationPattern) SearchEngine.createSearchPattern( "::*::A::B::c", METHOD, DECLARATIONS, true );
+		assertEquals( CharOperation.compareWith( "methodDecl/c/B/A/".toCharArray(), methodPattern.indexEntryPrefix() ), 0);
+				
+		methodPattern = (MethodDeclarationPattern) SearchEngine.createSearchPattern( "::RT*::c", METHOD, REFERENCES, true );
+		assertEquals( CharOperation.compareWith( "methodRef/c/RT".toCharArray(), methodPattern.indexEntryPrefix() ), 0);
+				
+		methodPattern = (MethodDeclarationPattern) SearchEngine.createSearchPattern( "A::B::c", METHOD, REFERENCES, false );
+		assertEquals( CharOperation.compareWith( "methodRef/".toCharArray(), methodPattern.indexEntryPrefix() ), 0);
+	}
+}
Index: search/org/eclipse/cdt/core/search/tests/OtherPatternTests.java
===================================================================
RCS file: search/org/eclipse/cdt/core/search/tests/OtherPatternTests.java
diff -N search/org/eclipse/cdt/core/search/tests/OtherPatternTests.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ search/org/eclipse/cdt/core/search/tests/OtherPatternTests.java	23 Jul 2003 20:28:32 -0000
@@ -0,0 +1,87 @@
+/*******************************************************************************
+ * Copyright (c) 2003 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials 
+ * are made available under the terms of the Common Public License v0.5 
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v05.html
+ * 
+ * Contributors:
+ *     IBM Corp. - Rational Software - initial implementation
+ ******************************************************************************/
+/*
+ * Created on Jul 23, 2003
+ */
+package org.eclipse.cdt.core.search.tests;
+
+import org.eclipse.cdt.core.search.ICSearchPattern;
+import org.eclipse.cdt.core.search.SearchEngine;
+import org.eclipse.cdt.internal.core.search.CharOperation;
+import org.eclipse.cdt.internal.core.search.matching.FieldDeclarationPattern;
+import org.eclipse.cdt.internal.core.search.matching.NamespaceDeclarationPattern;
+import org.eclipse.cdt.internal.core.search.matching.VariableDeclarationPattern;
+
+/**
+ * @author aniefer
+ *
+ * To change the template for this generated type comment go to
+ * Window>Preferences>Java>Code Generation>Code and Comments
+ */
+public class OtherPatternTests extends BaseSearchTest {
+
+	/**
+	 * @param name
+	 */
+	public OtherPatternTests(String name) {
+		super(name);
+		// TODO Auto-generated constructor stub
+	}
+	
+	public void testNamespaceIndexPrefix(){
+		ICSearchPattern pattern = SearchEngine.createSearchPattern( "A::B::c", NAMESPACE, DECLARATIONS, true );
+		assertTrue( pattern instanceof NamespaceDeclarationPattern );
+		
+		NamespaceDeclarationPattern nsPattern = (NamespaceDeclarationPattern)pattern;
+		assertEquals( CharOperation.compareWith( "namespaceDecl/c/B/A".toCharArray(), nsPattern.indexEntryPrefix() ), 0);
+		
+		nsPattern = (NamespaceDeclarationPattern) SearchEngine.createSearchPattern( "::*::A::B::c", NAMESPACE, DECLARATIONS, true );
+		assertEquals( CharOperation.compareWith( "namespaceDecl/c/B/A/".toCharArray(), nsPattern.indexEntryPrefix() ), 0);
+				
+		nsPattern = (NamespaceDeclarationPattern) SearchEngine.createSearchPattern( "::RT*::c", NAMESPACE, REFERENCES, true );
+		assertEquals( CharOperation.compareWith( "namespaceRef/c/RT".toCharArray(), nsPattern.indexEntryPrefix() ), 0);
+				
+		nsPattern = (NamespaceDeclarationPattern) SearchEngine.createSearchPattern( "A::B::c", NAMESPACE, REFERENCES, false );
+		assertEquals( CharOperation.compareWith( "namespaceRef/".toCharArray(), nsPattern.indexEntryPrefix() ), 0);
+	}
+	
+	public void testVariableIndexPrefix(){
+		ICSearchPattern pattern = SearchEngine.createSearchPattern( "c", VAR, DECLARATIONS, true );
+		assertTrue( pattern instanceof VariableDeclarationPattern );
+		
+		VariableDeclarationPattern variablePattern = (VariableDeclarationPattern)pattern;
+		assertEquals( CharOperation.compareWith( "typeDecl/V/c".toCharArray(), variablePattern.indexEntryPrefix() ), 0);
+		
+		variablePattern = (VariableDeclarationPattern) SearchEngine.createSearchPattern( "rt*", VAR, DECLARATIONS, true );
+		assertEquals( CharOperation.compareWith( "typeDecl/V/rt".toCharArray(), variablePattern.indexEntryPrefix() ), 0);
+				
+		variablePattern = (VariableDeclarationPattern) SearchEngine.createSearchPattern( "Ac", VAR, REFERENCES, false );
+		assertEquals( CharOperation.compareWith( "typeRef/V/".toCharArray(), variablePattern.indexEntryPrefix() ), 0);
+	}
+	
+	public void testFieldIndexPrefix(){
+		ICSearchPattern pattern = SearchEngine.createSearchPattern( "A::B::c", FIELD, DECLARATIONS, true );
+		assertTrue( pattern instanceof FieldDeclarationPattern );
+		
+		FieldDeclarationPattern fieldPattern = (FieldDeclarationPattern)pattern;
+		assertEquals( CharOperation.compareWith( "fieldDecl/c/B/A".toCharArray(), fieldPattern.indexEntryPrefix() ), 0);
+		
+		fieldPattern = (FieldDeclarationPattern) SearchEngine.createSearchPattern( "::*::A::B::c", FIELD, DECLARATIONS, true );
+		assertEquals( CharOperation.compareWith( "fieldDecl/c/B/A/".toCharArray(), fieldPattern.indexEntryPrefix() ), 0);
+				
+		fieldPattern = (FieldDeclarationPattern) SearchEngine.createSearchPattern( "::RT*::c", FIELD, REFERENCES, true );
+		assertEquals( CharOperation.compareWith( "fieldRef/c/RT".toCharArray(), fieldPattern.indexEntryPrefix() ), 0);
+				
+		fieldPattern = (FieldDeclarationPattern) SearchEngine.createSearchPattern( "A::B::c", FIELD, REFERENCES, false );
+		assertEquals( CharOperation.compareWith( "fieldRef/".toCharArray(), fieldPattern.indexEntryPrefix() ), 0);
+	}
+
+}
Index: suite/org/eclipse/cdt/core/suite/AutomatedIntegrationSuite.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/suite/AutomatedIntegrationSuite.java,v
retrieving revision 1.5
diff -u -r1.5 AutomatedIntegrationSuite.java
--- suite/org/eclipse/cdt/core/suite/AutomatedIntegrationSuite.java	17 Jul 2003 20:15:03 -0000	1.5
+++ suite/org/eclipse/cdt/core/suite/AutomatedIntegrationSuite.java	23 Jul 2003 20:28:32 -0000
@@ -28,6 +28,8 @@
 import org.eclipse.cdt.core.parser.failedTests.STLFailedTests;
 import org.eclipse.cdt.core.parser.tests.ParserTestSuite;
 import org.eclipse.cdt.core.search.tests.ClassDeclarationPatternTests;
+import org.eclipse.cdt.core.search.tests.FunctionMethodPatternTests;
+import org.eclipse.cdt.core.search.tests.OtherPatternTests;
 import org.eclipse.cdt.core.indexer.tests.IndexManagerTests;
 import org.eclipse.core.boot.IPlatformRunnable;
 
@@ -81,6 +83,8 @@
 		suite.addTest(ElementDeltaTests.suite());
 		suite.addTest(WorkingCopyTests.suite());
 		suite.addTestSuite(ClassDeclarationPatternTests.class );
+		suite.addTestSuite(FunctionMethodPatternTests.class );
+		suite.addTestSuite(OtherPatternTests.class );		
 		suite.addTest(IndexManagerTests.suite());
 		
 		// Last test to trigger report generation
Index: index/ChangeLog
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/index/ChangeLog,v
retrieving revision 1.4
diff -u -r1.4 ChangeLog
--- index/ChangeLog	21 Jul 2003 21:14:06 -0000	1.4
+++ index/ChangeLog	23 Jul 2003 20:19:01 -0000
@@ -1,3 +1,15 @@
+2003-07-24 Andrew Niefer
+	Modified 
+	*index/org/eclipse/cdt/internal/core/search/indexing/AbstractIndexer.java
+		-changed so that the index prefixes contain the qualified names of the 
+		 elements in reverse order.
+		-Added functions:
+			bestVariablePrefix
+			bestNamespacePrefix
+			bestFieldPrefix
+			bestFunctionPrefix
+			bestMethodPrefix
+
 2003-07-21 Bogdan Gheorghe
 	Added additional declarations to index: enums, enumerators, namespace,
 	functions, vars, methods, fields, typedefs.
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.5
diff -u -r1.5 AbstractIndexer.java
--- index/org/eclipse/cdt/internal/core/search/indexing/AbstractIndexer.java	21 Jul 2003 21:14:06 -0000	1.5
+++ index/org/eclipse/cdt/internal/core/search/indexing/AbstractIndexer.java	23 Jul 2003 20:19:01 -0000
@@ -177,7 +177,7 @@
 			pos += tempName.length;
 		}
 		//Extract the qualifiers
-		for (int i=0; i<(fullTypeName.length - 1); i++){
+		for (int i=fullTypeName.length - 2; i >= 0; i--){
 			result[pos++] = SEPARATOR;
 			char [] tempName = fullTypeName[i].toCharArray();
 			System.arraycopy(tempName, 0, result, pos, tempName.length);
@@ -205,7 +205,7 @@
 			pos += tempName.length;
 		}
 		//Extract the qualifiers
-		for (int i=0; i<(elementName.length - 1); i++){
+		for (int i=elementName.length - 2; i>=0; i--){
 			result[pos++] = SEPARATOR;
 			char [] tempName = elementName[i].toCharArray();
 			System.arraycopy(tempName, 0, result, pos, tempName.length);
@@ -243,12 +243,7 @@
 	 * Type entries are encoded as follow: 'typeDecl/' ('C' | 'S' | 'U' ) '/'  TypeName '/' 
 	 * Current encoding is optimized for queries: all classes
 	 */
-	 public static final char[] bestTypeDeclarationPrefix(char[] typeName, char[][] containingTypes, ASTClassKind classKind, int matchMode, boolean isCaseSensitive) {
-		// index is case sensitive, thus in case attempting case insensitive search, cannot consider
-		// type name.
-		if (!isCaseSensitive){
-			typeName = null;
-		}
+	public static final char[] bestTypePrefix( LimitTo limitTo, char[] typeName, char[][] containingTypes, ASTClassKind classKind, int matchMode, boolean isCaseSensitive) {
 		//Class kind not provided, best we can do
 		if (classKind == null){
 			return TYPE_DECL;
@@ -261,107 +256,162 @@
 		else if (classKind == ASTClassKind.UNION){
 			classType = UNION_SUFFIX;
 		}
-		
-		switch(matchMode){
-			case EXACT_MATCH :
-			case PREFIX_MATCH :
-				break;
-			case PATTERN_MATCH :
-				if (typeName != null){
-					int starPos = CharOperation.indexOf('*', typeName);
-					switch(starPos) {
-						case -1 :
-							break;
-						case 0 :
-							typeName = null;
-							break;
-						default : 
-							typeName = CharOperation.subarray(typeName, 0, starPos);
-					}
-				}
+		else if (classKind == ASTClassKind.ENUM){
+			classType = ENUM_SUFFIX;
 		}
 		
-		int containingTypesLength=0; 
-		int typeLength = typeName == null ? 0 : typeName.length;
-		int pos;
-		//figure out the total length of the qualifiers
-		for (int i=0; i<containingTypes.length; i++){
-			containingTypesLength+= containingTypes[i].length;
-		}
-		//typed decl length + length of qualifiers + qualifier separators + name length + 2 (1 for name separator, 1 for letter)
-		char[] result = new char[TYPE_DECL_LENGTH + containingTypesLength + containingTypes.length + typeLength + 2 ];
-		System.arraycopy(TYPE_DECL, 0, result, 0, pos = TYPE_DECL_LENGTH);
-		result[pos++] = classType;
-		result[pos++] = SEPARATOR;
-		
-		if (typeLength > 0){
-			System.arraycopy(typeName, 0, result, pos, typeName.length);
-			pos += typeName.length;
+		char [] prefix = null;
+		if( limitTo == DECLARATIONS ){
+			prefix = TYPE_DECL;
+		} else if( limitTo == REFERENCES ){
+			prefix = TYPE_REF;
 		}
-				
-		for (int i=0; i<containingTypes.length; i++){
-			result[pos++] = SEPARATOR;
-			char[] tempName = containingTypes[i];
-			System.arraycopy(tempName, 0, result, pos, tempName.length);
-			pos += tempName.length;
+		
+		return bestPrefix( prefix, classType, typeName, containingTypes, matchMode, isCaseSensitive );
+	}
+	public static final char[] bestNamespacePrefix(LimitTo limitTo, char[] namespaceName, char[][] containingTypes, int matchMode, boolean isCaseSensitive) {
+		char [] prefix = null;
+		if( limitTo == REFERENCES ){
+			prefix = NAMESPACE_REF;
+		} else {
+			prefix = NAMESPACE_DECL;
+		}
+		return bestPrefix( prefix, (char) 0, namespaceName, containingTypes, matchMode, isCaseSensitive );
+	}	
+		
+	public static final char[] bestVariablePrefix( LimitTo limitTo, char[] varName, int matchMode, boolean isCaseSenstive ){
+		char [] prefix = null;
+		if( limitTo == REFERENCES ){
+			prefix = TYPE_REF;
+		} else {
+			prefix = TYPE_DECL;
 		}
 		
-		return result;
+		return bestPrefix( prefix, VAR_SUFFIX, varName, null, matchMode, isCaseSenstive );	
 	}
+
+	public static final char[] bestFieldPrefix( LimitTo limitTo, char[] fieldName,char[][] containingTypes, int matchMode, boolean isCaseSensitive) {
+		char [] prefix = null;
+		if( limitTo == REFERENCES ){
+			prefix = FIELD_REF;
+		} else {
+			prefix = FIELD_DECL;
+		}		
+		return bestPrefix( prefix, (char)0, fieldName, containingTypes, matchMode, isCaseSensitive );
+	}  
+
+	public static final char[] bestMethodPrefix( LimitTo limitTo, char[] methodName,char[][] containingTypes, int matchMode, boolean isCaseSensitive) {
+		char [] prefix = null;
+		if( limitTo == REFERENCES ){
+			prefix = METHOD_REF;
+		} else {
+			prefix = METHOD_DECL;
+		}		
+		return bestPrefix( prefix, (char)0, methodName, containingTypes, matchMode, isCaseSensitive );
+	}  
 	
-	public static final char[] bestNamespacePrefix(char[] namespaceName, char[][] containingTypes, int matchMode, boolean isCaseSensitive) {
-		   // index is case sensitive, thus in case attempting case insensitive search, cannot consider
-		   // type name.
-		   if (!isCaseSensitive){
-			   namespaceName = null;
-		   }
-		
-		   switch(matchMode){
-			   case EXACT_MATCH :
-			   case PREFIX_MATCH :
-				   break;
-			   case PATTERN_MATCH :
-				   if (namespaceName != null){
-					   int starPos = CharOperation.indexOf('*', namespaceName);
-					   switch(starPos) {
-						   case -1 :
-							   break;
-						   case 0 :
-							   namespaceName = null;
-							   break;
-						   default : 
-							   namespaceName = CharOperation.subarray(namespaceName, 0, starPos);
-					   }
-				   }
-		   }
-		
-		   int containingTypesLength=0; 
-		   int typeLength = namespaceName == null ? 0 : namespaceName.length;
-		   int pos;
-		   //figure out the total length of the qualifiers
-		   for (int i=0; i<containingTypes.length; i++){
-			   containingTypesLength+= containingTypes[i].length;
-		   }
-		   //typed decl length + length of qualifiers + qualifier separators + name length + 2 (1 for name separator, 1 for letter)
-		   char[] result = new char[TYPE_DECL_LENGTH + containingTypesLength + containingTypes.length + typeLength + 2 ];
-		   System.arraycopy(TYPE_DECL, 0, result, 0, pos = TYPE_DECL_LENGTH);
-		   //result[pos++] = classType;
-		   result[pos++] = SEPARATOR;
-		
-		   if (typeLength > 0){
-			   System.arraycopy(namespaceName, 0, result, pos, namespaceName.length);
-			   pos += namespaceName.length;
-		   }
+	public static final char[] bestFunctionPrefix( LimitTo limitTo, char[] functionName, int matchMode, boolean isCaseSensitive) {
+		char [] prefix = null;
+		if( limitTo == REFERENCES ){
+			prefix = FUNCTION_REF;
+		} else {
+			prefix = FUNCTION_DECL;
+		}		
+		return bestPrefix( prefix, (char)0, functionName, null, matchMode, isCaseSensitive );
+	}  
+		
+	public static final char[] bestPrefix( char [] prefix, char optionalType, char[] name, char[][] containingTypes, int matchMode, boolean isCaseSensitive) {
+		char[] 	result = null;
+		int 	pos    = 0;
+		
+		//length of prefix + separator
+		int length = prefix.length;
+		
+		//add length for optional type + another separator
+		if( optionalType != 0 )
+			length += 2;
+		
+		if (!isCaseSensitive){
+			//index is case sensitive, thus in case attempting case insensitive search, cannot consider
+			//type name.
+			name = null;
+		} else if( matchMode == PATTERN_MATCH && name != null ){
+			int starPos = CharOperation.indexOf( '*', name );
+			switch( starPos ){
+				case -1 : break;
+				case 0  : name = null;
+				default : name = CharOperation.subarray( name, 0, starPos );
+			}
+		}
+		//add length for name
+		if( name != null ){
+			length += name.length;
+		} else {
+			//name is null, don't even consider qualifications.
+			result = new char [ length ];
+			System.arraycopy( prefix, 0, result, 0, pos = prefix.length );
+			if( optionalType != 0){
+				result[ pos++ ] = optionalType;
+				result[ pos++ ] = SEPARATOR; 
+			}
+			return result;
+		}
+		 		
+		//add the total length of the qualifiers
+		//we don't want to mess with the contents of this array (treat it as constant)
+		//so check for wild cards later.
+		if( containingTypes != null ){
+			for( int i = 0; i < containingTypes.length; i++ ){
+				if( containingTypes[i].length > 0 ){
+					length += containingTypes[ i ].length;
+					length++; //separator
+				}
+			}
+		}
+		
+		//because we haven't checked qualifier wild cards yet, this array might turn out
+		//to be too long. So fill a temp array, then check the length after
+		char [] temp = new char [ length ];
+		
+		System.arraycopy( prefix, 0, temp, 0, pos = prefix.length );
+		
+		if( optionalType != 0 ){
+			temp[ pos++ ] = optionalType;
+			temp[ pos++ ] = SEPARATOR;
+		}
+		
+		System.arraycopy( name, 0, temp, pos, name.length );
+		pos += name.length;
+		
+		if( containingTypes != null ){
+			for( int i = containingTypes.length - 1; i >= 0; i-- ){
+				if( matchMode == PATTERN_MATCH ){
+					int starPos = CharOperation.indexOf( '*', containingTypes[i] );
+					if( starPos >= 0 ){
+						temp[ pos++ ] = SEPARATOR;
+						System.arraycopy( containingTypes[i], 0, temp, pos, starPos );
+						pos += starPos;
+						break;
+					}
+				}
 				
-		   for (int i=0; i<containingTypes.length; i++){
-			   result[pos++] = SEPARATOR;
-			   char[] tempName = containingTypes[i];
-			   System.arraycopy(tempName, 0, result, pos, tempName.length);
-			   pos += tempName.length;
-		   }
+				if( containingTypes[i].length > 0 ){
+					temp[ pos++ ] = SEPARATOR;
+					System.arraycopy( containingTypes[i], 0, temp, pos, containingTypes[i].length );
+					pos += containingTypes[i].length;
+				}
+			}
+		}
+	
+		if( pos < length ){
+			result = new char[ pos ];
+			System.arraycopy( temp, 0, result, 0, pos );	
+		} else {
+			result = temp;
+		}
 		
-		   return result;
-	   }
+		return result;
+	}   
 
 }
 
Index: search/ChangeLog
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/search/ChangeLog,v
retrieving revision 1.5
diff -u -r1.5 ChangeLog
--- search/ChangeLog	15 Jul 2003 14:43:50 -0000	1.5
+++ search/ChangeLog	23 Jul 2003 20:19:02 -0000
@@ -1,3 +1,14 @@
+2003-07-23 Andrew Niefer
+	-Changed ICSearchPattern.matchLevel to take a ISourceElementCallbackDelegate
+	-Changed ICSearchResultCollector.createMatch to take a ISourceElementCallbackDelegate
+	-first implementations of:
+		-CSearchPattern.createFunctionPattern
+		-CSearchPattern.createVariablePattern
+		-CSearchPattern.createMethodPattern
+	-preliminary matching for remaining patterns
+	-handling of remaining parser callbacks
+	-generating index Prefixes for the patterns
+
 2003-07-14 Andrew Niefer
 	-Modified SearchFor instances in ICSearchConstants to more closely match what we are searching for
 	-added IMatch interface, it represents matches found by the search engine, implementors can store
Index: search/org/eclipse/cdt/core/search/ICSearchPattern.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/search/org/eclipse/cdt/core/search/ICSearchPattern.java,v
retrieving revision 1.3
diff -u -r1.3 ICSearchPattern.java
--- search/org/eclipse/cdt/core/search/ICSearchPattern.java	15 Jul 2003 14:43:50 -0000	1.3
+++ search/org/eclipse/cdt/core/search/ICSearchPattern.java	23 Jul 2003 20:19:02 -0000
@@ -13,7 +13,7 @@
  */
 package org.eclipse.cdt.core.search;
 
-import org.eclipse.cdt.core.parser.ast.IASTOffsetableElement;
+import org.eclipse.cdt.core.parser.ISourceElementCallbackDelegate;
 
 /**
  * @author aniefer
@@ -32,7 +32,7 @@
 	 * @param node
 	 * @return
 	 */
-	int matchLevel( IASTOffsetableElement node );
+	int matchLevel( ISourceElementCallbackDelegate node );
 	
 	LimitTo   getLimitTo();
 }
Index: search/org/eclipse/cdt/core/search/ICSearchResultCollector.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/search/org/eclipse/cdt/core/search/ICSearchResultCollector.java,v
retrieving revision 1.4
diff -u -r1.4 ICSearchResultCollector.java
--- search/org/eclipse/cdt/core/search/ICSearchResultCollector.java	15 Jul 2003 14:43:50 -0000	1.4
+++ search/org/eclipse/cdt/core/search/ICSearchResultCollector.java	23 Jul 2003 20:19:02 -0000
@@ -13,8 +13,7 @@
  */
 package org.eclipse.cdt.core.search;
 
-import org.eclipse.cdt.core.model.ICElement;
-import org.eclipse.cdt.core.parser.ast.IASTOffsetableNamedElement;
+import org.eclipse.cdt.core.parser.ISourceElementCallbackDelegate;
 import org.eclipse.cdt.core.parser.ast.IASTScope;
 import org.eclipse.core.resources.IResource;
 import org.eclipse.core.runtime.CoreException;
@@ -98,5 +97,5 @@
 	 * @param node
 	 * @return
 	 */
-	public IMatch createMatch(IASTOffsetableNamedElement node, IASTScope parent );
+	public IMatch createMatch(ISourceElementCallbackDelegate node, IASTScope parent );
 }
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.9
diff -u -r1.9 CSearchPattern.java
--- search/org/eclipse/cdt/internal/core/search/matching/CSearchPattern.java	18 Jul 2003 16:39:22 -0000	1.9
+++ search/org/eclipse/cdt/internal/core/search/matching/CSearchPattern.java	23 Jul 2003 20:19:02 -0000
@@ -114,8 +114,21 @@
 	 * @return
 	 */
 	private static CSearchPattern createFunctionPattern(String patternString, LimitTo limitTo, int matchMode, boolean caseSensitive) {
-		// TODO Auto-generated method stub
-		return null;
+		int index = patternString.indexOf( '(' );
+		
+		String paramString = ( index == -1 ) ? "" : patternString.substring( index );
+		
+		String nameString = ( index == -1 ) ? patternString : patternString.substring( 0, index );
+				
+		IScanner scanner = ParserFactory.createScanner( new StringReader( paramString ), "TEXT", new ScannerInfo(), ParserMode.QUICK_PARSE, null );
+				
+		LinkedList params = scanForParameters( scanner );
+				
+		char [] name = nameString.toCharArray();
+		char [][] parameters = new char [0][];
+		parameters = (char[][])params.toArray( parameters );
+				
+		return new FunctionDeclarationPattern( name, parameters, matchMode, limitTo, caseSensitive );
 	}
 
 	/**
@@ -126,8 +139,7 @@
 	 * @return
 	 */
 	private static CSearchPattern createVariablePattern(String patternString, LimitTo limitTo, int matchMode, boolean caseSensitive) {
-		// TODO Auto-generated method stub
-		return null;
+		return new VariableDeclarationPattern( patternString.toCharArray(), matchMode, limitTo, caseSensitive );
 	}
 
 	/**
@@ -155,10 +167,28 @@
 	 * @return
 	 */
 	private static CSearchPattern createMethodPattern(String patternString, LimitTo limitTo, int matchMode, boolean caseSensitive) {
-		return null;
+		
+		int index = patternString.indexOf( '(' );
+		String paramString = ( index == -1 ) ? "" : patternString.substring( index );
+		String nameString = ( index == -1 ) ? patternString : patternString.substring( 0, index - 1 );
+		
+		IScanner scanner = ParserFactory.createScanner( new StringReader( nameString ), "TEXT", new ScannerInfo(), ParserMode.QUICK_PARSE, null );
+		
+		LinkedList names = scanForNames( scanner, null );
+		
+		scanner = ParserFactory.createScanner( new StringReader( paramString ), "TEXT", new ScannerInfo(), ParserMode.QUICK_PARSE, null );
+		
+		LinkedList params = scanForParameters( scanner );
+		
+		char [] name = (char [])names.removeLast();
+		char [][] qualifications = new char[0][];
+		qualifications = (char[][])names.toArray( qualifications );
+		char [][] parameters = new char [0][];
+		parameters = (char[][])params.toArray( parameters );
+		
+		return new MethodDeclarationPattern( name, qualifications, parameters, matchMode, limitTo, caseSensitive );
 	}
 
-
 	/**
 	 * @param patternString
 	 * @param limitTo
@@ -210,7 +240,61 @@
 		
 		return new ClassDeclarationPattern( name, (char[][])list.toArray( qualifications ), kind, matchMode, limitTo, caseSensitive );
 	}
-	
+
+
+
+	/**
+	 * @param scanner
+	 * @param object
+	 * @return
+	 */
+	private static LinkedList scanForParameters(IScanner scanner) {
+		LinkedList list = new LinkedList();
+		
+		String param = new String("");
+		
+		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;
+				}
+				
+				token = scanner.nextToken();
+			}
+		} catch ( EndOfFile e ){
+			list.addLast( param.toCharArray() );
+		} catch( ScannerException e ){
+		}
+		
+		return list;
+	}
+		
 	static private LinkedList scanForNames( IScanner scanner, IToken unusedToken ){
 		LinkedList list = new LinkedList();
 		
@@ -219,6 +303,8 @@
 		try {
 			IToken token = ( unusedToken != null ) ? unusedToken : scanner.nextToken();
 			
+			boolean lastTokenWasWild = false;
+			
 			while( true ){
 				switch( token.getType() ){
 					case IToken.tCOLONCOLON :
@@ -226,12 +312,12 @@
 						name = new String("");
 						break;
 					default:
-						if( token.getType() != IToken.tSTAR &&
-							token.getType() != IToken.tQUESTION &&
-							name.length() > 0 )
-						{
+						if( token.getType() == IToken.tSTAR || token.getType() == IToken.tQUESTION ){
+							lastTokenWasWild = true;
+						} else if( !lastTokenWasWild && name.length() > 0 ) {
 							name += " ";
 						}
+						
 						name += token.getImage();
 						break;
 				}
Index: search/org/eclipse/cdt/internal/core/search/matching/ClassDeclarationPattern.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/search/org/eclipse/cdt/internal/core/search/matching/ClassDeclarationPattern.java,v
retrieving revision 1.6
diff -u -r1.6 ClassDeclarationPattern.java
--- search/org/eclipse/cdt/internal/core/search/matching/ClassDeclarationPattern.java	15 Jul 2003 14:43:50 -0000	1.6
+++ search/org/eclipse/cdt/internal/core/search/matching/ClassDeclarationPattern.java	23 Jul 2003 20:19:02 -0000
@@ -15,11 +15,12 @@
 
 import java.io.IOException;
 
+import org.eclipse.cdt.core.parser.ISourceElementCallbackDelegate;
 import org.eclipse.cdt.core.parser.ast.ASTClassKind;
 import org.eclipse.cdt.core.parser.ast.IASTClassSpecifier;
 import org.eclipse.cdt.core.parser.ast.IASTEnumerationSpecifier;
-import org.eclipse.cdt.core.parser.ast.IASTOffsetableElement;
 import org.eclipse.cdt.core.parser.ast.IASTOffsetableNamedElement;
+import org.eclipse.cdt.core.parser.ast.IASTQualifiedNameElement;
 import org.eclipse.cdt.core.search.ICSearchScope;
 import org.eclipse.cdt.internal.core.index.IEntryResult;
 import org.eclipse.cdt.internal.core.index.impl.IndexInput;
@@ -57,7 +58,7 @@
 		limitTo = limit;
 	}
 	
-	public int matchLevel( IASTOffsetableElement node ){
+	public int matchLevel( ISourceElementCallbackDelegate node ){
 		
 		if( !( node instanceof IASTClassSpecifier ) && !( node instanceof IASTEnumerationSpecifier ) )
 			return IMPOSSIBLE_MATCH;
@@ -69,14 +70,7 @@
 			return IMPOSSIBLE_MATCH;
 		}
 
-		String [] fullyQualifiedName = null;
-		
-		if( node instanceof IASTClassSpecifier ){
-			IASTClassSpecifier clsSpec = (IASTClassSpecifier) node;
-			fullyQualifiedName = clsSpec.getFullyQualifiedName();		
-		} else {
-			//TODO fully qualified names for enums
-		}
+		String [] fullyQualifiedName = ((IASTQualifiedNameElement) node).getFullyQualifiedName();
 		
 		//check containing scopes
 		if( !matchQualifications( containingTypes, fullyQualifiedName ) ){
@@ -151,7 +145,8 @@
 	}
 
 	public char[] indexEntryPrefix() {
-		return AbstractIndexer.bestTypeDeclarationPrefix(
+		return AbstractIndexer.bestTypePrefix(
+				limitTo,
 				simpleName,
 				containingTypes,
 				classKind,
Index: search/org/eclipse/cdt/internal/core/search/matching/FieldDeclarationPattern.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/search/org/eclipse/cdt/internal/core/search/matching/FieldDeclarationPattern.java,v
retrieving revision 1.1
diff -u -r1.1 FieldDeclarationPattern.java
--- search/org/eclipse/cdt/internal/core/search/matching/FieldDeclarationPattern.java	15 Jul 2003 14:43:50 -0000	1.1
+++ search/org/eclipse/cdt/internal/core/search/matching/FieldDeclarationPattern.java	23 Jul 2003 20:19:02 -0000
@@ -13,6 +13,11 @@
  */
 package org.eclipse.cdt.internal.core.search.matching;
 
+import org.eclipse.cdt.core.parser.ISourceElementCallbackDelegate;
+import org.eclipse.cdt.core.parser.ast.IASTField;
+import org.eclipse.cdt.core.parser.ast.IASTQualifiedNameElement;
+import org.eclipse.cdt.internal.core.search.indexing.AbstractIndexer;
+
 
 /**
  * @author aniefer
@@ -29,9 +34,37 @@
 	 * @param limitTo
 	 * @param caseSensitive
 	 */
-	public FieldDeclarationPattern(char[] name, char[][] cs, int matchMode, LimitTo limitTo, boolean caseSensitive) {
+	public FieldDeclarationPattern(char[] name, char[][] qual, int matchMode, LimitTo limitTo, boolean caseSensitive) {
 		super( name, matchMode, limitTo, caseSensitive );
-		// TODO Auto-generated constructor stub
+		qualifications = qual;
 	}
 
+
+	public int matchLevel(ISourceElementCallbackDelegate node) {
+		if( !(node instanceof IASTField) ){
+			return IMPOSSIBLE_MATCH;
+		}
+		
+		if( super.matchLevel( node ) == IMPOSSIBLE_MATCH ){
+			return IMPOSSIBLE_MATCH;
+		}
+		
+		//check containing scopes
+		String [] fullyQualifiedName = ((IASTQualifiedNameElement) node).getFullyQualifiedName();
+		if( !matchQualifications( qualifications, fullyQualifiedName ) ){
+			return IMPOSSIBLE_MATCH;
+		}
+		
+		return ACCURATE_MATCH;
+	}
+	
+	public char[] indexEntryPrefix() {
+		return AbstractIndexer.bestFieldPrefix( _limitTo, simpleName, qualifications, _matchMode, _caseSensitive );
+	}
+	
+	protected boolean matchIndexEntry() {
+		return true;
+	}
+	
+	private char [][] qualifications;
 }
Index: search/org/eclipse/cdt/internal/core/search/matching/FunctionDeclarationPattern.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/search/org/eclipse/cdt/internal/core/search/matching/FunctionDeclarationPattern.java,v
retrieving revision 1.1
diff -u -r1.1 FunctionDeclarationPattern.java
--- search/org/eclipse/cdt/internal/core/search/matching/FunctionDeclarationPattern.java	15 Jul 2003 14:43:50 -0000	1.1
+++ search/org/eclipse/cdt/internal/core/search/matching/FunctionDeclarationPattern.java	23 Jul 2003 20:19:02 -0000
@@ -14,12 +14,19 @@
 package org.eclipse.cdt.internal.core.search.matching;
 
 import java.io.IOException;
+import java.util.Iterator;
 
-import org.eclipse.cdt.core.parser.ast.IASTOffsetableElement;
+import org.eclipse.cdt.core.parser.ISourceElementCallbackDelegate;
+import org.eclipse.cdt.core.parser.ast.IASTFunction;
+import org.eclipse.cdt.core.parser.ast.IASTOffsetableNamedElement;
+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.ICSearchScope;
 import org.eclipse.cdt.internal.core.index.IEntryResult;
 import org.eclipse.cdt.internal.core.index.impl.IndexInput;
 import org.eclipse.cdt.internal.core.search.IIndexSearchRequestor;
+import org.eclipse.cdt.internal.core.search.indexing.AbstractIndexer;
 
 /**
  * @author aniefer
@@ -29,14 +36,67 @@
  */
 public class FunctionDeclarationPattern extends CSearchPattern {
 
+	protected char[][] parameterNames;
+
+	protected char[] simpleName;
+
+	public FunctionDeclarationPattern(char[] name, char [][] params, int matchMode, LimitTo limitTo, boolean caseSensitive) {
+		super( matchMode, caseSensitive, limitTo );
+		
+		simpleName = name;
+		parameterNames = params;
+	}
+	
 	/* (non-Javadoc)
 	 * @see org.eclipse.cdt.core.search.ICSearchPattern#matchLevel(org.eclipse.cdt.core.parser.ast.IASTOffsetableElement)
 	 */
-	public int matchLevel(IASTOffsetableElement node) {
-		// TODO Auto-generated method stub
-		return 0;
+	public int matchLevel(ISourceElementCallbackDelegate node) {
+		if( !( node instanceof IASTFunction ) )
+			return IMPOSSIBLE_MATCH;
+			
+		IASTFunction function = (IASTFunction) node;
+		String nodeName = function.getName();
+		
+		//check name, if simpleName == null, its treated the same as "*"	
+		if( simpleName != null && !matchesName( simpleName, nodeName.toCharArray() ) ){
+			return IMPOSSIBLE_MATCH;
+		}
+		
+		if( parameterNames != null ){
+			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.
+				//or if this function has a parameter, but parameterNames only has null.
+				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;
+				}
+				
+				if( !matchesName( parameterNames[i], paramName.toCharArray() ) )
+					return IMPOSSIBLE_MATCH;
+			}
+			//if this function still has more parameters, it is not a match
+			if( params.hasNext() )
+				return IMPOSSIBLE_MATCH;
+		}
+		
+		return ACCURATE_MATCH;
 	}
 
+
 	/* (non-Javadoc)
 	 * @see org.eclipse.cdt.internal.core.search.matching.CSearchPattern#feedIndexRequestor(org.eclipse.cdt.internal.core.search.IIndexSearchRequestor, int, int[], org.eclipse.cdt.internal.core.index.impl.IndexInput, org.eclipse.cdt.core.search.ICSearchScope)
 	 */
@@ -57,16 +117,14 @@
 	 * @see org.eclipse.cdt.internal.core.search.matching.CSearchPattern#indexEntryPrefix()
 	 */
 	public char[] indexEntryPrefix() {
-		// TODO Auto-generated method stub
-		return null;
+		return AbstractIndexer.bestFunctionPrefix( _limitTo, simpleName, _matchMode, _caseSensitive );
 	}
 
 	/* (non-Javadoc)
 	 * @see org.eclipse.cdt.internal.core.search.matching.CSearchPattern#matchIndexEntry()
 	 */
 	protected boolean matchIndexEntry() {
-		// TODO Auto-generated method stub
-		return false;
+		return true;
 	}
 
 }
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.10
diff -u -r1.10 MatchLocator.java
--- search/org/eclipse/cdt/internal/core/search/matching/MatchLocator.java	21 Jul 2003 17:29:55 -0000	1.10
+++ search/org/eclipse/cdt/internal/core/search/matching/MatchLocator.java	23 Jul 2003 20:19:02 -0000
@@ -19,48 +19,17 @@
 import java.io.Reader;
 import java.util.Arrays;
 import java.util.HashMap;
+import java.util.Iterator;
 import java.util.LinkedList;
 
 import org.eclipse.cdt.core.parser.IParser;
 import org.eclipse.cdt.core.parser.IProblem;
 import org.eclipse.cdt.core.parser.IScanner;
+import org.eclipse.cdt.core.parser.ISourceElementCallbackDelegate;
 import org.eclipse.cdt.core.parser.ISourceElementRequestor;
 import org.eclipse.cdt.core.parser.ParserFactory;
 import org.eclipse.cdt.core.parser.ParserMode;
-import org.eclipse.cdt.core.parser.ast.ASTClassKind;
-import org.eclipse.cdt.core.parser.ast.IASTASMDefinition;
-import org.eclipse.cdt.core.parser.ast.IASTAbstractTypeSpecifierDeclaration;
-import org.eclipse.cdt.core.parser.ast.IASTClassReference;
-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.IASTEnumerationReference;
-import org.eclipse.cdt.core.parser.ast.IASTEnumerationSpecifier;
-import org.eclipse.cdt.core.parser.ast.IASTEnumerator;
-import org.eclipse.cdt.core.parser.ast.IASTField;
-import org.eclipse.cdt.core.parser.ast.IASTFieldReference;
-import org.eclipse.cdt.core.parser.ast.IASTFunction;
-import org.eclipse.cdt.core.parser.ast.IASTFunctionReference;
-import org.eclipse.cdt.core.parser.ast.IASTInclusion;
-import org.eclipse.cdt.core.parser.ast.IASTLinkageSpecification;
-import org.eclipse.cdt.core.parser.ast.IASTMacro;
-import org.eclipse.cdt.core.parser.ast.IASTMethod;
-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.IASTPointerToFunction;
-import org.eclipse.cdt.core.parser.ast.IASTPointerToMethod;
-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;
-import org.eclipse.cdt.core.parser.ast.IASTTypedefDeclaration;
-import org.eclipse.cdt.core.parser.ast.IASTTypedefReference;
-import org.eclipse.cdt.core.parser.ast.IASTUsingDeclaration;
-import org.eclipse.cdt.core.parser.ast.IASTUsingDirective;
-import org.eclipse.cdt.core.parser.ast.IASTVariable;
-import org.eclipse.cdt.core.parser.ast.IASTVariableReference;
+import org.eclipse.cdt.core.parser.ast.*;
 import org.eclipse.cdt.core.search.ICSearchConstants;
 import org.eclipse.cdt.core.search.ICSearchPattern;
 import org.eclipse.cdt.core.search.ICSearchResultCollector;
@@ -86,7 +55,6 @@
  */
 public class MatchLocator implements ISourceElementRequestor, ICSearchConstants {
 
-	
 	/**
 	 * 
 	 */
@@ -100,97 +68,122 @@
 
 	public void acceptProblem(IProblem problem) 								{	}
 	public void acceptMacro(IASTMacro macro) 									{	}
-	public void acceptVariable(IASTVariable variable) 							{	}
-	public void acceptFunctionDeclaration(IASTFunction function) 				{	}
 	public void acceptUsingDirective(IASTUsingDirective usageDirective) 		{	}
 	public void acceptUsingDeclaration(IASTUsingDeclaration usageDeclaration) 	{	}
 	public void acceptASMDefinition(IASTASMDefinition asmDefinition) 			{	}
-	public void acceptTypedefDeclaration(IASTTypedefDeclaration typedef) 								{	}
-	public void acceptEnumerator(IASTEnumerator enumerator) 					{	}
+	public void acceptTypedefDeclaration(IASTTypedefDeclaration typedef) 		{	}
+	
 	public void acceptAbstractTypeSpecDeclaration(IASTAbstractTypeSpecifierDeclaration abstractDeclaration) {}
 	public void acceptPointerToFunction(IASTPointerToFunction function) {}
 	public void acceptPointerToMethod(IASTPointerToMethod method)   { }
+	public void acceptTypedefReference( IASTTypedefReference reference )        {	}
 	
-	public void acceptEnumerationSpecifier(IASTEnumerationSpecifier enumeration){
-		if( searchPattern.getLimitTo() == DECLARATIONS || searchPattern.getLimitTo() == ALL_OCCURRENCES ){
-			if( searchPattern instanceof ClassDeclarationPattern ){
-				ClassDeclarationPattern classPattern = (ClassDeclarationPattern)searchPattern;
-				if( classPattern.getKind() == null || classPattern.getKind() == ASTClassKind.ENUM ){
-					int level = searchPattern.matchLevel( enumeration ); 
-					if(  level != ICSearchPattern.IMPOSSIBLE_MATCH ){
-						report( enumeration, level );				
-					}
-				}
-			}
-		}
-	}	
+	public void enterLinkageSpecification(IASTLinkageSpecification linkageSpec) {	}
+	public void enterTemplateDeclaration(IASTTemplateDeclaration declaration) 	{	}
+	public void enterTemplateSpecialization(IASTTemplateSpecialization specialization) 		{	}
+	public void enterTemplateInstantiation(IASTTemplateInstantiation instantiation) {	}
+
+	public void exitTemplateDeclaration(IASTTemplateDeclaration declaration) 	{}
+	public void exitTemplateSpecialization(IASTTemplateSpecialization specialization) 		{	}
+	public void exitTemplateExplicitInstantiation(IASTTemplateInstantiation instantiation) 	{	}
+	public void exitLinkageSpecification(IASTLinkageSpecification linkageSpec) 	{	}
+	
+	public void acceptVariable(IASTVariable variable){
+		check( DECLARATIONS, VariableDeclarationPattern.class, variable );   
+	}
+	
+	public void acceptField(IASTField field){ 
+		check( DECLARATIONS, FieldDeclarationPattern.class, field ); 	   
+	}
+	
+	public void acceptEnumerationSpecifier(IASTEnumerationSpecifier enumeration){ 
+		check( DECLARATIONS, ClassDeclarationPattern.class, enumeration );
+		Iterator iter = enumeration.getEnumerators();
+		while( iter.hasNext() ){
+			check ( DECLARATIONS, FieldDeclarationPattern.class, (ISourceElementCallbackDelegate) iter.next() );
+		}  
+	}
+		
+	public void acceptFunctionDeclaration(IASTFunction function){
+		check( DECLARATIONS, FunctionDeclarationPattern.class, function );
+	}
+	
+	public void acceptMethodDeclaration(IASTMethod method){
+		check( DECLARATIONS, MethodDeclarationPattern.class, method );
+	}
+		
+	public void acceptClassReference(IASTClassReference reference) {
+		check( REFERENCES, ClassDeclarationPattern.class, reference );
+	}
+	
+	public void acceptNamespaceReference( IASTNamespaceReference reference ){
+		check( REFERENCES, NamespaceDeclarationPattern.class, reference );
+	}
+	
+	public void acceptVariableReference( IASTVariableReference reference ){
+		check( REFERENCES, VariableDeclarationPattern.class, reference );		
+	}
+	
+	public void acceptFieldReference( IASTFieldReference reference ){
+		check( REFERENCES, FieldDeclarationPattern.class, reference );
+	}
 	
-	public void acceptClassReference(IASTClassReference reference) {	}
-	public void acceptTypedefReference( IASTTypedefReference reference ){	}
-	public void acceptNamespaceReference( IASTNamespaceReference reference ){	}
-	public void acceptEnumerationReference( IASTEnumerationReference reference ){	}
-	public void acceptVariableReference( IASTVariableReference reference ){	}
-	public void acceptFunctionReference( IASTFunctionReference reference ){	}
-	public void acceptFieldReference( IASTFieldReference reference ){	}
-	public void acceptMethodReference( IASTMethodReference reference ) {	}
+	public void acceptEnumerationReference( IASTEnumerationReference reference ){
+		check( REFERENCES, ClassDeclarationPattern.class, reference );
+	}
+	
+	public void acceptFunctionReference( IASTFunctionReference reference ){
+		check( REFERENCES, FunctionDeclarationPattern.class,  reference );
+	}
 	
-	public void acceptMethodDeclaration(IASTMethod method) 						{	}
-	public void acceptField(IASTField field) 									{	}
+	public void acceptMethodReference( IASTMethodReference reference ){
+		check( REFERENCES, MethodDeclarationPattern.class, reference );	
+	}
 	
 	public void enterFunctionBody(IASTFunction function){
+		check( DEFINITIONS, FunctionDeclarationPattern.class, function );
 		pushScope( function );
 	}
 	
+	public void enterMethodBody(IASTMethod method) {
+		check( DEFINITIONS, MethodDeclarationPattern.class, method );
+		pushScope( method );
+	}
+	
 	public void enterCompilationUnit(IASTCompilationUnit compilationUnit) {
 		pushScope( compilationUnit );
 	}
 	
 	public void enterNamespaceDefinition(IASTNamespaceDefinition namespaceDefinition) {
-		if( searchPattern.getLimitTo() == DECLARATIONS || searchPattern.getLimitTo() == ALL_OCCURRENCES ){
-			if( searchPattern instanceof NamespaceDeclarationPattern ){
-				int level = searchPattern.matchLevel( namespaceDefinition ); 
-				if(  level != ICSearchPattern.IMPOSSIBLE_MATCH ){
-					report( namespaceDefinition, level );				
-				}
-			}
-		}			
-				
+		check( DECLARATIONS, NamespaceDeclarationPattern.class, namespaceDefinition );			
 		pushScope( namespaceDefinition );
 	}
-	
-	public void enterLinkageSpecification(IASTLinkageSpecification linkageSpec) {	}
-	public void enterTemplateDeclaration(IASTTemplateDeclaration declaration) 	{	}
-	public void enterTemplateSpecialization(IASTTemplateSpecialization specialization) 		{	}
-	public void enterTemplateInstantiation(IASTTemplateInstantiation instantiation) {	}
-	
-	public void enterMethodBody(IASTMethod method) {
-		pushScope( method );
+
+	public void enterClassSpecifier(IASTClassSpecifier classSpecification) {
+		check( DECLARATIONS, ClassDeclarationPattern.class, classSpecification );		
+		pushScope( classSpecification );
 	}
 	
 	public void exitFunctionBody(IASTFunction function) {
 		popScope();	
 	}
+
 	public void exitMethodBody(IASTMethod method) {
 		popScope();	
 	}
-	
-	public void exitTemplateDeclaration(IASTTemplateDeclaration declaration) 	{}
-	public void exitTemplateSpecialization(IASTTemplateSpecialization specialization) 		{	}
-	public void exitTemplateExplicitInstantiation(IASTTemplateInstantiation instantiation) 	{	}
-	public void exitLinkageSpecification(IASTLinkageSpecification linkageSpec) 	{	}
-	
+
 	public void exitClassSpecifier(IASTClassSpecifier classSpecification) {
 		popScope();
 	}
-	
+
 	public void exitNamespaceDefinition(IASTNamespaceDefinition namespaceDefinition) {
 		popScope();
 	}
-	
+
 	public void exitCompilationUnit(IASTCompilationUnit compilationUnit){
 		popScope();
 	}
-
+	
 	public void enterInclusion(IASTInclusion inclusion) {
 		String includePath = inclusion.getFullFileName();
 
@@ -227,17 +220,6 @@
 		}
 	}
 		
-	public void enterClassSpecifier(IASTClassSpecifier classSpecification) {
-		if( searchPattern.getLimitTo() == DECLARATIONS || searchPattern.getLimitTo() == ALL_OCCURRENCES ){
-			if( searchPattern instanceof ClassDeclarationPattern ){
-				int level = searchPattern.matchLevel( classSpecification ); 
-				if(  level != ICSearchPattern.IMPOSSIBLE_MATCH ){
-					report( classSpecification, level );				
-				}
-			}
-		}			
-		pushScope( classSpecification );
-	}
 
 	public void locateMatches( String [] paths, IWorkspace workspace, IWorkingCopy[] workingCopies ){
 		workspaceRoot = (workspace != null) ? workspace.getRoot() : null;
@@ -269,8 +251,12 @@
 		}
 		
 		for( int i = 0; i < length; i++ ){
-			if( progressMonitor != null &&  progressMonitor.isCanceled() ){
-				throw new OperationCanceledException();
+			if( progressMonitor != null ) {
+				if( progressMonitor.isCanceled() ){
+					throw new OperationCanceledException();
+				} else {
+					progressMonitor.worked( 1 );
+				}
 			}
 			
 			String pathString = paths[ i ];
@@ -318,37 +304,59 @@
 		}
 	}
 	
-	protected void report( IASTOffsetableNamedElement node, int accuracyLevel ){
+	protected void report( ISourceElementCallbackDelegate node, int accuracyLevel ){
 		try {
-			if( progressMonitor != null ) {
-				if( progressMonitor.isCanceled() ) {
-					throw new OperationCanceledException();
-				} else {
-					progressMonitor.worked( 1 );
-				}
-			}
+			int offset = 0;
+			int length = 0;
 			
-			int offset = node.getNameOffset();
-			if( offset == 0 )
-				offset = node.getStartingOffset();
-				
+			if( node instanceof IASTReference ){
+				IASTReference reference = (IASTReference) node;
+				offset = reference.getOffset();
+				length = reference.getName().length();
+			} else if( node instanceof IASTOffsetableNamedElement ){
+				IASTOffsetableNamedElement offsetableElement = (IASTOffsetableNamedElement) node;
+				offset = offsetableElement.getNameOffset() != 0 ? offsetableElement.getNameOffset() 
+															    : offsetableElement.getStartingOffset();
+				length = offsetableElement.getName().length();															  
+			}
+						
 			if( currentResource != null ){
 				
 				resultCollector.accept( currentResource, 
-								  offset, 
-								  offset + node.getName().length(), 
-								  resultCollector.createMatch( node, currentScope ), 
-								  accuracyLevel );
+									    offset, 
+									    offset + length, 
+									    resultCollector.createMatch( node, currentScope ), 
+									    accuracyLevel );
+									    
 			} else if( currentPath != null ){
+				
 				resultCollector.accept( currentPath, 
 										offset, 
-										offset + node.getName().length(), 
+										offset + length, 
 										resultCollector.createMatch( node, currentScope ), 
 										accuracyLevel );				
 			}
 		} catch (CoreException e) {
-			// TODO Auto-generated catch block
-			e.printStackTrace();
+		}
+	}
+
+	private void check( LimitTo limit, Class patternClass, ISourceElementCallbackDelegate node ){
+		if( searchPattern.getLimitTo() != limit && searchPattern.getLimitTo() != ALL_OCCURRENCES )
+			return;
+			
+		if( searchPattern.getClass() == patternClass ){
+			int level = ICSearchPattern.IMPOSSIBLE_MATCH;
+			
+			if( node instanceof IASTReference ){
+				level = searchPattern.matchLevel( ((IASTReference)node).getReferencedElement() );
+			} else  {
+				level = searchPattern.matchLevel(  node );
+			} 
+			
+			if( level != ICSearchPattern.IMPOSSIBLE_MATCH )
+			{
+				report( node, level );
+			}
 		}
 	}
 	
@@ -375,5 +383,6 @@
 	
 	private IASTScope				currentScope = null;
 	private LinkedList				scopeStack = new LinkedList();
+
 
 }
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.1
diff -u -r1.1 MethodDeclarationPattern.java
--- search/org/eclipse/cdt/internal/core/search/matching/MethodDeclarationPattern.java	15 Jul 2003 14:43:50 -0000	1.1
+++ search/org/eclipse/cdt/internal/core/search/matching/MethodDeclarationPattern.java	23 Jul 2003 20:19:02 -0000
@@ -13,6 +13,10 @@
  */
 package org.eclipse.cdt.internal.core.search.matching;
 
+import org.eclipse.cdt.core.parser.ISourceElementCallbackDelegate;
+import org.eclipse.cdt.core.parser.ast.*;
+import org.eclipse.cdt.internal.core.search.indexing.AbstractIndexer;
+
 /**
  * @author aniefer
  *
@@ -21,4 +25,38 @@
  */
 public class MethodDeclarationPattern extends FunctionDeclarationPattern {
 
+	private char[][] qualifications;
+
+
+	public MethodDeclarationPattern(char[] name, char[][] qual, char [][] params, int matchMode, LimitTo limitTo, boolean caseSensitive) {
+		super( name, params, matchMode, limitTo, caseSensitive );
+		qualifications = qual;
+	}
+
+
+	public int matchLevel(ISourceElementCallbackDelegate node) {
+		if( !(node instanceof IASTMethod) ){
+			return IMPOSSIBLE_MATCH;
+		}
+		
+		if( super.matchLevel( node ) == IMPOSSIBLE_MATCH ){
+			return IMPOSSIBLE_MATCH;
+		}
+		
+		//check containing scopes
+		String [] fullyQualifiedName = ((IASTQualifiedNameElement) node).getFullyQualifiedName();
+		if( !matchQualifications( qualifications, fullyQualifiedName ) ){
+			return IMPOSSIBLE_MATCH;
+		}
+		
+		return ACCURATE_MATCH;
+	}
+	
+	public char[] indexEntryPrefix() {
+		return AbstractIndexer.bestMethodPrefix( _limitTo, simpleName, qualifications, _matchMode, _caseSensitive );
+	}
+	
+	protected boolean matchIndexEntry() {
+		return true;
+	}
 }
Index: search/org/eclipse/cdt/internal/core/search/matching/NamespaceDeclarationPattern.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/search/org/eclipse/cdt/internal/core/search/matching/NamespaceDeclarationPattern.java,v
retrieving revision 1.1
diff -u -r1.1 NamespaceDeclarationPattern.java
--- search/org/eclipse/cdt/internal/core/search/matching/NamespaceDeclarationPattern.java	15 Jul 2003 14:43:50 -0000	1.1
+++ search/org/eclipse/cdt/internal/core/search/matching/NamespaceDeclarationPattern.java	23 Jul 2003 20:19:02 -0000
@@ -15,12 +15,13 @@
 
 import java.io.IOException;
 
+import org.eclipse.cdt.core.parser.ISourceElementCallbackDelegate;
 import org.eclipse.cdt.core.parser.ast.IASTNamespaceDefinition;
-import org.eclipse.cdt.core.parser.ast.IASTOffsetableElement;
 import org.eclipse.cdt.core.search.ICSearchScope;
 import org.eclipse.cdt.internal.core.index.IEntryResult;
 import org.eclipse.cdt.internal.core.index.impl.IndexInput;
 import org.eclipse.cdt.internal.core.search.IIndexSearchRequestor;
+import org.eclipse.cdt.internal.core.search.indexing.AbstractIndexer;
 
 /**
  * @author aniefer
@@ -48,7 +49,7 @@
 	/* (non-Javadoc)
 	 * @see org.eclipse.cdt.core.search.ICSearchPattern#matchLevel(org.eclipse.cdt.core.parser.ast.IASTOffsetableElement)
 	 */
-	public int matchLevel(IASTOffsetableElement node) {
+	public int matchLevel(ISourceElementCallbackDelegate node) {
 		if( !( node instanceof IASTNamespaceDefinition ) )
 			return IMPOSSIBLE_MATCH;
 			
@@ -87,16 +88,19 @@
 	 * @see org.eclipse.cdt.internal.core.search.matching.CSearchPattern#indexEntryPrefix()
 	 */
 	public char[] indexEntryPrefix() {
-		// TODO Auto-generated method stub
-		return null;
+		return AbstractIndexer.bestNamespacePrefix(
+				_limitTo,
+				_name,
+				_qualifications,
+				_matchMode, _caseSensitive
+		);
 	}
-
 	/* (non-Javadoc)
 	 * @see org.eclipse.cdt.internal.core.search.matching.CSearchPattern#matchIndexEntry()
 	 */
 	protected boolean matchIndexEntry() {
 		// TODO Auto-generated method stub
-		return false;
+		return true;
 	}
 
 }
Index: search/org/eclipse/cdt/internal/core/search/matching/VariableDeclarationPattern.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/search/org/eclipse/cdt/internal/core/search/matching/VariableDeclarationPattern.java,v
retrieving revision 1.1
diff -u -r1.1 VariableDeclarationPattern.java
--- search/org/eclipse/cdt/internal/core/search/matching/VariableDeclarationPattern.java	15 Jul 2003 14:43:50 -0000	1.1
+++ search/org/eclipse/cdt/internal/core/search/matching/VariableDeclarationPattern.java	23 Jul 2003 20:19:02 -0000
@@ -15,11 +15,14 @@
 
 import java.io.IOException;
 
-import org.eclipse.cdt.core.parser.ast.IASTOffsetableElement;
+import org.eclipse.cdt.core.parser.ISourceElementCallbackDelegate;
+import org.eclipse.cdt.core.parser.ast.IASTOffsetableNamedElement;
+import org.eclipse.cdt.core.parser.ast.IASTVariable;
 import org.eclipse.cdt.core.search.ICSearchScope;
 import org.eclipse.cdt.internal.core.index.IEntryResult;
 import org.eclipse.cdt.internal.core.index.impl.IndexInput;
 import org.eclipse.cdt.internal.core.search.IIndexSearchRequestor;
+import org.eclipse.cdt.internal.core.search.indexing.AbstractIndexer;
 
 /**
  * @author aniefer
@@ -38,14 +41,25 @@
 	public VariableDeclarationPattern(char[] name, int matchMode, LimitTo limitTo, boolean caseSensitive) {
 		super( matchMode, caseSensitive, limitTo );
 		
+		simpleName = name;
 	}
 
 	/* (non-Javadoc)
 	 * @see org.eclipse.cdt.core.search.ICSearchPattern#matchLevel(org.eclipse.cdt.core.parser.ast.IASTOffsetableElement)
 	 */
-	public int matchLevel(IASTOffsetableElement node) {
-		// TODO Auto-generated method stub
-		return 0;
+	public int matchLevel(ISourceElementCallbackDelegate node) {
+		if( !(node instanceof IASTVariable) ){
+			return IMPOSSIBLE_MATCH;
+		}
+		
+		String nodeName = ((IASTOffsetableNamedElement)node).getName();
+		
+		//check name, if simpleName == null, its treated the same as "*"	
+		if( simpleName != null && !matchesName( simpleName, nodeName.toCharArray() ) ){
+			return IMPOSSIBLE_MATCH;
+		}
+		
+		return ACCURATE_MATCH;
 	}
 
 	/* (non-Javadoc)
@@ -68,16 +82,20 @@
 	 * @see org.eclipse.cdt.internal.core.search.matching.CSearchPattern#indexEntryPrefix()
 	 */
 	public char[] indexEntryPrefix() {
-		// TODO Auto-generated method stub
-		return null;
+		return AbstractIndexer.bestVariablePrefix(
+						_limitTo,
+						simpleName,
+						_matchMode, _caseSensitive
+		);
 	}
 
 	/* (non-Javadoc)
 	 * @see org.eclipse.cdt.internal.core.search.matching.CSearchPattern#matchIndexEntry()
 	 */
 	protected boolean matchIndexEntry() {
-		// TODO Auto-generated method stub
-		return false;
+		return true;
 	}
+	
+	protected char [] simpleName;
 
 }

Back to the top