mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-01 06:05:24 +02:00
Patch for Andrew Niefer
Core : Index Enumerator references - Added createEnumeratorFullyQualifiedName in AbstractIndexer - Added addEnumeratorReference in AbstractIndexer - implemented acceptEnumeratorReference in SourceIndexerRequestor Search pattern matching on function parameters: - modified scanForParameters in CSearchPattern - added getParamString in CSearchPattern - modified matchLevel in MethodDeclarationPattern Enumeration references - modified acceptEnumeratorReference in MatchLocator core.tests: Modified resources/search/classDecl.cpp - to include more function declarations to test parameter matching - to include an enumerator reference to test enumerators Added testMethodDeclarationParameterMatching to FunctionMethodPatternTests.java Added testEnumeratorReferences to OtherPatternTests
This commit is contained in:
parent
0ec0b04c3e
commit
ceee55836e
12 changed files with 196 additions and 100 deletions
|
@ -1,3 +1,10 @@
|
||||||
|
2003-09-09 Andrew Niefer
|
||||||
|
Modified resources/search/classDecl.cpp
|
||||||
|
- to include more function declarations to test parameter matching
|
||||||
|
- to include an enumerator reference to test enumerators
|
||||||
|
Added testMethodDeclarationParameterMatching to FunctionMethodPatternTests.java
|
||||||
|
Added testEnumeratorReferences to OtherPatternTests
|
||||||
|
|
||||||
2003-09-08 John Camelon
|
2003-09-08 John Camelon
|
||||||
Added CompleteParseASTTest::testThrowStatement(), testScoping(), testEnumeratorReferences().
|
Added CompleteParseASTTest::testThrowStatement(), testScoping(), testEnumeratorReferences().
|
||||||
Removed LineNumberTest source as it is obsolete.
|
Removed LineNumberTest source as it is obsolete.
|
||||||
|
|
|
@ -7,6 +7,9 @@ class Heal{};
|
||||||
class A {
|
class A {
|
||||||
class B {
|
class B {
|
||||||
void f( A );
|
void f( A );
|
||||||
|
void f( A & );
|
||||||
|
void f( A* );
|
||||||
|
void f( int &, const char [], A ** );
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -15,6 +18,7 @@ namespace NS {
|
||||||
struct a{};
|
struct a{};
|
||||||
}
|
}
|
||||||
class B: public A {
|
class B: public A {
|
||||||
|
public:
|
||||||
struct AA {};
|
struct AA {};
|
||||||
enum e {
|
enum e {
|
||||||
One,
|
One,
|
||||||
|
@ -32,7 +36,7 @@ namespace NS {
|
||||||
|
|
||||||
namespace NS3{
|
namespace NS3{
|
||||||
class C : public NS::B {
|
class C : public NS::B {
|
||||||
e eE;
|
e eE = One;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -198,7 +198,7 @@ public class ClassDeclarationPatternTests extends BaseSearchTest implements ICSe
|
||||||
search( workspace, pattern, scope, resultCollector );
|
search( workspace, pattern, scope, resultCollector );
|
||||||
|
|
||||||
Set matches = resultCollector.getSearchResults();
|
Set matches = resultCollector.getSearchResults();
|
||||||
assertEquals( matches.size(), 3 );
|
assertEquals( matches.size(), 6 );
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testClassReferenceInFieldType(){
|
public void testClassReferenceInFieldType(){
|
||||||
|
@ -255,6 +255,6 @@ public class ClassDeclarationPatternTests extends BaseSearchTest implements ICSe
|
||||||
|
|
||||||
Set matches = resultCollector.getSearchResults();
|
Set matches = resultCollector.getSearchResults();
|
||||||
|
|
||||||
assertEquals( matches.size(), 4 );//TODO was 6, changed for bug 41445
|
assertEquals( matches.size(), 7 );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -73,7 +73,7 @@ public class FunctionMethodPatternTests extends BaseSearchTest {
|
||||||
|
|
||||||
Set matches = resultCollector.getSearchResults();
|
Set matches = resultCollector.getSearchResults();
|
||||||
|
|
||||||
assertEquals( matches.size(), 1 );
|
assertEquals( matches.size(), 4 );
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testMethodDeclarationWithParams() {
|
public void testMethodDeclarationWithParams() {
|
||||||
|
@ -83,5 +83,24 @@ public class FunctionMethodPatternTests extends BaseSearchTest {
|
||||||
|
|
||||||
Set matches = resultCollector.getSearchResults();
|
Set matches = resultCollector.getSearchResults();
|
||||||
|
|
||||||
assertEquals( matches.size(), 1 ); }
|
assertEquals( matches.size(), 1 );
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testMethodDeclarationParameterMatching(){
|
||||||
|
ICSearchPattern pattern = SearchEngine.createSearchPattern( "f( A & )", METHOD, DECLARATIONS, true );
|
||||||
|
|
||||||
|
search( workspace, pattern, scope, resultCollector );
|
||||||
|
Set matches = resultCollector.getSearchResults();
|
||||||
|
assertEquals( matches.size(), 1 );
|
||||||
|
|
||||||
|
pattern = SearchEngine.createSearchPattern( "f( A * )", METHOD, DECLARATIONS, true );
|
||||||
|
search( workspace, pattern, scope, resultCollector );
|
||||||
|
matches = resultCollector.getSearchResults();
|
||||||
|
assertEquals( matches.size(), 1 );
|
||||||
|
|
||||||
|
pattern = SearchEngine.createSearchPattern( "f( int &, const char [], A** )", METHOD, DECLARATIONS, true );
|
||||||
|
search( workspace, pattern, scope, resultCollector );
|
||||||
|
matches = resultCollector.getSearchResults();
|
||||||
|
assertEquals( matches.size(), 1 );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -193,4 +193,13 @@ public class OtherPatternTests extends BaseSearchTest {
|
||||||
assertEquals( matches.size(), 1 );
|
assertEquals( matches.size(), 1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testEnumeratorReferences(){
|
||||||
|
ICSearchPattern pattern = SearchEngine.createSearchPattern( "One", FIELD, REFERENCES, true );
|
||||||
|
|
||||||
|
search( workspace, pattern, scope, resultCollector );
|
||||||
|
|
||||||
|
Set matches = resultCollector.getSearchResults();
|
||||||
|
assertEquals( matches.size(), 1 );
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,9 @@
|
||||||
|
2003-09-09 Andrew Niefer
|
||||||
|
Enumerator references
|
||||||
|
- Added createEnumeratorFullyQualifiedName in AbstractIndexer
|
||||||
|
- Added addEnumeratorReference in AbstractIndexer
|
||||||
|
- implemented acceptEnumeratorReference in SourceIndexerRequestor
|
||||||
|
|
||||||
2003-09-08 Andrew Niefer
|
2003-09-08 Andrew Niefer
|
||||||
- Modified calls to ParserFactory to specify which language to use
|
- Modified calls to ParserFactory to specify which language to use
|
||||||
|
|
||||||
|
|
|
@ -71,25 +71,35 @@ public abstract class AbstractIndexer implements IIndexer, IIndexConstants, ICSe
|
||||||
public void addEnumerationSpecifier(IASTEnumerationSpecifier enumeration) {
|
public void addEnumerationSpecifier(IASTEnumerationSpecifier enumeration) {
|
||||||
this.output.addRef(encodeTypeEntry(enumeration.getFullyQualifiedName(), ENUM, ICSearchConstants.DECLARATIONS));
|
this.output.addRef(encodeTypeEntry(enumeration.getFullyQualifiedName(), ENUM, ICSearchConstants.DECLARATIONS));
|
||||||
|
|
||||||
Iterator i = enumeration.getEnumerators();
|
Iterator i = enumeration.getEnumerators();
|
||||||
while (i.hasNext())
|
while (i.hasNext())
|
||||||
{
|
{
|
||||||
IASTEnumerator en = (IASTEnumerator) i.next();
|
IASTEnumerator en = (IASTEnumerator) i.next();
|
||||||
String name = en.getName();
|
String[] enumeratorFullName =
|
||||||
IASTEnumerationSpecifier parent = en.getOwnerEnumerationSpecifier();
|
createEnumeratorFullyQualifiedName(en);
|
||||||
String[] parentName = parent.getFullyQualifiedName();
|
|
||||||
|
|
||||||
//See spec 7.2-10, the the scope of the enumerator is the same level as the enumeration
|
|
||||||
String[] enumeratorFullName = new String[ parentName.length ];
|
|
||||||
|
|
||||||
System.arraycopy( parentName, 0, enumeratorFullName, 0, parentName.length);
|
|
||||||
enumeratorFullName[ parentName.length - 1 ] = name;
|
|
||||||
|
|
||||||
this.output.addRef(encodeEntry( enumeratorFullName, FIELD_DECL, FIELD_DECL_LENGTH ));
|
this.output.addRef(encodeEntry( enumeratorFullName, FIELD_DECL, FIELD_DECL_LENGTH ));
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected String[] createEnumeratorFullyQualifiedName(IASTEnumerator en) {
|
||||||
|
String name = en.getName();
|
||||||
|
IASTEnumerationSpecifier parent = en.getOwnerEnumerationSpecifier();
|
||||||
|
String[] parentName = parent.getFullyQualifiedName();
|
||||||
|
|
||||||
|
//See spec 7.2-10, the the scope of the enumerator is the same level as the enumeration
|
||||||
|
String[] enumeratorFullName = new String[ parentName.length ];
|
||||||
|
|
||||||
|
System.arraycopy( parentName, 0, enumeratorFullName, 0, parentName.length);
|
||||||
|
enumeratorFullName[ parentName.length - 1 ] = name;
|
||||||
|
return enumeratorFullName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addEnumeratorReference(IASTEnumerator enumerator) {
|
||||||
|
this.output.addRef(encodeEntry(createEnumeratorFullyQualifiedName(enumerator),FIELD_REF,FIELD_REF_LENGTH));
|
||||||
|
}
|
||||||
|
|
||||||
public void addMacro(IASTMacro macro) {
|
public void addMacro(IASTMacro macro) {
|
||||||
String[] macroName = new String[1];
|
String[] macroName = new String[1];
|
||||||
macroName[0] = macro.getName();
|
macroName[0] = macro.getName();
|
||||||
|
@ -574,6 +584,5 @@ public abstract class AbstractIndexer implements IIndexer, IIndexConstants, ICSe
|
||||||
|
|
||||||
return bestPrefix( prefix, (char)0, macroName, null, matchMode, isCaseSenstive );
|
return bestPrefix( prefix, (char)0, macroName, null, matchMode, isCaseSenstive );
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,6 +26,7 @@ import org.eclipse.cdt.core.parser.ast.IASTCompilationUnit;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTElaboratedTypeSpecifier;
|
import org.eclipse.cdt.core.parser.ast.IASTElaboratedTypeSpecifier;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTEnumerationReference;
|
import org.eclipse.cdt.core.parser.ast.IASTEnumerationReference;
|
||||||
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.IASTEnumeratorReference;
|
import org.eclipse.cdt.core.parser.ast.IASTEnumeratorReference;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTField;
|
import org.eclipse.cdt.core.parser.ast.IASTField;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTFieldReference;
|
import org.eclipse.cdt.core.parser.ast.IASTFieldReference;
|
||||||
|
@ -38,7 +39,6 @@ import org.eclipse.cdt.core.parser.ast.IASTMethod;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTMethodReference;
|
import org.eclipse.cdt.core.parser.ast.IASTMethodReference;
|
||||||
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.IASTNamespaceReference;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTScope;
|
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTTemplateDeclaration;
|
import org.eclipse.cdt.core.parser.ast.IASTTemplateDeclaration;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTTemplateInstantiation;
|
import org.eclipse.cdt.core.parser.ast.IASTTemplateInstantiation;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTTemplateSpecialization;
|
import org.eclipse.cdt.core.parser.ast.IASTTemplateSpecialization;
|
||||||
|
@ -438,7 +438,8 @@ public class SourceIndexerRequestor implements ISourceElementRequestor, IIndexCo
|
||||||
*/
|
*/
|
||||||
public void acceptEnumeratorReference(IASTEnumeratorReference reference)
|
public void acceptEnumeratorReference(IASTEnumeratorReference reference)
|
||||||
{
|
{
|
||||||
// TODO Auto-generated method stub
|
if( reference.getReferencedElement() instanceof IASTEnumerator )
|
||||||
|
indexer.addEnumeratorReference( (IASTEnumerator)reference.getReferencedElement() );
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,12 @@
|
||||||
|
2003-09-09 Andrew Niefer
|
||||||
|
pattern matching on function parameters:
|
||||||
|
- modified scanForParameters in CSearchPattern
|
||||||
|
- added getParamString in CSearchPattern
|
||||||
|
- modified matchLevel in MethodDeclarationPattern
|
||||||
|
|
||||||
|
Enumeration references
|
||||||
|
- modified acceptEnumeratorReference in MatchLocator
|
||||||
|
|
||||||
2003-09-05 Andrew Niefer
|
2003-09-05 Andrew Niefer
|
||||||
- fix searching for enumerators
|
- fix searching for enumerators
|
||||||
|
|
||||||
|
|
|
@ -15,9 +15,12 @@ package org.eclipse.cdt.internal.core.search.matching;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.StringReader;
|
import java.io.StringReader;
|
||||||
|
import java.util.Iterator;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.parser.EndOfFile;
|
import org.eclipse.cdt.core.parser.EndOfFile;
|
||||||
|
import org.eclipse.cdt.core.parser.IParser;
|
||||||
|
import org.eclipse.cdt.core.parser.IQuickParseCallback;
|
||||||
import org.eclipse.cdt.core.parser.IScanner;
|
import org.eclipse.cdt.core.parser.IScanner;
|
||||||
import org.eclipse.cdt.core.parser.IToken;
|
import org.eclipse.cdt.core.parser.IToken;
|
||||||
import org.eclipse.cdt.core.parser.ParserLanguage;
|
import org.eclipse.cdt.core.parser.ParserLanguage;
|
||||||
|
@ -25,6 +28,16 @@ import org.eclipse.cdt.core.parser.ParserFactory;
|
||||||
import org.eclipse.cdt.core.parser.ParserMode;
|
import org.eclipse.cdt.core.parser.ParserMode;
|
||||||
import org.eclipse.cdt.core.parser.ScannerException;
|
import org.eclipse.cdt.core.parser.ScannerException;
|
||||||
import org.eclipse.cdt.core.parser.ast.ASTClassKind;
|
import org.eclipse.cdt.core.parser.ast.ASTClassKind;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.ASTNotImplementedException;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.ASTPointerOperator;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTClassSpecifier;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTCompilationUnit;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTElaboratedTypeSpecifier;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTEnumerationSpecifier;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTFunction;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTParameterDeclaration;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTSimpleTypeSpecifier;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTTypeSpecifier;
|
||||||
import org.eclipse.cdt.core.search.ICSearchConstants;
|
import org.eclipse.cdt.core.search.ICSearchConstants;
|
||||||
import org.eclipse.cdt.core.search.ICSearchPattern;
|
import org.eclipse.cdt.core.search.ICSearchPattern;
|
||||||
import org.eclipse.cdt.core.search.ICSearchScope;
|
import org.eclipse.cdt.core.search.ICSearchScope;
|
||||||
|
@ -210,10 +223,8 @@ public abstract class CSearchPattern implements ICSearchConstants, ICSearchPatte
|
||||||
IScanner scanner = ParserFactory.createScanner( new StringReader( nameString ), "TEXT", new ScannerInfo(), ParserMode.QUICK_PARSE, ParserLanguage.CPP, null );
|
IScanner scanner = ParserFactory.createScanner( new StringReader( nameString ), "TEXT", new ScannerInfo(), ParserMode.QUICK_PARSE, ParserLanguage.CPP, null );
|
||||||
|
|
||||||
LinkedList names = scanForNames( scanner, null );
|
LinkedList names = scanForNames( scanner, null );
|
||||||
|
|
||||||
scanner = ParserFactory.createScanner( new StringReader( paramString ), "TEXT", new ScannerInfo(), ParserMode.QUICK_PARSE, ParserLanguage.CPP, null );
|
LinkedList params = scanForParameters( paramString );
|
||||||
|
|
||||||
LinkedList params = scanForParameters( scanner );
|
|
||||||
|
|
||||||
char [] name = (char [])names.removeLast();
|
char [] name = (char [])names.removeLast();
|
||||||
char [][] qualifications = new char[0][];
|
char [][] qualifications = new char[0][];
|
||||||
|
@ -298,53 +309,99 @@ public abstract class CSearchPattern implements ICSearchConstants, ICSearchPatte
|
||||||
* @param object
|
* @param object
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
private static LinkedList scanForParameters(IScanner scanner) {
|
private static LinkedList scanForParameters( String paramString ) {
|
||||||
LinkedList list = new LinkedList();
|
LinkedList list = new LinkedList();
|
||||||
|
|
||||||
String param = new String("");
|
if( paramString == null || paramString.equals("") )
|
||||||
|
return list;
|
||||||
|
|
||||||
boolean lastTokenWasWild = false;
|
String functionString = "void f " + paramString + ";";
|
||||||
try{
|
|
||||||
IToken token = scanner.nextToken();
|
|
||||||
|
|
||||||
tokenConsumption:
|
|
||||||
while( true ){
|
|
||||||
switch( token.getType() ){
|
|
||||||
case IToken.tCOMMA :
|
|
||||||
list.addLast( param.toCharArray() );
|
|
||||||
param = new String("");
|
|
||||||
break;
|
|
||||||
|
|
||||||
case IToken.tLPAREN :
|
|
||||||
break;
|
|
||||||
|
|
||||||
case IToken.tRPAREN :
|
|
||||||
list.addLast( param.toCharArray() );
|
|
||||||
break tokenConsumption;
|
|
||||||
|
|
||||||
case IToken.tSTAR:
|
|
||||||
case IToken.tQUESTION:
|
|
||||||
lastTokenWasWild = true;
|
|
||||||
param += token.getImage();
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
if( !lastTokenWasWild && param.length() > 0 )
|
|
||||||
param += " ";
|
|
||||||
param += token.getImage();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
token = scanner.nextToken();
|
IScanner scanner = ParserFactory.createScanner( new StringReader( functionString ), "TEXT", new ScannerInfo(), ParserMode.QUICK_PARSE, ParserLanguage.CPP, null );
|
||||||
|
IQuickParseCallback callback = ParserFactory.createQuickParseCallback();
|
||||||
|
IParser parser = ParserFactory.createParser( scanner, callback, ParserMode.QUICK_PARSE, ParserLanguage.CPP );
|
||||||
|
|
||||||
|
if( parser.parse() ){
|
||||||
|
IASTCompilationUnit compUnit = callback.getCompilationUnit();
|
||||||
|
Iterator declarations = null;
|
||||||
|
try {
|
||||||
|
declarations = compUnit.getDeclarations();
|
||||||
|
} catch (ASTNotImplementedException e) {
|
||||||
|
}
|
||||||
|
|
||||||
|
if( declarations == null || ! declarations.hasNext() )
|
||||||
|
return null;
|
||||||
|
IASTFunction function = (IASTFunction) declarations.next();
|
||||||
|
|
||||||
|
Iterator parameters = function.getParameters();
|
||||||
|
char [] param = null;
|
||||||
|
while( parameters.hasNext() ){
|
||||||
|
param = getParamString( (IASTParameterDeclaration)parameters.next() );
|
||||||
|
list.add( param );
|
||||||
}
|
}
|
||||||
} catch ( EndOfFile e ){
|
|
||||||
list.addLast( param.toCharArray() );
|
|
||||||
} catch( ScannerException e ){
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static public char [] getParamString( IASTParameterDeclaration param ){
|
||||||
|
if( param == null ) return null;
|
||||||
|
|
||||||
|
String signature = "";
|
||||||
|
|
||||||
|
IASTTypeSpecifier typeSpec = param.getTypeSpecifier();
|
||||||
|
if( typeSpec instanceof IASTSimpleTypeSpecifier ){
|
||||||
|
IASTSimpleTypeSpecifier simple = (IASTSimpleTypeSpecifier)typeSpec;
|
||||||
|
signature += simple.getTypename();
|
||||||
|
} else if( typeSpec instanceof IASTElaboratedTypeSpecifier ){
|
||||||
|
IASTElaboratedTypeSpecifier elaborated = (IASTElaboratedTypeSpecifier)typeSpec;
|
||||||
|
if( elaborated.getClassKind() == ASTClassKind.CLASS ){
|
||||||
|
signature += "class ";
|
||||||
|
} else if( elaborated.getClassKind() == ASTClassKind.ENUM ) {
|
||||||
|
signature += "enum ";
|
||||||
|
} else if( elaborated.getClassKind() == ASTClassKind.STRUCT ) {
|
||||||
|
signature += "struct ";
|
||||||
|
} else if( elaborated.getClassKind() == ASTClassKind.UNION ) {
|
||||||
|
signature += "union";
|
||||||
|
}
|
||||||
|
|
||||||
|
signature += elaborated.getName();
|
||||||
|
} else if( typeSpec instanceof IASTClassSpecifier ){
|
||||||
|
IASTClassSpecifier classSpec = (IASTClassSpecifier)typeSpec;
|
||||||
|
signature += classSpec.getName();
|
||||||
|
} else if( typeSpec instanceof IASTEnumerationSpecifier ){
|
||||||
|
IASTEnumerationSpecifier enumSpec = (IASTEnumerationSpecifier)typeSpec;
|
||||||
|
signature += enumSpec.getName();
|
||||||
|
}
|
||||||
|
|
||||||
|
signature += " ";
|
||||||
|
|
||||||
|
if( param.isConst() ) signature += "const ";
|
||||||
|
if( param.isVolatile() ) signature += "volatile ";
|
||||||
|
|
||||||
|
Iterator ptrs = param.getPointerOperators();
|
||||||
|
while( ptrs.hasNext() ){
|
||||||
|
ASTPointerOperator ptrOp = (ASTPointerOperator) ptrs.next();
|
||||||
|
if( ptrOp == ASTPointerOperator.POINTER ){
|
||||||
|
signature += " * ";
|
||||||
|
} else if( ptrOp == ASTPointerOperator.REFERENCE ){
|
||||||
|
signature += " & ";
|
||||||
|
} else if( ptrOp == ASTPointerOperator.CONST_POINTER ){
|
||||||
|
signature += " const * ";
|
||||||
|
} else if( ptrOp == ASTPointerOperator.VOLATILE_POINTER ){
|
||||||
|
signature += " volatile * ";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Iterator arrayModifiers = param.getArrayModifiers();
|
||||||
|
while( arrayModifiers.hasNext() ){
|
||||||
|
arrayModifiers.next();
|
||||||
|
signature += " [] ";
|
||||||
|
}
|
||||||
|
|
||||||
|
return signature.toCharArray();
|
||||||
|
}
|
||||||
|
|
||||||
static private LinkedList scanForNames( IScanner scanner, IToken unusedToken ){
|
static private LinkedList scanForNames( IScanner scanner, IToken unusedToken ){
|
||||||
LinkedList list = new LinkedList();
|
LinkedList list = new LinkedList();
|
||||||
|
|
||||||
|
|
|
@ -126,7 +126,15 @@ public class MatchLocator implements ISourceElementRequestor, ICSearchConstants
|
||||||
public void exitTemplateSpecialization(IASTTemplateSpecialization specialization) { }
|
public void exitTemplateSpecialization(IASTTemplateSpecialization specialization) { }
|
||||||
public void exitTemplateExplicitInstantiation(IASTTemplateInstantiation instantiation) { }
|
public void exitTemplateExplicitInstantiation(IASTTemplateInstantiation instantiation) { }
|
||||||
public void exitLinkageSpecification(IASTLinkageSpecification linkageSpec) { }
|
public void exitLinkageSpecification(IASTLinkageSpecification linkageSpec) { }
|
||||||
|
|
||||||
|
public void enterCodeBlock(IASTCodeScope scope) { }
|
||||||
|
public void exitCodeBlock(IASTCodeScope scope) { }
|
||||||
|
|
||||||
|
|
||||||
|
public void acceptEnumeratorReference(IASTEnumeratorReference reference){
|
||||||
|
check( REFERENCES, reference );
|
||||||
|
}
|
||||||
|
|
||||||
public void acceptMacro(IASTMacro macro){
|
public void acceptMacro(IASTMacro macro){
|
||||||
check( DECLARATIONS, macro );
|
check( DECLARATIONS, macro );
|
||||||
}
|
}
|
||||||
|
@ -465,29 +473,5 @@ public class MatchLocator implements ISourceElementRequestor, ICSearchConstants
|
||||||
System.out.println("(" + Thread.currentThread() + ") " + log);
|
System.out.println("(" + Thread.currentThread() + ") " + log);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.core.parser.ISourceElementRequestor#enterCodeBlock(org.eclipse.cdt.core.parser.ast.IASTScope)
|
|
||||||
*/
|
|
||||||
public void enterCodeBlock(IASTCodeScope scope) {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.core.parser.ISourceElementRequestor#exitCodeBlock(org.eclipse.cdt.core.parser.ast.IASTScope)
|
|
||||||
*/
|
|
||||||
public void exitCodeBlock(IASTCodeScope scope) {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.core.parser.ISourceElementRequestor#acceptEnumeratorReference(org.eclipse.cdt.core.parser.ast.IASTEnumerationReference)
|
|
||||||
*/
|
|
||||||
public void acceptEnumeratorReference(IASTEnumeratorReference reference)
|
|
||||||
{
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,11 +19,8 @@ import java.util.Iterator;
|
||||||
import org.eclipse.cdt.core.parser.ISourceElementCallbackDelegate;
|
import org.eclipse.cdt.core.parser.ISourceElementCallbackDelegate;
|
||||||
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.IASTOffsetableNamedElement;
|
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTParameterDeclaration;
|
import org.eclipse.cdt.core.parser.ast.IASTParameterDeclaration;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTQualifiedNameElement;
|
import org.eclipse.cdt.core.parser.ast.IASTQualifiedNameElement;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTSimpleTypeSpecifier;
|
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTTypeSpecifier;
|
|
||||||
import org.eclipse.cdt.core.search.ICSearchScope;
|
import org.eclipse.cdt.core.search.ICSearchScope;
|
||||||
import org.eclipse.cdt.internal.core.CharOperation;
|
import org.eclipse.cdt.internal.core.CharOperation;
|
||||||
import org.eclipse.cdt.internal.core.index.IEntryResult;
|
import org.eclipse.cdt.internal.core.index.IEntryResult;
|
||||||
|
@ -96,8 +93,9 @@ public class MethodDeclarationPattern extends CSearchPattern {
|
||||||
|
|
||||||
//parameters
|
//parameters
|
||||||
if( parameterNames != null && parameterNames.length > 0 && parameterNames[0].length > 0 ){
|
if( parameterNames != null && parameterNames.length > 0 && parameterNames[0].length > 0 ){
|
||||||
|
|
||||||
Iterator params = function.getParameters();
|
Iterator params = function.getParameters();
|
||||||
|
|
||||||
for( int i = 0; i < parameterNames.length; i++ ){
|
for( int i = 0; i < parameterNames.length; i++ ){
|
||||||
|
|
||||||
//if this function doesn't have this many parameters, it is not a match.
|
//if this function doesn't have this many parameters, it is not a match.
|
||||||
|
@ -105,21 +103,14 @@ public class MethodDeclarationPattern extends CSearchPattern {
|
||||||
if( !params.hasNext() || parameterNames[ i ] == null )
|
if( !params.hasNext() || parameterNames[ i ] == null )
|
||||||
return IMPOSSIBLE_MATCH;
|
return IMPOSSIBLE_MATCH;
|
||||||
|
|
||||||
IASTParameterDeclaration param = (IASTParameterDeclaration) params.next();
|
IASTParameterDeclaration parameter = (IASTParameterDeclaration) params.next();
|
||||||
IASTTypeSpecifier typeSpec = param.getTypeSpecifier();
|
char[] param = CSearchPattern.getParamString( parameter );
|
||||||
String paramName = null;
|
|
||||||
if( typeSpec instanceof IASTSimpleTypeSpecifier ){
|
|
||||||
paramName = ((IASTSimpleTypeSpecifier)typeSpec).getTypename();
|
|
||||||
} else if( typeSpec instanceof IASTOffsetableNamedElement ){
|
|
||||||
paramName = ((IASTOffsetableNamedElement)typeSpec).getName();
|
|
||||||
} else {
|
|
||||||
//???
|
|
||||||
return IMPOSSIBLE_MATCH;
|
|
||||||
}
|
|
||||||
|
|
||||||
if( !matchesName( parameterNames[i], paramName.toCharArray() ) )
|
//no wildcards in parameters strings
|
||||||
|
if( !CharOperation.equals( parameterNames[i], param, _caseSensitive ) )
|
||||||
return IMPOSSIBLE_MATCH;
|
return IMPOSSIBLE_MATCH;
|
||||||
}
|
}
|
||||||
|
|
||||||
//if this function still has more parameters, it is not a match
|
//if this function still has more parameters, it is not a match
|
||||||
if( params.hasNext() )
|
if( params.hasNext() )
|
||||||
return IMPOSSIBLE_MATCH;
|
return IMPOSSIBLE_MATCH;
|
||||||
|
|
Loading…
Add table
Reference in a new issue