1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

Patch for Andrew Niefer

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
This commit is contained in:
John Camelon 2003-07-24 21:43:47 +00:00
parent bcbcf4266c
commit e312c1724b
12 changed files with 296 additions and 95 deletions

View file

@ -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

View file

@ -244,9 +244,18 @@ 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;
@ -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,8 +331,13 @@ 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 );
}

View file

@ -20,10 +20,12 @@ 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$
@ -31,14 +33,18 @@ public interface IIndexConstants {
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$

View file

@ -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

View file

@ -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;
}
}

View file

@ -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;
@ -130,25 +132,29 @@ public class ClassDeclarationPattern extends CSearchPattern {
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);
int firstSlash = CharOperation.indexOf( SEPARATOR, word, 0 );
this.decodedSimpleName = CharOperation.subarray(word, oldSlash+1, slash);
this.decodedType = word[ firstSlash + 1 ];
firstSlash += 2;
if (slash != -1){
if (slash+1 < size){
this.decodedContainingTypes = CharOperation.splitOn('/', CharOperation.subarray(word, slash+1, size));
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 ];
}
}
}
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 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;
}

View file

@ -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;
}

View file

@ -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;
}
}

View file

@ -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();
}

View file

@ -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;
}
}

View file

@ -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,7 +91,22 @@ 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 ];
}
}
}
@ -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;
}

View file

@ -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;
}