Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[cdt-patch] Search Engine stuff

This patch is for the search.  No new things can be searched yet, but this 
brings more things closer to being able to be searched.

        - Implemented decodeIndexEntry & matchIndexEntry for all patterns
        - changed MatchLocator to use a COMPLETE_PARSE.
        - added TYPE_ALL, FUNCTION_ALL, METHOD_ALL, NAMESPACE_ALL, 
FIELD_ALL constants to IIndexConstants
        - modified AbstractIndexer prefix functions to properly handle 
searching for all occurences

-Andrew

Index: index/ChangeLog
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/index/ChangeLog,v
retrieving revision 1.5
diff -u -r1.5 ChangeLog
--- index/ChangeLog	24 Jul 2003 14:20:16 -0000	1.5
+++ index/ChangeLog	24 Jul 2003 19:28:57 -0000
@@ -1,4 +1,8 @@
 2003-07-24 Andrew Niefer
+	- added TYPE_ALL, FUNCTION_ALL, METHOD_ALL, NAMESPACE_ALL, FIELD_ALL constants to IIndexConstants
+	- modified AbstractIndexer prefix functions to properly handle searching for all occurences
+	
+2003-07-23 Andrew Niefer
 	Modified 
 	*index/org/eclipse/cdt/internal/core/search/indexing/AbstractIndexer.java
 		-changed so that the index prefixes contain the qualified names of the 
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.6
diff -u -r1.6 AbstractIndexer.java
--- index/org/eclipse/cdt/internal/core/search/indexing/AbstractIndexer.java	24 Jul 2003 14:20:16 -0000	1.6
+++ index/org/eclipse/cdt/internal/core/search/indexing/AbstractIndexer.java	24 Jul 2003 19:28:57 -0000
@@ -244,11 +244,20 @@
 	 * 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) {
+		char [] prefix = null;
+		if( limitTo == DECLARATIONS ){
+			prefix = TYPE_DECL;
+		} else if( limitTo == REFERENCES ){
+			prefix = TYPE_REF;
+		} else {
+			return TYPE_ALL;
+		}
+
 		//Class kind not provided, best we can do
 		if (classKind == null){
-			return TYPE_DECL;
+			return prefix;
 		}
-		
+						
 		char classType=CLASS_SUFFIX;
 		if (classKind == ASTClassKind.STRUCT){
 			classType = STRUCT_SUFFIX;
@@ -260,22 +269,19 @@
 			classType = ENUM_SUFFIX;
 		}
 		
-		char [] prefix = null;
-		if( limitTo == DECLARATIONS ){
-			prefix = TYPE_DECL;
-		} else if( limitTo == REFERENCES ){
-			prefix = TYPE_REF;
-		}
-		
 		return bestPrefix( prefix, classType, typeName, containingTypes, matchMode, isCaseSensitive );
 	}
+	
 	public static final char[] bestNamespacePrefix(LimitTo limitTo, char[] namespaceName, char[][] containingTypes, int matchMode, boolean isCaseSensitive) {
 		char [] prefix = null;
 		if( limitTo == REFERENCES ){
 			prefix = NAMESPACE_REF;
-		} else {
+		} else if ( limitTo == DECLARATIONS ) {
 			prefix = NAMESPACE_DECL;
+		} else {
+			return NAMESPACE_ALL;
 		}
+		
 		return bestPrefix( prefix, (char) 0, namespaceName, containingTypes, matchMode, isCaseSensitive );
 	}	
 		
@@ -283,8 +289,10 @@
 		char [] prefix = null;
 		if( limitTo == REFERENCES ){
 			prefix = TYPE_REF;
-		} else {
+		} else if( limitTo == DECLARATIONS ){
 			prefix = TYPE_DECL;
+		} else {
+			return TYPE_ALL;
 		}
 		
 		return bestPrefix( prefix, VAR_SUFFIX, varName, null, matchMode, isCaseSenstive );	
@@ -294,9 +302,12 @@
 		char [] prefix = null;
 		if( limitTo == REFERENCES ){
 			prefix = FIELD_REF;
-		} else {
+		} else if( limitTo == DECLARATIONS ){
 			prefix = FIELD_DECL;
-		}		
+		} else {
+			return FIELD_ALL;
+		}
+		
 		return bestPrefix( prefix, (char)0, fieldName, containingTypes, matchMode, isCaseSensitive );
 	}  
 
@@ -304,9 +315,15 @@
 		char [] prefix = null;
 		if( limitTo == REFERENCES ){
 			prefix = METHOD_REF;
-		} else {
+		} else if( limitTo == DECLARATIONS ){
 			prefix = METHOD_DECL;
-		}		
+		} else if( limitTo == DEFINITIONS ){
+			//TODO prefix = METHOD_DEF;
+			return METHOD_ALL;	
+		} else {
+			return METHOD_ALL;
+		}
+		
 		return bestPrefix( prefix, (char)0, methodName, containingTypes, matchMode, isCaseSensitive );
 	}  
 	
@@ -314,9 +331,14 @@
 		char [] prefix = null;
 		if( limitTo == REFERENCES ){
 			prefix = FUNCTION_REF;
-		} else {
+		} else if( limitTo == DECLARATIONS ){
 			prefix = FUNCTION_DECL;
-		}		
+		} else if ( limitTo == DEFINITIONS ){
+			//TODO prefix = FUNCTION_DEF;
+			return FUNCTION_ALL;
+		} else {
+			return FUNCTION_ALL;
+		}
 		return bestPrefix( prefix, (char)0, functionName, null, 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.3
diff -u -r1.3 IIndexConstants.java
--- index/org/eclipse/cdt/internal/core/search/indexing/IIndexConstants.java	21 Jul 2003 21:14:06 -0000	1.3
+++ index/org/eclipse/cdt/internal/core/search/indexing/IIndexConstants.java	24 Jul 2003 19:28:57 -0000
@@ -20,25 +20,31 @@
 	
 	char[] TYPE_REF= "typeRef/".toCharArray(); //$NON-NLS-1$
 	char[] TYPE_DECL = "typeDecl/".toCharArray(); //$NON-NLS-1$
+	char[] TYPE_ALL = "type".toCharArray(); //$NON-NLS-1$
 	int TYPE_DECL_LENGTH = 9;
 	
 	char[] FUNCTION_REF= "functionRef/".toCharArray(); //$NON-NLS-1$
 	char[] FUNCTION_DECL= "functionDecl/".toCharArray(); //$NON-NLS-1$
+	char[] FUNCTION_ALL= "function".toCharArray(); //$NON-NLS-1$
 	int FUNCTION_DECL_LENGTH = 13;
-	
+		
 	char[] CONSTRUCTOR_REF= "constructorRef/".toCharArray(); //$NON-NLS-1$
 	char[] CONSTRUCTOR_DECL= "constructorDecl/".toCharArray(); //$NON-NLS-1$
 	
 	char[] NAMESPACE_REF= "namespaceRef/".toCharArray(); //$NON-NLS-1$
 	char[] NAMESPACE_DECL= "namespaceDecl/".toCharArray(); //$NON-NLS-1$
+	char[] NAMESPACE_ALL = "namespace".toCharArray(); //$NON-NLS-1$
 	int NAMESPACE_DECL_LENGTH = 14;
+	
 		
 	char[] FIELD_REF= "fieldRef/".toCharArray(); //$NON-NLS-1$
 	char[] FIELD_DECL= "fieldDecl/".toCharArray(); //$NON-NLS-1$
+	char[] FIELD_ALL= "field".toCharArray(); //$NON-NLS-1$
 	int FIELD_DECL_LENGTH = 10;
 	
 	char[] METHOD_REF= "methodRef/".toCharArray(); //$NON-NLS-1$
 	char[] METHOD_DECL= "methodDecl/".toCharArray(); //$NON-NLS-1$
+	char[] METHOD_ALL= "method".toCharArray(); //$NON-NLS-1$
 	int METHOD_DECL_LENGTH = 11;
 		
 	char[] TYPEDEF_DECL = "typedefDecl/".toCharArray(); //$NON-NLS-1$
Index: search/ChangeLog
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/search/ChangeLog,v
retrieving revision 1.6
diff -u -r1.6 ChangeLog
--- search/ChangeLog	24 Jul 2003 14:20:16 -0000	1.6
+++ search/ChangeLog	24 Jul 2003 19:28:58 -0000
@@ -1,3 +1,7 @@
+2003-07-24 Andrew Niefer
+	- Implemented decodeIndexEntry & matchIndexEntry for all patterns
+	- changed MatchLocator to use a COMPLETE_PARSE.
+
 2003-07-23 Andrew Niefer
 	-Changed ICSearchPattern.matchLevel to take a ISourceElementCallbackDelegate
 	-Changed ICSearchResultCollector.createMatch to take a ISourceElementCallbackDelegate
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.10
diff -u -r1.10 CSearchPattern.java
--- search/org/eclipse/cdt/internal/core/search/matching/CSearchPattern.java	24 Jul 2003 14:20:16 -0000	1.10
+++ search/org/eclipse/cdt/internal/core/search/matching/CSearchPattern.java	24 Jul 2003 19:28:58 -0000
@@ -354,25 +354,25 @@
 		return false;
 	}
 	
-	protected boolean matchQualifications( char[][] qualifications, String [] fullyQualifiedName ){
+	protected boolean matchQualifications( char[][] qualifications, char[][] candidate ){
 		
-		int qualLen = qualifications != null ? qualifications.length : 0;
-		int fullLen = fullyQualifiedName != null ? fullyQualifiedName.length : 0;
+		int qualLength = qualifications != null ? qualifications.length : 0;
+		int candidateLength = candidate != null ? candidate.length : 0;
 		
-		if( qualLen == 0 ){
+		if( qualLength == 0 ){
 			return true;
 		}
 		
 		int root = ( qualifications[0].length == 0 ) ? 1 : 0;
 		
-		if( (root == 1 && fullLen - 1 != qualLen - 1 ) ||
-			(root == 0 && fullLen - 1 < qualLen ) )
+		if( (root == 1 && candidateLength != qualLength - 1 ) ||
+			(root == 0 && candidateLength < qualLength ) )
 		{
 			return false;
 		}
 		
-		for( int i = 1; i <= qualLen - root; i++ ){
-			if( !matchesName( qualifications[ qualLen - i - root ], fullyQualifiedName[ fullLen - i - 1 ].toCharArray() ) ){
+		for( int i = 1; i <= qualLength - root; i++ ){
+			if( !matchesName( qualifications[ qualLength - i - root ], candidate[ candidateLength - i ] ) ){
 				return false;		
 			}
 		}
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.7
diff -u -r1.7 ClassDeclarationPattern.java
--- search/org/eclipse/cdt/internal/core/search/matching/ClassDeclarationPattern.java	24 Jul 2003 14:20:16 -0000	1.7
+++ search/org/eclipse/cdt/internal/core/search/matching/ClassDeclarationPattern.java	24 Jul 2003 19:28:58 -0000
@@ -45,17 +45,16 @@
 		
 		simpleName = caseSensitive ? name : CharOperation.toLowerCase( name );
 		if( caseSensitive || containers == null ){
-			containingTypes = containers;
+			qualifications = containers;
 		} else {
 			int len = containers.length;
-			this.containingTypes = new char[ len ][];
+			this.qualifications = new char[ len ][];
 			for( int i = 0; i < len; i++ ){
-				this.containingTypes[i] = CharOperation.toLowerCase( containers[i] );
+				this.qualifications[i] = CharOperation.toLowerCase( containers[i] );
 			}
 		} 
 		
 		classKind = kind;
-		limitTo = limit;
 	}
 	
 	public int matchLevel( ISourceElementCallbackDelegate node ){
@@ -70,10 +69,14 @@
 			return IMPOSSIBLE_MATCH;
 		}
 
-		String [] fullyQualifiedName = ((IASTQualifiedNameElement) node).getFullyQualifiedName();
-		
+		//create char[][] out of full name, 
+		String [] fullName = ((IASTQualifiedNameElement) node).getFullyQualifiedName();
+		char [][] qualName = new char [ fullName.length - 1 ][];
+		for( int i = 0; i < fullName.length - 1; i++ ){
+			qualName[i] = fullName[i].toCharArray();
+		}
 		//check containing scopes
-		if( !matchQualifications( containingTypes, fullyQualifiedName ) ){
+		if( !matchQualifications( qualifications, qualName ) ){
 			return IMPOSSIBLE_MATCH;
 		}
 		
@@ -94,16 +97,15 @@
 		return simpleName;
 	}
 	public char[] [] getContainingTypes () {
-		return containingTypes;
+		return qualifications;
 	}
 	public ASTClassKind getKind(){
 		return classKind;
 	}
 
 	private char[] 	  simpleName;
-	private char[][]  containingTypes;
+	private char[][]  qualifications;
 	private ASTClassKind classKind;
-	private LimitTo	  limitTo;
 	
 	protected char[] decodedSimpleName;
 	private char[][] decodedContainingTypes;
@@ -129,26 +131,30 @@
 	protected void decodeIndexEntry(IEntryResult entryResult) {	
 		char[] word = entryResult.getWord();
 		int size = word.length;
-
-		this.decodedType = word[TYPE_DECL_LENGTH];
-		int oldSlash = TYPE_DECL_LENGTH+1;
-		int slash = CharOperation.indexOf(SEPARATOR, word, oldSlash+1);
 		
-		this.decodedSimpleName = CharOperation.subarray(word, oldSlash+1, slash);
+		int firstSlash = CharOperation.indexOf( SEPARATOR, word, 0 );
+		
+		this.decodedType = word[ firstSlash + 1 ];
+		firstSlash += 2;
+		
+		int slash = CharOperation.indexOf( SEPARATOR, word, firstSlash + 1 );
+		
+		this.decodedSimpleName = CharOperation.subarray( word, firstSlash + 1, slash );
 	
-		if (slash != -1){
-			if (slash+1 < size){
-				this.decodedContainingTypes = CharOperation.splitOn('/', CharOperation.subarray(word, slash+1, size));
+		if( slash != -1 && slash+1 < size ){
+			char [][] temp = CharOperation.splitOn('/', CharOperation.subarray( word, slash + 1, size ));
+			this.decodedContainingTypes = new char [ temp.length ][];
+			for( int i = 0; i < temp.length; i++ ){
+				this.decodedContainingTypes[ i ] = temp[ temp.length - i - 1 ];
 			}
 		} 
-
 	}
 
 	public char[] indexEntryPrefix() {
 		return AbstractIndexer.bestTypePrefix(
-				limitTo,
+				getLimitTo(),
 				simpleName,
-				containingTypes,
+				qualifications,
 				classKind,
 				_matchMode,
 				_caseSensitive
@@ -156,36 +162,41 @@
 	}
 
 	protected boolean matchIndexEntry() {
-
-		//TODO: BOG PUT QUALIFIER CHECKING BACK IN
-//		if (containingTypes != null){
-//			// empty char[][] means no enclosing type (in which case, the decoded one is the empty char array)
-//			if (containingTypes.length == 0){
-//				if (decodedContainingTypes != CharOperation.NO_CHAR_CHAR) return false;
-//			} else {
-//				if (!CharOperation.equals(containingTypes, decodedContainingTypes, _caseSensitive)) return false;
-//			}
-//		}
-
+		//check type matches
+		if( classKind == null ){
+			//don't match variable entries
+			if( decodedType == VAR_SUFFIX ){
+				return false;
+			}
+		} else if( classKind == ASTClassKind.CLASS ) {
+			if( decodedType != CLASS_SUFFIX ){
+				return false;
+			} 
+		} else if ( classKind == ASTClassKind.STRUCT ) {
+			if( decodedType != STRUCT_SUFFIX ){
+				return false;
+			}
+		} else if ( classKind == ASTClassKind.UNION ) {
+			if( decodedType != UNION_SUFFIX ){
+				return false;
+			}
+		} else if ( classKind == ASTClassKind.ENUM ) {
+			if( decodedType != ENUM_SUFFIX ) {
+				return false;
+			}
+		}
+		
 		/* check simple name matches */
 		if (simpleName != null){
-			switch(_matchMode){
-				case EXACT_MATCH :
-					if (!CharOperation.equals(simpleName, decodedSimpleName, _caseSensitive)){
-						return false;
-					}
-					break;
-				case PREFIX_MATCH :
-					if (!CharOperation.prefixEquals(simpleName, decodedSimpleName, _caseSensitive)){
-						return false;
-					}
-					break;
-				case PATTERN_MATCH :
-					if (!CharOperation.match(simpleName, decodedSimpleName, _caseSensitive)){
-						return false;
-					}
+			if( ! matchesName( simpleName, decodedSimpleName ) ){
+				return false; 
 			}
 		}
+		
+		if( !matchQualifications( qualifications, decodedContainingTypes ) ){
+			return false;
+		}
+		
 		return true;
 	}
 	
Index: search/org/eclipse/cdt/internal/core/search/matching/FieldDeclarationPattern.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/search/org/eclipse/cdt/internal/core/search/matching/FieldDeclarationPattern.java,v
retrieving revision 1.2
diff -u -r1.2 FieldDeclarationPattern.java
--- search/org/eclipse/cdt/internal/core/search/matching/FieldDeclarationPattern.java	24 Jul 2003 14:20:16 -0000	1.2
+++ search/org/eclipse/cdt/internal/core/search/matching/FieldDeclarationPattern.java	24 Jul 2003 19:28:58 -0000
@@ -16,6 +16,8 @@
 import org.eclipse.cdt.core.parser.ISourceElementCallbackDelegate;
 import org.eclipse.cdt.core.parser.ast.IASTField;
 import org.eclipse.cdt.core.parser.ast.IASTQualifiedNameElement;
+import org.eclipse.cdt.internal.core.index.IEntryResult;
+import org.eclipse.cdt.internal.core.search.CharOperation;
 import org.eclipse.cdt.internal.core.search.indexing.AbstractIndexer;
 
 
@@ -50,8 +52,14 @@
 		}
 		
 		//check containing scopes
-		String [] fullyQualifiedName = ((IASTQualifiedNameElement) node).getFullyQualifiedName();
-		if( !matchQualifications( qualifications, fullyQualifiedName ) ){
+		//create char[][] out of full name, 
+		String [] fullName = ((IASTQualifiedNameElement) node).getFullyQualifiedName();
+		char [][] qualName = new char [ fullName.length - 1 ][];
+		for( int i = 0; i < fullName.length - 1; i++ ){
+			qualName[i] = fullName[i].toCharArray();
+		}
+		//check containing scopes
+		if( !matchQualifications( qualifications, qualName ) ){
 			return IMPOSSIBLE_MATCH;
 		}
 		
@@ -62,9 +70,40 @@
 		return AbstractIndexer.bestFieldPrefix( _limitTo, simpleName, qualifications, _matchMode, _caseSensitive );
 	}
 	
+	protected void decodeIndexEntry(IEntryResult entryResult) {
+		char[] word = entryResult.getWord();
+		int size = word.length;
+		
+		int firstSlash = CharOperation.indexOf( SEPARATOR, word, 0 );
+		
+		int slash = CharOperation.indexOf(SEPARATOR, word, firstSlash + 1);
+		
+		this.decodedSimpleName = CharOperation.subarray(word, firstSlash + 1, slash);
+		
+		if( slash != -1 && slash+1 < size ){
+			char [][] temp = CharOperation.splitOn('/', CharOperation.subarray(word, slash+1, size));
+			this.decodedQualifications = new char [ temp.length ][];
+			for( int i = 0; i < temp.length; i++ ){
+				this.decodedQualifications[ i ] = temp[ temp.length - i - 1 ];
+			}
+		}
+	}
+
 	protected boolean matchIndexEntry() {
+		/* check simple name matches */
+		if (simpleName != null){
+			if( ! matchesName( simpleName, decodedSimpleName ) ){
+				return false; 
+			}
+		}
+		
+		if( !matchQualifications( qualifications, decodedQualifications ) ){
+			return false;
+		}
+		
 		return true;
 	}
 	
 	private char [][] qualifications;
+	private char [][] decodedQualifications;
 }
Index: search/org/eclipse/cdt/internal/core/search/matching/FunctionDeclarationPattern.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/search/org/eclipse/cdt/internal/core/search/matching/FunctionDeclarationPattern.java,v
retrieving revision 1.2
diff -u -r1.2 FunctionDeclarationPattern.java
--- search/org/eclipse/cdt/internal/core/search/matching/FunctionDeclarationPattern.java	24 Jul 2003 14:20:16 -0000	1.2
+++ search/org/eclipse/cdt/internal/core/search/matching/FunctionDeclarationPattern.java	24 Jul 2003 19:28:58 -0000
@@ -25,6 +25,7 @@
 import org.eclipse.cdt.core.search.ICSearchScope;
 import org.eclipse.cdt.internal.core.index.IEntryResult;
 import org.eclipse.cdt.internal.core.index.impl.IndexInput;
+import org.eclipse.cdt.internal.core.search.CharOperation;
 import org.eclipse.cdt.internal.core.search.IIndexSearchRequestor;
 import org.eclipse.cdt.internal.core.search.indexing.AbstractIndexer;
 
@@ -36,9 +37,12 @@
  */
 public class FunctionDeclarationPattern extends CSearchPattern {
 
+	protected char[] decodedSimpleName;
+	protected char[] simpleName;
+	
 	protected char[][] parameterNames;
 
-	protected char[] simpleName;
+	
 
 	public FunctionDeclarationPattern(char[] name, char [][] params, int matchMode, LimitTo limitTo, boolean caseSensitive) {
 		super( matchMode, caseSensitive, limitTo );
@@ -109,8 +113,14 @@
 	 * @see org.eclipse.cdt.internal.core.search.matching.CSearchPattern#decodeIndexEntry(org.eclipse.cdt.internal.core.index.IEntryResult)
 	 */
 	protected void decodeIndexEntry(IEntryResult entryResult) {
-		// TODO Auto-generated method stub
+		char[] word = entryResult.getWord();
+		int size = word.length;
+		
+		int firstSlash = CharOperation.indexOf( SEPARATOR, word, 0 );
 		
+		int slash = CharOperation.indexOf( SEPARATOR, word, firstSlash + 1 );
+		
+		this.decodedSimpleName = CharOperation.subarray(word, firstSlash + 1, slash);
 	}
 
 	/* (non-Javadoc)
@@ -124,7 +134,13 @@
 	 * @see org.eclipse.cdt.internal.core.search.matching.CSearchPattern#matchIndexEntry()
 	 */
 	protected boolean matchIndexEntry() {
+		/* check simple name matches */
+		if (simpleName != null){
+			if( ! matchesName( simpleName, decodedSimpleName ) ){
+				return false; 
+			}
+		}
+		
 		return true;
 	}
-
 }
Index: search/org/eclipse/cdt/internal/core/search/matching/MatchLocator.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/search/org/eclipse/cdt/internal/core/search/matching/MatchLocator.java,v
retrieving revision 1.11
diff -u -r1.11 MatchLocator.java
--- search/org/eclipse/cdt/internal/core/search/matching/MatchLocator.java	24 Jul 2003 14:20:16 -0000	1.11
+++ search/org/eclipse/cdt/internal/core/search/matching/MatchLocator.java	24 Jul 2003 19:28:58 -0000
@@ -298,7 +298,7 @@
 			}
 			
 			IScanner scanner = ParserFactory.createScanner( reader, pathString, new ScannerInfo(), ParserMode.QUICK_PARSE, this );
-			IParser  parser  = ParserFactory.createParser( scanner, this, ParserMode.QUICK_PARSE );
+			IParser  parser  = ParserFactory.createParser( scanner, this, ParserMode.COMPLETE_PARSE );
 			
 			parser.parse();
 		}
Index: search/org/eclipse/cdt/internal/core/search/matching/MethodDeclarationPattern.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/search/org/eclipse/cdt/internal/core/search/matching/MethodDeclarationPattern.java,v
retrieving revision 1.2
diff -u -r1.2 MethodDeclarationPattern.java
--- search/org/eclipse/cdt/internal/core/search/matching/MethodDeclarationPattern.java	24 Jul 2003 14:20:16 -0000	1.2
+++ search/org/eclipse/cdt/internal/core/search/matching/MethodDeclarationPattern.java	24 Jul 2003 19:28:59 -0000
@@ -15,6 +15,8 @@
 
 import org.eclipse.cdt.core.parser.ISourceElementCallbackDelegate;
 import org.eclipse.cdt.core.parser.ast.*;
+import org.eclipse.cdt.internal.core.index.IEntryResult;
+import org.eclipse.cdt.internal.core.search.CharOperation;
 import org.eclipse.cdt.internal.core.search.indexing.AbstractIndexer;
 
 /**
@@ -25,6 +27,9 @@
  */
 public class MethodDeclarationPattern extends FunctionDeclarationPattern {
 
+	private char[][] decodedQualifications;
+
+
 	private char[][] qualifications;
 
 
@@ -43,9 +48,14 @@
 			return IMPOSSIBLE_MATCH;
 		}
 		
+		//create char[][] out of full name, 
+		String [] fullName = ((IASTQualifiedNameElement) node).getFullyQualifiedName();
+		char [][] qualName = new char [ fullName.length - 1 ][];
+		for( int i = 0; i < fullName.length - 1; i++ ){
+			qualName[i] = fullName[i].toCharArray();
+		}
 		//check containing scopes
-		String [] fullyQualifiedName = ((IASTQualifiedNameElement) node).getFullyQualifiedName();
-		if( !matchQualifications( qualifications, fullyQualifiedName ) ){
+		if( !matchQualifications( qualifications, qualName ) ){
 			return IMPOSSIBLE_MATCH;
 		}
 		
@@ -56,7 +66,37 @@
 		return AbstractIndexer.bestMethodPrefix( _limitTo, simpleName, qualifications, _matchMode, _caseSensitive );
 	}
 	
+	protected void decodeIndexEntry(IEntryResult entryResult) {
+		char[] word = entryResult.getWord();
+		int size = word.length;
+		
+		int firstSlash = CharOperation.indexOf( SEPARATOR, word, 0 );
+		
+		int slash = CharOperation.indexOf( SEPARATOR, word, firstSlash + 1 );
+		
+		this.decodedSimpleName = CharOperation.subarray(word, firstSlash + 1, slash);
+		
+		if( slash != -1 && slash+1 < size ){
+			char [][] temp = CharOperation.splitOn('/', CharOperation.subarray(word, slash + 1, size));
+			this.decodedQualifications = new char [ temp.length ][];
+			for( int i = 0; i < temp.length; i++ ){
+				this.decodedQualifications[ i ] = temp[ temp.length - i - 1 ];
+			}
+		}
+	}
+
 	protected boolean matchIndexEntry() {
+		/* check simple name matches */
+		if (simpleName != null){
+			if( ! matchesName( simpleName, decodedSimpleName ) ){
+				return false; 
+			}
+		}
+		
+		if( !matchQualifications( qualifications, decodedQualifications ) ){
+			return false;
+		}
+		
 		return true;
 	}
 }
Index: search/org/eclipse/cdt/internal/core/search/matching/NamespaceDeclarationPattern.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/search/org/eclipse/cdt/internal/core/search/matching/NamespaceDeclarationPattern.java,v
retrieving revision 1.2
diff -u -r1.2 NamespaceDeclarationPattern.java
--- search/org/eclipse/cdt/internal/core/search/matching/NamespaceDeclarationPattern.java	24 Jul 2003 14:20:16 -0000	1.2
+++ search/org/eclipse/cdt/internal/core/search/matching/NamespaceDeclarationPattern.java	24 Jul 2003 19:28:59 -0000
@@ -20,6 +20,7 @@
 import org.eclipse.cdt.core.search.ICSearchScope;
 import org.eclipse.cdt.internal.core.index.IEntryResult;
 import org.eclipse.cdt.internal.core.index.impl.IndexInput;
+import org.eclipse.cdt.internal.core.search.CharOperation;
 import org.eclipse.cdt.internal.core.search.IIndexSearchRequestor;
 import org.eclipse.cdt.internal.core.search.indexing.AbstractIndexer;
 
@@ -39,11 +40,11 @@
 	 * @param limitTo
 	 * @param caseSensitive
 	 */
-	public NamespaceDeclarationPattern(char[] name, char[][] qualifications, int matchMode, LimitTo limitTo, boolean caseSensitive) {
+	public NamespaceDeclarationPattern(char[] name, char[][] quals, int matchMode, LimitTo limitTo, boolean caseSensitive) {
 		super( matchMode, caseSensitive, limitTo );
 		
-		_name = name;
-		_qualifications = qualifications;
+		simpleName = name;
+		qualifications = quals;
 	}
 
 	/* (non-Javadoc)
@@ -55,19 +56,29 @@
 			
 		IASTNamespaceDefinition namespace = (IASTNamespaceDefinition)node;
 		
-		if( _name != null && !matchesName( _name, namespace.getName().toCharArray() ) ){
+		if( simpleName != null && !matchesName( simpleName, namespace.getName().toCharArray() ) ){
 			return IMPOSSIBLE_MATCH;
 		}
 
-		if( !matchQualifications( _qualifications, namespace.getFullyQualifiedName() ) ){
+		//create char[][] out of full name, 
+		String [] fullName = namespace.getFullyQualifiedName();
+		char [] [] qualName = new char [ fullName.length - 1 ][];
+		for( int i = 0; i < fullName.length - 1; i++ ){
+			qualName[i] = fullName[i].toCharArray();
+		}
+		
+		if( !matchQualifications( qualifications, qualName ) ){
 			return IMPOSSIBLE_MATCH;
 		}
 
 		return ACCURATE_MATCH;
 	}
 
-	private char[][] _qualifications;
-	private char[] _name;
+	private char[][] decodedContainingTypes;
+	private char[] decodedSimpleName;
+	private char[][] qualifications;
+	private char[] simpleName;
+	
 	/* (non-Javadoc)
 	 * @see org.eclipse.cdt.internal.core.search.matching.CSearchPattern#feedIndexRequestor(org.eclipse.cdt.internal.core.search.IIndexSearchRequestor, int, int[], org.eclipse.cdt.internal.core.index.impl.IndexInput, org.eclipse.cdt.core.search.ICSearchScope)
 	 */
@@ -80,8 +91,23 @@
 	 * @see org.eclipse.cdt.internal.core.search.matching.CSearchPattern#decodeIndexEntry(org.eclipse.cdt.internal.core.index.IEntryResult)
 	 */
 	protected void decodeIndexEntry(IEntryResult entryResult) {
-		// TODO Auto-generated method stub
+		char[] word = entryResult.getWord();
+		int size = word.length;
+
+		int firstSlash = CharOperation.indexOf( SEPARATOR, word, 0 );
+		
+		int slash = CharOperation.indexOf(SEPARATOR, word, firstSlash + 1);
 		
+		this.decodedSimpleName = CharOperation.subarray(word, firstSlash+1, slash);
+	
+		if( slash != -1 && slash+1 < size ){
+			char [][] temp = CharOperation.splitOn('/', CharOperation.subarray(word, slash+1, size));
+			this.decodedContainingTypes = new char [ temp.length ][];
+			for( int i = 0; i < temp.length; i++ ){
+				this.decodedContainingTypes[ i ] = temp[ temp.length - i - 1 ];
+			}
+		} 
+
 	}
 
 	/* (non-Javadoc)
@@ -90,8 +116,8 @@
 	public char[] indexEntryPrefix() {
 		return AbstractIndexer.bestNamespacePrefix(
 				_limitTo,
-				_name,
-				_qualifications,
+				simpleName,
+				qualifications,
 				_matchMode, _caseSensitive
 		);
 	}
@@ -99,7 +125,17 @@
 	 * @see org.eclipse.cdt.internal.core.search.matching.CSearchPattern#matchIndexEntry()
 	 */
 	protected boolean matchIndexEntry() {
-		// TODO Auto-generated method stub
+		/* check simple name matches */
+		if( simpleName != null ){
+			if( ! matchesName( simpleName, decodedSimpleName ) ){
+				return false; 
+			}
+		}
+	
+		if( !matchQualifications( qualifications, decodedContainingTypes ) ){
+			return false;
+		}
+	
 		return true;
 	}
 
Index: search/org/eclipse/cdt/internal/core/search/matching/VariableDeclarationPattern.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/search/org/eclipse/cdt/internal/core/search/matching/VariableDeclarationPattern.java,v
retrieving revision 1.2
diff -u -r1.2 VariableDeclarationPattern.java
--- search/org/eclipse/cdt/internal/core/search/matching/VariableDeclarationPattern.java	24 Jul 2003 14:20:16 -0000	1.2
+++ search/org/eclipse/cdt/internal/core/search/matching/VariableDeclarationPattern.java	24 Jul 2003 19:28:59 -0000
@@ -21,6 +21,7 @@
 import org.eclipse.cdt.core.search.ICSearchScope;
 import org.eclipse.cdt.internal.core.index.IEntryResult;
 import org.eclipse.cdt.internal.core.index.impl.IndexInput;
+import org.eclipse.cdt.internal.core.search.CharOperation;
 import org.eclipse.cdt.internal.core.search.IIndexSearchRequestor;
 import org.eclipse.cdt.internal.core.search.indexing.AbstractIndexer;
 
@@ -74,8 +75,17 @@
 	 * @see org.eclipse.cdt.internal.core.search.matching.CSearchPattern#decodeIndexEntry(org.eclipse.cdt.internal.core.index.IEntryResult)
 	 */
 	protected void decodeIndexEntry(IEntryResult entryResult) {
-		// TODO Auto-generated method stub
+		char[] word = entryResult.getWord();
+		int size = word.length;
+		
+		int firstSlash = CharOperation.indexOf( SEPARATOR, word, 0 );
+		
+		this.decodedType = word[ firstSlash + 1 ];
+		firstSlash += 2;
+		
+		int slash = CharOperation.indexOf(SEPARATOR, word, firstSlash + 1);
 		
+		this.decodedSimpleName = CharOperation.subarray(word, firstSlash + 1, slash);
 	}
 
 	/* (non-Javadoc)
@@ -93,9 +103,22 @@
 	 * @see org.eclipse.cdt.internal.core.search.matching.CSearchPattern#matchIndexEntry()
 	 */
 	protected boolean matchIndexEntry() {
+		if( decodedType != VAR_SUFFIX ){
+			return false;
+		}
+			
+		/* check simple name matches */
+		if (simpleName != null){
+			if( ! matchesName( simpleName, decodedSimpleName ) ){
+				return false; 
+			}
+		}
+		
 		return true;
 	}
 	
 	protected char [] simpleName;
+	protected char [] decodedSimpleName;
+	protected char    decodedType;
 
 }

Back to the top