From 93a1b87c76eaceaa071c74b245a5bf34bbe46f57 Mon Sep 17 00:00:00 2001
From: John Camelon <jcamelon@ca.ibm.com>
Date: Wed, 1 Oct 2003 19:55:04 +0000
Subject: [PATCH] Patch for Andrew Niefer

Search filtering was broken, it would have become more obvious when
searching larger projects with includes.

core:
-modify BasicSearchMatch.equals()

tests:
modified OtherPatternTests.testBug42911() and renamed it
testBug42911_43988
---
 core/org.eclipse.cdt.core.tests/ChangeLog     |  3 ++
 .../core/search/tests/OtherPatternTests.java  |  7 ++++-
 core/org.eclipse.cdt.core/search/ChangeLog    |  3 ++
 .../cdt/core/search/BasicSearchMatch.java     | 29 ++++++++++++-------
 4 files changed, 31 insertions(+), 11 deletions(-)

diff --git a/core/org.eclipse.cdt.core.tests/ChangeLog b/core/org.eclipse.cdt.core.tests/ChangeLog
index 6a97a2ad171..18eb7f206a1 100644
--- a/core/org.eclipse.cdt.core.tests/ChangeLog
+++ b/core/org.eclipse.cdt.core.tests/ChangeLog
@@ -1,3 +1,6 @@
+2003-10-01 Andrew Niefer
+	modified OtherPatternTests.testBug42911() and renamed it testBug42911_43988
+
 2003-10-01 Andrew Niefer
 	added testBug43450 to ManagedBuildTests.java
 	added a user include to plugin.xml
diff --git a/core/org.eclipse.cdt.core.tests/search/org/eclipse/cdt/core/search/tests/OtherPatternTests.java b/core/org.eclipse.cdt.core.tests/search/org/eclipse/cdt/core/search/tests/OtherPatternTests.java
index cfc5e7c535c..aa4e373c70c 100644
--- a/core/org.eclipse.cdt.core.tests/search/org/eclipse/cdt/core/search/tests/OtherPatternTests.java
+++ b/core/org.eclipse.cdt.core.tests/search/org/eclipse/cdt/core/search/tests/OtherPatternTests.java
@@ -330,7 +330,7 @@ public class OtherPatternTests extends BaseSearchTest {
 		assertEquals( matches.size(), 4 );
 	}
 	
-	public void testBug42911(){
+	public void testBug42911_43988(){
 		BasicSearchMatch match1 = new BasicSearchMatch();
 		BasicSearchMatch match2 = new BasicSearchMatch();
 		
@@ -344,5 +344,10 @@ public class OtherPatternTests extends BaseSearchTest {
 		assertFalse( match1.equals( match2 ) );
 		assertFalse( match2.equals( match1 ) );
 		
+		match2.setName( "IWasSaying" );
+		match2.setParentName( "boo" );
+		match2.setReturnType( "urns" );
+		
+		assertTrue( match1.equals( match2 ) );
 	}
 }
diff --git a/core/org.eclipse.cdt.core/search/ChangeLog b/core/org.eclipse.cdt.core/search/ChangeLog
index d1543463bf9..0bb6106106c 100644
--- a/core/org.eclipse.cdt.core/search/ChangeLog
+++ b/core/org.eclipse.cdt.core/search/ChangeLog
@@ -1,3 +1,6 @@
+2003-10-01 Andrew Niefer
+	- fix BasicSearchMatch.equals() for bug43988
+
 2003-09-30 Bogdan Gheorghe
 	- changed logging in JobManager to use new ICLogConstants
 	
diff --git a/core/org.eclipse.cdt.core/search/org/eclipse/cdt/core/search/BasicSearchMatch.java b/core/org.eclipse.cdt.core/search/org/eclipse/cdt/core/search/BasicSearchMatch.java
index 3c27aa0c6f7..d641881c6e3 100644
--- a/core/org.eclipse.cdt.core/search/org/eclipse/cdt/core/search/BasicSearchMatch.java
+++ b/core/org.eclipse.cdt.core/search/org/eclipse/cdt/core/search/BasicSearchMatch.java
@@ -67,17 +67,26 @@ public class BasicSearchMatch implements IMatch, Comparable {
 		if( type != match.getElementType() || visibility != match.getVisibility() )
 			return false;
 			
-		if( ( name != null && match.getName() != null && !name.equals( match.getName() ) ) 
-		 ||	name != match.getName() )
-			return false; 
+		if( name != null && match.getName() != null){
+			if( !name.equals( match.getName() ) ) 
+		 		return false; 
+		} else if( 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; 
+		if( parentName != null && match.getParentName() != null){
+			if( !parentName.equals( match.getParentName() ) ) 
+				return false; 
+		} else if( parentName != match.getParentName() ){
+			return false;
+		}
+		
+		if( returnType != null && match.getReturnType() != null){
+			if( !returnType.equals( match.getReturnType() ) ) 
+				return false; 
+		} else if( returnType != match.getReturnType() ){
+			return false;
+		}
 		
 		IPath thisPath = getLocation();
 		IPath matchPath = match.getLocation();