mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-05 00:36:16 +02:00
Added derived, enumerator types to the index. Modified search tests to work with new types, added new derived test. Modified Search dialog; added new types.
This commit is contained in:
parent
06cdcc0e39
commit
91aab4d719
15 changed files with 276 additions and 19 deletions
|
@ -1,3 +1,5 @@
|
|||
2004-04-12
|
||||
Updated search tests to work with new Enumerator type, added a derived search test
|
||||
2004-04-11 John Camelon
|
||||
Updated clients for ISourceElementRequestor.createReader() updates.
|
||||
|
||||
|
|
|
@ -162,7 +162,8 @@ public class IndexManagerTests extends TestCase {
|
|||
assertTrue("Entry Results exist", eresults != null);
|
||||
|
||||
String [] queryResultModel = {"IndexedFile(1: /IndexerTestProject/mail.cpp)"};
|
||||
String [] entryResultModel ={"EntryResult: word=typeDecl/C/Mail, refs={ 1 }", "EntryResult: word=typeDecl/C/Unknown, refs={ 1 }", "EntryResult: word=typeDecl/C/container, refs={ 1 }", "EntryResult: word=typeDecl/C/first_class, refs={ 1 }", "EntryResult: word=typeDecl/C/postcard, refs={ 1 }", "EntryResult: word=typeDecl/V/PO_Box, refs={ 1 }", "EntryResult: word=typeDecl/V/size, refs={ 1 }", "EntryResult: word=typeDecl/V/temp, refs={ 1 }", "EntryResult: word=typeDecl/V/x, refs={ 1 }"};
|
||||
String [] entryResultModel ={"EntryResult: word=typeDecl/C/Mail, refs={ 1 }", "EntryResult: word=typeDecl/C/Unknown, refs={ 1 }", "EntryResult: word=typeDecl/C/container, refs={ 1 }", "EntryResult: word=typeDecl/C/first_class, refs={ 1 }", "EntryResult: word=typeDecl/C/postcard, refs={ 1 }","EntryResult: word=typeDecl/D/Mail, refs={ 1 }", "EntryResult: word=typeDecl/D/first_class, refs={ 1 }", "EntryResult: word=typeDecl/D/postcard, refs={ 1 }","EntryResult: word=typeDecl/V/PO_Box, refs={ 1 }", "EntryResult: word=typeDecl/V/size, refs={ 1 }", "EntryResult: word=typeDecl/V/temp, refs={ 1 }", "EntryResult: word=typeDecl/V/x, refs={ 1 }"};
|
||||
|
||||
|
||||
if (qresults.length != queryResultModel.length)
|
||||
fail("Query Result length different from model");
|
||||
|
@ -263,7 +264,7 @@ public class IndexManagerTests extends TestCase {
|
|||
IEntryResult[] eresults = ind.queryEntries(prefix);
|
||||
assertTrue("Entry result found for typdeDecl/", eresults != null);
|
||||
|
||||
String [] entryResultBeforeModel ={"EntryResult: word=typeDecl/C/CDocumentManager, refs={ 1 }", "EntryResult: word=typeDecl/C/Mail, refs={ 2 }", "EntryResult: word=typeDecl/C/Unknown, refs={ 2 }", "EntryResult: word=typeDecl/C/container, refs={ 2 }", "EntryResult: word=typeDecl/C/first_class, refs={ 2 }", "EntryResult: word=typeDecl/C/postcard, refs={ 2 }", "EntryResult: word=typeDecl/V/PO_Box, refs={ 2 }", "EntryResult: word=typeDecl/V/size, refs={ 2 }", "EntryResult: word=typeDecl/V/temp, refs={ 2 }", "EntryResult: word=typeDecl/V/x, refs={ 2 }"};
|
||||
String [] entryResultBeforeModel ={"EntryResult: word=typeDecl/C/CDocumentManager, refs={ 1 }", "EntryResult: word=typeDecl/C/Mail, refs={ 2 }", "EntryResult: word=typeDecl/C/Unknown, refs={ 2 }", "EntryResult: word=typeDecl/C/container, refs={ 2 }", "EntryResult: word=typeDecl/C/first_class, refs={ 2 }", "EntryResult: word=typeDecl/C/postcard, refs={ 2 }", "EntryResult: word=typeDecl/D/Mail, refs={ 2 }", "EntryResult: word=typeDecl/D/first_class, refs={ 2 }", "EntryResult: word=typeDecl/D/postcard, refs={ 2 }","EntryResult: word=typeDecl/V/PO_Box, refs={ 2 }", "EntryResult: word=typeDecl/V/size, refs={ 2 }", "EntryResult: word=typeDecl/V/temp, refs={ 2 }", "EntryResult: word=typeDecl/V/x, refs={ 2 }"};
|
||||
if (eresults.length != entryResultBeforeModel.length)
|
||||
fail("Entry Result length different from model");
|
||||
|
||||
|
@ -303,7 +304,7 @@ public class IndexManagerTests extends TestCase {
|
|||
IEntryResult[] typerefreesults = ind.queryEntries(IIndexConstants.TYPE_REF);
|
||||
assertTrue("Type Ref Results exist", typerefreesults != null);
|
||||
|
||||
String [] typeDeclEntryResultModel ={"EntryResult: word=typeDecl/C/Mail/Y/X/Z, refs={ 1 }","EntryResult: word=typeDecl/C/Unknown/Y/X/Z, refs={ 1 }","EntryResult: word=typeDecl/C/container/Y/X/Z, refs={ 1 }","EntryResult: word=typeDecl/C/first_class/Y/X/Z, refs={ 1 }","EntryResult: word=typeDecl/C/postcard/Y/X/Z, refs={ 1 }","EntryResult: word=typeDecl/E/test/Y/X/Z, refs={ 1 }","EntryResult: word=typeDecl/T/int32, refs={ 1 }", "EntryResult: word=typeDecl/V/PO_Box, refs={ 1 }", "EntryResult: word=typeDecl/V/size, refs={ 1 }", "EntryResult: word=typeDecl/V/temp, refs={ 1 }", "EntryResult: word=typeDecl/V/x, refs={ 1 }", "EntryResult: word=typeDecl/V/x/Z, refs={ 1 }"};
|
||||
String [] typeDeclEntryResultModel ={"EntryResult: word=typeDecl/C/Mail/Y/X/Z, refs={ 1 }","EntryResult: word=typeDecl/C/Unknown/Y/X/Z, refs={ 1 }","EntryResult: word=typeDecl/C/container/Y/X/Z, refs={ 1 }","EntryResult: word=typeDecl/C/first_class/Y/X/Z, refs={ 1 }","EntryResult: word=typeDecl/C/postcard/Y/X/Z, refs={ 1 }","EntryResult: word=typeDecl/D/Mail/Y/X/Z, refs={ 1 }", "EntryResult: word=typeDecl/D/first_class/Y/X/Z, refs={ 1 }", "EntryResult: word=typeDecl/D/postcard/Y/X/Z, refs={ 1 }","EntryResult: word=typeDecl/E/test/Y/X/Z, refs={ 1 }","EntryResult: word=typeDecl/T/int32, refs={ 1 }", "EntryResult: word=typeDecl/V/PO_Box, refs={ 1 }", "EntryResult: word=typeDecl/V/size, refs={ 1 }", "EntryResult: word=typeDecl/V/temp, refs={ 1 }", "EntryResult: word=typeDecl/V/x, refs={ 1 }", "EntryResult: word=typeDecl/V/x/Z, refs={ 1 }"};
|
||||
|
||||
IEntryResult[] typedeclresults =ind.queryEntries(IIndexConstants.TYPE_DECL);
|
||||
assertTrue("Type Decl Results exist", typedeclresults != null);
|
||||
|
@ -340,7 +341,7 @@ public class IndexManagerTests extends TestCase {
|
|||
assertEquals(namespaceResultModel[i],namespaceresults[i].toString());
|
||||
}
|
||||
|
||||
String [] fieldResultModel = {"EntryResult: word=fieldDecl/array/container/Y/X/Z, refs={ 1 }", "EntryResult: word=fieldDecl/bye/Y/X/Z, refs={ 1 }", "EntryResult: word=fieldDecl/cool/Y/X/Z, refs={ 1 }", "EntryResult: word=fieldDecl/hi/Y/X/Z, refs={ 1 }", "EntryResult: word=fieldDecl/index/container/Y/X/Z, refs={ 1 }", "EntryResult: word=fieldDecl/postage/Mail/Y/X/Z, refs={ 1 }", "EntryResult: word=fieldDecl/sz/container/Y/X/Z, refs={ 1 }", "EntryResult: word=fieldDecl/type/Mail/Y/X/Z, refs={ 1 }", "EntryResult: word=fieldDecl/why/Y/X/Z, refs={ 1 }"};
|
||||
String [] fieldResultModel = {"EntryResult: word=fieldDecl/array/container/Y/X/Z, refs={ 1 }", "EntryResult: word=fieldDecl/index/container/Y/X/Z, refs={ 1 }", "EntryResult: word=fieldDecl/postage/Mail/Y/X/Z, refs={ 1 }", "EntryResult: word=fieldDecl/sz/container/Y/X/Z, refs={ 1 }", "EntryResult: word=fieldDecl/type/Mail/Y/X/Z, refs={ 1 }"};
|
||||
IEntryResult[] fieldresults =ind.queryEntries(IIndexConstants.FIELD_DECL);
|
||||
assertTrue("Field Results exist", fieldresults != null);
|
||||
|
||||
|
@ -351,6 +352,18 @@ public class IndexManagerTests extends TestCase {
|
|||
{
|
||||
assertEquals(fieldResultModel[i],fieldresults[i].toString());
|
||||
}
|
||||
|
||||
String [] enumeratorResultModel = {"EntryResult: word=enumtorDecl/bye/Y/X/Z, refs={ 1 }", "EntryResult: word=enumtorDecl/cool/Y/X/Z, refs={ 1 }", "EntryResult: word=enumtorDecl/hi/Y/X/Z, refs={ 1 }", "EntryResult: word=enumtorDecl/why/Y/X/Z, refs={ 1 }"};
|
||||
IEntryResult[] enumeratorresults =ind.queryEntries(IIndexConstants.ENUMTOR_DECL);
|
||||
assertTrue("Enumerator Results exist", enumeratorresults != null);
|
||||
|
||||
if (enumeratorresults.length != enumeratorResultModel.length)
|
||||
fail("Entry Result length different from model for enumtorDecl");
|
||||
|
||||
for (int i=0;i<enumeratorresults.length; i++)
|
||||
{
|
||||
assertEquals(enumeratorResultModel[i],enumeratorresults[i].toString());
|
||||
}
|
||||
|
||||
String [] functionResultModel = {"EntryResult: word=functionDecl/doSomething, refs={ 1 }", "EntryResult: word=functionDecl/main/Y/X/Z, refs={ 1 }"};
|
||||
IEntryResult[] functionresults =ind.queryEntries(IIndexConstants.FUNCTION_DECL);
|
||||
|
|
|
@ -207,8 +207,21 @@ public class OtherPatternTests extends BaseSearchTest {
|
|||
assertEquals( matches.size(), 1 );
|
||||
}
|
||||
|
||||
public void testDerived(){
|
||||
ICSearchPattern pattern = SearchEngine.createSearchPattern( "A", DERIVED, DECLARATIONS, true );
|
||||
search( workspace, pattern, scope, resultCollector );
|
||||
|
||||
Set matches = resultCollector.getSearchResults();
|
||||
assertEquals( matches.size(), 1 );
|
||||
IMatch match = (IMatch) matches.iterator().next();
|
||||
assertTrue( match.getName().equals( "B" ) );
|
||||
assertTrue( match.getParentName().equals( "NS" ));
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void testEnumerators(){
|
||||
ICSearchPattern pattern = SearchEngine.createSearchPattern( "One", FIELD, DECLARATIONS, true );
|
||||
ICSearchPattern pattern = SearchEngine.createSearchPattern( "One", ENUMTOR, DECLARATIONS, true );
|
||||
|
||||
search( workspace, pattern, scope, resultCollector );
|
||||
|
||||
|
@ -218,7 +231,7 @@ public class OtherPatternTests extends BaseSearchTest {
|
|||
assertTrue( match.getName().equals( "One" ) );
|
||||
assertTrue( match.getParentName().equals( "NS::B" ));
|
||||
|
||||
pattern = SearchEngine.createSearchPattern( "NS::B::Two", FIELD, DECLARATIONS, true );
|
||||
pattern = SearchEngine.createSearchPattern( "NS::B::Two", ENUMTOR, DECLARATIONS, true );
|
||||
|
||||
search( workspace, pattern, scope, resultCollector );
|
||||
|
||||
|
@ -230,7 +243,7 @@ public class OtherPatternTests extends BaseSearchTest {
|
|||
}
|
||||
|
||||
public void testEnumeratorReferences(){
|
||||
ICSearchPattern pattern = SearchEngine.createSearchPattern( "One", FIELD, REFERENCES, true );
|
||||
ICSearchPattern pattern = SearchEngine.createSearchPattern( "One", ENUMTOR, REFERENCES, true );
|
||||
|
||||
search( workspace, pattern, scope, resultCollector );
|
||||
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
2004-04-12 Bogdan Gheorghe
|
||||
Added Enumerator and Derived types to index
|
||||
|
||||
2004-03-31 Bogdan Gheorghe
|
||||
Added a check to SourceIndexRequestor.removeMarkers to prevent hang.
|
||||
|
||||
|
|
|
@ -15,6 +15,8 @@ import java.io.IOException;
|
|||
import java.util.Iterator;
|
||||
|
||||
import org.eclipse.cdt.core.parser.ast.ASTClassKind;
|
||||
import org.eclipse.cdt.core.parser.ast.ASTNotImplementedException;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTBaseSpecifier;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTClassSpecifier;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTElaboratedTypeSpecifier;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTEnumerationSpecifier;
|
||||
|
@ -45,6 +47,7 @@ public abstract class AbstractIndexer implements IIndexer, IIndexConstants, ICSe
|
|||
final static int ENUM = 4;
|
||||
final static int VAR = 5;
|
||||
final static int TYPEDEF = 6;
|
||||
final static int DERIVED = 7;
|
||||
|
||||
public static boolean VERBOSE = false;
|
||||
|
||||
|
@ -60,10 +63,38 @@ public abstract class AbstractIndexer implements IIndexer, IIndexConstants, ICSe
|
|||
|
||||
if (classSpecification.getClassKind().equals(ASTClassKind.CLASS))
|
||||
{
|
||||
//Get base clauses
|
||||
Iterator i = classSpecification.getBaseClauses();
|
||||
while (i.hasNext()){
|
||||
IASTBaseSpecifier baseSpec = (IASTBaseSpecifier) i.next();
|
||||
try {
|
||||
IASTTypeSpecifier typeSpec = baseSpec.getParentClassSpecifier();
|
||||
if (typeSpec instanceof IASTClassSpecifier){
|
||||
IASTClassSpecifier baseClassSpec = (IASTClassSpecifier) typeSpec;
|
||||
String[] baseFullyQualifiedName = baseClassSpec.getFullyQualifiedName();
|
||||
this.output.addRef(encodeTypeEntry(baseFullyQualifiedName,DERIVED,ICSearchConstants.DECLARATIONS));
|
||||
}
|
||||
} catch (ASTNotImplementedException e) {}
|
||||
}
|
||||
|
||||
this.output.addRef(encodeTypeEntry(classSpecification.getFullyQualifiedName(),CLASS, ICSearchConstants.DECLARATIONS));
|
||||
}
|
||||
else if (classSpecification.getClassKind().equals(ASTClassKind.STRUCT))
|
||||
{
|
||||
//Get base clauses
|
||||
Iterator i = classSpecification.getBaseClauses();
|
||||
while (i.hasNext()){
|
||||
IASTBaseSpecifier baseSpec = (IASTBaseSpecifier) i.next();
|
||||
try {
|
||||
IASTTypeSpecifier typeSpec = baseSpec.getParentClassSpecifier();
|
||||
if (typeSpec instanceof IASTClassSpecifier){
|
||||
IASTClassSpecifier baseClassSpec = (IASTClassSpecifier) typeSpec;
|
||||
String[] baseFullyQualifiedName = baseClassSpec.getFullyQualifiedName();
|
||||
this.output.addRef(encodeTypeEntry(baseFullyQualifiedName,DERIVED,ICSearchConstants.DECLARATIONS));
|
||||
}
|
||||
} catch (ASTNotImplementedException e) {}
|
||||
}
|
||||
|
||||
this.output.addRef(encodeTypeEntry(classSpecification.getFullyQualifiedName(),STRUCT, ICSearchConstants.DECLARATIONS));
|
||||
}
|
||||
else if (classSpecification.getClassKind().equals(ASTClassKind.UNION))
|
||||
|
@ -82,7 +113,7 @@ public abstract class AbstractIndexer implements IIndexer, IIndexConstants, ICSe
|
|||
String[] enumeratorFullName =
|
||||
createEnumeratorFullyQualifiedName(en);
|
||||
|
||||
this.output.addRef(encodeEntry( enumeratorFullName, FIELD_DECL, FIELD_DECL_LENGTH ));
|
||||
this.output.addRef(encodeEntry( enumeratorFullName, ENUMTOR_DECL, ENUMTOR_DECL_LENGTH ));
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -101,7 +132,7 @@ public abstract class AbstractIndexer implements IIndexer, IIndexConstants, ICSe
|
|||
}
|
||||
|
||||
public void addEnumeratorReference(IASTEnumerator enumerator) {
|
||||
this.output.addRef(encodeEntry(createEnumeratorFullyQualifiedName(enumerator),FIELD_REF,FIELD_REF_LENGTH));
|
||||
this.output.addRef(encodeEntry(createEnumeratorFullyQualifiedName(enumerator),ENUMTOR_REF,ENUMTOR_REF_LENGTH));
|
||||
}
|
||||
|
||||
public void addMacro(IASTMacro macro) {
|
||||
|
@ -281,6 +312,9 @@ public abstract class AbstractIndexer implements IIndexer, IIndexConstants, ICSe
|
|||
case (TYPEDEF):
|
||||
result[pos++] = TYPEDEF_SUFFIX;
|
||||
break;
|
||||
|
||||
case(DERIVED):
|
||||
result[pos++]= DERIVED_SUFFIX;
|
||||
}
|
||||
result[pos++] = SEPARATOR;
|
||||
//Encode in the following manner
|
||||
|
@ -392,6 +426,8 @@ public abstract class AbstractIndexer implements IIndexer, IIndexConstants, ICSe
|
|||
classType = ENUM_SUFFIX;
|
||||
} else if ( searchFor == ICSearchConstants.TYPEDEF ){
|
||||
classType = TYPEDEF_SUFFIX;
|
||||
} else if ( searchFor == ICSearchConstants.DERIVED){
|
||||
classType = DERIVED_SUFFIX;
|
||||
} else {
|
||||
//could be TYPE or CLASS_STRUCT, best we can do for these is the prefix
|
||||
return prefix;
|
||||
|
@ -438,6 +474,19 @@ public abstract class AbstractIndexer implements IIndexer, IIndexConstants, ICSe
|
|||
|
||||
return bestPrefix( prefix, (char)0, fieldName, containingTypes, matchMode, isCaseSensitive );
|
||||
}
|
||||
|
||||
public static final char[] bestEnumeratorPrefix( LimitTo limitTo, char[] enumeratorName,char[][] containingTypes, int matchMode, boolean isCaseSensitive) {
|
||||
char [] prefix = null;
|
||||
if( limitTo == REFERENCES ){
|
||||
prefix = ENUMTOR_REF;
|
||||
} else if( limitTo == DECLARATIONS ){
|
||||
prefix = ENUMTOR_DECL;
|
||||
} else {
|
||||
return ENUMTOR_ALL;
|
||||
}
|
||||
|
||||
return bestPrefix( prefix, (char)0, enumeratorName, containingTypes, matchMode, isCaseSensitive );
|
||||
}
|
||||
|
||||
public static final char[] bestMethodPrefix( LimitTo limitTo, char[] methodName,char[][] containingTypes, int matchMode, boolean isCaseSensitive) {
|
||||
char [] prefix = null;
|
||||
|
|
|
@ -50,6 +50,13 @@ public interface IIndexConstants {
|
|||
char[] FIELD_ALL= "field".toCharArray(); //$NON-NLS-1$
|
||||
int FIELD_DECL_LENGTH = 10;
|
||||
|
||||
char[] ENUMTOR_REF= "enumtorRef/".toCharArray(); //$NON-NLS-1$
|
||||
int ENUMTOR_REF_LENGTH=11;
|
||||
|
||||
char[] ENUMTOR_DECL = "enumtorDecl/".toCharArray(); //$NON-NLS-1$
|
||||
char[] ENUMTOR_ALL = "enumtor".toCharArray(); //$NON-NLS-1$
|
||||
int ENUMTOR_DECL_LENGTH = 12;
|
||||
|
||||
char[] METHOD_REF= "methodRef/".toCharArray(); //$NON-NLS-1$
|
||||
int METHOD_REF_LENGTH = 10;
|
||||
|
||||
|
@ -96,6 +103,7 @@ public interface IIndexConstants {
|
|||
char ENUM_SUFFIX = 'E';
|
||||
char UNION_SUFFIX = 'U';
|
||||
char TYPEDEF_SUFFIX = 'T';
|
||||
char DERIVED_SUFFIX = 'D';
|
||||
|
||||
char TYPE_SUFFIX = 0;
|
||||
char SEPARATOR= '/';
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
2004-04-12 Bogdan Gheorghe
|
||||
Modified FieldDeclarationPattern to work with new Enumerator type, added
|
||||
DerivedTypesPattern.
|
||||
|
||||
2004-04-05 Andrew Niefer
|
||||
fix bug 54169, TYPE includes enum & typedef, handle that in ClassDeclarationPattern.matchLevel
|
||||
|
||||
|
|
|
@ -101,7 +101,10 @@ public interface ICSearchConstants {
|
|||
|
||||
public static final SearchFor INCLUDE = new SearchFor( 13 );
|
||||
|
||||
|
||||
public static final SearchFor DERIVED = new SearchFor( 14 );
|
||||
|
||||
public static final SearchFor ENUMTOR = new SearchFor( 15 );
|
||||
|
||||
/* Nature of match */
|
||||
|
||||
/**
|
||||
|
|
|
@ -114,12 +114,14 @@ public abstract class CSearchPattern implements ICSearchConstants, ICSearchPatte
|
|||
CSearchPattern pattern = null;
|
||||
if( searchFor == TYPE || searchFor == CLASS || searchFor == STRUCT ||
|
||||
searchFor == ENUM || searchFor == UNION || searchFor == CLASS_STRUCT ||
|
||||
searchFor == TYPEDEF )
|
||||
searchFor == TYPEDEF )
|
||||
{
|
||||
pattern = createClassPattern( patternString, searchFor, limitTo, matchMode, caseSensitive );
|
||||
} else if ( searchFor == DERIVED){
|
||||
pattern = createDerivedPattern(patternString, searchFor, limitTo, matchMode, caseSensitive );
|
||||
} else if ( searchFor == METHOD || searchFor == FUNCTION ){
|
||||
pattern = createMethodPattern( patternString, searchFor, limitTo, matchMode, caseSensitive );
|
||||
} else if ( searchFor == FIELD || searchFor == VAR ){
|
||||
} else if ( searchFor == FIELD || searchFor == VAR || searchFor == ENUMTOR){
|
||||
pattern = createFieldPattern( patternString, searchFor, limitTo, matchMode, caseSensitive );
|
||||
} else if ( searchFor == NAMESPACE ){
|
||||
pattern = createNamespacePattern( patternString, limitTo, matchMode, caseSensitive );
|
||||
|
@ -397,7 +399,31 @@ public abstract class CSearchPattern implements ICSearchConstants, ICSearchPatte
|
|||
}
|
||||
|
||||
|
||||
|
||||
private static CSearchPattern createDerivedPattern(String patternString, SearchFor searchFor, LimitTo limitTo, int matchMode, boolean caseSensitive) {
|
||||
|
||||
|
||||
IScanner scanner =null;
|
||||
try {
|
||||
scanner =
|
||||
ParserFactory.createScanner(
|
||||
new StringReader(patternString),
|
||||
"TEXT", //$NON-NLS-1$
|
||||
new ScannerInfo(),
|
||||
ParserMode.QUICK_PARSE,
|
||||
ParserLanguage.CPP,
|
||||
callback, nullLog, null);
|
||||
} catch (ParserFactoryError e1) {
|
||||
}
|
||||
|
||||
searchFor = DERIVED;
|
||||
|
||||
LinkedList list = scanForNames( scanner, null );
|
||||
|
||||
char[] name = (char [])list.removeLast();
|
||||
char [][] qualifications = new char[0][];
|
||||
|
||||
return new DerivedTypesPattern( name, (char[][])list.toArray( qualifications ), searchFor, limitTo, matchMode, caseSensitive );
|
||||
}
|
||||
/**
|
||||
* @param scanner
|
||||
* @param object
|
||||
|
|
|
@ -146,10 +146,10 @@ public class ClassDeclarationPattern extends CSearchPattern {
|
|||
return classKind;
|
||||
}
|
||||
|
||||
private char[] simpleName;
|
||||
private char[][] qualifications;
|
||||
private ASTClassKind classKind;
|
||||
private SearchFor searchFor;
|
||||
protected char[] simpleName;
|
||||
protected char[][] qualifications;
|
||||
protected ASTClassKind classKind;
|
||||
protected SearchFor searchFor;
|
||||
|
||||
protected char[] decodedSimpleName;
|
||||
private char[][] decodedContainingTypes;
|
||||
|
|
|
@ -0,0 +1,122 @@
|
|||
/*
|
||||
* Created on Apr 8, 2004
|
||||
*
|
||||
* TODO To change the template for this generated file go to
|
||||
* Window - Preferences - Java - Code Generation - Code and Comments
|
||||
*/
|
||||
package org.eclipse.cdt.internal.core.search.matching;
|
||||
|
||||
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.ASTNotImplementedException;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTBaseSpecifier;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTClassSpecifier;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTElaboratedTypeSpecifier;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTEnumerationSpecifier;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTOffsetableNamedElement;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTQualifiedNameElement;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTTypeSpecifier;
|
||||
import org.eclipse.cdt.core.search.ICSearchConstants;
|
||||
import org.eclipse.cdt.internal.core.search.indexing.AbstractIndexer;
|
||||
|
||||
/**
|
||||
* @author bgheorgh
|
||||
*
|
||||
* TODO To change the template for this generated type comment go to
|
||||
* Window - Preferences - Java - Code Generation - Code and Comments
|
||||
*/
|
||||
public class DerivedTypesPattern extends ClassDeclarationPattern {
|
||||
|
||||
/**
|
||||
* @param name
|
||||
* @param containers
|
||||
* @param searchFor
|
||||
* @param limit
|
||||
* @param mode
|
||||
* @param caseSensitive
|
||||
*/
|
||||
public DerivedTypesPattern(char[] name, char[][] containers, SearchFor searchFor, LimitTo limit, int mode, boolean caseSensitive) {
|
||||
super(name, containers, searchFor, limit, mode, caseSensitive);
|
||||
}
|
||||
|
||||
public char[] indexEntryPrefix() {
|
||||
return AbstractIndexer.bestTypePrefix(
|
||||
searchFor,
|
||||
getLimitTo(),
|
||||
simpleName,
|
||||
qualifications,
|
||||
_matchMode,
|
||||
_caseSensitive
|
||||
);
|
||||
}
|
||||
|
||||
protected boolean matchIndexEntry() {
|
||||
if( decodedType != DERIVED_SUFFIX ){
|
||||
return false;
|
||||
}
|
||||
|
||||
return super.matchIndexEntry();
|
||||
}
|
||||
|
||||
public int matchLevel( ISourceElementCallbackDelegate node, LimitTo limit ){
|
||||
|
||||
if (!( node instanceof IASTClassSpecifier )) {
|
||||
return IMPOSSIBLE_MATCH;
|
||||
}
|
||||
|
||||
if( ! canAccept( limit ) )
|
||||
return IMPOSSIBLE_MATCH;
|
||||
|
||||
IASTClassSpecifier tempNode = (IASTClassSpecifier) node;
|
||||
Iterator i = tempNode.getBaseClauses();
|
||||
|
||||
boolean matchFlag=false;
|
||||
|
||||
while (i.hasNext()){
|
||||
IASTBaseSpecifier baseSpec = (IASTBaseSpecifier) i.next();
|
||||
IASTTypeSpecifier typeSpec = null;
|
||||
try {
|
||||
typeSpec = baseSpec.getParentClassSpecifier();
|
||||
} catch (ASTNotImplementedException e) {}
|
||||
if (typeSpec instanceof IASTClassSpecifier){
|
||||
IASTClassSpecifier baseClassSpec = (IASTClassSpecifier) typeSpec;
|
||||
String[] baseFullyQualifiedName = baseClassSpec.getFullyQualifiedName();
|
||||
|
||||
//check name, if simpleName == null, its treated the same as "*"
|
||||
if( simpleName != null && !matchesName( simpleName, baseClassSpec.getName().toCharArray() ) ){
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
char [][] qualName = new char [ baseFullyQualifiedName.length - 1 ][];
|
||||
for( int j = 0; j < baseFullyQualifiedName.length - 1; j++ ){
|
||||
qualName[j] = baseFullyQualifiedName[j].toCharArray();
|
||||
}
|
||||
//check containing scopes
|
||||
if( !matchQualifications( qualifications, qualName ) ){
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
matchFlag = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* //check type
|
||||
if( classKind != null ){
|
||||
if( node instanceof IASTClassSpecifier ){
|
||||
IASTClassSpecifier clsSpec = (IASTClassSpecifier) node;
|
||||
return ( classKind == clsSpec.getClassKind() ) ? ACCURATE_MATCH : IMPOSSIBLE_MATCH;
|
||||
}
|
||||
}*/
|
||||
|
||||
if (matchFlag)
|
||||
return ACCURATE_MATCH;
|
||||
|
||||
return IMPOSSIBLE_MATCH;
|
||||
}
|
||||
}
|
|
@ -64,7 +64,7 @@ public class FieldDeclarationPattern extends CSearchPattern {
|
|||
if( searchFor != VAR || !canAccept( limit ) )
|
||||
return IMPOSSIBLE_MATCH;
|
||||
} else if ( node instanceof IASTEnumerator ){
|
||||
if( searchFor != FIELD || !canAccept( limit ) )
|
||||
if( searchFor != ENUMTOR || !canAccept( limit ) )
|
||||
return IMPOSSIBLE_MATCH;
|
||||
} else if( node instanceof IASTParameterDeclaration ){
|
||||
if( searchFor != VAR || !canAccept( limit ) )
|
||||
|
@ -127,6 +127,8 @@ public class FieldDeclarationPattern extends CSearchPattern {
|
|||
simpleName, qualifications,
|
||||
_matchMode, _caseSensitive
|
||||
);
|
||||
} else if (searchFor == ENUMTOR) {
|
||||
return AbstractIndexer.bestEnumeratorPrefix(_limitTo, simpleName, qualifications, _matchMode, _caseSensitive );
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
@ -149,6 +151,9 @@ public class FieldDeclarationPattern extends CSearchPattern {
|
|||
int realStart = CharOperation.indexOf( SEPARATOR, word, 0 );
|
||||
firstSlash = CharOperation.indexOf( SEPARATOR, word, realStart + 1);
|
||||
slash = CharOperation.indexOf(SEPARATOR, word, firstSlash + 1);
|
||||
} else if ( searchFor == ENUMTOR ){
|
||||
firstSlash = CharOperation.indexOf( SEPARATOR, word, 0 );
|
||||
slash = CharOperation.indexOf(SEPARATOR, word, firstSlash + 1);
|
||||
}
|
||||
|
||||
this.decodedSimpleName = CharOperation.subarray(word, firstSlash + 1, slash);
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
2004-04-12 Bogdan Gheorghe
|
||||
Added Enumerator, Derived types to search dialog
|
||||
|
||||
2004-04-12 Hoda Amer
|
||||
From Chris Wiebe
|
||||
This patch updates the class wizard to use the type cache & type
|
||||
|
|
|
@ -37,6 +37,8 @@ CSearchPage.searchFor.class= &Class
|
|||
CSearchPage.searchFor.struct= &Struct
|
||||
CSearchPage.searchFor.union= U&nion
|
||||
CSearchPage.searchFor.enum= &Enumeration
|
||||
CSearchPage.searchFor.enumr = Enume&rator
|
||||
CSearchPage.searchFor.derived = &Derived
|
||||
CSearchPage.searchFor.any= An&y Element
|
||||
CSearchPage.searchFor.classStruct= &Class / Struct
|
||||
|
||||
|
|
|
@ -16,6 +16,7 @@ package org.eclipse.cdt.internal.ui.search;
|
|||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.StringReader;
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
|
@ -317,6 +318,7 @@ public class CSearchPage extends DialogPage implements ISearchPage, ICSearchCons
|
|||
set.add( DEFINITIONS );
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
for( int i = 0; i < fLimitTo.length; i++ )
|
||||
|
@ -646,7 +648,7 @@ public class CSearchPage extends DialogPage implements ISearchPage, ICSearchCons
|
|||
private static List fgPreviousSearchPatterns = new ArrayList(20);
|
||||
|
||||
private Button[] fSearchFor;
|
||||
private SearchFor[] fSearchForValues = { CLASS_STRUCT, FUNCTION, VAR, UNION, METHOD, FIELD, ENUM, NAMESPACE, UNKNOWN_SEARCH_FOR };
|
||||
private SearchFor[] fSearchForValues = { CLASS_STRUCT, FUNCTION, VAR, UNION, METHOD, FIELD, ENUM, ENUMTOR, NAMESPACE, DERIVED, UNKNOWN_SEARCH_FOR };
|
||||
|
||||
private String[] fSearchForText= {
|
||||
CSearchMessages.getString("CSearchPage.searchFor.classStruct"), //$NON-NLS-1$
|
||||
|
@ -656,7 +658,9 @@ public class CSearchPage extends DialogPage implements ISearchPage, ICSearchCons
|
|||
CSearchMessages.getString("CSearchPage.searchFor.method"), //$NON-NLS-1$
|
||||
CSearchMessages.getString("CSearchPage.searchFor.field"), //$NON-NLS-1$
|
||||
CSearchMessages.getString("CSearchPage.searchFor.enum"), //$NON-NLS-1$
|
||||
CSearchMessages.getString("CSearchPage.searchFor.enumr"), //$NON-NLS-1$
|
||||
CSearchMessages.getString("CSearchPage.searchFor.namespace"), //$NON-NLS-1$
|
||||
CSearchMessages.getString("CSearchPage.searchFor.derived"), //$NON-NLS-1$
|
||||
CSearchMessages.getString("CSearchPage.searchFor.any") }; //$NON-NLS-1$
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue