[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
[cdt-patch] bug 43062 outline is confused on operator methods containing spaces
|
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
-Andrew
Index: search/ChangeLog
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/search/ChangeLog,v
retrieving revision 1.31
diff -u -r1.31 ChangeLog
--- search/ChangeLog 29 Sep 2003 19:49:13 -0000 1.31
+++ search/ChangeLog 29 Sep 2003 20:12:16 -0000
@@ -1,4 +1,9 @@
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
-fix NPE if IScannerInfoProvider returns null IScannerInfo
2003-09-25 Andrew Niefer
Index: search/org/eclipse/cdt/internal/core/search/matching/CSearchPattern.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/search/org/eclipse/cdt/internal/core/search/matching/CSearchPattern.java,v
retrieving revision 1.25
diff -u -r1.25 CSearchPattern.java
--- search/org/eclipse/cdt/internal/core/search/matching/CSearchPattern.java 26 Sep 2003 17:53:31 -0000 1.25
+++ search/org/eclipse/cdt/internal/core/search/matching/CSearchPattern.java 29 Sep 2003 20:12:16 -0000
@@ -433,6 +433,8 @@
try {
IToken token = ( unusedToken != null ) ? unusedToken : scanner.nextToken();
+ IToken prev = null;
+
scanner.setThrowExceptionOnBadCharacterRead( true );
boolean encounteredWild = false;
@@ -453,11 +455,17 @@
default:
if( token.getType() == IToken.tSTAR ||
- token.getType() == IToken.tQUESTION ||
- token.getType() == IToken.tCOMPL //Need this for destructors
+ token.getType() == IToken.tQUESTION
){
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 += " ";
} else {
encounteredWild = false;
@@ -468,6 +476,8 @@
lastTokenWasOperator = false;
break;
}
+ prev = token;
+
token = null;
while( token == null ){
try{
@@ -478,10 +488,10 @@
name += "\\";
encounteredWild = true;
lastTokenWasOperator = false;
+ prev = null;
}
}
}
-
}
} catch (EndOfFile e) {
list.addLast( name.toCharArray() );
Index: search/org/eclipse/cdt/internal/core/search/matching/MatchLocator.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/search/org/eclipse/cdt/internal/core/search/matching/MatchLocator.java,v
retrieving revision 1.34
diff -u -r1.34 MatchLocator.java
--- search/org/eclipse/cdt/internal/core/search/matching/MatchLocator.java 29 Sep 2003 19:49:13 -0000 1.34
+++ search/org/eclipse/cdt/internal/core/search/matching/MatchLocator.java 29 Sep 2003 20:12:16 -0000
@@ -442,19 +442,23 @@
protected void report( ISourceElementCallbackDelegate node, int accuracyLevel ){
try {
int offset = 0;
- int length = 0;
+ int end = 0;
if( node instanceof IASTReference ){
IASTReference reference = (IASTReference) node;
offset = reference.getOffset();
- length = reference.getName().length();
+ end = offset + reference.getName().length();;
if (VERBOSE)
MatchLocator.verbose("Report Match: " + reference.getName());
} else if( node instanceof IASTOffsetableNamedElement ){
IASTOffsetableNamedElement offsetableElement = (IASTOffsetableNamedElement) node;
offset = offsetableElement.getNameOffset() != 0 ? offsetableElement.getNameOffset()
: offsetableElement.getStartingOffset();
- length = offsetableElement.getName().length();
+ end = offsetableElement.getNameEndOffset();
+ if( end == 0 ){
+ end = offset + offsetableElement.getName().length();;
+ }
+
if (VERBOSE)
MatchLocator.verbose("Report Match: " + offsetableElement.getName());
}
@@ -482,9 +486,9 @@
}
if( currentResource != null ){
- match = resultCollector.createMatch( currentResource, offset, offset + length, object );
+ match = resultCollector.createMatch( currentResource, offset, end, object );
} else if( currentPath != null ){
- match = resultCollector.createMatch( currentPath, offset, offset + length, object );
+ match = resultCollector.createMatch( currentPath, offset, end, object );
}
if( match != null ){
resultCollector.acceptMatch( match );
Index: ChangeLog
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core.tests/ChangeLog,v
retrieving revision 1.121
diff -u -r1.121 ChangeLog
--- ChangeLog 29 Sep 2003 19:49:19 -0000 1.121
+++ ChangeLog 29 Sep 2003 20:10:35 -0000
@@ -1,4 +1,9 @@
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
added testbug43834() to ParserSymbolTableTest
2003-09-29 John Camelon
Index: resources/search/classDecl.cpp
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core.tests/resources/search/classDecl.cpp,v
retrieving revision 1.12
diff -u -r1.12 classDecl.cpp
--- resources/search/classDecl.cpp 26 Sep 2003 14:58:17 -0000 1.12
+++ resources/search/classDecl.cpp 29 Sep 2003 20:10:35 -0000
@@ -5,6 +5,8 @@
class Heal{};
class A {
+ A() {}
+ ~A(){}
class B {
void f( A );
void f( A & );
Index: resources/search/include.h
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core.tests/resources/search/include.h,v
retrieving revision 1.3
diff -u -r1.3 include.h
--- resources/search/include.h 26 Sep 2003 14:58:17 -0000 1.3
+++ resources/search/include.h 29 Sep 2003 20:10:35 -0000
@@ -6,6 +6,10 @@
Head * operator * ( int index ){ return array[ index ]; }
Head * operator += ( int index );
+ operator const short & ();
+ operator short ();
+ operator short int ();
+
Head ** array;
};
Index: search/org/eclipse/cdt/core/search/tests/FunctionMethodPatternTests.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core.tests/search/org/eclipse/cdt/core/search/tests/FunctionMethodPatternTests.java,v
retrieving revision 1.10
diff -u -r1.10 FunctionMethodPatternTests.java
--- search/org/eclipse/cdt/core/search/tests/FunctionMethodPatternTests.java 24 Sep 2003 13:36:46 -0000 1.10
+++ search/org/eclipse/cdt/core/search/tests/FunctionMethodPatternTests.java 29 Sep 2003 20:10:35 -0000
@@ -138,7 +138,7 @@
pattern = SearchEngine.createSearchPattern( "operator *", METHOD, DECLARATIONS, true );
search( workspace, pattern, scope, resultCollector );
matches = resultCollector.getSearchResults();
- assertEquals( matches.size(), 3 ); //3 in classDecl.cpp
+ assertEquals( matches.size(), 6 ); //3 in classDecl.cpp
}
public void testBug43498(){
@@ -162,5 +162,33 @@
string = new char[] {'w','o','r','d','?','w','o','r','d'};
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 );
}
}