mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Patch for Andrew Niefer
core: - fixed a couple of bugs to do with searching for globally qualified patterns - fixed a bug to do with the '?' wildcard - fixed a bug to do with searching for functions/methods using patterns specifying parameters tests: - new search tests: ClassDeclarationPatternTests.testClassReferenceInFieldType ClassDeclarationPatternTests.testClassReferences ClassDeclarationPatternTests.testEnumerationReferenceVisibleByInheritance ClassDeclarationPatternTests.testGloballyQualifiedItem ClassDeclarationPatternTests.testTypeReferenceVisibleByUsingDirective FunctionMethodPatternTests.testMethodDeclaration FunctionMethodPatternTests.testMethodDeclarationWithParams OtherPatternTests.testFieldDeclaration OtherPatternTests.testNamespaceDeclaration OtherPatternTests.testNamespaceReferenceInClassBaseClause OtherPatternTests.testNamespaceReferenceInUsingDirective OtherPatternTests.testVariableDeclaration
This commit is contained in:
parent
5ad84a932b
commit
a3e052456b
15 changed files with 261 additions and 13 deletions
|
@ -1,3 +1,19 @@
|
||||||
|
2008-07-28 Andrew Niefer
|
||||||
|
-changes to resources/search/classDecl.cpp
|
||||||
|
-new search tests:
|
||||||
|
ClassDeclarationPatternTests.testClassReferenceInFieldType
|
||||||
|
ClassDeclarationPatternTests.testClassReferences
|
||||||
|
ClassDeclarationPatternTests.testEnumerationReferenceVisibleByInheritance
|
||||||
|
ClassDeclarationPatternTests.testGloballyQualifiedItem
|
||||||
|
ClassDeclarationPatternTests.testTypeReferenceVisibleByUsingDirective
|
||||||
|
FunctionMethodPatternTests.testMethodDeclaration
|
||||||
|
FunctionMethodPatternTests.testMethodDeclarationWithParams
|
||||||
|
OtherPatternTests.testFieldDeclaration
|
||||||
|
OtherPatternTests.testNamespaceDeclaration
|
||||||
|
OtherPatternTests.testNamespaceReferenceInClassBaseClause
|
||||||
|
OtherPatternTests.testNamespaceReferenceInUsingDirective
|
||||||
|
OtherPatternTests.testVariableDeclaration
|
||||||
|
|
||||||
2003-07-28 John Camelon
|
2003-07-28 John Camelon
|
||||||
Added/moved tests as necessary for bugfix 40842 & 40843.
|
Added/moved tests as necessary for bugfix 40842 & 40843.
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
class A {
|
class A {
|
||||||
class B {
|
class B {
|
||||||
|
void f( A );
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -7,12 +8,26 @@ namespace NS {
|
||||||
namespace NS2{
|
namespace NS2{
|
||||||
struct a{};
|
struct a{};
|
||||||
}
|
}
|
||||||
class B {
|
class B: public A {
|
||||||
struct A {};
|
struct A {};
|
||||||
enum e {};
|
enum e {};
|
||||||
|
|
||||||
|
using namespace NS2;
|
||||||
|
|
||||||
|
a aStruct;
|
||||||
|
A anotherStruct;
|
||||||
};
|
};
|
||||||
union u{ } ;
|
union u{ } ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace NS3{
|
||||||
|
class C : public NS::B {
|
||||||
|
e eE;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
A::B b1;
|
||||||
|
NS::B b2;
|
||||||
|
|
||||||
union u{
|
union u{
|
||||||
};
|
};
|
|
@ -171,4 +171,68 @@ public class ClassDeclarationPatternTests extends BaseSearchTest implements ICSe
|
||||||
assertEquals( CharOperation.compareWith( "typeRef/U/".toCharArray(), clsPattern.indexEntryPrefix() ), 0);
|
assertEquals( CharOperation.compareWith( "typeRef/U/".toCharArray(), clsPattern.indexEntryPrefix() ), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testGloballyQualifiedItem(){
|
||||||
|
ICSearchPattern pattern = SearchEngine.createSearchPattern( "::A", TYPE, DECLARATIONS, true );
|
||||||
|
assertTrue( pattern instanceof ClassDeclarationPattern );
|
||||||
|
|
||||||
|
search( workspace, pattern, scope, resultCollector );
|
||||||
|
|
||||||
|
Set matches = resultCollector.getMatches();
|
||||||
|
|
||||||
|
assertEquals( matches.size(), 1 );
|
||||||
|
|
||||||
|
pattern = SearchEngine.createSearchPattern( "::u", TYPE, DECLARATIONS, true );
|
||||||
|
assertTrue( pattern instanceof ClassDeclarationPattern );
|
||||||
|
|
||||||
|
search( workspace, pattern, scope, resultCollector );
|
||||||
|
|
||||||
|
matches = resultCollector.getMatches();
|
||||||
|
|
||||||
|
assertEquals( matches.size(), 1 );
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testClassReferences(){
|
||||||
|
ICSearchPattern pattern = SearchEngine.createSearchPattern( "::A", TYPE, REFERENCES, true );
|
||||||
|
|
||||||
|
search( workspace, pattern, scope, resultCollector );
|
||||||
|
|
||||||
|
Set matches = resultCollector.getMatches();
|
||||||
|
assertEquals( matches.size(), 3 );
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testClassReferenceInFieldType(){
|
||||||
|
ICSearchPattern pattern = SearchEngine.createSearchPattern( "::NS::B::A", TYPE, REFERENCES, true );
|
||||||
|
|
||||||
|
search( workspace, pattern, scope, resultCollector );
|
||||||
|
|
||||||
|
Set matches = resultCollector.getMatches();
|
||||||
|
assertEquals( matches.size(), 1 );
|
||||||
|
|
||||||
|
Match match = (Match) matches.iterator().next();
|
||||||
|
assertTrue( match.parent.equals( "NS::B" ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testTypeReferenceVisibleByUsingDirective(){
|
||||||
|
ICSearchPattern pattern = SearchEngine.createSearchPattern( "::NS::NS2::a", STRUCT, REFERENCES, true );
|
||||||
|
|
||||||
|
search( workspace, pattern, scope, resultCollector );
|
||||||
|
Set matches = resultCollector.getMatches();
|
||||||
|
assertEquals( matches.size(), 1 );
|
||||||
|
|
||||||
|
Match match = (Match) matches.iterator().next();
|
||||||
|
assertTrue( match.parent.equals( "NS::B" ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testEnumerationReferenceVisibleByInheritance(){
|
||||||
|
ICSearchPattern pattern = SearchEngine.createSearchPattern( "::NS::B::e", ENUM, REFERENCES, true );
|
||||||
|
|
||||||
|
search( workspace, pattern, scope, resultCollector );
|
||||||
|
|
||||||
|
Set matches = resultCollector.getMatches();
|
||||||
|
assertEquals( matches.size(), 1 );
|
||||||
|
|
||||||
|
Match match = (Match) matches.iterator().next();
|
||||||
|
assertTrue( match.parent.equals( "NS3::C" ) );
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,8 @@
|
||||||
*/
|
*/
|
||||||
package org.eclipse.cdt.core.search.tests;
|
package org.eclipse.cdt.core.search.tests;
|
||||||
|
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.search.ICSearchPattern;
|
import org.eclipse.cdt.core.search.ICSearchPattern;
|
||||||
import org.eclipse.cdt.core.search.SearchEngine;
|
import org.eclipse.cdt.core.search.SearchEngine;
|
||||||
import org.eclipse.cdt.internal.core.search.CharOperation;
|
import org.eclipse.cdt.internal.core.search.CharOperation;
|
||||||
|
@ -65,4 +67,23 @@ public class FunctionMethodPatternTests extends BaseSearchTest {
|
||||||
methodPattern = (MethodDeclarationPattern) SearchEngine.createSearchPattern( "A::B::c", METHOD, REFERENCES, false );
|
methodPattern = (MethodDeclarationPattern) SearchEngine.createSearchPattern( "A::B::c", METHOD, REFERENCES, false );
|
||||||
assertEquals( CharOperation.compareWith( "methodRef/".toCharArray(), methodPattern.indexEntryPrefix() ), 0);
|
assertEquals( CharOperation.compareWith( "methodRef/".toCharArray(), methodPattern.indexEntryPrefix() ), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testMethodDeclaration() {
|
||||||
|
ICSearchPattern pattern = SearchEngine.createSearchPattern( "A::B::f", METHOD, DECLARATIONS, true );
|
||||||
|
|
||||||
|
search( workspace, pattern, scope, resultCollector );
|
||||||
|
|
||||||
|
Set matches = resultCollector.getMatches();
|
||||||
|
|
||||||
|
assertEquals( matches.size(), 1 );
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testMethodDeclarationWithParams() {
|
||||||
|
ICSearchPattern pattern = SearchEngine.createSearchPattern( "A::B::f( A )", METHOD, DECLARATIONS, true );
|
||||||
|
|
||||||
|
search( workspace, pattern, scope, resultCollector );
|
||||||
|
|
||||||
|
Set matches = resultCollector.getMatches();
|
||||||
|
|
||||||
|
assertEquals( matches.size(), 1 ); }
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,12 +13,15 @@
|
||||||
*/
|
*/
|
||||||
package org.eclipse.cdt.core.search.tests;
|
package org.eclipse.cdt.core.search.tests;
|
||||||
|
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.search.ICSearchPattern;
|
import org.eclipse.cdt.core.search.ICSearchPattern;
|
||||||
import org.eclipse.cdt.core.search.SearchEngine;
|
import org.eclipse.cdt.core.search.SearchEngine;
|
||||||
import org.eclipse.cdt.internal.core.search.CharOperation;
|
import org.eclipse.cdt.internal.core.search.CharOperation;
|
||||||
import org.eclipse.cdt.internal.core.search.matching.FieldDeclarationPattern;
|
import org.eclipse.cdt.internal.core.search.matching.FieldDeclarationPattern;
|
||||||
import org.eclipse.cdt.internal.core.search.matching.NamespaceDeclarationPattern;
|
import org.eclipse.cdt.internal.core.search.matching.NamespaceDeclarationPattern;
|
||||||
import org.eclipse.cdt.internal.core.search.matching.VariableDeclarationPattern;
|
import org.eclipse.cdt.internal.core.search.matching.VariableDeclarationPattern;
|
||||||
|
import org.eclipse.cdt.internal.ui.search.Match;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author aniefer
|
* @author aniefer
|
||||||
|
@ -65,6 +68,9 @@ public class OtherPatternTests extends BaseSearchTest {
|
||||||
|
|
||||||
variablePattern = (VariableDeclarationPattern) SearchEngine.createSearchPattern( "Ac", VAR, REFERENCES, false );
|
variablePattern = (VariableDeclarationPattern) SearchEngine.createSearchPattern( "Ac", VAR, REFERENCES, false );
|
||||||
assertEquals( CharOperation.compareWith( "typeRef/V/".toCharArray(), variablePattern.indexEntryPrefix() ), 0);
|
assertEquals( CharOperation.compareWith( "typeRef/V/".toCharArray(), variablePattern.indexEntryPrefix() ), 0);
|
||||||
|
|
||||||
|
variablePattern = (VariableDeclarationPattern) SearchEngine.createSearchPattern( "A?c", VAR, REFERENCES, true );
|
||||||
|
assertEquals( CharOperation.compareWith( "typeRef/V/A".toCharArray(), variablePattern.indexEntryPrefix() ), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testFieldIndexPrefix(){
|
public void testFieldIndexPrefix(){
|
||||||
|
@ -83,5 +89,61 @@ public class OtherPatternTests extends BaseSearchTest {
|
||||||
fieldPattern = (FieldDeclarationPattern) SearchEngine.createSearchPattern( "A::B::c", FIELD, REFERENCES, false );
|
fieldPattern = (FieldDeclarationPattern) SearchEngine.createSearchPattern( "A::B::c", FIELD, REFERENCES, false );
|
||||||
assertEquals( CharOperation.compareWith( "fieldRef/".toCharArray(), fieldPattern.indexEntryPrefix() ), 0);
|
assertEquals( CharOperation.compareWith( "fieldRef/".toCharArray(), fieldPattern.indexEntryPrefix() ), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testNamespaceDeclaration(){
|
||||||
|
ICSearchPattern pattern = SearchEngine.createSearchPattern( "NS*", NAMESPACE, DECLARATIONS, true );
|
||||||
|
|
||||||
|
search( workspace, pattern, scope, resultCollector );
|
||||||
|
|
||||||
|
Set matches = resultCollector.getMatches();
|
||||||
|
|
||||||
|
assertEquals( matches.size(), 3 );
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testNamespaceReferenceInUsingDirective() {
|
||||||
|
ICSearchPattern pattern = SearchEngine.createSearchPattern( "::NS::NS2", NAMESPACE, REFERENCES, true );
|
||||||
|
|
||||||
|
search( workspace, pattern, scope, resultCollector );
|
||||||
|
|
||||||
|
Set matches = resultCollector.getMatches();
|
||||||
|
|
||||||
|
assertEquals( matches.size(), 1 );
|
||||||
|
|
||||||
|
Match match = (Match) matches.iterator().next();
|
||||||
|
assertTrue( match.parent.equals( "NS::B" ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testNamespaceReferenceInClassBaseClause(){
|
||||||
|
ICSearchPattern pattern = SearchEngine.createSearchPattern( "::NS", NAMESPACE, REFERENCES, true );
|
||||||
|
|
||||||
|
search( workspace, pattern, scope, resultCollector );
|
||||||
|
|
||||||
|
Set matches = resultCollector.getMatches();
|
||||||
|
assertEquals( matches.size(), 2 );
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testFieldDeclaration(){
|
||||||
|
ICSearchPattern pattern = SearchEngine.createSearchPattern( "a*Struct", FIELD, DECLARATIONS, true );
|
||||||
|
|
||||||
|
search( workspace, pattern, scope, resultCollector );
|
||||||
|
|
||||||
|
Set matches = resultCollector.getMatches();
|
||||||
|
assertEquals( matches.size(), 2 );
|
||||||
|
|
||||||
|
Match match = (Match) matches.iterator().next();
|
||||||
|
assertTrue( match.parent.equals( "NS::B" ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testVariableDeclaration(){
|
||||||
|
ICSearchPattern pattern = SearchEngine.createSearchPattern( "b?", VAR, DECLARATIONS, true );
|
||||||
|
|
||||||
|
search( workspace, pattern, scope, resultCollector );
|
||||||
|
|
||||||
|
Set matches = resultCollector.getMatches();
|
||||||
|
assertEquals( matches.size(), 2 );
|
||||||
|
|
||||||
|
Match match = (Match) matches.iterator().next();
|
||||||
|
assertTrue( match.parent.equals( "" ) );
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,6 @@
|
||||||
|
2003-07-28 Andrew Niefer
|
||||||
|
- added support for '?' wildcards in AbstractIndexer.bestPrefix
|
||||||
|
|
||||||
2003-07-25 Bogdan Gheorghe
|
2003-07-25 Bogdan Gheorghe
|
||||||
- Changed parser to COMPLETE mode
|
- Changed parser to COMPLETE mode
|
||||||
- Added functionRef, methodRef, typeRef, namespaceRef, fieldRef
|
- Added functionRef, methodRef, typeRef, namespaceRef, fieldRef
|
||||||
|
|
|
@ -14,9 +14,7 @@ package org.eclipse.cdt.internal.core.search.indexing;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.parser.ISourceElementCallbackDelegate;
|
|
||||||
import org.eclipse.cdt.core.parser.ast.ASTClassKind;
|
import org.eclipse.cdt.core.parser.ast.ASTClassKind;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTClassReference;
|
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTClassSpecifier;
|
import org.eclipse.cdt.core.parser.ast.IASTClassSpecifier;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTEnumerationSpecifier;
|
import org.eclipse.cdt.core.parser.ast.IASTEnumerationSpecifier;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTEnumerator;
|
import org.eclipse.cdt.core.parser.ast.IASTEnumerator;
|
||||||
|
@ -24,7 +22,6 @@ import org.eclipse.cdt.core.parser.ast.IASTField;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTFunction;
|
import org.eclipse.cdt.core.parser.ast.IASTFunction;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTMethod;
|
import org.eclipse.cdt.core.parser.ast.IASTMethod;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTNamespaceDefinition;
|
import org.eclipse.cdt.core.parser.ast.IASTNamespaceDefinition;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTNamespaceReference;
|
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTTypedefDeclaration;
|
import org.eclipse.cdt.core.parser.ast.IASTTypedefDeclaration;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTVariable;
|
import org.eclipse.cdt.core.parser.ast.IASTVariable;
|
||||||
import org.eclipse.cdt.core.search.ICSearchConstants;
|
import org.eclipse.cdt.core.search.ICSearchConstants;
|
||||||
|
@ -393,6 +390,8 @@ public abstract class AbstractIndexer implements IIndexer, IIndexConstants, ICSe
|
||||||
char[] result = null;
|
char[] result = null;
|
||||||
int pos = 0;
|
int pos = 0;
|
||||||
|
|
||||||
|
int wildPos, starPos, questionPos;
|
||||||
|
|
||||||
//length of prefix + separator
|
//length of prefix + separator
|
||||||
int length = prefix.length;
|
int length = prefix.length;
|
||||||
|
|
||||||
|
@ -405,11 +404,22 @@ public abstract class AbstractIndexer implements IIndexer, IIndexConstants, ICSe
|
||||||
//type name.
|
//type name.
|
||||||
name = null;
|
name = null;
|
||||||
} else if( matchMode == PATTERN_MATCH && name != null ){
|
} else if( matchMode == PATTERN_MATCH && name != null ){
|
||||||
int starPos = CharOperation.indexOf( '*', name );
|
starPos = CharOperation.indexOf( '*', name );
|
||||||
switch( starPos ){
|
questionPos = CharOperation.indexOf( '?', name );
|
||||||
|
|
||||||
|
if( starPos >= 0 ){
|
||||||
|
if( questionPos >= 0 )
|
||||||
|
wildPos = ( starPos < questionPos ) ? starPos : questionPos;
|
||||||
|
else
|
||||||
|
wildPos = starPos;
|
||||||
|
} else {
|
||||||
|
wildPos = questionPos;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch( wildPos ){
|
||||||
case -1 : break;
|
case -1 : break;
|
||||||
case 0 : name = null;
|
case 0 : name = null; break;
|
||||||
default : name = CharOperation.subarray( name, 0, starPos );
|
default : name = CharOperation.subarray( name, 0, wildPos ); break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//add length for name
|
//add length for name
|
||||||
|
@ -455,10 +465,21 @@ public abstract class AbstractIndexer implements IIndexer, IIndexConstants, ICSe
|
||||||
if( containingTypes != null ){
|
if( containingTypes != null ){
|
||||||
for( int i = containingTypes.length - 1; i >= 0; i-- ){
|
for( int i = containingTypes.length - 1; i >= 0; i-- ){
|
||||||
if( matchMode == PATTERN_MATCH ){
|
if( matchMode == PATTERN_MATCH ){
|
||||||
int starPos = CharOperation.indexOf( '*', containingTypes[i] );
|
starPos = CharOperation.indexOf( '*', containingTypes[i] );
|
||||||
|
questionPos = CharOperation.indexOf( '?', containingTypes[i] );
|
||||||
|
|
||||||
if( starPos >= 0 ){
|
if( starPos >= 0 ){
|
||||||
|
if( questionPos >= 0 )
|
||||||
|
wildPos = ( starPos < questionPos ) ? starPos : questionPos;
|
||||||
|
else
|
||||||
|
wildPos = starPos;
|
||||||
|
} else {
|
||||||
|
wildPos = questionPos;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( wildPos >= 0 ){
|
||||||
temp[ pos++ ] = SEPARATOR;
|
temp[ pos++ ] = SEPARATOR;
|
||||||
System.arraycopy( containingTypes[i], 0, temp, pos, starPos );
|
System.arraycopy( containingTypes[i], 0, temp, pos, wildPos );
|
||||||
pos += starPos;
|
pos += starPos;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,9 @@
|
||||||
|
2003-07-28 Andrew Niefer
|
||||||
|
- added abstract CSearchPattern.resetIndexInfo fix bug with searching with globally
|
||||||
|
qualified names
|
||||||
|
- fixed bug in CSearchPattern.matchQualifications to do with globally qualified names
|
||||||
|
- fixed bug in CSearchPattern.createFunctionPattern to do with parameter lists.
|
||||||
|
|
||||||
2003-07-25 Bogdan Gheorghe
|
2003-07-25 Bogdan Gheorghe
|
||||||
- Added refs to PathCollector
|
- Added refs to PathCollector
|
||||||
- Filled in feedIndexRequestor for the new search patterns
|
- Filled in feedIndexRequestor for the new search patterns
|
||||||
|
|
|
@ -170,7 +170,7 @@ public abstract class CSearchPattern implements ICSearchConstants, ICSearchPatte
|
||||||
|
|
||||||
int index = patternString.indexOf( '(' );
|
int index = patternString.indexOf( '(' );
|
||||||
String paramString = ( index == -1 ) ? "" : patternString.substring( index );
|
String paramString = ( index == -1 ) ? "" : patternString.substring( index );
|
||||||
String nameString = ( index == -1 ) ? patternString : patternString.substring( 0, index - 1 );
|
String nameString = ( index == -1 ) ? patternString : patternString.substring( 0, index );
|
||||||
|
|
||||||
IScanner scanner = ParserFactory.createScanner( new StringReader( nameString ), "TEXT", new ScannerInfo(), ParserMode.QUICK_PARSE, null );
|
IScanner scanner = ParserFactory.createScanner( new StringReader( nameString ), "TEXT", new ScannerInfo(), ParserMode.QUICK_PARSE, null );
|
||||||
|
|
||||||
|
@ -372,7 +372,7 @@ public abstract class CSearchPattern implements ICSearchConstants, ICSearchPatte
|
||||||
}
|
}
|
||||||
|
|
||||||
for( int i = 1; i <= qualLength - root; i++ ){
|
for( int i = 1; i <= qualLength - root; i++ ){
|
||||||
if( !matchesName( qualifications[ qualLength - i - root ], candidate[ candidateLength - i ] ) ){
|
if( !matchesName( qualifications[ qualLength - i ], candidate[ candidateLength - i ] ) ){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -416,6 +416,7 @@ public abstract class CSearchPattern implements ICSearchConstants, ICSearchPatte
|
||||||
|
|
||||||
/* retrieve and decode entry */
|
/* retrieve and decode entry */
|
||||||
IEntryResult entry = entries[i];
|
IEntryResult entry = entries[i];
|
||||||
|
resetIndexInfo();
|
||||||
decodeIndexEntry(entry);
|
decodeIndexEntry(entry);
|
||||||
if (matchIndexEntry()){
|
if (matchIndexEntry()){
|
||||||
feedIndexRequestor(requestor, detailLevel, entry.getFileReferences(), input, scope);
|
feedIndexRequestor(requestor, detailLevel, entry.getFileReferences(), input, scope);
|
||||||
|
@ -427,6 +428,14 @@ public abstract class CSearchPattern implements ICSearchConstants, ICSearchPatte
|
||||||
* Feed the requestor according to the current search pattern
|
* Feed the requestor according to the current search pattern
|
||||||
*/
|
*/
|
||||||
public abstract void feedIndexRequestor(IIndexSearchRequestor requestor, int detailLevel, int[] references, IndexInput input, ICSearchScope scope) throws IOException ;
|
public abstract void feedIndexRequestor(IIndexSearchRequestor requestor, int detailLevel, int[] references, IndexInput input, ICSearchScope scope) throws IOException ;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called to reset any variables used in the decoding of index entries,
|
||||||
|
* this ensures that the matchIndexEntry is not polluted by index info
|
||||||
|
* from previous entries.
|
||||||
|
*/
|
||||||
|
protected abstract void resetIndexInfo();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Decodes the index entry
|
* Decodes the index entry
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -125,9 +125,15 @@ public class ClassDeclarationPattern extends CSearchPattern {
|
||||||
requestor.acceptClassDeclaration(path, decodedSimpleName, decodedContainingTypes);
|
requestor.acceptClassDeclaration(path, decodedSimpleName, decodedContainingTypes);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void resetIndexInfo(){
|
||||||
|
decodedType = 0;
|
||||||
|
decodedSimpleName = null;
|
||||||
|
decodedContainingTypes = null;
|
||||||
|
}
|
||||||
|
|
||||||
protected void decodeIndexEntry(IEntryResult entryResult) {
|
protected void decodeIndexEntry(IEntryResult entryResult) {
|
||||||
char[] word = entryResult.getWord();
|
char[] word = entryResult.getWord();
|
||||||
int size = word.length;
|
int size = word.length;
|
||||||
|
|
|
@ -76,6 +76,11 @@ public class FieldDeclarationPattern extends VariableDeclarationPattern {
|
||||||
return AbstractIndexer.bestFieldPrefix( _limitTo, simpleName, qualifications, _matchMode, _caseSensitive );
|
return AbstractIndexer.bestFieldPrefix( _limitTo, simpleName, qualifications, _matchMode, _caseSensitive );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void resetIndexInfo(){
|
||||||
|
decodedSimpleName = null;
|
||||||
|
decodedQualifications = null;
|
||||||
|
}
|
||||||
|
|
||||||
protected void decodeIndexEntry(IEntryResult entryResult) {
|
protected void decodeIndexEntry(IEntryResult entryResult) {
|
||||||
char[] word = entryResult.getWord();
|
char[] word = entryResult.getWord();
|
||||||
int size = word.length;
|
int size = word.length;
|
||||||
|
|
|
@ -117,6 +117,11 @@ public class FunctionDeclarationPattern extends CSearchPattern {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
protected void resetIndexInfo(){
|
||||||
|
decodedSimpleName = null;
|
||||||
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.internal.core.search.matching.CSearchPattern#decodeIndexEntry(org.eclipse.cdt.internal.core.index.IEntryResult)
|
* @see org.eclipse.cdt.internal.core.search.matching.CSearchPattern#decodeIndexEntry(org.eclipse.cdt.internal.core.index.IEntryResult)
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -72,6 +72,11 @@ public class MethodDeclarationPattern extends FunctionDeclarationPattern {
|
||||||
return AbstractIndexer.bestMethodPrefix( _limitTo, simpleName, qualifications, _matchMode, _caseSensitive );
|
return AbstractIndexer.bestMethodPrefix( _limitTo, simpleName, qualifications, _matchMode, _caseSensitive );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void resetIndexInfo(){
|
||||||
|
decodedSimpleName = null;
|
||||||
|
decodedQualifications = null;
|
||||||
|
}
|
||||||
|
|
||||||
protected void decodeIndexEntry(IEntryResult entryResult) {
|
protected void decodeIndexEntry(IEntryResult entryResult) {
|
||||||
char[] word = entryResult.getWord();
|
char[] word = entryResult.getWord();
|
||||||
int size = word.length;
|
int size = word.length;
|
||||||
|
|
|
@ -93,6 +93,11 @@ public class NamespaceDeclarationPattern extends CSearchPattern {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void resetIndexInfo(){
|
||||||
|
decodedSimpleName = null;
|
||||||
|
decodedContainingTypes = null;
|
||||||
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.internal.core.search.matching.CSearchPattern#decodeIndexEntry(org.eclipse.cdt.internal.core.index.IEntryResult)
|
* @see org.eclipse.cdt.internal.core.search.matching.CSearchPattern#decodeIndexEntry(org.eclipse.cdt.internal.core.index.IEntryResult)
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -77,6 +77,11 @@ public class VariableDeclarationPattern extends CSearchPattern {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void resetIndexInfo(){
|
||||||
|
decodedType = 0;
|
||||||
|
decodedSimpleName = null;
|
||||||
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.internal.core.search.matching.CSearchPattern#decodeIndexEntry(org.eclipse.cdt.internal.core.index.IEntryResult)
|
* @see org.eclipse.cdt.internal.core.search.matching.CSearchPattern#decodeIndexEntry(org.eclipse.cdt.internal.core.index.IEntryResult)
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Add table
Reference in a new issue