mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Patch for Andrew Niefer
core: - modifications to CSearchPattern.scanForNames() - add getSimpleName to MethodDeclarationPattern tests: - Added FunctionMethodPatternTests.testBug43498()
This commit is contained in:
parent
02c194aaf4
commit
18e0534368
5 changed files with 52 additions and 7 deletions
|
@ -3,6 +3,9 @@
|
|||
Moved testPostfixTypeIdExpression2() && testPostfixTypeIdTypeId2() to CompleteParseASTExpressionTest.
|
||||
Restructured expression reference tests so that the order of arrival will not cause JUnit failures.
|
||||
|
||||
2003-09-23 Andrew Niefer
|
||||
Added FunctionMethodPatternTests.testBug43498()
|
||||
|
||||
2003-09-23 Hoda Amer
|
||||
Added CompleteParseASTTest.testBug43373()
|
||||
Added QuickParseASTTests.testBug43371()
|
||||
|
|
|
@ -140,4 +140,27 @@ public class FunctionMethodPatternTests extends BaseSearchTest {
|
|||
matches = resultCollector.getSearchResults();
|
||||
assertEquals( matches.size(), 3 ); //3 in classDecl.cpp
|
||||
}
|
||||
|
||||
public void testBug43498(){
|
||||
ICSearchPattern pattern = SearchEngine.createSearchPattern( "operator ?elete", METHOD, DECLARATIONS, true );
|
||||
|
||||
assertTrue( pattern instanceof MethodDeclarationPattern );
|
||||
MethodDeclarationPattern methodPattern = (MethodDeclarationPattern) pattern;
|
||||
|
||||
char [] string = new char[] {'o','p','e','r','a','t','o','r',' ','?','e','l','e','t','e'};
|
||||
assertTrue( CharOperation.equals( string, methodPattern.getSimpleName() ) );
|
||||
|
||||
pattern = SearchEngine.createSearchPattern( "operator delete", METHOD, DECLARATIONS, true );
|
||||
assertTrue( pattern instanceof MethodDeclarationPattern );
|
||||
methodPattern = (MethodDeclarationPattern) pattern;
|
||||
string = new char[] {'o','p','e','r','a','t','o','r',' ','d','e','l','e','t','e'};
|
||||
assertTrue( CharOperation.equals( string, methodPattern.getSimpleName() ) );
|
||||
|
||||
pattern = SearchEngine.createSearchPattern( "word?word", METHOD, DECLARATIONS, true );
|
||||
assertTrue( pattern instanceof MethodDeclarationPattern );
|
||||
methodPattern = (MethodDeclarationPattern) pattern;
|
||||
|
||||
string = new char[] {'w','o','r','d','?','w','o','r','d'};
|
||||
assertTrue( CharOperation.equals( string, methodPattern.getSimpleName() ) );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,3 +1,8 @@
|
|||
2003-09-23 Andrew Niefer
|
||||
fix bug 43498 Search with ? fails on first letter of second word
|
||||
-modifications to CSearchPattern.scanForNames()
|
||||
-add getSimpleName to MethodDeclarationPattern
|
||||
|
||||
2003-09-19 Andrew Niefer
|
||||
fix bug 43327 Code Complete finds local variables
|
||||
- modified MatchLocator to not report local declarations when boolean is set
|
||||
|
|
|
@ -417,27 +417,37 @@ public abstract class CSearchPattern implements ICSearchConstants, ICSearchPatte
|
|||
IToken token = ( unusedToken != null ) ? unusedToken : scanner.nextToken();
|
||||
scanner.setThrowExceptionOnBadCharacterRead( true );
|
||||
|
||||
boolean lastTokenWasWild = false;
|
||||
boolean encounteredWild = false;
|
||||
boolean lastTokenWasOperator = false;
|
||||
|
||||
while( true ){
|
||||
switch( token.getType() ){
|
||||
case IToken.tCOLONCOLON :
|
||||
list.addLast( name.toCharArray() );
|
||||
name = new String("");
|
||||
lastTokenWasOperator = false;
|
||||
break;
|
||||
|
||||
case IToken.t_operator :
|
||||
name += token.getImage() + " ";
|
||||
lastTokenWasOperator = true;
|
||||
break;
|
||||
|
||||
default:
|
||||
if( token.getType() == IToken.tSTAR ||
|
||||
token.getType() == IToken.tQUESTION ||
|
||||
token.getType() == IToken.tCOMPL //Need this for destructors
|
||||
){
|
||||
lastTokenWasWild = true;
|
||||
} else if( !lastTokenWasWild && name.length() > 0 ) {
|
||||
encounteredWild = true;
|
||||
} else if( !encounteredWild && !lastTokenWasOperator && name.length() > 0 ) {
|
||||
name += " ";
|
||||
} else {
|
||||
lastTokenWasWild = false;
|
||||
encounteredWild = false;
|
||||
}
|
||||
|
||||
name += token.getImage();
|
||||
|
||||
lastTokenWasOperator = false;
|
||||
break;
|
||||
}
|
||||
token = null;
|
||||
|
@ -446,9 +456,10 @@ public abstract class CSearchPattern implements ICSearchConstants, ICSearchPatte
|
|||
token = scanner.nextToken();
|
||||
} catch ( ScannerException e ){
|
||||
if( e.getErrorCode() == ScannerException.ErrorCode.INVALID_ESCAPE_CHARACTER_SEQUENCE ){
|
||||
if( !lastTokenWasWild ) name += " ";
|
||||
if( !encounteredWild && !lastTokenWasOperator ) name += " ";
|
||||
name += "\\";
|
||||
lastTokenWasWild = true;
|
||||
encounteredWild = true;
|
||||
lastTokenWasOperator = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -57,7 +57,10 @@ public class MethodDeclarationPattern extends CSearchPattern {
|
|||
searchFor = search;
|
||||
}
|
||||
|
||||
|
||||
public char [] getSimpleName(){
|
||||
return simpleName;
|
||||
}
|
||||
|
||||
public int matchLevel(ISourceElementCallbackDelegate node, LimitTo limit ) {
|
||||
if( node instanceof IASTMethod ){
|
||||
if( searchFor != METHOD || !canAccept( limit ) ){
|
||||
|
|
Loading…
Add table
Reference in a new issue