Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[cdt-patch] C++ Search UI

Core:
For bug42815
- Modified ICSearchResultCollector.createMatch to not take a parent 
parameter
- modified BasicSearchResultCollector to create the parent string from the 
fully qualified name of the node
- modified MatchLocator to keep track of most recent declaration for 
reporting purposes
- modified MatchLocator.report to use the most recent declaration

Core.Tests:
- Created search/SearchTestSuite
- Added SearchTestSuite to AutomatedIntegrationSuite and removed the 
individual search tests
- Added testReferencesInFunction to ClassDeclarationPatternTests
- Modified resources/search/classDecl.cpp
- Modified testNamespaceReferenceInClassBaseClause, testMacroPattern, 
testEnumerators, 
  and testEnumeratorReferences in OtherPatternTests to test the Match 
result strings

UI:
- bug42837 - fixed populating search dialog on function declarations
- bug42829 - prepopulated search dialog to any element declarations
- bug42815 - group together search results with same label
- modified CSearchResultLabelProvider to not display the "-" in the search 
label
  while sorting by name if there is no parent.

-Andrew

Index: search/ChangeLog
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/search/ChangeLog,v
retrieving revision 1.22
diff -u -r1.22 ChangeLog
--- search/ChangeLog	9 Sep 2003 15:46:38 -0000	1.22
+++ search/ChangeLog	11 Sep 2003 18:31:31 -0000
@@ -1,3 +1,9 @@
+2003-09-11 Andrew Niefer
+	- Modified ICSearchResultCollector.createMatch to not take a parent parameter
+	- modified BasicSearchResultCollector to create the parent string from the fully qualified name of the node
+	- modified MatchLocator to keep track of most recent declaration for reporting purposes
+	- modified MatchLocator.report to use the most recent declaration
+
 2003-09-09 Andrew Niefer
 	pattern matching on function parameters:
 	 - modified scanForParameters in CSearchPattern
Index: search/org/eclipse/cdt/core/search/BasicSearchResultCollector.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/search/org/eclipse/cdt/core/search/BasicSearchResultCollector.java,v
retrieving revision 1.5
diff -u -r1.5 BasicSearchResultCollector.java
--- search/org/eclipse/cdt/core/search/BasicSearchResultCollector.java	20 Aug 2003 20:53:50 -0000	1.5
+++ search/org/eclipse/cdt/core/search/BasicSearchResultCollector.java	11 Sep 2003 18:31:31 -0000
@@ -36,7 +36,6 @@
 import org.eclipse.cdt.core.parser.ast.IASTParameterDeclaration;
 import org.eclipse.cdt.core.parser.ast.IASTQualifiedNameElement;
 import org.eclipse.cdt.core.parser.ast.IASTReference;
-import org.eclipse.cdt.core.parser.ast.IASTScope;
 import org.eclipse.cdt.core.parser.ast.IASTSimpleTypeSpecifier;
 import org.eclipse.cdt.core.parser.ast.IASTTypeSpecifier;
 import org.eclipse.cdt.core.parser.ast.IASTVariable;
@@ -64,13 +63,13 @@
 		return null;
 	}
 
-	public IMatch createMatch(Object fileResource, int start, int end, ISourceElementCallbackDelegate node, IASTScope parent) throws CoreException 
+	public IMatch createMatch(Object fileResource, int start, int end, ISourceElementCallbackDelegate node ) throws CoreException 
 	{
 		BasicSearchMatch result = new BasicSearchMatch();
-		return createMatch( result, fileResource, start, end, node, parent );
+		return createMatch( result, fileResource, start, end, node );
 	}
 	
-	public IMatch createMatch( BasicSearchMatch result, Object fileResource, int start, int end, ISourceElementCallbackDelegate node, IASTScope parent) throws CoreException {
+	public IMatch createMatch( BasicSearchMatch result, Object fileResource, int start, int end, ISourceElementCallbackDelegate node ) throws CoreException {
 		if( fileResource instanceof IResource )
 			result.resource = (IResource) fileResource;
 		else if( fileResource instanceof IPath )
@@ -78,26 +77,34 @@
 			
 		result.startOffset = start;
 		result.endOffset = end;
-		
 		result.parentName = "";
-		if( parent instanceof IASTQualifiedNameElement ){
-			String [] names = ((IASTQualifiedNameElement)parent).getFullyQualifiedName();
-			for( int i = 0; i < names.length; i++ ){
-				if( i > 0 )
-					result.parentName += "::";
-					
-				result.parentName += names[ i ];
-			}
-		}
 		
 		IASTOffsetableNamedElement offsetable = null;
-		
+
 		if( node instanceof IASTReference ){
 			offsetable = (IASTOffsetableNamedElement) ((IASTReference)node).getReferencedElement();
 			result.name = ((IASTReference)node).getName();
 		} else if( node instanceof IASTOffsetableNamedElement ){
 			offsetable = (IASTOffsetableNamedElement)node;
 			result.name = offsetable.getName();
+		}
+		
+		result.parentName = "";
+		String [] names = null;
+		if( offsetable instanceof IASTEnumerator ){
+			IASTEnumerator enumerator = (IASTEnumerator) offsetable;
+			names = enumerator.getOwnerEnumerationSpecifier().getFullyQualifiedName();
+		} else if( offsetable instanceof IASTQualifiedNameElement ) {
+			names = ((IASTQualifiedNameElement) offsetable).getFullyQualifiedName();
+		}
+
+		if( names != null ){
+			for( int i = 0; i < names.length - 1; i++ ){
+				if( i > 0 )
+					result.parentName += "::";
+			
+				result.parentName += names[ i ];
+			}
 		}
 		
 		if( offsetable instanceof IASTFunction ){
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.7
diff -u -r1.7 ICSearchResultCollector.java
--- search/org/eclipse/cdt/core/search/ICSearchResultCollector.java	1 Aug 2003 19:26:50 -0000	1.7
+++ search/org/eclipse/cdt/core/search/ICSearchResultCollector.java	11 Sep 2003 18:31:31 -0000
@@ -14,7 +14,6 @@
 package org.eclipse.cdt.core.search;
 
 import org.eclipse.cdt.core.parser.ISourceElementCallbackDelegate;
-import org.eclipse.cdt.core.parser.ast.IASTScope;
 import org.eclipse.core.runtime.CoreException;
 import org.eclipse.core.runtime.IProgressMonitor;
 
@@ -46,24 +45,9 @@
 	 * Called when the search has ended.
 	 */
 	public void done();
-	
-	/**
-	 * Accepts the given search result.
-	 *
-	 * @param resource the resource in which the match has been found
-	 * @param start the start position of the match, -1 if it is unknown
-	 * @param end the end position of the match, -1 if it is unknown;
-	 *  the ending offset is exclusive, meaning that the actual range of characters 
-	 *  covered is <code>[start, end]</code>
-	 * @param enclosingObject an object that contains the character range
-	 *	<code>[start, end]</code>; the value can be <code>null</code> indicating that
-	 *	no enclosing object has been found
-	 * @param accuracy the level of accuracy the search result has; either
-	 *  <code>EXACT_MATCH</code> or <code>POTENTIAL_MATCH</code>
-	 * @exception CoreException if this collector had a problem accepting the search result
-	 */
+
 	public IMatch createMatch( Object fileResource, int start, int end, 
-						ISourceElementCallbackDelegate node, IASTScope parent) throws CoreException;
+						ISourceElementCallbackDelegate node ) throws CoreException;
 	
 	//return whether or not the match was accepted
 	public boolean acceptMatch( IMatch match ) throws CoreException;
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.26
diff -u -r1.26 MatchLocator.java
--- search/org/eclipse/cdt/internal/core/search/matching/MatchLocator.java	11 Sep 2003 18:05:55 -0000	1.26
+++ search/org/eclipse/cdt/internal/core/search/matching/MatchLocator.java	11 Sep 2003 18:31:31 -0000
@@ -44,6 +44,7 @@
 import org.eclipse.cdt.core.parser.ast.IASTElaboratedTypeSpecifier;
 import org.eclipse.cdt.core.parser.ast.IASTEnumerationReference;
 import org.eclipse.cdt.core.parser.ast.IASTEnumerationSpecifier;
+import org.eclipse.cdt.core.parser.ast.IASTEnumerator;
 import org.eclipse.cdt.core.parser.ast.IASTEnumeratorReference;
 import org.eclipse.cdt.core.parser.ast.IASTField;
 import org.eclipse.cdt.core.parser.ast.IASTFieldReference;
@@ -141,26 +142,33 @@
 	}
 	
 	public void acceptVariable(IASTVariable variable){
+		lastDeclaration = variable;
 		check( DECLARATIONS, variable );   
 	}
 	
-	public void acceptField(IASTField field){ 
+	public void acceptField(IASTField field){
+		lastDeclaration = field; 
 		check( DECLARATIONS, field ); 	   
 	}
 	
-	public void acceptEnumerationSpecifier(IASTEnumerationSpecifier enumeration){ 
+	public void acceptEnumerationSpecifier(IASTEnumerationSpecifier enumeration){
+		lastDeclaration = enumeration; 
 		check( DECLARATIONS, enumeration );
 		Iterator iter = enumeration.getEnumerators();
 		while( iter.hasNext() ){
-			check ( DECLARATIONS, (ISourceElementCallbackDelegate) iter.next() );
+			IASTEnumerator enumerator = (IASTEnumerator) iter.next();
+			lastDeclaration = enumerator;
+			check ( DECLARATIONS, enumerator );
 		}  
 	}
 		
 	public void acceptFunctionDeclaration(IASTFunction function){
+		lastDeclaration = function;
 		check( DECLARATIONS, function );
 	}
 	
 	public void acceptMethodDeclaration(IASTMethod method){
+		lastDeclaration = method;
 		check( DECLARATIONS, method );
 	}
 		
@@ -193,11 +201,14 @@
 	}
 	
 	public void enterFunctionBody(IASTFunction function){
+		lastDeclaration = function;
+		check( DECLARATIONS, function );
 		check( DEFINITIONS, function );
 		pushScope( function );
 	}
 	
 	public void enterMethodBody(IASTMethod method) {
+		lastDeclaration = method;
 		check( DEFINITIONS, method );
 		pushScope( method );
 	}
@@ -207,13 +218,15 @@
 	}
 	
 	public void enterNamespaceDefinition(IASTNamespaceDefinition namespaceDefinition) {
-		check( DECLARATIONS, namespaceDefinition );			
-		pushScope( namespaceDefinition );
+		lastDeclaration = namespaceDefinition;
+		check( DECLARATIONS, namespaceDefinition );
+		pushScope( namespaceDefinition );			
 	}
 
 	public void enterClassSpecifier(IASTClassSpecifier classSpecification) {
-		check( DECLARATIONS, classSpecification );		
-		pushScope( classSpecification );
+		lastDeclaration = classSpecification;
+		check( DECLARATIONS, classSpecification );
+		pushScope( classSpecification );		
 	}
 	
 	public void exitFunctionBody(IASTFunction function) {
@@ -407,12 +420,27 @@
 					MatchLocator.verbose("Report Match: " + offsetableElement.getName());
 			}
 		
-				
-			IMatch match = null;		
+			IMatch match = null;
+			ISourceElementCallbackDelegate object = null;
+			
+			if( node instanceof IASTReference ){
+				if( currentScope instanceof IASTFunction || currentScope instanceof IASTMethod ){
+					object = (ISourceElementCallbackDelegate) currentScope;
+				} else {
+					object = lastDeclaration;
+				}
+			} else {
+				if( currentScope instanceof IASTFunction || currentScope instanceof IASTMethod ){
+					object = (ISourceElementCallbackDelegate) currentScope;
+				} else {
+					object = node;
+				}
+			}
+		
 			if( currentResource != null ){
-				match = resultCollector.createMatch( currentResource, offset, offset + length, node, currentScope );
+				match = resultCollector.createMatch( currentResource, offset, offset + length, object );
 			} else if( currentPath != null ){
-				match = resultCollector.createMatch( currentPath, offset, offset + length, node, currentScope );
+				match = resultCollector.createMatch( currentPath, offset, offset + length, object );
 			}
 			if( match != null ){
 				resultCollector.acceptMatch( match );
@@ -450,6 +478,8 @@
 		currentScope = (scopeStack.size() > 0 ) ? (IASTScope) scopeStack.removeFirst() : null;
 		return oldScope;
 	}
+	
+	private ISourceElementCallbackDelegate lastDeclaration;
 	
 	private ICSearchPattern 		searchPattern;
 	private ICSearchResultCollector resultCollector;
Index: ChangeLog
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core.tests/ChangeLog,v
retrieving revision 1.90
diff -u -r1.90 ChangeLog
--- ChangeLog	11 Sep 2003 18:06:15 -0000	1.90
+++ ChangeLog	11 Sep 2003 18:16:41 -0000
@@ -1,3 +1,11 @@
+2003-09-11 Andrew Niefer
+	Created search/SearchTestSuite
+	Added SearchTestSuite to AutomatedIntegrationSuite and removed the individual search tests
+	Added testReferencesInFunction to ClassDeclarationPatternTests
+	Modified resources/search/classDecl.cpp
+	Modified testNamespaceReferenceInClassBaseClause, testMacroPattern, testEnumerators, 
+	testEnumeratorReferences in OtherPatternTests to test the Match result strings
+
 2003-09-11 John Camelon
 	Added CompleteParseASTTest::testBug42840() & testBug42872().
 	Moved testBug39504B(), testBug39505A() & testBug39505B() from failed to QuickParse tests.
Index: resources/search/classDecl.cpp
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core.tests/resources/search/classDecl.cpp,v
retrieving revision 1.8
diff -u -r1.8 classDecl.cpp
--- resources/search/classDecl.cpp	9 Sep 2003 15:46:44 -0000	1.8
+++ resources/search/classDecl.cpp	11 Sep 2003 18:16:41 -0000
@@ -44,4 +44,11 @@
 NS::B b2;
 
 union u{
-};
\ No newline at end of file
+};
+
+class AClassForFoo {};
+
+AClassForFoo foo( AClassForFoo ){
+	AClassForFoo b;
+	return b;
+}
\ No newline at end of file
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.13
diff -u -r1.13 ClassDeclarationPatternTests.java
--- search/org/eclipse/cdt/core/search/tests/ClassDeclarationPatternTests.java	9 Sep 2003 15:46:44 -0000	1.13
+++ search/org/eclipse/cdt/core/search/tests/ClassDeclarationPatternTests.java	11 Sep 2003 18:16:41 -0000
@@ -257,4 +257,22 @@
 		
 		assertEquals( matches.size(), 7 );
 	}
+	
+	public void testReferencesInFunction(){
+		ICSearchPattern pattern = SearchEngine.createSearchPattern( "AClassForFoo", CLASS, REFERENCES, true );
+		
+		search( workspace, pattern, scope, resultCollector );
+		Set matches = resultCollector.getSearchResults();
+		assertEquals( matches.size(), 3 );
+		
+		Iterator iter = matches.iterator();
+		
+		while( iter.hasNext() ){
+			IMatch match = (IMatch) iter.next();
+
+			assertTrue( match.getName().equals("foo(AClassForFoo)") );
+			assertTrue( match.getParentName().equals("") );
+		}
+	}
 }
+
Index: search/org/eclipse/cdt/core/search/tests/OtherPatternTests.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core.tests/search/org/eclipse/cdt/core/search/tests/OtherPatternTests.java,v
retrieving revision 1.10
diff -u -r1.10 OtherPatternTests.java
--- search/org/eclipse/cdt/core/search/tests/OtherPatternTests.java	9 Sep 2003 15:46:44 -0000	1.10
+++ search/org/eclipse/cdt/core/search/tests/OtherPatternTests.java	11 Sep 2003 18:16:42 -0000
@@ -13,6 +13,7 @@
  */
 package org.eclipse.cdt.core.search.tests;
 
+import java.util.Iterator;
 import java.util.Set;
 
 import org.eclipse.cdt.core.search.ICSearchPattern;
@@ -120,6 +121,21 @@
 		
 		Set matches = resultCollector.getSearchResults();
 		assertEquals( matches.size(), 2 );
+		
+		Iterator iter = matches.iterator();
+		IMatch match = (IMatch) iter.next();
+		if( match.getName().equals("b2") ){
+			assertTrue( match.getParentName().equals("") );
+			match = (IMatch) iter.next();
+			assertTrue( match.getName().equals( "C" ) );
+			assertTrue( match.getParentName().equals( "NS3" ));
+		} else {
+			assertTrue( match.getName().equals( "C" ) );
+			assertTrue( match.getParentName().equals( "NS3" ));
+			match = (IMatch) iter.next();
+			assertTrue( match.getName().equals( "b2" ) );
+			assertTrue( match.getParentName().equals( "" ));
+		}
 	}
 	
 	public void testFieldDeclaration(){
@@ -175,6 +191,10 @@
 		
 		Set matches = resultCollector.getSearchResults();
 		assertEquals( matches.size(), 1 );
+		
+		IMatch match = (IMatch) matches.iterator().next();
+		assertTrue( match.getName().equals( "FOO" ) );
+		assertTrue( match.getParentName().equals( "" ));
 	}
 	
 	public void testEnumerators(){
@@ -184,6 +204,9 @@
 		
 		Set matches = resultCollector.getSearchResults();
 		assertEquals( matches.size(), 1 );
+		IMatch match = (IMatch) matches.iterator().next();
+		assertTrue( match.getName().equals( "One" ) );
+		assertTrue( match.getParentName().equals( "NS::B" ));
 		
 		pattern = SearchEngine.createSearchPattern( "NS::B::Two", FIELD, DECLARATIONS, true );
 		
@@ -191,6 +214,9 @@
 		
 		matches = resultCollector.getSearchResults();
 		assertEquals( matches.size(), 1 );
+		match = (IMatch) matches.iterator().next();
+		assertTrue( match.getName().equals( "Two" ) );
+		assertTrue( match.getParentName().equals( "NS::B" ) );
 	}
 	
 	public void testEnumeratorReferences(){
@@ -200,6 +226,9 @@
 		
 		Set matches = resultCollector.getSearchResults();
 		assertEquals( matches.size(), 1 );
+		
+		IMatch match = (IMatch) matches.iterator().next();
+		assertTrue( match.getName().equals( "eE" ) );
+		assertTrue( match.getParentName().equals( "NS3::C" ));
 	}
-	
 }
Index: search/org/eclipse/cdt/core/search/tests/SearchTestSuite.java
===================================================================
RCS file: search/org/eclipse/cdt/core/search/tests/SearchTestSuite.java
diff -N search/org/eclipse/cdt/core/search/tests/SearchTestSuite.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ search/org/eclipse/cdt/core/search/tests/SearchTestSuite.java	11 Sep 2003 18:16:42 -0000
@@ -0,0 +1,34 @@
+/*******************************************************************************
+ * 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
+ ******************************************************************************/
+
+package org.eclipse.cdt.core.search.tests;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+/**
+ * @author aniefer
+ *
+ * To change the template for this generated type comment go to
+ * Window>Preferences>Java>Code Generation>Code and Comments
+ */
+public class SearchTestSuite extends TestCase {
+	public static Test suite() { 
+			TestSuite suite= new TestSuite(SearchTestSuite.class.getName());
+			 
+			suite.addTestSuite(ClassDeclarationPatternTests.class);
+			suite.addTestSuite(FunctionMethodPatternTests.class);
+			suite.addTestSuite(OtherPatternTests.class);
+			suite.addTestSuite(ParseTestOnSearchFiles.class);
+			return suite;
+		}
+}
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.17
diff -u -r1.17 AutomatedIntegrationSuite.java
--- suite/org/eclipse/cdt/core/suite/AutomatedIntegrationSuite.java	10 Sep 2003 13:21:53 -0000	1.17
+++ suite/org/eclipse/cdt/core/suite/AutomatedIntegrationSuite.java	11 Sep 2003 18:16:42 -0000
@@ -30,10 +30,7 @@
 import org.eclipse.cdt.core.parser.failedTests.LokiFailures;
 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.search.tests.ParseTestOnSearchFiles;
+import org.eclipse.cdt.core.search.tests.SearchTestSuite;
 import org.eclipse.core.boot.IPlatformRunnable;
 
 /**
@@ -86,10 +83,7 @@
 		suite.addTest(BinaryTests.suite());
 		suite.addTest(ElementDeltaTests.suite());
 		suite.addTest(WorkingCopyTests.suite());
-		suite.addTestSuite(ClassDeclarationPatternTests.class );
-		suite.addTestSuite(FunctionMethodPatternTests.class );
-		suite.addTestSuite(OtherPatternTests.class );		
-		suite.addTestSuite( ParseTestOnSearchFiles.class);
+		suite.addTest(SearchTestSuite.suite());
 		suite.addTestSuite( CompletionProposalsTest.class);
 		//Indexer Tests need to be run after any indexer client tests
 		//as the last test shuts down the indexing thread
Index: ChangeLog
===================================================================
RCS file: /home/tools/org.eclipse.cdt.ui/ChangeLog,v
retrieving revision 1.169
diff -u -r1.169 ChangeLog
--- ChangeLog	11 Sep 2003 18:05:17 -0000	1.169
+++ ChangeLog	11 Sep 2003 18:30:57 -0000
@@ -1,3 +1,14 @@
+2003-09-11 Andrew Niefer
+	- bug42837 - fixed populating search dialog on function declarations
+		- modified determineInitValuesFrom in CSearchPage
+	- bug42829 - prepopulated search dialog to any element declarations
+		- modified trySimpleTextSelection in CSearchPage
+	- bug42815 - group together search results with same label
+		- modified GroupByKeyComputer to use Name, ParentName & Path in the group key
+		- modified CSearchResultCollector to properly use the GroupByKeyComputer	
+	- modified CSearchResultLabelProvider to not display the "-" in the search label
+	  while sorting by name if there is no parent.
+
 2003-09-11 John Camelon
 	Updated SourceElementRequestor callbacks to include IASTParameterReference callbacks. 
 
Index: src/org/eclipse/cdt/internal/ui/search/CSearchMessages.properties
===================================================================
RCS file: /home/tools/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchMessages.properties,v
retrieving revision 1.6
diff -u -r1.6 CSearchMessages.properties
--- src/org/eclipse/cdt/internal/ui/search/CSearchMessages.properties	4 Sep 2003 14:13:02 -0000	1.6
+++ src/org/eclipse/cdt/internal/ui/search/CSearchMessages.properties	11 Sep 2003 18:30:57 -0000
@@ -143,7 +143,7 @@
 CSearchOperation.pluralReadReferencesPostfix={0} - {1} Read References in {2}
 CSearchOperation.pluralWriteReferencesPostfix={0} - {1} Write References in {2}
 CSearchOperation.pluralImplementorsPostfix={0} - {1} Implementors in {2}
-CSearchOperation.pluralOccurencesPostfix={0} - {1} Occurrences in {2}
+CSearchOperation.pluralOccurrencesPostfix={0} - {1} Occurrences in {2}
 
 
 # The first argument will be replaced by the element name and the second one by the file name
Index: src/org/eclipse/cdt/internal/ui/search/CSearchPage.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchPage.java,v
retrieving revision 1.7
diff -u -r1.7 CSearchPage.java
--- src/org/eclipse/cdt/internal/ui/search/CSearchPage.java	5 Sep 2003 18:31:52 -0000	1.7
+++ src/org/eclipse/cdt/internal/ui/search/CSearchPage.java	11 Sep 2003 18:30:57 -0000
@@ -102,16 +102,24 @@
 				CSearchUtil.updateLRUWorkingSets(getContainer().getSelectedWorkingSets());
 		}
 		
+		data.cElement= null;
+		
 		CSearchResultCollector collector= new CSearchResultCollector();
-		CSearchOperation op = null;
-//		if (data.cElement != null && getPattern().equals(fInitialData.pattern)) {
-//			op = new CSearchOperation(workspace, data.cElement, data.limitTo, scope, scopeDescription, collector);
-//			if (data.limitTo == ICSearchConstants.REFERENCES)
-//				CSearchUtil.warnIfBinaryConstant(data.cElement, getShell());
-//		} else {
-			data.cElement= null;
-			op = new CSearchOperation(workspace, data.pattern, data.isCaseSensitive, data.searchFor, data.limitTo, scope, scopeDescription, collector);
-	//}
+		
+		List searching = null;
+		
+		if( data.searchFor.contains( UNKNOWN_SEARCH_FOR ) ){
+			//UNKNOWN_SEARCH_FOR means search for anything, make a list with everything
+			searching = new LinkedList();
+			for( int i = 0; i < fSearchFor.length - 1; i++ ){
+				searching.add( fSearchForValues[ i ] );		
+			}
+		} else {
+			searching = data.searchFor;
+		}
+		
+		CSearchOperation op = new CSearchOperation(workspace, data.pattern, data.isCaseSensitive, searching, data.limitTo, scope, scopeDescription, collector);
+
 		
 		try {
 			getContainer().getRunnableContext().run(true, true, op);
@@ -320,10 +328,10 @@
 	private List getSearchFor() {
 		List search = new LinkedList( );
 		
-		boolean all = fSearchFor[ fSearchFor.length - 1 ].getSelection();
+//		boolean all = fSearchFor[ fSearchFor.length - 1 ].getSelection();
 		
-		for (int i= 0; i < fSearchFor.length - 1; i++) {
-			if( fSearchFor[i].getSelection() || all )
+		for (int i= 0; i < fSearchFor.length; i++) {
+			if( fSearchFor[i].getSelection() /*|| all */)
 				search.add( fSearchForValues[i] );
 		}
 		
@@ -409,6 +417,9 @@
 			fSearchFor[i].setEnabled( enabled );			
 		}
 		
+		if( !enabled )
+			fSearchFor[ fSearchFor.length - 1 ].setEnabled( true );
+			
 		setLimitTo( fInitialData.searchFor );
 			
 		for (int i = 0; i < fLimitTo.length; i++)
@@ -438,8 +449,8 @@
 				IWorkbenchAdapter adapter= (IWorkbenchAdapter)((IAdaptable)o).getAdapter( IWorkbenchAdapter.class );
 				if( adapter != null ){
 					List searchFor = new LinkedList();
-					searchFor.add( CLASS_STRUCT );
-					return new SearchPatternData( searchFor, REFERENCES, fIsCaseSensitive, adapter.getLabel(o), null );
+					searchFor.add( UNKNOWN_SEARCH_FOR );
+					return new SearchPatternData( searchFor, DECLARATIONS, fIsCaseSensitive, adapter.getLabel(o), null );
 				}
 			}
 		}
@@ -465,8 +476,8 @@
 			}
 			
 			List searchFor = new LinkedList();
-			searchFor.add( CLASS_STRUCT );
-			result= new SearchPatternData( searchFor, REFERENCES, fIsCaseSensitive, text, null);
+			searchFor.add( UNKNOWN_SEARCH_FOR );
+			result= new SearchPatternData( searchFor, DECLARATIONS, fIsCaseSensitive, text, null);
 		}
 		return result;
 	}
@@ -474,7 +485,7 @@
 	private SearchPatternData getDefaultInitValues() {
 		List searchFor = new LinkedList();
 		searchFor.add( CLASS_STRUCT );
-		return new SearchPatternData( searchFor, REFERENCES, fIsCaseSensitive, "", null); //$NON-NLS-1$
+		return new SearchPatternData( searchFor, DECLARATIONS, fIsCaseSensitive, "", null); //$NON-NLS-1$
 	}
 		
 	private String[] getPreviousSearchPatterns() {
@@ -518,6 +529,7 @@
 		boolean forceMethod = ( pattern.indexOf("::") != -1 );
 		
 		switch ( element.getElementType() ){
+			case ICElement.C_FUNCTION_DECLARATION: /*fall through to function */
 			case ICElement.C_FUNCTION:	if( forceMethod ) searchFor.add( METHOD ); 
 										else 			  searchFor.add( FUNCTION );		
 										break;
@@ -527,6 +539,7 @@
 			case ICElement.C_UNION:		searchFor.add( UNION );			break;
 			case ICElement.C_ENUMERATOR: /* fall through to FIELD    */
 			case ICElement.C_FIELD:		searchFor.add( FIELD );			break;
+			case ICElement.C_METHOD_DECLARATION : /*fall through to METHOD */
 			case ICElement.C_METHOD:	searchFor.add( METHOD );		break;
 			case ICElement.C_NAMESPACE: searchFor.add( NAMESPACE );		break;
 		}
@@ -600,7 +613,7 @@
 	private static List fgPreviousSearchPatterns = new ArrayList(20);
 
 	private Button[] fSearchFor;
-	private SearchFor[] fSearchForValues = { CLASS_STRUCT, FUNCTION, VAR, UNION, METHOD, FIELD, ENUM, NAMESPACE, null };
+	private SearchFor[] fSearchForValues = { CLASS_STRUCT, FUNCTION, VAR, UNION, METHOD, FIELD, ENUM, NAMESPACE, UNKNOWN_SEARCH_FOR };
 	
 	private String[] fSearchForText= {
 		CSearchMessages.getString("CSearchPage.searchFor.classStruct"), //$NON-NLS-1$
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.9
diff -u -r1.9 CSearchResultCollector.java
--- src/org/eclipse/cdt/internal/ui/search/CSearchResultCollector.java	5 Sep 2003 18:31:52 -0000	1.9
+++ src/org/eclipse/cdt/internal/ui/search/CSearchResultCollector.java	11 Sep 2003 18:30:58 -0000
@@ -23,6 +23,7 @@
 import org.eclipse.core.resources.IMarker;
 import org.eclipse.core.runtime.CoreException;
 import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.search.ui.IGroupByKeyComputer;
 import org.eclipse.search.ui.ISearchResultView;
 import org.eclipse.search.ui.SearchUI;
 
@@ -57,6 +58,8 @@
 		CSearchResultLabelProvider labelProvider = new CSearchResultLabelProvider();
 		labelProvider.setOrder( CSearchResultLabelProvider.SHOW_PATH );
 		
+		_computer = new GroupByKeyComputer();
+		
 		if( _view != null ){
 			_view.searchStarted(
 				null,//new ActionGroupFactory(),
@@ -66,7 +69,7 @@
 				CSearchPage.EXTENSION_POINT_ID,
 				labelProvider,
 				new GotoMarkerAction(),
-				new GroupByKeyComputer(),
+				_computer,
 				_operation
 			);
 		}
@@ -86,9 +89,7 @@
 			return false;
 		 
 		IMarker marker =  searchMatch.resource.createMarker( SearchUI.SEARCH_MARKER );
-		
-		Object groupKey = match;
-		
+	
 		HashMap markerAttributes = new HashMap( 2 );
 		
 		//we can hang any other info we want off the marker
@@ -98,9 +99,10 @@
 		
 		marker.setAttributes( markerAttributes );
 		
-		if( _view != null )
-			_view.addMatch( searchMatch.name, groupKey, searchMatch.resource, marker );
-		
+		if( _view != null ){
+			_view.addMatch( searchMatch.name, _computer.computeGroupByKey( marker ), searchMatch.resource, marker );		
+		}
+
 		_matchCount++;
 		
 		return true;
@@ -152,5 +154,6 @@
 	private IProgressMonitor 	_monitor;
 	private CSearchOperation 	_operation;
 	private ISearchResultView 	_view;
+	private IGroupByKeyComputer _computer;
 	private int					_matchCount;
 }
Index: src/org/eclipse/cdt/internal/ui/search/GroupByKeyComputer.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/GroupByKeyComputer.java,v
retrieving revision 1.3
diff -u -r1.3 GroupByKeyComputer.java
--- src/org/eclipse/cdt/internal/ui/search/GroupByKeyComputer.java	29 Jul 2003 22:47:59 -0000	1.3
+++ src/org/eclipse/cdt/internal/ui/search/GroupByKeyComputer.java	11 Sep 2003 18:30:58 -0000
@@ -42,6 +42,5 @@
 		} catch (CoreException e) {
 		}
 		
-		return match.getParentName();
-	}
+		return match.getParentName() + "::" + match.getName() + " - " + match.getLocation();
	}
 }
Index: src/org/eclipse/cdt/ui/CSearchResultLabelProvider.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CSearchResultLabelProvider.java,v
retrieving revision 1.3
diff -u -r1.3 CSearchResultLabelProvider.java
--- src/org/eclipse/cdt/ui/CSearchResultLabelProvider.java	4 Sep 2003 14:13:02 -0000	1.3
+++ src/org/eclipse/cdt/ui/CSearchResultLabelProvider.java	11 Sep 2003 18:30:58 -0000
@@ -137,7 +137,11 @@
 			case SHOW_NAME_ONLY:
 				result = match.getName();
 			case SHOW_ELEMENT_CONTAINER:
-				result = match.getName() + " - " + match.getParentName() + " ( " + path + " )";
+				if( !match.getParentName().equals("") )
+					result = match.getName() + " - " + match.getParentName() + " ( " + path + " )";
+				else
+					result = match.getName() + " ( " + path + " )";
+						
 				break;
 			case SHOW_PATH:
 				result = path + " - " + match.getParentName()+ "::" + match.getName();

Back to the top