Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Resubmitted : Re: REJECTED : Re: [cdt-patch] Search Bugs (42836, 42902, 43016)

The tests were passing on my computer, it turns out the failure was due to 
the order of the items returned from a hashSet iterator.  The test had two 
cases to handle the two possible orders (set had 2 elements), one of the 
cases had a mistake but the other case was being executed for me.

The test has been changed to sort the set in order to remove this 
vulnerability.

-Andrew





John Camelon/Ottawa/IBM@IBMCA 
Sent by: cdt-patch-admin@xxxxxxxxxxx
09/15/2003 09:15 AM
Please respond to
cdt-patch@xxxxxxxxxxx


To
cdt-patch@xxxxxxxxxxx
cc

Subject
REJECTED : Re: [cdt-patch] Search Bugs (42836, 42902, 43016)






JUnit failure : OtherPatternTests::testNamespaceReferenceInClassBaseClause 

fails consistently. 

junit.framework.AssertionFailedError
        at junit.framework.Assert.fail(Assert.java:47)
        at junit.framework.Assert.assertTrue(Assert.java:20)
        at junit.framework.Assert.assertTrue(Assert.java:27)
        at 
org.eclipse.cdt.core.search.tests.OtherPatternTests.testNamespaceReferenceInClassBaseClause(OtherPatternTests.java:133)
        at java.lang.reflect.Method.invoke(Native Method)
        at junit.framework.TestCase.runTest(TestCase.java:154)
        at junit.framework.TestCase.runBare(TestCase.java:127)
        at junit.framework.TestResult$1.protect(TestResult.java:106)
        at junit.framework.TestResult.runProtected(TestResult.java:124)
        at junit.framework.TestResult.run(TestResult.java:109)
        at junit.framework.TestCase.run(TestCase.java:118)
        at junit.framework.TestSuite.runTest(TestSuite.java:208)
        at junit.framework.TestSuite.run(TestSuite.java:203)
        at junit.framework.TestSuite.runTest(TestSuite.java:208)
        at junit.framework.TestSuite.run(TestSuite.java:203)
        at junit.framework.TestSuite.runTest(TestSuite.java:208)
        at junit.framework.TestSuite.run(TestSuite.java:203)
        at 
org.eclipse.cdt.core.suite.AutomatedIntegrationSuite.run(AutomatedIntegrationSuite.java:115)
        at 
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:392)
        at 
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:276)
        at 
org.eclipse.pde.internal.junit.ui.RemotePluginTestRunner.main(RemotePluginTestRunner.java:30)
        at 
org.eclipse.pde.internal.junit.ui.UITestApplication.runEventLoop(UITestApplication.java:35)
        at org.eclipse.ui.internal.Workbench.run(Workbench.java:1385)
        at 
org.eclipse.core.internal.boot.InternalBootLoader.run(InternalBootLoader.java:845)
        at org.eclipse.core.boot.BootLoader.run(BootLoader.java:431)
        at EclipseRuntimeLauncher.main(EclipseRuntimeLauncher.java:24)


From the email : Applied [HEAD] Re: Resubmitted: Re: Rejected : Re: 
[cdt-patch] ParserFactory functions now take a ParserLanguage Parameter
>  Thank You But Please Be More Careful In The Future Thanks

My time is just as precious as yours ... run the tests before you submit a 

patch. 
Thank you, 

JohnC

cdt-patch-admin@xxxxxxxxxxx wrote on 09/12/2003 04:35:07 PM:

> This patch is for the following bugs:
> bug42836 - Navigate/search: prepopulate template classes from Outline...
> bug42902 - Search: Cannot find typedef
> bug43016 - Search: Cannot find macro declarations
> 
> Core:
> - add Typedefs to index as Types with suffix T (bug42902)
>         - added addTypedefReference to AbstractIndexer
>         - modified bestTypePrefix in AbstractIndexer
> - added TYPEDEF_DECL, TYPEDEF_SUFFIX to IIndexConstants
>         - modified acceptTypedefReference in SourceIndexerRequestor
> -Searching for Typedefs: (bug42902)
>         - modified setElementInfo in BasicSearchResultCollector
>         - added TYPEDEF to ICSearchConstants
>         - modified CSearchPattern & ClassDeclarationPattern
>         - implemented acceptTypedef* in MatchLocator
> 
> Core.tests
> - updated testIndexContents and testIndexAll and added them back into 
the 
> IndexManagerTests suite
> - modified resources/search/classDecl.cpp to include a typedef
> - added testbug42902_TypeDefs to ClassDeclarationPatternTests
> - updated testNamespaceReferenceInClassBaseClause in OtherPatternTests
> 
> UI
> - modified performAction & determineInitValuesFrom in CSearchPage
> - modified getImage in CSearchResultLabelProvider
> 
> -Andrew
> [attachment "patch_09.12.03(cdt.core).txt" deleted by John 
> Camelon/Ottawa/IBM] [attachment "patch_09.12.03(cdt.core.tests).txt"
> deleted by John Camelon/Ottawa/IBM] [attachment "patch_09.12.03(cdt.
> ui).txt" deleted by John Camelon/Ottawa/IBM] 
_______________________________________________
cdt-patch mailing list
cdt-patch@xxxxxxxxxxx
http://dev.eclipse.org/mailman/listinfo/cdt-patch

Index: index/ChangeLog
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/index/ChangeLog,v
retrieving revision 1.17
diff -u -r1.17 ChangeLog
--- index/ChangeLog	9 Sep 2003 15:46:38 -0000	1.17
+++ index/ChangeLog	15 Sep 2003 15:35:50 -0000
@@ -1,3 +1,10 @@
+2003-09-13 Andrew Niefer
+	- add Typedefs to index as Types with suffix T (bug42902)
+		- added addTypedefReference to AbstractIndexer
+		- modified bestTypePrefix in AbstractIndexer
+		- added TYPEDEF_DECL, TYPEDEF_SUFFIX to IIndexConstants
+		- modified acceptTypedefReference in SourceIndexerRequestor
+
 2003-09-09 Andrew Niefer
 	Enumerator references
  	 - Added createEnumeratorFullyQualifiedName in AbstractIndexer
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.17
diff -u -r1.17 AbstractIndexer.java
--- index/org/eclipse/cdt/internal/core/search/indexing/AbstractIndexer.java	9 Sep 2003 17:53:51 -0000	1.17
+++ index/org/eclipse/cdt/internal/core/search/indexing/AbstractIndexer.java	15 Sep 2003 15:35:51 -0000
@@ -41,7 +41,8 @@
 	final static int UNION = 3;
 	final static int ENUM = 4;
 	final static int VAR = 5;
-
+	final static int TYPEDEF = 6;
+	
 	public static boolean VERBOSE = false;
 	
 	public AbstractIndexer() {
@@ -185,6 +186,10 @@
 	public void addNamespaceReference(IASTNamespaceDefinition namespace) {
 		this.output.addRef(encodeEntry(namespace.getFullyQualifiedName(),NAMESPACE_REF,NAMESPACE_REF_LENGTH));
 	}
+	
+	public void addTypedefReference( IASTTypedefDeclaration typedef ){
+		this.output.addRef( encodeTypeEntry( typedef.getFullyQualifiedName(), TYPEDEF, ICSearchConstants.REFERENCES) );
+	}
 
 	private void addSuperTypeReference(int modifiers, char[] packageName, char[] typeName, char[][] enclosingTypeNames, char classOrInterface, char[] superTypeName, char superClassOrInterface){
 
@@ -265,6 +270,10 @@
 			case (VAR):
 			result[pos++] = VAR_SUFFIX;
 			break;
+			
+			case (TYPEDEF):
+			result[pos++] = TYPEDEF_SUFFIX;
+			break;
 		}
 		result[pos++] = SEPARATOR;
 		//Encode in the following manner
@@ -350,7 +359,7 @@
 	 * Type entries are encoded as follow: 'typeDecl/' ('C' | 'S' | 'U' ) '/'  TypeName '/' 
 	 * Current encoding is optimized for queries: all classes
 	 */
-	public static final char[] bestTypePrefix( LimitTo limitTo, char[] typeName, char[][] containingTypes, ASTClassKind classKind, int matchMode, boolean isCaseSensitive) {
+	public static final char[] bestTypePrefix( SearchFor searchFor, LimitTo limitTo, char[] typeName, char[][] containingTypes, int matchMode, boolean isCaseSensitive) {
 		char [] prefix = null;
 		if( limitTo == DECLARATIONS ){
 			prefix = TYPE_DECL;
@@ -359,21 +368,22 @@
 		} else {
 			return TYPE_ALL;
 		}
-
-		//Class kind not provided, best we can do
-		if (classKind == null){
-			return prefix;
-		}
-						
-		char classType=CLASS_SUFFIX;
-		if (classKind == ASTClassKind.STRUCT){
+					
+		char classType = 0;
+		
+		if( searchFor == ICSearchConstants.CLASS ){
+			classType = CLASS_SUFFIX;
+		} else if ( searchFor == ICSearchConstants.STRUCT ){
 			classType = STRUCT_SUFFIX;
-		}
-		else if (classKind == ASTClassKind.UNION){
+		} else if ( searchFor == ICSearchConstants.UNION ){
 			classType = UNION_SUFFIX;
-		}
-		else if (classKind == ASTClassKind.ENUM){
+		} else if ( searchFor == ICSearchConstants.ENUM ){
 			classType = ENUM_SUFFIX;
+		} else if ( searchFor == ICSearchConstants.TYPEDEF ){
+			classType = TYPEDEF_SUFFIX;
+		} else {
+			//could be TYPE or CLASS_STRUCT, best we can do for these is the prefix
+			return prefix;
 		}
 		
 		return bestPrefix( prefix, classType, typeName, containingTypes, matchMode, isCaseSensitive );
Index: index/org/eclipse/cdt/internal/core/search/indexing/IIndexConstants.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/search/indexing/IIndexConstants.java,v
retrieving revision 1.6
diff -u -r1.6 IIndexConstants.java
--- index/org/eclipse/cdt/internal/core/search/indexing/IIndexConstants.java	11 Aug 2003 19:10:45 -0000	1.6
+++ index/org/eclipse/cdt/internal/core/search/indexing/IIndexConstants.java	15 Sep 2003 15:35:51 -0000
@@ -57,8 +57,8 @@
 	char[] METHOD_ALL= "method".toCharArray(); //$NON-NLS-1$
 	int METHOD_DECL_LENGTH = 11;
 		
-	char[] TYPEDEF_DECL = "typedefDecl/".toCharArray(); //$NON-NLS-1$
-	int TYPEDEF_DECL_LENGTH = 12;
+	char[] TYPEDEF_DECL = "typeDecl/T/".toCharArray(); //$NON-NLS-1$
+	int TYPEDEF_DECL_LENGTH = 11;
 	
 	char[] MACRO_DECL = "macroDecl/".toCharArray();
 	int MACRO_DECL_LENGTH = 10;
@@ -92,6 +92,7 @@
 	char STRUCT_SUFFIX = 'S';
 	char ENUM_SUFFIX = 'E';
 	char UNION_SUFFIX = 'U';
+	char TYPEDEF_SUFFIX = 'T';
 	
 	char TYPE_SUFFIX = 0;
 	char SEPARATOR= '/';
Index: index/org/eclipse/cdt/internal/core/search/indexing/SourceIndexerRequestor.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/search/indexing/SourceIndexerRequestor.java,v
retrieving revision 1.16
diff -u -r1.16 SourceIndexerRequestor.java
--- index/org/eclipse/cdt/internal/core/search/indexing/SourceIndexerRequestor.java	11 Sep 2003 18:05:56 -0000	1.16
+++ index/org/eclipse/cdt/internal/core/search/indexing/SourceIndexerRequestor.java	15 Sep 2003 15:35:51 -0000
@@ -366,6 +366,8 @@
 	 */
 	public void acceptTypedefReference(IASTTypedefReference reference) {
 		// TODO Auto-generated method stub
+		if( reference.getReferencedElement() instanceof IASTTypedefDeclaration )
+			indexer.addTypedefReference( (IASTTypedefDeclaration) reference.getReferencedElement() );
 		
 	}
 	/* (non-Javadoc)
Index: search/ChangeLog
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/search/ChangeLog,v
retrieving revision 1.23
diff -u -r1.23 ChangeLog
--- search/ChangeLog	12 Sep 2003 13:13:50 -0000	1.23
+++ search/ChangeLog	15 Sep 2003 15:35:51 -0000
@@ -1,3 +1,11 @@
+2003-09-13 Andrew Niefer
+	-Searching for Typedefs: (bug42902)
+		- modified setElementInfo in BasicSearchResultCollector
+		- added TYPEDEF to ICSearchConstants
+		- modified CSearchPattern & ClassDeclarationPattern
+		- implemented acceptTypedef* in MatchLocator
+	- modified BasicSearchMatch to implement Comparable
+
 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
Index: search/org/eclipse/cdt/core/search/BasicSearchMatch.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/search/org/eclipse/cdt/core/search/BasicSearchMatch.java,v
retrieving revision 1.4
diff -u -r1.4 BasicSearchMatch.java
--- search/org/eclipse/cdt/core/search/BasicSearchMatch.java	12 Aug 2003 20:20:04 -0000	1.4
+++ search/org/eclipse/cdt/core/search/BasicSearchMatch.java	15 Sep 2003 15:35:51 -0000
@@ -22,7 +22,7 @@
  * To change the template for this generated type comment go to
  * Window>Preferences>Java>Code Generation>Code and Comments
  */
-public class BasicSearchMatch implements IMatch {
+public class BasicSearchMatch implements IMatch, Comparable {
 
 	public BasicSearchMatch() {
 	}
@@ -75,6 +75,25 @@
 		}
 
 		return true;
+	}
+	
+	public int compareTo( Object o ){
+		if( !( o instanceof BasicSearchMatch ) ){
+			throw new ClassCastException();
+		}
+		
+		BasicSearchMatch match = (BasicSearchMatch) o;
+		
+		String str1 = getLocation().toString();
+		String str2 = match.getLocation().toString();
+		
+		str1 += " " + getStartOffset()+ " ";
+		str2 += " " + match.getStartOffset()+ " ";
+		
+		str1 += getName() + " " + getParentName();
+		str2 += match.getName() + " " + match.getParentName();
+		
+		return str1.compareTo( str2 );
 	}
 	
 	public String name 		  = null;
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.6
diff -u -r1.6 BasicSearchResultCollector.java
--- search/org/eclipse/cdt/core/search/BasicSearchResultCollector.java	12 Sep 2003 13:13:50 -0000	1.6
+++ search/org/eclipse/cdt/core/search/BasicSearchResultCollector.java	15 Sep 2003 15:35:51 -0000
@@ -38,6 +38,7 @@
 import org.eclipse.cdt.core.parser.ast.IASTReference;
 import org.eclipse.cdt.core.parser.ast.IASTSimpleTypeSpecifier;
 import org.eclipse.cdt.core.parser.ast.IASTTypeSpecifier;
+import org.eclipse.cdt.core.parser.ast.IASTTypedefDeclaration;
 import org.eclipse.cdt.core.parser.ast.IASTVariable;
 import org.eclipse.core.resources.IResource;
 import org.eclipse.core.runtime.CoreException;
@@ -252,6 +253,8 @@
 			match.type = ICElement.C_FUNCTION;
 			IASTFunction function = (IASTFunction)node;
 			match.isStatic = function.isStatic();
+		} else if ( node instanceof IASTTypedefDeclaration ){
+			match.type = ICElement.C_TYPEDEF;
 		}
 	}
 	
Index: search/org/eclipse/cdt/core/search/ICSearchConstants.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/search/org/eclipse/cdt/core/search/ICSearchConstants.java,v
retrieving revision 1.6
diff -u -r1.6 ICSearchConstants.java
--- search/org/eclipse/cdt/core/search/ICSearchConstants.java	4 Sep 2003 13:50:42 -0000	1.6
+++ search/org/eclipse/cdt/core/search/ICSearchConstants.java	15 Sep 2003 15:35:51 -0000
@@ -97,6 +97,8 @@
 	
 	public static final SearchFor CLASS_STRUCT = new SearchFor( 11 );
 	
+	public static final SearchFor TYPEDEF = new SearchFor( 12 );
+	
 	/* Nature of match */
 	
 	/**
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.20
diff -u -r1.20 CSearchPattern.java
--- search/org/eclipse/cdt/internal/core/search/matching/CSearchPattern.java	9 Sep 2003 15:46:38 -0000	1.20
+++ search/org/eclipse/cdt/internal/core/search/matching/CSearchPattern.java	15 Sep 2003 15:35:52 -0000
@@ -90,7 +90,10 @@
 		}
 		
 		CSearchPattern pattern = null;
-		if( searchFor == TYPE || searchFor == CLASS || searchFor == STRUCT || searchFor == ENUM || searchFor == UNION || searchFor == CLASS_STRUCT ){
+		if( searchFor == TYPE || searchFor == CLASS || searchFor == STRUCT || 
+			searchFor == ENUM || searchFor == UNION || searchFor == CLASS_STRUCT  ||
+			searchFor == TYPEDEF )
+		{
 			pattern = createClassPattern( patternString, searchFor, limitTo, matchMode, caseSensitive );
 		} else if ( searchFor == METHOD || searchFor == FUNCTION ){
 			pattern = createMethodPattern( patternString, searchFor, limitTo, matchMode, caseSensitive );
@@ -257,6 +260,15 @@
 			orPattern.addPattern( createClassPattern( patternString, STRUCT, limitTo, matchMode, caseSensitive ) );
 			return orPattern;
 		}
+//		 else if( searchFor == TYPE ){
+//			OrPattern orPattern = new OrPattern();
+//			orPattern.addPattern( createClassPattern( patternString, CLASS, limitTo, matchMode, caseSensitive ) );
+//			orPattern.addPattern( createClassPattern( patternString, STRUCT, limitTo, matchMode, caseSensitive ) );
+//			orPattern.addPattern( createClassPattern( patternString, UNION, limitTo, matchMode, caseSensitive ) );
+//			orPattern.addPattern( createClassPattern( patternString, ENUM, limitTo, matchMode, caseSensitive ) );
+//			orPattern.addPattern( createClassPattern( patternString, TYPEDEF, limitTo, matchMode, caseSensitive ) );
+//			return orPattern;
+//		}
 		
 		IScanner scanner = ParserFactory.createScanner( new StringReader( patternString ), "TEXT", new ScannerInfo(), ParserMode.QUICK_PARSE, ParserLanguage.CPP, null );
 		
@@ -270,28 +282,22 @@
 		}
 		
 		if( token != null ){
+			boolean nullifyToken = true;
 			if( token.getType() == IToken.t_class ){
-				kind = ASTClassKind.CLASS;
+				searchFor = CLASS;
 			} else if ( token.getType() == IToken.t_struct ){
-				kind = ASTClassKind.STRUCT;
+				searchFor = STRUCT;
 			} else if ( token.getType() == IToken.t_union ){
-				kind = ASTClassKind.UNION;
+				searchFor = UNION;
 			} else if ( token.getType() == IToken.t_enum ){
-				kind = ASTClassKind.ENUM;
-			}
-			if( kind != null ){
-				token = null;
+				searchFor = ENUM;
+			} else if ( token.getType() == IToken.t_typedef ){
+				searchFor = TYPEDEF;
 			} else {
-				if( searchFor == CLASS ){
-					kind = ASTClassKind.CLASS;
-				} else if( searchFor == STRUCT ) {
-					kind = ASTClassKind.STRUCT;
-				} else if ( searchFor == ENUM ) {
-					kind = ASTClassKind.ENUM;
-				} else if ( searchFor == UNION ) {
-					kind = ASTClassKind.UNION;
-				}		
+				nullifyToken = false;
 			}
+			if( nullifyToken )
+				token = null;
 		}
 			
 		LinkedList list = scanForNames( scanner, token );
@@ -299,7 +305,7 @@
 		char[] name = (char [])list.removeLast();
 		char [][] qualifications = new char[0][];
 		
-		return new ClassDeclarationPattern( name, (char[][])list.toArray( qualifications ), kind, matchMode, limitTo, caseSensitive );
+		return new ClassDeclarationPattern( name, (char[][])list.toArray( qualifications ), searchFor, limitTo, matchMode, caseSensitive );
 	}
 
 
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.12
diff -u -r1.12 ClassDeclarationPattern.java
--- search/org/eclipse/cdt/internal/core/search/matching/ClassDeclarationPattern.java	20 Aug 2003 20:53:50 -0000	1.12
+++ search/org/eclipse/cdt/internal/core/search/matching/ClassDeclarationPattern.java	15 Sep 2003 15:35:52 -0000
@@ -22,6 +22,7 @@
 import org.eclipse.cdt.core.parser.ast.IASTEnumerationSpecifier;
 import org.eclipse.cdt.core.parser.ast.IASTOffsetableNamedElement;
 import org.eclipse.cdt.core.parser.ast.IASTQualifiedNameElement;
+import org.eclipse.cdt.core.parser.ast.IASTTypedefDeclaration;
 import org.eclipse.cdt.core.search.ICSearchScope;
 import org.eclipse.cdt.internal.core.CharOperation;
 import org.eclipse.cdt.internal.core.index.IEntryResult;
@@ -37,11 +38,11 @@
 
 public class ClassDeclarationPattern extends CSearchPattern {
 
-	public ClassDeclarationPattern( int matchMode, boolean caseSensitive ){
-		super( matchMode, caseSensitive, DECLARATIONS );
-	}
+//	public ClassDeclarationPattern( int matchMode, boolean caseSensitive ){
+//		super( matchMode, caseSensitive, DECLARATIONS );
+//	}
 	
-	public ClassDeclarationPattern( char[] name, char[][] containers, ASTClassKind kind, int mode, LimitTo limit, boolean caseSensitive ){
+	public ClassDeclarationPattern( char[] name, char[][] containers, SearchFor searchFor, LimitTo limit, int mode, boolean caseSensitive ){
 		super( mode, caseSensitive, limit );
 		
 		simpleName = caseSensitive ? name : CharOperation.toLowerCase( name );
@@ -55,14 +56,35 @@
 			}
 		} 
 		
-		classKind = kind;
+		this.searchFor = searchFor;
+		
+		if( searchFor == CLASS ){
+			classKind = ASTClassKind.CLASS;
+		} else if( searchFor == STRUCT ) {
+			classKind = ASTClassKind.STRUCT;
+		} else if ( searchFor == ENUM ) {
+			classKind = ASTClassKind.ENUM;
+		} else if ( searchFor == UNION ) {
+			classKind = ASTClassKind.UNION;
+		} else {
+			classKind = null;		
+		}
+		
 	}
 	
 	public int matchLevel( ISourceElementCallbackDelegate node, LimitTo limit ){
-		
-		if( !( node instanceof IASTClassSpecifier ) && !( node instanceof IASTEnumerationSpecifier ) && !(node instanceof IASTElaboratedTypeSpecifier) )
+		if( searchFor == TYPEDEF ){
+			if( !( node instanceof IASTTypedefDeclaration ) )
+				return IMPOSSIBLE_MATCH;
+		} else if( searchFor == ENUM ){
+			if( !( node instanceof IASTEnumerationSpecifier ) )
+				return IMPOSSIBLE_MATCH;
+		} else if ( !( node instanceof IASTClassSpecifier ) &&
+					!( node instanceof IASTElaboratedTypeSpecifier ) )
+		{
 			return IMPOSSIBLE_MATCH;
-			
+		}
+		
 		if( ! canAccept( limit ) )
 			return IMPOSSIBLE_MATCH;
 		
@@ -71,9 +93,11 @@
 		{
 			nodeName = ((IASTElaboratedTypeSpecifier)node).getName();
 		}
-		else
+		else if( node instanceof IASTOffsetableNamedElement )
 		{
 			nodeName = ((IASTOffsetableNamedElement)node).getName();
+		} else {
+			return IMPOSSIBLE_MATCH;
 		}
 		
 		//check name, if simpleName == null, its treated the same as "*"	
@@ -102,8 +126,7 @@
 			} else if (node instanceof IASTElaboratedTypeSpecifier ){
 				IASTElaboratedTypeSpecifier elabTypeSpec = (IASTElaboratedTypeSpecifier) node;
 				return ( classKind == elabTypeSpec.getClassKind() ) ? ACCURATE_MATCH : IMPOSSIBLE_MATCH;
-			
-			}	
+			}
 		}
 		
 		return ACCURATE_MATCH;
@@ -122,6 +145,7 @@
 	private char[] 	  simpleName;
 	private char[][]  qualifications;
 	private ASTClassKind classKind;
+	private SearchFor    searchFor;
 	
 	protected char[] decodedSimpleName;
 	private char[][] decodedContainingTypes;
@@ -174,10 +198,10 @@
 
 	public char[] indexEntryPrefix() {
 		return AbstractIndexer.bestTypePrefix(
+				searchFor,
 				getLimitTo(),
 				simpleName,
 				qualifications,
-				classKind,
 				_matchMode,
 				_caseSensitive
 		);
@@ -186,6 +210,9 @@
 	protected boolean matchIndexEntry() {
 		//check type matches
 		if( classKind == null ){
+			if( searchFor == TYPEDEF && decodedType != TYPEDEF_SUFFIX ){
+				return false;
+			}
 			//don't match variable entries
 			if( decodedType == VAR_SUFFIX ){
 				return false;
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.27
diff -u -r1.27 MatchLocator.java
--- search/org/eclipse/cdt/internal/core/search/matching/MatchLocator.java	12 Sep 2003 13:13:50 -0000	1.27
+++ search/org/eclipse/cdt/internal/core/search/matching/MatchLocator.java	15 Sep 2003 15:35:52 -0000
@@ -114,11 +114,8 @@
 	public void acceptUsingDirective(IASTUsingDirective usageDirective) 		{	}
 	public void acceptUsingDeclaration(IASTUsingDeclaration usageDeclaration) 	{	}
 	public void acceptASMDefinition(IASTASMDefinition asmDefinition) 			{	}
-	public void acceptTypedefDeclaration(IASTTypedefDeclaration typedef) 		{	}
-	
 	public void acceptAbstractTypeSpecDeclaration(IASTAbstractTypeSpecifierDeclaration abstractDeclaration) {}
-	public void acceptTypedefReference( IASTTypedefReference reference )        {	}
-	
+
 	public void enterLinkageSpecification(IASTLinkageSpecification linkageSpec) {	}
 	public void enterTemplateDeclaration(IASTTemplateDeclaration declaration) 	{	}
 	public void enterTemplateSpecialization(IASTTemplateSpecialization specialization) 		{	}
@@ -132,6 +129,15 @@
 	public void enterCodeBlock(IASTCodeScope scope) {	}
 	public void exitCodeBlock(IASTCodeScope scope) 	{	}
 	
+	
+	public void acceptTypedefDeclaration(IASTTypedefDeclaration typedef){
+		lastDeclaration = typedef;
+		check( DECLARATIONS, typedef );
+	}
+	
+	public void acceptTypedefReference( IASTTypedefReference reference ){
+		check( REFERENCES, reference );
+	}
 	
 	public void acceptEnumeratorReference(IASTEnumeratorReference reference){
 		check( REFERENCES, reference );	
Index: ChangeLog
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core.tests/ChangeLog,v
retrieving revision 1.94
diff -u -r1.94 ChangeLog
--- ChangeLog	15 Sep 2003 13:20:23 -0000	1.94
+++ ChangeLog	15 Sep 2003 15:38:30 -0000
@@ -1,3 +1,6 @@
+2003-09-13 Andrew Niefer
+	- added testBadParameterInfo to ParserSymbolTableTest
+
 2003-09-12 Hoda Amer
     - Added lots of test cases to CompleteParseASTExpressionTest
     
@@ -5,9 +8,6 @@
 	Created QuickParseASTTests::testBug42985(). 
 	Moved LokiFailures::testBug40419() to QuickParseASTTests. 
 	Deleted LokiFailures as it was empty. 
-
-2003-09-12 Andrew Niefer
-	- added testBadParameterInfo to ParserSymbolTableTest
 
 2003-09-11 Andrew Niefer
 	Created search/SearchTestSuite
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.15
diff -u -r1.15 IndexManagerTests.java
--- indexer/org/eclipse/cdt/core/indexer/tests/IndexManagerTests.java	9 Sep 2003 20:13:37 -0000	1.15
+++ indexer/org/eclipse/cdt/core/indexer/tests/IndexManagerTests.java	15 Sep 2003 15:38:30 -0000
@@ -107,6 +107,8 @@
 		suite.addTest(new IndexManagerTests("testRefs"));
 		suite.addTest(new IndexManagerTests("testMacros"));
 		suite.addTest(new IndexManagerTests("testForwardDeclarations"));
+		//suite.addTest(new IndexManagerTests("testIndexContents"));
+		//suite.addTest(new IndexManagerTests("testIndexAll"));
 		suite.addTest(new IndexManagerTests("testDependencyTree"));
 		suite.addTest(new IndexManagerTests("testIndexShutdown"));
 
@@ -193,7 +195,7 @@
 		IQueryResult[] qresults = ind.queryPrefix(prefix);
 		IEntryResult[] eresults = ind.queryEntries(prefix);
 		String [] queryResultModel = {"IndexedFile(1: /IndexerTestProject/mail.cpp)"};
-		String [] entryResultModel ={"EntryResult: word=typeDecl/C/Mail, refs={ 1 }", "EntryResult: word=typeDecl/C/Unknown, refs={ 1 }", "EntryResult: word=typeDecl/C/container, refs={ 1 }", "EntryResult: word=typeDecl/C/first_class, refs={ 1 }", "EntryResult: word=typeDecl/C/postcard, refs={ 1 }"};
+		String [] entryResultModel ={"EntryResult: word=typeDecl/C/Mail, refs={ 1 }", "EntryResult: word=typeDecl/C/Unknown, refs={ 1 }", "EntryResult: word=typeDecl/C/container, refs={ 1 }", "EntryResult: word=typeDecl/C/first_class, refs={ 1 }", "EntryResult: word=typeDecl/C/postcard, refs={ 1 }", "EntryResult: word=typeDecl/V/PO_Box, refs={ 1 }", "EntryResult: word=typeDecl/V/x, refs={ 1 }"};
 		
 		if (qresults.length != queryResultModel.length)
 			fail("Query Result length different from model");
@@ -269,7 +271,7 @@
 		try {
 			testProject.delete(true,monitor);
 		} catch (CoreException e) {
-			Thread.sleep(1000);
+			Thread.sleep(5000);
 			testProject.delete(true,monitor);
 		}
 		
@@ -334,7 +336,7 @@
 	
 		IEntryResult[] typerefreesults = ind.queryEntries(IIndexConstants.TYPE_REF);
 		
-		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 }"};
+		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/T/int32, refs={ 1 }", "EntryResult: word=typeDecl/V/PO_Box, refs={ 1 }", "EntryResult: word=typeDecl/V/x, refs={ 1 }", "EntryResult: word=typeDecl/V/x/Z, refs={ 1 }"};
 		IEntryResult[] typedeclresults =ind.queryEntries(IIndexConstants.TYPE_DECL);
 
 		if (typedeclresults.length != typeDeclEntryResultModel.length)
@@ -345,7 +347,7 @@
 			assertEquals(typeDeclEntryResultModel[i],typedeclresults[i].toString());
 		}
 	
-		String [] typeDefEntryResultModel ={"EntryResult: word=typedefDecl/int32, refs={ 1 }"};
+		String [] typeDefEntryResultModel ={"EntryResult: word=typeDecl/T/int32, refs={ 1 }"};
 		IEntryResult[] typedefresults =ind.queryEntries(IIndexConstants.TYPEDEF_DECL);
 		
 		if (typedefresults.length != typeDefEntryResultModel.length)
@@ -367,7 +369,7 @@
 			assertEquals(namespaceResultModel[i],namespaceresults[i].toString());
 		}
 				
-		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 }"};
+		String [] fieldResultModel = {"EntryResult: word=fieldDecl/array/container/Y/X/Z, refs={ 1 }", "EntryResult: word=fieldDecl/bye/Y/X/Z, refs={ 1 }", "EntryResult: word=fieldDecl/cool/Y/X/Z, refs={ 1 }", "EntryResult: word=fieldDecl/hi/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/Y/X/Z, refs={ 1 }"};
 		IEntryResult[] fieldresults =ind.queryEntries(IIndexConstants.FIELD_DECL);
 	
 		if (fieldresults.length != fieldResultModel.length)
@@ -378,7 +380,7 @@
 			assertEquals(fieldResultModel[i],fieldresults[i].toString());
 		}
 	
-		String [] functionResultModel = {"EntryResult: word=functionDecl/doSomething, refs={ 1 }"};	
+		String [] functionResultModel = {"EntryResult: word=functionDecl/doSomething, refs={ 1 }", "EntryResult: word=functionDecl/main/Y/X/Z, refs={ 1 }"};
 		IEntryResult[] functionresults =ind.queryEntries(IIndexConstants.FUNCTION_DECL);
 		
 		if (functionresults.length != functionResultModel.length)
@@ -389,7 +391,25 @@
 			assertEquals(functionResultModel[i],functionresults[i].toString());
 		}
 		
-		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 }"};	
+		String [] methodResultModel = {"EntryResult: word=methodDecl/Mail/Mail/Y/X/Z, refs={ 1 }",
+										"EntryResult: word=methodDecl/Unknown/Unknown/Y/X/Z, refs={ 1 }",
+										"EntryResult: word=methodDecl/container/container/Y/X/Z, refs={ 1 }", 
+										"EntryResult: word=methodDecl/first_class/first_class/Y/X/Z, refs={ 1 }",
+										//"EntryResult: word=methodDecl/operator=/Y/X/Z, refs={ 1 }", 
+										"EntryResult: word=methodDecl/operator=/container/Y/X/Z, refs={ 1 }",
+										//"EntryResult: word=methodDecl/operator[]/Y/X/Z, refs={ 1 }",
+										"EntryResult: word=methodDecl/operator[]/container/Y/X/Z, refs={ 1 }", 
+										"EntryResult: word=methodDecl/postcard/postcard/Y/X/Z, refs={ 1 }", 
+										"EntryResult: word=methodDecl/print/Mail/Y/X/Z, refs={ 1 }", 
+										"EntryResult: word=methodDecl/print/Unknown/Y/X/Z, refs={ 1 }",
+										"EntryResult: word=methodDecl/print/first_class/Y/X/Z, refs={ 1 }", 
+										"EntryResult: word=methodDecl/print/postcard/Y/X/Z, refs={ 1 }", 
+										"EntryResult: word=methodDecl/size/container/Y/X/Z, refs={ 1 }", 
+										"EntryResult: word=methodDecl/~container/container/Y/X/Z, refs={ 1 }" };
+									   
+									    
+									   
+	
 		IEntryResult[] methodresults =ind.queryEntries(IIndexConstants.METHOD_DECL);
 		
 		if (methodresults.length != methodResultModel.length)
Index: resources/search/classDecl.cpp
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core.tests/resources/search/classDecl.cpp,v
retrieving revision 1.9
diff -u -r1.9 classDecl.cpp
--- resources/search/classDecl.cpp	12 Sep 2003 13:13:45 -0000	1.9
+++ resources/search/classDecl.cpp	15 Sep 2003 15:38:30 -0000
@@ -41,7 +41,9 @@
 }
 
 A::B b1;
-NS::B b2;
+
+typedef NS::B NS_B;
+NS_B b2;
 
 union u{
 };
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.14
diff -u -r1.14 ClassDeclarationPatternTests.java
--- search/org/eclipse/cdt/core/search/tests/ClassDeclarationPatternTests.java	12 Sep 2003 13:13:45 -0000	1.14
+++ search/org/eclipse/cdt/core/search/tests/ClassDeclarationPatternTests.java	15 Sep 2003 15:38:31 -0000
@@ -274,5 +274,14 @@
 			assertTrue( match.getParentName().equals("") );
 		}
 	}
+	
+	public void testbug42902_TypeDefs(){
+		ICSearchPattern pattern = SearchEngine.createSearchPattern("NS_B", TYPEDEF, ALL_OCCURRENCES, true );
+		
+		search( workspace, pattern, scope, resultCollector );
+		Set matches = resultCollector.getSearchResults();
+		
+		assertEquals( matches.size(), 2 );
+	}
 }
 
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.11
diff -u -r1.11 OtherPatternTests.java
--- search/org/eclipse/cdt/core/search/tests/OtherPatternTests.java	12 Sep 2003 13:13:45 -0000	1.11
+++ search/org/eclipse/cdt/core/search/tests/OtherPatternTests.java	15 Sep 2003 15:38:31 -0000
@@ -15,6 +15,7 @@
 
 import java.util.Iterator;
 import java.util.Set;
+import java.util.TreeSet;
 
 import org.eclipse.cdt.core.search.ICSearchPattern;
 import org.eclipse.cdt.core.search.IMatch;
@@ -122,20 +123,16 @@
 		Set matches = resultCollector.getSearchResults();
 		assertEquals( matches.size(), 2 );
 		
-		Iterator iter = matches.iterator();
+		TreeSet sorted = new TreeSet( matches );
+		
+		Iterator iter = sorted.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( "" ));
-		}
+		
+		assertTrue( match.getName().equals( "C" ) );
+		assertTrue( match.getParentName().equals( "NS3" ));
+		match = (IMatch) iter.next();
+		assertTrue( match.getName().equals( "NS_B" ) );
+		assertTrue( match.getParentName().equals( "" ));
 	}
 	
 	public void testFieldDeclaration(){
Index: ChangeLog
===================================================================
RCS file: /home/tools/org.eclipse.cdt.ui/ChangeLog,v
retrieving revision 1.171
diff -u -r1.171 ChangeLog
--- ChangeLog	12 Sep 2003 13:13:58 -0000	1.171
+++ ChangeLog	15 Sep 2003 15:36:26 -0000
@@ -1,3 +1,10 @@
+2003-09-13 Andrew Niefer
+	- bug42836 - prepopulate template classes from Outline View
+	- bug43016 - Search: Cannot find macro declarations 
+	- bug42902 - Search: Cannot find typedef 
+		- modified performAction & determineInitValuesFrom in CSearchPage
+		- modified getImage in CSearchResultLabelProvider
+		
 2003-09-11 Andrew Niefer
 	- bug42837 - fixed populating search dialog on function declarations
 		- modified determineInitValuesFrom in CSearchPage
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.8
diff -u -r1.8 CSearchPage.java
--- src/org/eclipse/cdt/internal/ui/search/CSearchPage.java	12 Sep 2003 13:13:57 -0000	1.8
+++ src/org/eclipse/cdt/internal/ui/search/CSearchPage.java	15 Sep 2003 15:36:26 -0000
@@ -114,6 +114,10 @@
 			for( int i = 0; i < fSearchFor.length - 1; i++ ){
 				searching.add( fSearchForValues[ i ] );		
 			}
+			
+			//include those items not represented in the UI
+			searching.add( MACRO );
+			searching.add( TYPEDEF );
 		} else {
 			searching = data.searchFor;
 		}
@@ -529,19 +533,30 @@
 		boolean forceMethod = ( pattern.indexOf("::") != -1 );
 		
 		switch ( element.getElementType() ){
+			case ICElement.C_TEMPLATE_FUNCTION:	   /*fall through to function */
 			case ICElement.C_FUNCTION_DECLARATION: /*fall through to function */
 			case ICElement.C_FUNCTION:	if( forceMethod ) searchFor.add( METHOD ); 
 										else 			  searchFor.add( FUNCTION );		
 										break;
+										
 			case ICElement.C_VARIABLE:	searchFor.add( VAR );			break;
-			case ICElement.C_STRUCT:	/*   fall through to CLASS   */	 
+			
+			case ICElement.C_TEMPLATE_CLASS:/*   fall through to CLASS   */ 
+			case ICElement.C_STRUCT:		/*   fall through to CLASS   */	 
 			case ICElement.C_CLASS:		searchFor.add( CLASS_STRUCT );	break;
+			
 			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_TEMPLATE_METHOD : 	  /*fall through to METHOD */
 			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;
+			
+			default: searchFor.add( UNKNOWN_SEARCH_FOR ); break;
 		}
 
 		LimitTo limitTo = ALL_OCCURRENCES;			
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.4
diff -u -r1.4 CSearchResultLabelProvider.java
--- src/org/eclipse/cdt/ui/CSearchResultLabelProvider.java	12 Sep 2003 13:13:58 -0000	1.4
+++ src/org/eclipse/cdt/ui/CSearchResultLabelProvider.java	15 Sep 2003 15:36:27 -0000
@@ -76,6 +76,7 @@
 			case ICElement.C_FUNCTION:		imageDescriptor = CPluginImages.DESC_OBJS_FUNCTION;		break;
 			case ICElement.C_VARIABLE:		imageDescriptor = CPluginImages.DESC_OBJS_FIELD;		break;
 			case ICElement.C_ENUMERATOR:	imageDescriptor = CPluginImages.DESC_OBJS_ENUMERATOR;	break;
+			case ICElement.C_TYPEDEF:		imageDescriptor = CPluginImages.DESC_OBJS_TYPEDEF;		break;
 			case ICElement.C_FIELD:		
 			{
 				switch( match.getVisibility() ){

Back to the top