mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-09 18:56:02 +02:00
Patch for Andrew Niefer
core: - modify CSearchPattern.scanForNames to use same naming convention as TokenDuple.toString() - modify MatchLocator.report to use IASTOffsetableNamedElement.getNameEndOffset() core.tests: - added testBug43062 and testConstructorDestructor to FunctionMethodPatternTests - modified resources/search/classDecl.cpp & include.h to include more operators and a constructor
This commit is contained in:
parent
9fa37457ae
commit
c50efc6fd5
7 changed files with 68 additions and 10 deletions
|
@ -1,3 +1,8 @@
|
||||||
|
2003-09-29 Andrew Niefer
|
||||||
|
added testBug43062 and testConstructorDestructor to FunctionMethodPatternTests
|
||||||
|
modified resources/search/classDecl.cpp & include.h to include more operators and a constructor
|
||||||
|
& destructor
|
||||||
|
|
||||||
2003-09-29 Andrew Niefer
|
2003-09-29 Andrew Niefer
|
||||||
added testbug43834() to ParserSymbolTableTest
|
added testbug43834() to ParserSymbolTableTest
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,8 @@
|
||||||
class Heal{};
|
class Heal{};
|
||||||
|
|
||||||
class A {
|
class A {
|
||||||
|
A() {}
|
||||||
|
~A(){}
|
||||||
class B {
|
class B {
|
||||||
void f( A );
|
void f( A );
|
||||||
void f( A & );
|
void f( A & );
|
||||||
|
|
|
@ -6,6 +6,10 @@ class Head {
|
||||||
Head * operator * ( int index ){ return array[ index ]; }
|
Head * operator * ( int index ){ return array[ index ]; }
|
||||||
Head * operator += ( int index );
|
Head * operator += ( int index );
|
||||||
|
|
||||||
|
operator const short & ();
|
||||||
|
operator short ();
|
||||||
|
operator short int ();
|
||||||
|
|
||||||
Head ** array;
|
Head ** array;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -138,7 +138,7 @@ public class FunctionMethodPatternTests extends BaseSearchTest {
|
||||||
pattern = SearchEngine.createSearchPattern( "operator *", METHOD, DECLARATIONS, true );
|
pattern = SearchEngine.createSearchPattern( "operator *", METHOD, DECLARATIONS, true );
|
||||||
search( workspace, pattern, scope, resultCollector );
|
search( workspace, pattern, scope, resultCollector );
|
||||||
matches = resultCollector.getSearchResults();
|
matches = resultCollector.getSearchResults();
|
||||||
assertEquals( matches.size(), 3 ); //3 in classDecl.cpp
|
assertEquals( matches.size(), 6 ); //3 in classDecl.cpp
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testBug43498(){
|
public void testBug43498(){
|
||||||
|
@ -163,4 +163,32 @@ public class FunctionMethodPatternTests extends BaseSearchTest {
|
||||||
string = new char[] {'w','o','r','d','?','w','o','r','d'};
|
string = new char[] {'w','o','r','d','?','w','o','r','d'};
|
||||||
assertTrue( CharOperation.equals( string, methodPattern.getSimpleName() ) );
|
assertTrue( CharOperation.equals( string, methodPattern.getSimpleName() ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testBug43062(){
|
||||||
|
MethodDeclarationPattern pattern = (MethodDeclarationPattern) SearchEngine.createSearchPattern( "operator const short &", METHOD, DECLARATIONS, true );
|
||||||
|
char [] string = new char [] { 'o','p','e','r','a','t','o','r',' ','c','o','n','s','t',' ','s','h','o','r','t',' ','&' };
|
||||||
|
assertTrue( CharOperation.equals( string, pattern.getSimpleName() ) );
|
||||||
|
|
||||||
|
pattern = (MethodDeclarationPattern) SearchEngine.createSearchPattern( "operator short", METHOD, DECLARATIONS, true );
|
||||||
|
string = new char [] { 'o','p','e','r','a','t','o','r',' ','s','h','o','r','t' };
|
||||||
|
assertTrue( CharOperation.equals( string, pattern.getSimpleName() ) );
|
||||||
|
|
||||||
|
pattern = (MethodDeclarationPattern) SearchEngine.createSearchPattern( "operator short int", METHOD, DECLARATIONS, true );
|
||||||
|
string = new char [] { 'o','p','e','r','a','t','o','r',' ','s','h','o','r','t',' ','i','n','t' };
|
||||||
|
assertTrue( CharOperation.equals( string, pattern.getSimpleName() ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testConstructorDestructor(){
|
||||||
|
ICSearchPattern pattern = SearchEngine.createSearchPattern( "A", METHOD, DECLARATIONS, true );
|
||||||
|
search( workspace, pattern, scope, resultCollector );
|
||||||
|
|
||||||
|
Set matches = resultCollector.getSearchResults();
|
||||||
|
assertEquals( matches.size(), 1 );
|
||||||
|
|
||||||
|
pattern = SearchEngine.createSearchPattern( "~A", METHOD, DECLARATIONS, true );
|
||||||
|
search( workspace, pattern, scope, resultCollector );
|
||||||
|
|
||||||
|
matches = resultCollector.getSearchResults();
|
||||||
|
assertEquals( matches.size(), 1 );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,8 @@
|
||||||
|
2003-09-29 Andrew Niefer
|
||||||
|
- fix bug 43062 outline is confused on operator methods containing spaces
|
||||||
|
- modify CSearchPattern.scanForNames to use same naming convention as TokenDuple.toString()
|
||||||
|
- modify MatchLocator.report to use IASTOffsetableNamedElement.getNameEndOffset()
|
||||||
|
|
||||||
2003-09-29 Andrew Niefer
|
2003-09-29 Andrew Niefer
|
||||||
-fix NPE if IScannerInfoProvider returns null IScannerInfo
|
-fix NPE if IScannerInfoProvider returns null IScannerInfo
|
||||||
|
|
||||||
|
|
|
@ -433,6 +433,8 @@ public abstract class CSearchPattern implements ICSearchConstants, ICSearchPatte
|
||||||
|
|
||||||
try {
|
try {
|
||||||
IToken token = ( unusedToken != null ) ? unusedToken : scanner.nextToken();
|
IToken token = ( unusedToken != null ) ? unusedToken : scanner.nextToken();
|
||||||
|
IToken prev = null;
|
||||||
|
|
||||||
scanner.setThrowExceptionOnBadCharacterRead( true );
|
scanner.setThrowExceptionOnBadCharacterRead( true );
|
||||||
|
|
||||||
boolean encounteredWild = false;
|
boolean encounteredWild = false;
|
||||||
|
@ -453,11 +455,17 @@ public abstract class CSearchPattern implements ICSearchConstants, ICSearchPatte
|
||||||
|
|
||||||
default:
|
default:
|
||||||
if( token.getType() == IToken.tSTAR ||
|
if( token.getType() == IToken.tSTAR ||
|
||||||
token.getType() == IToken.tQUESTION ||
|
token.getType() == IToken.tQUESTION
|
||||||
token.getType() == IToken.tCOMPL //Need this for destructors
|
|
||||||
){
|
){
|
||||||
encounteredWild = true;
|
encounteredWild = true;
|
||||||
} else if( !encounteredWild && !lastTokenWasOperator && name.length() > 0 ) {
|
} else if( !encounteredWild && !lastTokenWasOperator && name.length() > 0 &&
|
||||||
|
prev.getType() != IToken.tIDENTIFIER &&
|
||||||
|
prev.getType() != IToken.tLT &&
|
||||||
|
prev.getType() != IToken.tCOMPL &&
|
||||||
|
prev.getType() != IToken.tLBRACKET &&
|
||||||
|
token.getType() != IToken.tRBRACKET &&
|
||||||
|
token.getType()!= IToken.tGT
|
||||||
|
){
|
||||||
name += " ";
|
name += " ";
|
||||||
} else {
|
} else {
|
||||||
encounteredWild = false;
|
encounteredWild = false;
|
||||||
|
@ -468,6 +476,8 @@ public abstract class CSearchPattern implements ICSearchConstants, ICSearchPatte
|
||||||
lastTokenWasOperator = false;
|
lastTokenWasOperator = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
prev = token;
|
||||||
|
|
||||||
token = null;
|
token = null;
|
||||||
while( token == null ){
|
while( token == null ){
|
||||||
try{
|
try{
|
||||||
|
@ -478,10 +488,10 @@ public abstract class CSearchPattern implements ICSearchConstants, ICSearchPatte
|
||||||
name += "\\";
|
name += "\\";
|
||||||
encounteredWild = true;
|
encounteredWild = true;
|
||||||
lastTokenWasOperator = false;
|
lastTokenWasOperator = false;
|
||||||
|
prev = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
} catch (EndOfFile e) {
|
} catch (EndOfFile e) {
|
||||||
list.addLast( name.toCharArray() );
|
list.addLast( name.toCharArray() );
|
||||||
|
|
|
@ -442,19 +442,23 @@ public class MatchLocator implements ISourceElementRequestor, ICSearchConstants
|
||||||
protected void report( ISourceElementCallbackDelegate node, int accuracyLevel ){
|
protected void report( ISourceElementCallbackDelegate node, int accuracyLevel ){
|
||||||
try {
|
try {
|
||||||
int offset = 0;
|
int offset = 0;
|
||||||
int length = 0;
|
int end = 0;
|
||||||
|
|
||||||
if( node instanceof IASTReference ){
|
if( node instanceof IASTReference ){
|
||||||
IASTReference reference = (IASTReference) node;
|
IASTReference reference = (IASTReference) node;
|
||||||
offset = reference.getOffset();
|
offset = reference.getOffset();
|
||||||
length = reference.getName().length();
|
end = offset + reference.getName().length();;
|
||||||
if (VERBOSE)
|
if (VERBOSE)
|
||||||
MatchLocator.verbose("Report Match: " + reference.getName());
|
MatchLocator.verbose("Report Match: " + reference.getName());
|
||||||
} else if( node instanceof IASTOffsetableNamedElement ){
|
} else if( node instanceof IASTOffsetableNamedElement ){
|
||||||
IASTOffsetableNamedElement offsetableElement = (IASTOffsetableNamedElement) node;
|
IASTOffsetableNamedElement offsetableElement = (IASTOffsetableNamedElement) node;
|
||||||
offset = offsetableElement.getNameOffset() != 0 ? offsetableElement.getNameOffset()
|
offset = offsetableElement.getNameOffset() != 0 ? offsetableElement.getNameOffset()
|
||||||
: offsetableElement.getStartingOffset();
|
: offsetableElement.getStartingOffset();
|
||||||
length = offsetableElement.getName().length();
|
end = offsetableElement.getNameEndOffset();
|
||||||
|
if( end == 0 ){
|
||||||
|
end = offset + offsetableElement.getName().length();;
|
||||||
|
}
|
||||||
|
|
||||||
if (VERBOSE)
|
if (VERBOSE)
|
||||||
MatchLocator.verbose("Report Match: " + offsetableElement.getName());
|
MatchLocator.verbose("Report Match: " + offsetableElement.getName());
|
||||||
}
|
}
|
||||||
|
@ -482,9 +486,9 @@ public class MatchLocator implements ISourceElementRequestor, ICSearchConstants
|
||||||
}
|
}
|
||||||
|
|
||||||
if( currentResource != null ){
|
if( currentResource != null ){
|
||||||
match = resultCollector.createMatch( currentResource, offset, offset + length, object );
|
match = resultCollector.createMatch( currentResource, offset, end, object );
|
||||||
} else if( currentPath != null ){
|
} else if( currentPath != null ){
|
||||||
match = resultCollector.createMatch( currentPath, offset, offset + length, object );
|
match = resultCollector.createMatch( currentPath, offset, end, object );
|
||||||
}
|
}
|
||||||
if( match != null ){
|
if( match != null ){
|
||||||
resultCollector.acceptMatch( match );
|
resultCollector.acceptMatch( match );
|
||||||
|
|
Loading…
Add table
Reference in a new issue