diff --git a/core/org.eclipse.cdt.core.tests/ChangeLog b/core/org.eclipse.cdt.core.tests/ChangeLog index 6581fdf1544..2302b1dd08d 100644 --- a/core/org.eclipse.cdt.core.tests/ChangeLog +++ b/core/org.eclipse.cdt.core.tests/ChangeLog @@ -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. diff --git a/core/org.eclipse.cdt.core.tests/resources/search/classDecl.cpp b/core/org.eclipse.cdt.core.tests/resources/search/classDecl.cpp index 31a339d4a92..510edeca59b 100644 --- a/core/org.eclipse.cdt.core.tests/resources/search/classDecl.cpp +++ b/core/org.eclipse.cdt.core.tests/resources/search/classDecl.cpp @@ -44,4 +44,11 @@ A::B b1; 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 diff --git a/core/org.eclipse.cdt.core.tests/search/org/eclipse/cdt/core/search/tests/ClassDeclarationPatternTests.java b/core/org.eclipse.cdt.core.tests/search/org/eclipse/cdt/core/search/tests/ClassDeclarationPatternTests.java index b3e9562af82..22298975b12 100644 --- a/core/org.eclipse.cdt.core.tests/search/org/eclipse/cdt/core/search/tests/ClassDeclarationPatternTests.java +++ b/core/org.eclipse.cdt.core.tests/search/org/eclipse/cdt/core/search/tests/ClassDeclarationPatternTests.java @@ -257,4 +257,22 @@ public class ClassDeclarationPatternTests extends BaseSearchTest implements ICSe 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("") ); + } + } } + diff --git a/core/org.eclipse.cdt.core.tests/search/org/eclipse/cdt/core/search/tests/OtherPatternTests.java b/core/org.eclipse.cdt.core.tests/search/org/eclipse/cdt/core/search/tests/OtherPatternTests.java index ca904c345d7..fdce14e72ec 100644 --- a/core/org.eclipse.cdt.core.tests/search/org/eclipse/cdt/core/search/tests/OtherPatternTests.java +++ b/core/org.eclipse.cdt.core.tests/search/org/eclipse/cdt/core/search/tests/OtherPatternTests.java @@ -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 @@ public class OtherPatternTests extends BaseSearchTest { 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 @@ public class OtherPatternTests extends BaseSearchTest { 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 @@ public class OtherPatternTests extends BaseSearchTest { 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 @@ public class OtherPatternTests extends BaseSearchTest { 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 @@ public class OtherPatternTests extends BaseSearchTest { 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" )); } - } diff --git a/core/org.eclipse.cdt.core.tests/search/org/eclipse/cdt/core/search/tests/SearchTestSuite.java b/core/org.eclipse.cdt.core.tests/search/org/eclipse/cdt/core/search/tests/SearchTestSuite.java new file mode 100644 index 00000000000..bcb00fa2231 --- /dev/null +++ b/core/org.eclipse.cdt.core.tests/search/org/eclipse/cdt/core/search/tests/SearchTestSuite.java @@ -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; + } +} diff --git a/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/suite/AutomatedIntegrationSuite.java b/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/suite/AutomatedIntegrationSuite.java index 5d7ff3d270a..ef1d3665e8d 100644 --- a/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/suite/AutomatedIntegrationSuite.java +++ b/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/suite/AutomatedIntegrationSuite.java @@ -30,10 +30,7 @@ import org.eclipse.cdt.core.parser.failedTests.ASTFailedTests; 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 @@ public class AutomatedIntegrationSuite extends TestSuite 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 diff --git a/core/org.eclipse.cdt.core/search/ChangeLog b/core/org.eclipse.cdt.core/search/ChangeLog index f05a8b776cf..8a5d4f97814 100644 --- a/core/org.eclipse.cdt.core/search/ChangeLog +++ b/core/org.eclipse.cdt.core/search/ChangeLog @@ -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 diff --git a/core/org.eclipse.cdt.core/search/org/eclipse/cdt/core/search/BasicSearchResultCollector.java b/core/org.eclipse.cdt.core/search/org/eclipse/cdt/core/search/BasicSearchResultCollector.java index 722a11f38c7..bf55413df5f 100644 --- a/core/org.eclipse.cdt.core/search/org/eclipse/cdt/core/search/BasicSearchResultCollector.java +++ b/core/org.eclipse.cdt.core/search/org/eclipse/cdt/core/search/BasicSearchResultCollector.java @@ -36,7 +36,6 @@ import org.eclipse.cdt.core.parser.ast.IASTOffsetableNamedElement; import org.eclipse.cdt.core.parser.ast.IASTParameterDeclaration; import org.eclipse.cdt.core.parser.ast.IASTQualifiedNameElement; import org.eclipse.cdt.core.parser.ast.IASTReference; -import org.eclipse.cdt.core.parser.ast.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 @@ public class BasicSearchResultCollector implements ICSearchResultCollector { 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,20 +77,10 @@ public class BasicSearchResultCollector implements ICSearchResultCollector { 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(); @@ -100,6 +89,24 @@ public class BasicSearchResultCollector implements ICSearchResultCollector { 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 ){ result.name += getParameterString( (IASTFunction) offsetable ); } diff --git a/core/org.eclipse.cdt.core/search/org/eclipse/cdt/core/search/ICSearchResultCollector.java b/core/org.eclipse.cdt.core/search/org/eclipse/cdt/core/search/ICSearchResultCollector.java index 3815f199b88..e0fb0b463f9 100644 --- a/core/org.eclipse.cdt.core/search/org/eclipse/cdt/core/search/ICSearchResultCollector.java +++ b/core/org.eclipse.cdt.core/search/org/eclipse/cdt/core/search/ICSearchResultCollector.java @@ -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 @@ public interface ICSearchResultCollector { * 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 [start, end] - * @param enclosingObject an object that contains the character range - * [start, end]; the value can be null indicating that - * no enclosing object has been found - * @param accuracy the level of accuracy the search result has; either - * EXACT_MATCH or POTENTIAL_MATCH - * @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; diff --git a/core/org.eclipse.cdt.core/search/org/eclipse/cdt/internal/core/search/matching/MatchLocator.java b/core/org.eclipse.cdt.core/search/org/eclipse/cdt/internal/core/search/matching/MatchLocator.java index 6d8298d55b1..f5c85b0f465 100644 --- a/core/org.eclipse.cdt.core/search/org/eclipse/cdt/internal/core/search/matching/MatchLocator.java +++ b/core/org.eclipse.cdt.core/search/org/eclipse/cdt/internal/core/search/matching/MatchLocator.java @@ -44,6 +44,7 @@ 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.IASTEnumeratorReference; import org.eclipse.cdt.core.parser.ast.IASTField; import org.eclipse.cdt.core.parser.ast.IASTFieldReference; @@ -141,26 +142,33 @@ public class MatchLocator implements ISourceElementRequestor, ICSearchConstants } 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 class MatchLocator implements ISourceElementRequestor, ICSearchConstants } 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 class MatchLocator implements ISourceElementRequestor, ICSearchConstants } 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 @@ public class MatchLocator implements ISourceElementRequestor, ICSearchConstants 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 ); @@ -451,6 +479,8 @@ public class MatchLocator implements ISourceElementRequestor, ICSearchConstants return oldScope; } + private ISourceElementCallbackDelegate lastDeclaration; + private ICSearchPattern searchPattern; private ICSearchResultCollector resultCollector; private IProgressMonitor progressMonitor; diff --git a/core/org.eclipse.cdt.ui/ChangeLog b/core/org.eclipse.cdt.ui/ChangeLog index 7311bfe2b33..5472ed13481 100644 --- a/core/org.eclipse.cdt.ui/ChangeLog +++ b/core/org.eclipse.cdt.ui/ChangeLog @@ -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 David Inglis Deprecated diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchMessages.properties b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchMessages.properties index 63e472efca6..f6b64aa328b 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchMessages.properties +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchMessages.properties @@ -143,7 +143,7 @@ CSearchOperation.pluralReferencesPostfix={0} - {1} References in {2} 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 diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchPage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchPage.java index 566325e2e78..84e547125ce 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchPage.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchPage.java @@ -102,16 +102,24 @@ public class CSearchPage extends DialogPage implements ISearchPage, ICSearchCons 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 @@ public class CSearchPage extends DialogPage implements ISearchPage, ICSearchCons 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 @@ public class CSearchPage extends DialogPage implements ISearchPage, ICSearchCons 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 @@ public class CSearchPage extends DialogPage implements ISearchPage, ICSearchCons 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 @@ public class CSearchPage extends DialogPage implements ISearchPage, ICSearchCons } 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 @@ public class CSearchPage extends DialogPage implements ISearchPage, ICSearchCons 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 @@ public class CSearchPage extends DialogPage implements ISearchPage, ICSearchCons 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 @@ public class CSearchPage extends DialogPage implements ISearchPage, ICSearchCons 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 @@ public class CSearchPage extends DialogPage implements ISearchPage, ICSearchCons 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$ diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchResultCollector.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchResultCollector.java index 4f8c5ef4f3a..19567d3213f 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchResultCollector.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchResultCollector.java @@ -23,6 +23,7 @@ import org.eclipse.cdt.ui.*; 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 @@ public class CSearchResultCollector extends BasicSearchResultCollector{ CSearchResultLabelProvider labelProvider = new CSearchResultLabelProvider(); labelProvider.setOrder( CSearchResultLabelProvider.SHOW_PATH ); + _computer = new GroupByKeyComputer(); + if( _view != null ){ _view.searchStarted( null,//new ActionGroupFactory(), @@ -66,7 +69,7 @@ public class CSearchResultCollector extends BasicSearchResultCollector{ CSearchPage.EXTENSION_POINT_ID, labelProvider, new GotoMarkerAction(), - new GroupByKeyComputer(), + _computer, _operation ); } @@ -86,9 +89,7 @@ public class CSearchResultCollector extends BasicSearchResultCollector{ 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 @@ public class CSearchResultCollector extends BasicSearchResultCollector{ 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 @@ public class CSearchResultCollector extends BasicSearchResultCollector{ private IProgressMonitor _monitor; private CSearchOperation _operation; private ISearchResultView _view; + private IGroupByKeyComputer _computer; private int _matchCount; } \ No newline at end of file diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/GroupByKeyComputer.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/GroupByKeyComputer.java index ab17bcf1a10..b1b43cfd20b 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/GroupByKeyComputer.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/GroupByKeyComputer.java @@ -42,6 +42,5 @@ public class GroupByKeyComputer implements IGroupByKeyComputer { } catch (CoreException e) { } - return match.getParentName(); - } + return match.getParentName() + "::" + match.getName() + " - " + match.getLocation(); } } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CSearchResultLabelProvider.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CSearchResultLabelProvider.java index 457b5ed8bf1..d0297dd8dab 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CSearchResultLabelProvider.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CSearchResultLabelProvider.java @@ -137,7 +137,11 @@ public class CSearchResultLabelProvider extends LabelProvider { 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();