[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
[cdt-patch] Solution to of bug42911
|
Core:
-bug42911 - Search: cannot find beyond use of data member
- fix NPE's in BasicSearchMatch.equals & hashCode
UI:
-added testBug42911 to OtherPatternTests
tested on windows & linux
-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 21:25:11 -0000
@@ -1,4 +1,8 @@
2003-09-29 Andrew Niefer
+ -bug42911 - Search: cannot find beyond use of data member
+ - fix NPE's in BasicSearchMatch.equals & hashCode
+
+2003-09-29 Andrew Niefer
-fix NPE if IScannerInfoProvider returns null IScannerInfo
2003-09-25 Andrew Niefer
Index: search/org/eclipse/cdt/core/search/BasicSearchMatch.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/search/org/eclipse/cdt/core/search/BasicSearchMatch.java,v
retrieving revision 1.6
diff -u -r1.6 BasicSearchMatch.java
--- search/org/eclipse/cdt/core/search/BasicSearchMatch.java 23 Sep 2003 13:54:21 -0000 1.6
+++ search/org/eclipse/cdt/core/search/BasicSearchMatch.java 29 Sep 2003 21:25:11 -0000
@@ -43,7 +43,10 @@
hashString += name;
hashString += ":" + parentName;
hashString += ":" + returnType;
- hashString += ":" + getLocation().toString();
+
+ if( getLocation() != null)
+ hashString += ":" + getLocation().toString();
+
hashString += ":" + startOffset + ":" + endOffset;
hashString += ":" + type + ":" + visibility;
@@ -64,9 +67,16 @@
if( type != match.getElementType() || visibility != match.getVisibility() )
return false;
- if( !name.equals( match.getName() )
- || !parentName.equals( match.getParentName() )
- || !returnType.equals( match.getReturnType() ) )
+ if( ( name != null && match.getName() != null && !name.equals( match.getName() ) )
+ || name != match.getName() )
+ return false;
+
+ if( ( parentName != null && match.getParentName() != null && !parentName.equals( match.getParentName() ) )
+ || parentName != match.getParentName() )
+ return false;
+
+ if( ( returnType != null && match.getReturnType() != null && !returnType.equals( match.getReturnType() ) )
+ || returnType != match.getReturnType() )
return false;
IPath thisPath = getLocation();
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 21:28:36 -0000
@@ -1,4 +1,7 @@
2003-09-29 Andrew Niefer
+ added testBug42911 to OtherPatternTests
+
+2003-09-29 Andrew Niefer
added testbug43834() to ParserSymbolTableTest
2003-09-29 John Camelon
Index: search/org/eclipse/cdt/core/search/tests/OtherPatternTests.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core.tests/search/org/eclipse/cdt/core/search/tests/OtherPatternTests.java,v
retrieving revision 1.15
diff -u -r1.15 OtherPatternTests.java
--- search/org/eclipse/cdt/core/search/tests/OtherPatternTests.java 26 Sep 2003 14:58:17 -0000 1.15
+++ search/org/eclipse/cdt/core/search/tests/OtherPatternTests.java 29 Sep 2003 21:28:36 -0000
@@ -17,6 +17,7 @@
import java.util.Set;
import java.util.TreeSet;
+import org.eclipse.cdt.core.search.BasicSearchMatch;
import org.eclipse.cdt.core.search.ICSearchPattern;
import org.eclipse.cdt.core.search.IMatch;
import org.eclipse.cdt.core.search.SearchEngine;
@@ -322,5 +323,21 @@
Set matches = resultCollector.getSearchResults();
assertEquals( matches.size(), 4 );
+ }
+
+ public void testBug42911(){
+ BasicSearchMatch match1 = new BasicSearchMatch();
+ BasicSearchMatch match2 = new BasicSearchMatch();
+
+ assertTrue( match1.equals( match2 ) );
+ assertTrue( match2.equals( match1 ) );
+
+ match1.setName( "IWasSaying" );
+ match1.setParentName( "boo" );
+ match1.setReturnType( "urns" );
+
+ assertFalse( match1.equals( match2 ) );
+ assertFalse( match2.equals( match1 ) );
+
}
}