diff --git a/core/org.eclipse.cdt.core/index/ChangeLog b/core/org.eclipse.cdt.core/index/ChangeLog index d74bd67944f..b5aff0b8451 100644 --- a/core/org.eclipse.cdt.core/index/ChangeLog +++ b/core/org.eclipse.cdt.core/index/ChangeLog @@ -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 diff --git a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/search/indexing/AbstractIndexer.java b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/search/indexing/AbstractIndexer.java index ff439abb0ed..fdb0bb0e23e 100644 --- a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/search/indexing/AbstractIndexer.java +++ b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/search/indexing/AbstractIndexer.java @@ -244,11 +244,20 @@ public abstract class AbstractIndexer implements IIndexer, IIndexConstants, ICSe * 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 @@ public abstract class AbstractIndexer implements IIndexer, IIndexConstants, ICSe 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 @@ public abstract class AbstractIndexer implements IIndexer, IIndexConstants, ICSe 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 @@ public abstract class AbstractIndexer implements IIndexer, IIndexConstants, ICSe 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 @@ public abstract class AbstractIndexer implements IIndexer, IIndexConstants, ICSe 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 @@ public abstract class AbstractIndexer implements IIndexer, IIndexConstants, ICSe 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 ); } diff --git a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/search/indexing/IIndexConstants.java b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/search/indexing/IIndexConstants.java index a4fa2c3c68e..c7696f87d81 100644 --- a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/search/indexing/IIndexConstants.java +++ b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/search/indexing/IIndexConstants.java @@ -20,25 +20,31 @@ public interface IIndexConstants { 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$ diff --git a/core/org.eclipse.cdt.core/search/ChangeLog b/core/org.eclipse.cdt.core/search/ChangeLog index 9b6c8d677ae..a8fdde89112 100644 --- a/core/org.eclipse.cdt.core/search/ChangeLog +++ b/core/org.eclipse.cdt.core/search/ChangeLog @@ -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 diff --git a/core/org.eclipse.cdt.core/search/org/eclipse/cdt/internal/core/search/matching/CSearchPattern.java b/core/org.eclipse.cdt.core/search/org/eclipse/cdt/internal/core/search/matching/CSearchPattern.java index afc8c823cf3..5c31a3f753f 100644 --- a/core/org.eclipse.cdt.core/search/org/eclipse/cdt/internal/core/search/matching/CSearchPattern.java +++ b/core/org.eclipse.cdt.core/search/org/eclipse/cdt/internal/core/search/matching/CSearchPattern.java @@ -354,25 +354,25 @@ public abstract class CSearchPattern implements ICSearchConstants, ICSearchPatte 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; } } diff --git a/core/org.eclipse.cdt.core/search/org/eclipse/cdt/internal/core/search/matching/ClassDeclarationPattern.java b/core/org.eclipse.cdt.core/search/org/eclipse/cdt/internal/core/search/matching/ClassDeclarationPattern.java index 46a90eb8b16..aeb81d19726 100644 --- a/core/org.eclipse.cdt.core/search/org/eclipse/cdt/internal/core/search/matching/ClassDeclarationPattern.java +++ b/core/org.eclipse.cdt.core/search/org/eclipse/cdt/internal/core/search/matching/ClassDeclarationPattern.java @@ -45,17 +45,16 @@ public class ClassDeclarationPattern extends CSearchPattern { 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 @@ public class ClassDeclarationPattern extends CSearchPattern { 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 @@ public class ClassDeclarationPattern extends CSearchPattern { 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 @@ public class ClassDeclarationPattern extends CSearchPattern { 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 @@ public class ClassDeclarationPattern extends CSearchPattern { } 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 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; - } + //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){ + if( ! matchesName( simpleName, decodedSimpleName ) ){ + return false; + } + } + + if( !matchQualifications( qualifications, decodedContainingTypes ) ){ + return false; + } + return true; } diff --git a/core/org.eclipse.cdt.core/search/org/eclipse/cdt/internal/core/search/matching/FieldDeclarationPattern.java b/core/org.eclipse.cdt.core/search/org/eclipse/cdt/internal/core/search/matching/FieldDeclarationPattern.java index 6cb9ce027bf..a256140b9ae 100644 --- a/core/org.eclipse.cdt.core/search/org/eclipse/cdt/internal/core/search/matching/FieldDeclarationPattern.java +++ b/core/org.eclipse.cdt.core/search/org/eclipse/cdt/internal/core/search/matching/FieldDeclarationPattern.java @@ -16,6 +16,8 @@ package org.eclipse.cdt.internal.core.search.matching; import org.eclipse.cdt.core.parser.ISourceElementCallbackDelegate; import org.eclipse.cdt.core.parser.ast.IASTField; import org.eclipse.cdt.core.parser.ast.IASTQualifiedNameElement; +import org.eclipse.cdt.internal.core.index.IEntryResult; +import org.eclipse.cdt.internal.core.search.CharOperation; import org.eclipse.cdt.internal.core.search.indexing.AbstractIndexer; @@ -50,8 +52,14 @@ public class FieldDeclarationPattern extends VariableDeclarationPattern { } //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 @@ public class FieldDeclarationPattern extends VariableDeclarationPattern { 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; } diff --git a/core/org.eclipse.cdt.core/search/org/eclipse/cdt/internal/core/search/matching/FunctionDeclarationPattern.java b/core/org.eclipse.cdt.core/search/org/eclipse/cdt/internal/core/search/matching/FunctionDeclarationPattern.java index 97f7a67baf5..1a358a8db7e 100644 --- a/core/org.eclipse.cdt.core/search/org/eclipse/cdt/internal/core/search/matching/FunctionDeclarationPattern.java +++ b/core/org.eclipse.cdt.core/search/org/eclipse/cdt/internal/core/search/matching/FunctionDeclarationPattern.java @@ -25,6 +25,7 @@ import org.eclipse.cdt.core.parser.ast.IASTTypeSpecifier; import org.eclipse.cdt.core.search.ICSearchScope; import org.eclipse.cdt.internal.core.index.IEntryResult; import org.eclipse.cdt.internal.core.index.impl.IndexInput; +import org.eclipse.cdt.internal.core.search.CharOperation; import org.eclipse.cdt.internal.core.search.IIndexSearchRequestor; import org.eclipse.cdt.internal.core.search.indexing.AbstractIndexer; @@ -36,9 +37,12 @@ import org.eclipse.cdt.internal.core.search.indexing.AbstractIndexer; */ 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 @@ public class FunctionDeclarationPattern extends CSearchPattern { * @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 @@ public class FunctionDeclarationPattern extends CSearchPattern { * @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; } - } 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 704fc2a1f2c..09356a435ac 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 @@ -298,7 +298,7 @@ public class MatchLocator implements ISourceElementRequestor, ICSearchConstants } 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(); } diff --git a/core/org.eclipse.cdt.core/search/org/eclipse/cdt/internal/core/search/matching/MethodDeclarationPattern.java b/core/org.eclipse.cdt.core/search/org/eclipse/cdt/internal/core/search/matching/MethodDeclarationPattern.java index ad947eaeffe..0ef72c7a257 100644 --- a/core/org.eclipse.cdt.core/search/org/eclipse/cdt/internal/core/search/matching/MethodDeclarationPattern.java +++ b/core/org.eclipse.cdt.core/search/org/eclipse/cdt/internal/core/search/matching/MethodDeclarationPattern.java @@ -15,6 +15,8 @@ package org.eclipse.cdt.internal.core.search.matching; import org.eclipse.cdt.core.parser.ISourceElementCallbackDelegate; import org.eclipse.cdt.core.parser.ast.*; +import org.eclipse.cdt.internal.core.index.IEntryResult; +import org.eclipse.cdt.internal.core.search.CharOperation; import org.eclipse.cdt.internal.core.search.indexing.AbstractIndexer; /** @@ -25,6 +27,9 @@ import org.eclipse.cdt.internal.core.search.indexing.AbstractIndexer; */ public class MethodDeclarationPattern extends FunctionDeclarationPattern { + private char[][] decodedQualifications; + + private char[][] qualifications; @@ -43,9 +48,14 @@ public class MethodDeclarationPattern extends FunctionDeclarationPattern { 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 @@ public class MethodDeclarationPattern extends FunctionDeclarationPattern { 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; } } diff --git a/core/org.eclipse.cdt.core/search/org/eclipse/cdt/internal/core/search/matching/NamespaceDeclarationPattern.java b/core/org.eclipse.cdt.core/search/org/eclipse/cdt/internal/core/search/matching/NamespaceDeclarationPattern.java index 65dfe1cbef3..c2e979995a1 100644 --- a/core/org.eclipse.cdt.core/search/org/eclipse/cdt/internal/core/search/matching/NamespaceDeclarationPattern.java +++ b/core/org.eclipse.cdt.core/search/org/eclipse/cdt/internal/core/search/matching/NamespaceDeclarationPattern.java @@ -20,6 +20,7 @@ import org.eclipse.cdt.core.parser.ast.IASTNamespaceDefinition; 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 @@ public class NamespaceDeclarationPattern extends CSearchPattern { * @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 @@ public class NamespaceDeclarationPattern extends CSearchPattern { 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 @@ public class NamespaceDeclarationPattern extends CSearchPattern { * @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 class NamespaceDeclarationPattern extends CSearchPattern { public char[] indexEntryPrefix() { return AbstractIndexer.bestNamespacePrefix( _limitTo, - _name, - _qualifications, + simpleName, + qualifications, _matchMode, _caseSensitive ); } @@ -99,7 +125,17 @@ public class NamespaceDeclarationPattern extends CSearchPattern { * @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; } diff --git a/core/org.eclipse.cdt.core/search/org/eclipse/cdt/internal/core/search/matching/VariableDeclarationPattern.java b/core/org.eclipse.cdt.core/search/org/eclipse/cdt/internal/core/search/matching/VariableDeclarationPattern.java index 42cf45c4ac5..e98c17d3fb6 100644 --- a/core/org.eclipse.cdt.core/search/org/eclipse/cdt/internal/core/search/matching/VariableDeclarationPattern.java +++ b/core/org.eclipse.cdt.core/search/org/eclipse/cdt/internal/core/search/matching/VariableDeclarationPattern.java @@ -21,6 +21,7 @@ import org.eclipse.cdt.core.parser.ast.IASTVariable; import org.eclipse.cdt.core.search.ICSearchScope; import org.eclipse.cdt.internal.core.index.IEntryResult; import org.eclipse.cdt.internal.core.index.impl.IndexInput; +import org.eclipse.cdt.internal.core.search.CharOperation; import org.eclipse.cdt.internal.core.search.IIndexSearchRequestor; import org.eclipse.cdt.internal.core.search.indexing.AbstractIndexer; @@ -74,8 +75,17 @@ public class VariableDeclarationPattern extends CSearchPattern { * @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 @@ public class VariableDeclarationPattern extends CSearchPattern { * @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; } \ No newline at end of file