mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-08 02:06:01 +02:00
Patch for Bogdan : Search for function with no parameters VS ignore parameters.
This commit is contained in:
parent
90c0309950
commit
2937f68a8c
6 changed files with 314 additions and 269 deletions
|
@ -1,3 +1,6 @@
|
||||||
|
2004-02-06 Bogdan Gheorghe
|
||||||
|
Added FunctionMethodPatternTests.testMethodDeclarationWithNoParameters
|
||||||
|
|
||||||
2004-02-08 John Camelon
|
2004-02-08 John Camelon
|
||||||
Moved testErrorHandling_1() from failed tests to CompleteParseASTTest.
|
Moved testErrorHandling_1() from failed tests to CompleteParseASTTest.
|
||||||
Moved testBug44340() from failed tests to CompleteParseASTTest.
|
Moved testBug44340() from failed tests to CompleteParseASTTest.
|
||||||
|
|
|
@ -27,6 +27,8 @@ void forwardFunction();
|
||||||
|
|
||||||
class Direction{
|
class Direction{
|
||||||
void turn();
|
void turn();
|
||||||
|
void turn(int);
|
||||||
|
void turnAgain(void);
|
||||||
};
|
};
|
||||||
class Right : public Direction {
|
class Right : public Direction {
|
||||||
void turn() { }
|
void turn() { }
|
||||||
|
|
|
@ -105,6 +105,27 @@ public class FunctionMethodPatternTests extends BaseSearchTest {
|
||||||
assertEquals( matches.size(), 1 );
|
assertEquals( matches.size(), 1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testMethodWithNoParameters(){
|
||||||
|
ICSearchPattern pattern = SearchEngine.createSearchPattern( "turn( )", METHOD, DECLARATIONS, true );
|
||||||
|
|
||||||
|
search( workspace, pattern, scope, resultCollector );
|
||||||
|
Set matches = resultCollector.getSearchResults();
|
||||||
|
assertEquals( matches.size(), 2 );
|
||||||
|
|
||||||
|
pattern = SearchEngine.createSearchPattern( "turn(void)", METHOD, DECLARATIONS, true );
|
||||||
|
|
||||||
|
search( workspace, pattern, scope, resultCollector );
|
||||||
|
matches = resultCollector.getSearchResults();
|
||||||
|
assertEquals( matches.size(), 2 );
|
||||||
|
|
||||||
|
pattern = SearchEngine.createSearchPattern( "turnAgain()", METHOD, DECLARATIONS, true );
|
||||||
|
|
||||||
|
search( workspace, pattern, scope, resultCollector );
|
||||||
|
matches = resultCollector.getSearchResults();
|
||||||
|
assertEquals( matches.size(), 1 );
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public void testOperators_bug43063_bug42979(){
|
public void testOperators_bug43063_bug42979(){
|
||||||
ICSearchPattern pattern = SearchEngine.createSearchPattern( "operator \\*", METHOD, DECLARATIONS, true );
|
ICSearchPattern pattern = SearchEngine.createSearchPattern( "operator \\*", METHOD, DECLARATIONS, true );
|
||||||
|
|
||||||
|
@ -196,7 +217,7 @@ public class FunctionMethodPatternTests extends BaseSearchTest {
|
||||||
ICSearchPattern pattern = SearchEngine.createSearchPattern( "turn", METHOD, DECLARATIONS, true );
|
ICSearchPattern pattern = SearchEngine.createSearchPattern( "turn", METHOD, DECLARATIONS, true );
|
||||||
search( workspace, pattern, scope, resultCollector );
|
search( workspace, pattern, scope, resultCollector );
|
||||||
Set matches = resultCollector.getSearchResults();
|
Set matches = resultCollector.getSearchResults();
|
||||||
assertEquals( matches.size(), 2 );
|
assertEquals( matches.size(), 3 );
|
||||||
|
|
||||||
pattern = SearchEngine.createSearchPattern( "Direction::turn", METHOD, DEFINITIONS, true );
|
pattern = SearchEngine.createSearchPattern( "Direction::turn", METHOD, DEFINITIONS, true );
|
||||||
search( workspace, pattern, scope, resultCollector );
|
search( workspace, pattern, scope, resultCollector );
|
||||||
|
|
|
@ -1,3 +1,10 @@
|
||||||
|
2004-02-06 Bogdan Gheorghe
|
||||||
|
|
||||||
|
- Modified CSearchPattern.scanforParameters. If no parameters are passed in
|
||||||
|
as part of a function/method search, void is assigned as a parameter type.
|
||||||
|
|
||||||
|
- Modified MethodDeclarationPattern to check for void parameter types
|
||||||
|
|
||||||
2004-02-05 Alain Magloire
|
2004-02-05 Alain Magloire
|
||||||
PR 51221
|
PR 51221
|
||||||
Reformat Patch from Bogdan base on Thomas Fletcher original patch
|
Reformat Patch from Bogdan base on Thomas Fletcher original patch
|
||||||
|
|
|
@ -452,6 +452,12 @@ public abstract class CSearchPattern implements ICSearchConstants, ICSearchPatte
|
||||||
param = getParamString( (IASTParameterDeclaration)parameters.next() );
|
param = getParamString( (IASTParameterDeclaration)parameters.next() );
|
||||||
list.add( param );
|
list.add( param );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (param == null){
|
||||||
|
//This means that no params have been added (i.e. empty brackets - void case)
|
||||||
|
param = "void ".toCharArray();
|
||||||
|
list.add (param);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return list;
|
return list;
|
||||||
|
|
|
@ -96,11 +96,17 @@ 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();
|
||||||
|
|
||||||
|
if (!params.hasNext() && CharOperation.equals(parameterNames[0], "void ".toCharArray())){
|
||||||
|
//All empty lists have transformed to void, this function has no parms
|
||||||
|
return ACCURATE_MATCH;
|
||||||
|
}
|
||||||
|
|
||||||
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.
|
||||||
|
|
Loading…
Add table
Reference in a new issue