mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Patch for Andrew Niefer.
This patch contains modifications to BasicSearchMatch and BasicSearchResultCollector so that the collector will not accept matches that have already been seen. ( Addresses the problem of seeing a class definition in a header file multiple times because that header was included from multiple cpp files) This patch also fixes a small bug in finding the resource for header files we enter while parsing.
This commit is contained in:
parent
87e177ade2
commit
287009d748
14 changed files with 173 additions and 43 deletions
|
@ -1,3 +1,8 @@
|
||||||
|
2003-08-01 Andrew Niefer
|
||||||
|
Added resources/search/header.h
|
||||||
|
Added ClassDeclarationPatternTests.testHeadersVisitedTwice()
|
||||||
|
Modified other search tests to reflect ICSearchResultCollector changes
|
||||||
|
|
||||||
2003-07-31 Andrew Niefer
|
2003-07-31 Andrew Niefer
|
||||||
Added ParserSymbolTableTest.testForwardClassDeclaration
|
Added ParserSymbolTableTest.testForwardClassDeclaration
|
||||||
Added ParserSymbolTableTest.testForwardDeclarationUsedAsFunctionParam
|
Added ParserSymbolTableTest.testForwardDeclarationUsedAsFunctionParam
|
||||||
|
|
|
@ -1,3 +1,7 @@
|
||||||
|
#include "include.h"
|
||||||
|
|
||||||
|
class Heal{};
|
||||||
|
|
||||||
class A {
|
class A {
|
||||||
class B {
|
class B {
|
||||||
void f( A );
|
void f( A );
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
#ifndef INCLUDE_H
|
||||||
|
#define INCLUDE_H
|
||||||
|
|
||||||
|
class Head {
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
|
@ -78,6 +78,7 @@ public class BaseSearchTest extends TestCase implements ICSearchConstants {
|
||||||
//Add a file to the project
|
//Add a file to the project
|
||||||
importFile("mail.cpp", "resources/indexer/mail.cpp");
|
importFile("mail.cpp", "resources/indexer/mail.cpp");
|
||||||
importFile("classDecl.cpp", "resources/search/classDecl.cpp");
|
importFile("classDecl.cpp", "resources/search/classDecl.cpp");
|
||||||
|
importFile("head.h", "resources/search/include.h");
|
||||||
|
|
||||||
scope = SearchEngine.createWorkspaceScope();
|
scope = SearchEngine.createWorkspaceScope();
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
package org.eclipse.cdt.core.search.tests;
|
package org.eclipse.cdt.core.search.tests;
|
||||||
|
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.search.ICSearchConstants;
|
import org.eclipse.cdt.core.search.ICSearchConstants;
|
||||||
import org.eclipse.cdt.core.search.ICSearchPattern;
|
import org.eclipse.cdt.core.search.ICSearchPattern;
|
||||||
|
@ -23,7 +23,6 @@ import org.eclipse.cdt.core.search.SearchEngine;
|
||||||
import org.eclipse.cdt.internal.core.search.CharOperation;
|
import org.eclipse.cdt.internal.core.search.CharOperation;
|
||||||
import org.eclipse.cdt.internal.core.search.matching.ClassDeclarationPattern;
|
import org.eclipse.cdt.internal.core.search.matching.ClassDeclarationPattern;
|
||||||
import org.eclipse.cdt.internal.core.search.matching.MatchLocator;
|
import org.eclipse.cdt.internal.core.search.matching.MatchLocator;
|
||||||
//import org.eclipse.cdt.internal.ui.search.Match;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -49,7 +48,7 @@ public class ClassDeclarationPatternTests extends BaseSearchTest implements ICSe
|
||||||
|
|
||||||
search( workspace, pattern, scope, resultCollector );
|
search( workspace, pattern, scope, resultCollector );
|
||||||
|
|
||||||
List matches = resultCollector.getSearchResults();
|
Set matches = resultCollector.getSearchResults();
|
||||||
assertEquals( matches.size(), 2 );
|
assertEquals( matches.size(), 2 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -66,7 +65,7 @@ public class ClassDeclarationPatternTests extends BaseSearchTest implements ICSe
|
||||||
|
|
||||||
search( workspace, pattern, scope, resultCollector );
|
search( workspace, pattern, scope, resultCollector );
|
||||||
|
|
||||||
List matches = resultCollector.getSearchResults();
|
Set matches = resultCollector.getSearchResults();
|
||||||
assertEquals( matches.size(), 1 );
|
assertEquals( matches.size(), 1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -74,7 +73,7 @@ public class ClassDeclarationPatternTests extends BaseSearchTest implements ICSe
|
||||||
ICSearchPattern pattern = SearchEngine.createSearchPattern( "A::B", TYPE, DECLARATIONS, true );
|
ICSearchPattern pattern = SearchEngine.createSearchPattern( "A::B", TYPE, DECLARATIONS, true );
|
||||||
|
|
||||||
search( workspace, pattern, scope, resultCollector );
|
search( workspace, pattern, scope, resultCollector );
|
||||||
List matches = resultCollector.getSearchResults();
|
Set matches = resultCollector.getSearchResults();
|
||||||
|
|
||||||
/* Test should find 1 match */
|
/* Test should find 1 match */
|
||||||
assertTrue( matches != null );
|
assertTrue( matches != null );
|
||||||
|
@ -100,13 +99,13 @@ public class ClassDeclarationPatternTests extends BaseSearchTest implements ICSe
|
||||||
|
|
||||||
search( workspace, pattern, scope, resultCollector );
|
search( workspace, pattern, scope, resultCollector );
|
||||||
|
|
||||||
List matches = resultCollector.getSearchResults();
|
Set matches = resultCollector.getSearchResults();
|
||||||
assertEquals( matches.size(), 1 );
|
assertEquals( matches.size(), 1 );
|
||||||
|
|
||||||
pattern = SearchEngine.createSearchPattern( "NS::B::A", TYPE, DECLARATIONS, true );
|
pattern = SearchEngine.createSearchPattern( "NS::B::A", TYPE, DECLARATIONS, true );
|
||||||
search( workspace, pattern, scope, resultCollector );
|
search( workspace, pattern, scope, resultCollector );
|
||||||
|
|
||||||
List matches2 = resultCollector.getSearchResults();
|
Set matches2 = resultCollector.getSearchResults();
|
||||||
assertTrue( matches2 != null );
|
assertTrue( matches2 != null );
|
||||||
assertEquals( matches2.size(), 1 );
|
assertEquals( matches2.size(), 1 );
|
||||||
|
|
||||||
|
@ -125,7 +124,7 @@ public class ClassDeclarationPatternTests extends BaseSearchTest implements ICSe
|
||||||
ICSearchPattern pattern = SearchEngine.createSearchPattern( "::*::A", TYPE, DECLARATIONS, true );
|
ICSearchPattern pattern = SearchEngine.createSearchPattern( "::*::A", TYPE, DECLARATIONS, true );
|
||||||
search( workspace, pattern, scope, resultCollector );
|
search( workspace, pattern, scope, resultCollector );
|
||||||
|
|
||||||
List matches = resultCollector.getSearchResults();
|
Set matches = resultCollector.getSearchResults();
|
||||||
assertEquals( matches.size(), 0 );
|
assertEquals( matches.size(), 0 );
|
||||||
|
|
||||||
pattern = SearchEngine.createSearchPattern( "NS::*::A", TYPE, DECLARATIONS, false );
|
pattern = SearchEngine.createSearchPattern( "NS::*::A", TYPE, DECLARATIONS, false );
|
||||||
|
@ -139,7 +138,7 @@ public class ClassDeclarationPatternTests extends BaseSearchTest implements ICSe
|
||||||
ICSearchPattern pattern = SearchEngine.createSearchPattern( "struct A", TYPE, DECLARATIONS, true );
|
ICSearchPattern pattern = SearchEngine.createSearchPattern( "struct A", TYPE, DECLARATIONS, true );
|
||||||
search( workspace, pattern, scope, resultCollector );
|
search( workspace, pattern, scope, resultCollector );
|
||||||
|
|
||||||
List matches = resultCollector.getSearchResults();
|
Set matches = resultCollector.getSearchResults();
|
||||||
assertEquals( matches.size(), 1 );
|
assertEquals( matches.size(), 1 );
|
||||||
|
|
||||||
pattern = SearchEngine.createSearchPattern( "union u", TYPE, DECLARATIONS, true );
|
pattern = SearchEngine.createSearchPattern( "union u", TYPE, DECLARATIONS, true );
|
||||||
|
@ -178,7 +177,7 @@ public class ClassDeclarationPatternTests extends BaseSearchTest implements ICSe
|
||||||
|
|
||||||
search( workspace, pattern, scope, resultCollector );
|
search( workspace, pattern, scope, resultCollector );
|
||||||
|
|
||||||
List matches = resultCollector.getSearchResults();
|
Set matches = resultCollector.getSearchResults();
|
||||||
|
|
||||||
assertEquals( matches.size(), 1 );
|
assertEquals( matches.size(), 1 );
|
||||||
|
|
||||||
|
@ -197,7 +196,7 @@ public class ClassDeclarationPatternTests extends BaseSearchTest implements ICSe
|
||||||
|
|
||||||
search( workspace, pattern, scope, resultCollector );
|
search( workspace, pattern, scope, resultCollector );
|
||||||
|
|
||||||
List matches = resultCollector.getSearchResults();
|
Set matches = resultCollector.getSearchResults();
|
||||||
assertEquals( matches.size(), 3 );
|
assertEquals( matches.size(), 3 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -206,7 +205,7 @@ public class ClassDeclarationPatternTests extends BaseSearchTest implements ICSe
|
||||||
|
|
||||||
search( workspace, pattern, scope, resultCollector );
|
search( workspace, pattern, scope, resultCollector );
|
||||||
|
|
||||||
List matches = resultCollector.getSearchResults();
|
Set matches = resultCollector.getSearchResults();
|
||||||
assertEquals( matches.size(), 1 );
|
assertEquals( matches.size(), 1 );
|
||||||
|
|
||||||
IMatch match = (IMatch) matches.iterator().next();
|
IMatch match = (IMatch) matches.iterator().next();
|
||||||
|
@ -217,7 +216,7 @@ public class ClassDeclarationPatternTests extends BaseSearchTest implements ICSe
|
||||||
ICSearchPattern pattern = SearchEngine.createSearchPattern( "::NS::NS2::a", STRUCT, REFERENCES, true );
|
ICSearchPattern pattern = SearchEngine.createSearchPattern( "::NS::NS2::a", STRUCT, REFERENCES, true );
|
||||||
|
|
||||||
search( workspace, pattern, scope, resultCollector );
|
search( workspace, pattern, scope, resultCollector );
|
||||||
List matches = resultCollector.getSearchResults();
|
Set matches = resultCollector.getSearchResults();
|
||||||
assertEquals( matches.size(), 1 );
|
assertEquals( matches.size(), 1 );
|
||||||
|
|
||||||
IMatch match = (IMatch) matches.iterator().next();
|
IMatch match = (IMatch) matches.iterator().next();
|
||||||
|
@ -229,11 +228,22 @@ public class ClassDeclarationPatternTests extends BaseSearchTest implements ICSe
|
||||||
|
|
||||||
search( workspace, pattern, scope, resultCollector );
|
search( workspace, pattern, scope, resultCollector );
|
||||||
|
|
||||||
List matches = resultCollector.getSearchResults();
|
Set matches = resultCollector.getSearchResults();
|
||||||
assertEquals( matches.size(), 1 );
|
assertEquals( matches.size(), 1 );
|
||||||
|
|
||||||
IMatch match = (IMatch) matches.iterator().next();
|
IMatch match = (IMatch) matches.iterator().next();
|
||||||
assertTrue( match.getParentName().equals( "NS3::C" ) );
|
assertTrue( match.getParentName().equals( "NS3::C" ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testHeadersVisitedTwice(){
|
||||||
|
ICSearchPattern pattern = SearchEngine.createSearchPattern( "Hea*", CLASS, DECLARATIONS, true );
|
||||||
|
|
||||||
|
search( workspace, pattern, scope, resultCollector );
|
||||||
|
|
||||||
|
Set matches = resultCollector.getSearchResults();
|
||||||
|
|
||||||
|
//1 for Heal, 1 for Head
|
||||||
|
assertEquals( matches.size(), 2 );
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
*/
|
*/
|
||||||
package org.eclipse.cdt.core.search.tests;
|
package org.eclipse.cdt.core.search.tests;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.search.ICSearchPattern;
|
import org.eclipse.cdt.core.search.ICSearchPattern;
|
||||||
import org.eclipse.cdt.core.search.SearchEngine;
|
import org.eclipse.cdt.core.search.SearchEngine;
|
||||||
|
@ -73,7 +73,7 @@ public class FunctionMethodPatternTests extends BaseSearchTest {
|
||||||
|
|
||||||
search( workspace, pattern, scope, resultCollector );
|
search( workspace, pattern, scope, resultCollector );
|
||||||
|
|
||||||
List matches = resultCollector.getSearchResults();
|
Set matches = resultCollector.getSearchResults();
|
||||||
|
|
||||||
assertEquals( matches.size(), 1 );
|
assertEquals( matches.size(), 1 );
|
||||||
}
|
}
|
||||||
|
@ -83,7 +83,7 @@ public class FunctionMethodPatternTests extends BaseSearchTest {
|
||||||
|
|
||||||
search( workspace, pattern, scope, resultCollector );
|
search( workspace, pattern, scope, resultCollector );
|
||||||
|
|
||||||
List matches = resultCollector.getSearchResults();
|
Set matches = resultCollector.getSearchResults();
|
||||||
|
|
||||||
assertEquals( matches.size(), 1 ); }
|
assertEquals( matches.size(), 1 ); }
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
*/
|
*/
|
||||||
package org.eclipse.cdt.core.search.tests;
|
package org.eclipse.cdt.core.search.tests;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.search.ICSearchPattern;
|
import org.eclipse.cdt.core.search.ICSearchPattern;
|
||||||
import org.eclipse.cdt.core.search.IMatch;
|
import org.eclipse.cdt.core.search.IMatch;
|
||||||
|
@ -95,7 +95,7 @@ public class OtherPatternTests extends BaseSearchTest {
|
||||||
|
|
||||||
search( workspace, pattern, scope, resultCollector );
|
search( workspace, pattern, scope, resultCollector );
|
||||||
|
|
||||||
List matches = resultCollector.getSearchResults();
|
Set matches = resultCollector.getSearchResults();
|
||||||
|
|
||||||
assertEquals( matches.size(), 3 );
|
assertEquals( matches.size(), 3 );
|
||||||
}
|
}
|
||||||
|
@ -105,7 +105,7 @@ public class OtherPatternTests extends BaseSearchTest {
|
||||||
|
|
||||||
search( workspace, pattern, scope, resultCollector );
|
search( workspace, pattern, scope, resultCollector );
|
||||||
|
|
||||||
List matches = resultCollector.getSearchResults();
|
Set matches = resultCollector.getSearchResults();
|
||||||
|
|
||||||
assertEquals( matches.size(), 1 );
|
assertEquals( matches.size(), 1 );
|
||||||
|
|
||||||
|
@ -118,7 +118,7 @@ public class OtherPatternTests extends BaseSearchTest {
|
||||||
|
|
||||||
search( workspace, pattern, scope, resultCollector );
|
search( workspace, pattern, scope, resultCollector );
|
||||||
|
|
||||||
List matches = resultCollector.getSearchResults();
|
Set matches = resultCollector.getSearchResults();
|
||||||
assertEquals( matches.size(), 2 );
|
assertEquals( matches.size(), 2 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -127,7 +127,7 @@ public class OtherPatternTests extends BaseSearchTest {
|
||||||
|
|
||||||
search( workspace, pattern, scope, resultCollector );
|
search( workspace, pattern, scope, resultCollector );
|
||||||
|
|
||||||
List matches = resultCollector.getSearchResults();
|
Set matches = resultCollector.getSearchResults();
|
||||||
assertEquals( matches.size(), 2 );
|
assertEquals( matches.size(), 2 );
|
||||||
|
|
||||||
IMatch match = (IMatch) matches.iterator().next();
|
IMatch match = (IMatch) matches.iterator().next();
|
||||||
|
@ -139,7 +139,7 @@ public class OtherPatternTests extends BaseSearchTest {
|
||||||
|
|
||||||
search( workspace, pattern, scope, resultCollector );
|
search( workspace, pattern, scope, resultCollector );
|
||||||
|
|
||||||
List matches = resultCollector.getSearchResults();
|
Set matches = resultCollector.getSearchResults();
|
||||||
assertEquals( matches.size(), 2 );
|
assertEquals( matches.size(), 2 );
|
||||||
|
|
||||||
IMatch match = (IMatch) matches.iterator().next();
|
IMatch match = (IMatch) matches.iterator().next();
|
||||||
|
|
|
@ -1,3 +1,7 @@
|
||||||
|
2003-08-01 Andrew Niefer
|
||||||
|
- Modified BasicSearchResultCollector to only accept matches it has not already seen
|
||||||
|
- fixed bug in finding a resource when entering includes
|
||||||
|
|
||||||
2003-07-29 Andrew Niefer
|
2003-07-29 Andrew Niefer
|
||||||
Refactoring Search result collection:
|
Refactoring Search result collection:
|
||||||
- Modified ICSearchResultCollector
|
- Modified ICSearchResultCollector
|
||||||
|
|
|
@ -36,6 +36,47 @@ public class BasicSearchMatch implements IMatch {
|
||||||
endOffset = basicMatch.endOffset;
|
endOffset = basicMatch.endOffset;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int hashCode(){
|
||||||
|
String hashString = "";
|
||||||
|
|
||||||
|
hashString += name;
|
||||||
|
hashString += ":" + parentName;
|
||||||
|
hashString += ":" + getLocation().toString();
|
||||||
|
hashString += ":" + startOffset + ":" + endOffset;
|
||||||
|
hashString += ":" + type + ":" + visibility;
|
||||||
|
|
||||||
|
return hashString.hashCode();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean equals(Object obj){
|
||||||
|
if( !(obj instanceof BasicSearchMatch ) ){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
BasicSearchMatch match = (BasicSearchMatch)obj;
|
||||||
|
|
||||||
|
IPath path = getLocation();
|
||||||
|
|
||||||
|
if( startOffset != match.getStartOffset() || endOffset != match.getEndOffset() )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if( type != match.getElementType() || visibility != match.getVisibility() )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if( !name.equals( match.getName() ) || !parentName.equals( match.getParentName() ) )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
IPath thisPath = getLocation();
|
||||||
|
IPath matchPath = match.getLocation();
|
||||||
|
if( thisPath != null && matchPath != null ){
|
||||||
|
if( !thisPath.equals( matchPath ) )
|
||||||
|
return false;
|
||||||
|
} else if( thisPath != matchPath ){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
public String name = null;
|
public String name = null;
|
||||||
public String parentName = null;
|
public String parentName = null;
|
||||||
|
|
||||||
|
|
|
@ -13,12 +13,26 @@
|
||||||
*/
|
*/
|
||||||
package org.eclipse.cdt.core.search;
|
package org.eclipse.cdt.core.search;
|
||||||
|
|
||||||
import java.util.LinkedList;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.model.ICElement;
|
import org.eclipse.cdt.core.model.ICElement;
|
||||||
import org.eclipse.cdt.core.parser.ISourceElementCallbackDelegate;
|
import org.eclipse.cdt.core.parser.ISourceElementCallbackDelegate;
|
||||||
import org.eclipse.cdt.core.parser.ast.*;
|
import org.eclipse.cdt.core.parser.ast.ASTAccessVisibility;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.ASTClassKind;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTClassSpecifier;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTEnumerationSpecifier;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTEnumerator;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTField;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTFunction;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTMethod;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTNamespaceDefinition;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTOffsetableElement;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTOffsetableNamedElement;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTQualifiedNameElement;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTReference;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTScope;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTVariable;
|
||||||
import org.eclipse.core.resources.IResource;
|
import org.eclipse.core.resources.IResource;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.core.runtime.IPath;
|
import org.eclipse.core.runtime.IPath;
|
||||||
|
@ -33,7 +47,7 @@ import org.eclipse.core.runtime.IProgressMonitor;
|
||||||
public class BasicSearchResultCollector implements ICSearchResultCollector {
|
public class BasicSearchResultCollector implements ICSearchResultCollector {
|
||||||
|
|
||||||
public void aboutToStart() {
|
public void aboutToStart() {
|
||||||
results = new LinkedList();
|
results = new HashSet();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void done() {
|
public void done() {
|
||||||
|
@ -43,9 +57,13 @@ public class BasicSearchResultCollector implements ICSearchResultCollector {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IMatch createMatch(Object fileResource, int start, int end, ISourceElementCallbackDelegate node, IASTScope parent) throws CoreException {
|
public IMatch createMatch(Object fileResource, int start, int end, ISourceElementCallbackDelegate node, IASTScope parent) throws CoreException
|
||||||
|
{
|
||||||
BasicSearchMatch result = new BasicSearchMatch();
|
BasicSearchMatch result = new BasicSearchMatch();
|
||||||
|
return createMatch( result, fileResource, start, end, node, parent );
|
||||||
|
}
|
||||||
|
|
||||||
|
public IMatch createMatch( BasicSearchMatch result, Object fileResource, int start, int end, ISourceElementCallbackDelegate node, IASTScope parent) throws CoreException {
|
||||||
if( fileResource instanceof IResource )
|
if( fileResource instanceof IResource )
|
||||||
result.resource = (IResource) fileResource;
|
result.resource = (IResource) fileResource;
|
||||||
else if( fileResource instanceof IPath )
|
else if( fileResource instanceof IPath )
|
||||||
|
@ -81,11 +99,15 @@ public class BasicSearchResultCollector implements ICSearchResultCollector {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void acceptMatch(IMatch match) throws CoreException {
|
public boolean acceptMatch(IMatch match) throws CoreException {
|
||||||
|
if( !results.contains( match ) ){
|
||||||
results.add( match );
|
results.add( match );
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List getSearchResults(){
|
public Set getSearchResults(){
|
||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -140,6 +162,5 @@ public class BasicSearchResultCollector implements ICSearchResultCollector {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private List results;
|
private Set results;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -65,7 +65,8 @@ public interface ICSearchResultCollector {
|
||||||
public IMatch createMatch( Object fileResource, int start, int end,
|
public IMatch createMatch( Object fileResource, int start, int end,
|
||||||
ISourceElementCallbackDelegate node, IASTScope parent) throws CoreException;
|
ISourceElementCallbackDelegate node, IASTScope parent) throws CoreException;
|
||||||
|
|
||||||
public void acceptMatch( IMatch match ) throws CoreException;
|
//return whether or not the match was accepted
|
||||||
|
public boolean acceptMatch( IMatch match ) throws CoreException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the progress monitor used to report progress.
|
* Returns the progress monitor used to report progress.
|
||||||
|
|
|
@ -29,7 +29,36 @@ import org.eclipse.cdt.core.parser.ISourceElementCallbackDelegate;
|
||||||
import org.eclipse.cdt.core.parser.ISourceElementRequestor;
|
import org.eclipse.cdt.core.parser.ISourceElementRequestor;
|
||||||
import org.eclipse.cdt.core.parser.ParserFactory;
|
import org.eclipse.cdt.core.parser.ParserFactory;
|
||||||
import org.eclipse.cdt.core.parser.ParserMode;
|
import org.eclipse.cdt.core.parser.ParserMode;
|
||||||
import org.eclipse.cdt.core.parser.ast.*;
|
import org.eclipse.cdt.core.parser.ast.IASTASMDefinition;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTAbstractTypeSpecifierDeclaration;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTClassReference;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTClassSpecifier;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTCompilationUnit;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTEnumerationReference;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTEnumerationSpecifier;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTField;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTFieldReference;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTFunction;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTFunctionReference;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTInclusion;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTLinkageSpecification;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTMacro;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTMethod;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTMethodReference;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTNamespaceDefinition;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTNamespaceReference;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTOffsetableNamedElement;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTReference;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTScope;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTTemplateDeclaration;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTTemplateInstantiation;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTTemplateSpecialization;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTTypedefDeclaration;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTTypedefReference;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTUsingDeclaration;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTUsingDirective;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTVariable;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTVariableReference;
|
||||||
import org.eclipse.cdt.core.search.ICSearchConstants;
|
import org.eclipse.cdt.core.search.ICSearchConstants;
|
||||||
import org.eclipse.cdt.core.search.ICSearchPattern;
|
import org.eclipse.cdt.core.search.ICSearchPattern;
|
||||||
import org.eclipse.cdt.core.search.ICSearchResultCollector;
|
import org.eclipse.cdt.core.search.ICSearchResultCollector;
|
||||||
|
@ -190,7 +219,7 @@ public class MatchLocator implements ISourceElementRequestor, ICSearchConstants
|
||||||
IResource resource = null;
|
IResource resource = null;
|
||||||
|
|
||||||
if( workspaceRoot != null ){
|
if( workspaceRoot != null ){
|
||||||
resource = workspaceRoot.findMember( path, true );
|
resource = workspaceRoot.getFileForLocation( path );
|
||||||
if( resource == null ){
|
if( resource == null ){
|
||||||
IFile file = workspaceRoot.getFile( path );
|
IFile file = workspaceRoot.getFile( path );
|
||||||
try{
|
try{
|
||||||
|
|
|
@ -1,3 +1,8 @@
|
||||||
|
2003-08-01 Andrew Niefer
|
||||||
|
- Modified CSearchResultCollector to reflect changes in BasicSearchResultCollector,
|
||||||
|
acceptMatch will return false if the match was not accepted because it has already
|
||||||
|
been seen.
|
||||||
|
|
||||||
2003-07-30 Hoda Amer
|
2003-07-30 Hoda Amer
|
||||||
The New Class Wizard uses search to look for base classes in the workspace.
|
The New Class Wizard uses search to look for base classes in the workspace.
|
||||||
|
|
||||||
|
|
|
@ -76,14 +76,14 @@ public class CSearchResultCollector extends BasicSearchResultCollector{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void acceptMatch( IMatch match ) throws CoreException
|
public boolean acceptMatch( IMatch match ) throws CoreException
|
||||||
{
|
{
|
||||||
super.acceptMatch( match );
|
|
||||||
|
|
||||||
BasicSearchMatch searchMatch = (BasicSearchMatch) match;
|
BasicSearchMatch searchMatch = (BasicSearchMatch) match;
|
||||||
if( searchMatch.resource == null )
|
if( searchMatch.resource == null )
|
||||||
return;
|
return false;
|
||||||
|
|
||||||
|
if( !super.acceptMatch( match ) )
|
||||||
|
return false;
|
||||||
|
|
||||||
IMarker marker = searchMatch.resource.createMarker( SearchUI.SEARCH_MARKER );
|
IMarker marker = searchMatch.resource.createMarker( SearchUI.SEARCH_MARKER );
|
||||||
|
|
||||||
|
@ -102,6 +102,8 @@ public class CSearchResultCollector extends BasicSearchResultCollector{
|
||||||
_view.addMatch( searchMatch.name, groupKey, searchMatch.resource, marker );
|
_view.addMatch( searchMatch.name, groupKey, searchMatch.resource, marker );
|
||||||
|
|
||||||
_matchCount++;
|
_matchCount++;
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
|
|
Loading…
Add table
Reference in a new issue