1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

Search Refactoring for bugs

50983 - OrPattern not visible
51250 - search engine throws runtime exception OperationCanceledException
This commit is contained in:
Andrew Niefer 2004-02-16 20:46:12 +00:00
parent a693c52f25
commit c1a246da20
20 changed files with 1789 additions and 1766 deletions

View file

@ -1,3 +1,6 @@
2004-02-13 Andrew Niefer
updated tests using search to handle InterruptedExcpetion
2004-02-12 Andrew Niefer 2004-02-12 Andrew Niefer
UnCommented CompleteParseASTTest.testBug47628 UnCommented CompleteParseASTTest.testBug47628
Added CompleteParseASTTest.testBug47636 Added CompleteParseASTTest.testBug47636

View file

@ -650,9 +650,12 @@ import org.eclipse.core.runtime.Platform;
} }
} }
protected void search(IWorkspace workspace, ICSearchPattern pattern, ICSearchScope scope, ICSearchResultCollector collector) { protected void search(IWorkspace workspace, ICSearchPattern pattern, ICSearchScope scope, ICSearchResultCollector collector) {
searchEngine.search( workspace, pattern, scope, collector, false ); try {
} searchEngine.search( workspace, pattern, scope, collector, false );
} catch (InterruptedException e) {
}
}
/* /*
* Utils * Utils

View file

@ -122,7 +122,11 @@ public class BaseSearchTest extends TestCase implements ICSearchConstants {
} }
protected void search(IWorkspace workspace, ICSearchPattern pattern, ICSearchScope scope, ICSearchResultCollector collector) { protected void search(IWorkspace workspace, ICSearchPattern pattern, ICSearchScope scope, ICSearchResultCollector collector) {
searchEngine.search( workspace, pattern, scope, collector, false ); try {
searchEngine.search( workspace, pattern, scope, collector, false );
} catch (InterruptedException e) {
}
} }
} }

View file

@ -19,10 +19,10 @@ 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;
import org.eclipse.cdt.core.search.IMatch; import org.eclipse.cdt.core.search.IMatch;
import org.eclipse.cdt.core.search.OrPattern;
import org.eclipse.cdt.core.search.SearchEngine; import org.eclipse.cdt.core.search.SearchEngine;
import org.eclipse.cdt.internal.core.CharOperation; import org.eclipse.cdt.internal.core.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.OrPattern;
/** /**

View file

@ -22,13 +22,13 @@ import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.search.BasicSearchMatch; import org.eclipse.cdt.core.search.BasicSearchMatch;
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;
import org.eclipse.cdt.core.search.OrPattern;
import org.eclipse.cdt.core.search.SearchEngine; import org.eclipse.cdt.core.search.SearchEngine;
import org.eclipse.cdt.internal.core.CharOperation; import org.eclipse.cdt.internal.core.CharOperation;
import org.eclipse.cdt.internal.core.search.AcceptMatchOperation; import org.eclipse.cdt.internal.core.search.AcceptMatchOperation;
import org.eclipse.cdt.internal.core.search.matching.FieldDeclarationPattern; import org.eclipse.cdt.internal.core.search.matching.FieldDeclarationPattern;
import org.eclipse.cdt.internal.core.search.matching.MatchLocator; import org.eclipse.cdt.internal.core.search.matching.MatchLocator;
import org.eclipse.cdt.internal.core.search.matching.NamespaceDeclarationPattern; import org.eclipse.cdt.internal.core.search.matching.NamespaceDeclarationPattern;
import org.eclipse.cdt.internal.core.search.matching.OrPattern;
import org.eclipse.cdt.testplugin.CTestPlugin; import org.eclipse.cdt.testplugin.CTestPlugin;
import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.Path; import org.eclipse.core.runtime.Path;
@ -327,7 +327,10 @@ public class OtherPatternTests extends BaseSearchTest {
ArrayList matchesList = new ArrayList(); ArrayList matchesList = new ArrayList();
MatchLocator matchLocator = new MatchLocator( pattern, resultCollector, scope, monitor ); MatchLocator matchLocator = new MatchLocator( pattern, resultCollector, scope, monitor );
matchLocator.locateMatches( new String [] { path }, workspace, null, matchesList); try {
matchLocator.locateMatches( new String [] { path }, workspace, null, matchesList);
} catch (InterruptedException e1) {
}
AcceptMatchOperation acceptMatchOp = new AcceptMatchOperation(resultCollector, matchesList); AcceptMatchOperation acceptMatchOp = new AcceptMatchOperation(resultCollector, matchesList);
try { try {

View file

@ -1,3 +1,9 @@
2004-02-16 Andrew Niefer
fixed a couple of warnings
moved OrPattern from org.eclipse.cdt.internal.core.search.matching to org.eclipse.cdt.core.search
changed SearchEngine.search & MatchLocator.locateMatches to throw InterruptedException when cancelled
updates calls to search to handle InterruptedException
2004-02-13 Bogdan Gheorghe 2004-02-13 Bogdan Gheorghe
- Added error handling to MatchLocator.locateMatches to handle possible - Added error handling to MatchLocator.locateMatches to handle possible
parser failures. parser failures.

View file

@ -59,8 +59,6 @@ public class BasicSearchMatch implements IMatch, Comparable {
} }
BasicSearchMatch match = (BasicSearchMatch)obj; BasicSearchMatch match = (BasicSearchMatch)obj;
IPath path = getLocation();
if( startOffset != match.getStartOffset() || endOffset != match.getEndOffset() ) if( startOffset != match.getStartOffset() || endOffset != match.getEndOffset() )
return false; return false;

View file

@ -11,18 +11,17 @@
/* /*
* Created on Aug 6, 2003 * Created on Aug 6, 2003
*/ */
package org.eclipse.cdt.internal.core.search.matching; package org.eclipse.cdt.core.search;
import java.io.IOException; import java.io.IOException;
import java.util.Iterator; import java.util.Iterator;
import java.util.LinkedList; import java.util.LinkedList;
import org.eclipse.cdt.core.parser.ISourceElementCallbackDelegate; import org.eclipse.cdt.core.parser.ISourceElementCallbackDelegate;
import org.eclipse.cdt.core.search.ICSearchPattern;
import org.eclipse.cdt.core.search.ICSearchScope;
import org.eclipse.cdt.internal.core.index.IEntryResult; import org.eclipse.cdt.internal.core.index.IEntryResult;
import org.eclipse.cdt.internal.core.index.impl.IndexInput; import org.eclipse.cdt.internal.core.index.impl.IndexInput;
import org.eclipse.cdt.internal.core.search.IIndexSearchRequestor; import org.eclipse.cdt.internal.core.search.IIndexSearchRequestor;
import org.eclipse.cdt.internal.core.search.matching.CSearchPattern;
import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IProgressMonitor;

View file

@ -36,7 +36,6 @@ import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.OperationCanceledException;
import org.eclipse.core.runtime.Path; import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.SubProgressMonitor; import org.eclipse.core.runtime.SubProgressMonitor;
@ -109,7 +108,6 @@ public class SearchEngine implements ICSearchConstants{
*/ */
public static ICSearchScope createCFileSearchScope(IFile sourceFile, ArrayList elements) { public static ICSearchScope createCFileSearchScope(IFile sourceFile, ArrayList elements) {
CSearchScope scope = new CSearchScope(); CSearchScope scope = new CSearchScope();
HashSet visitedProjects = new HashSet(2);
if (sourceFile != null){ if (sourceFile != null){
//Add the source file and project //Add the source file and project
@ -155,7 +153,7 @@ public class SearchEngine implements ICSearchConstants{
* @param _scope * @param _scope
* @param _collector * @param _collector
*/ */
public void search(IWorkspace workspace, ICSearchPattern pattern, ICSearchScope scope, ICSearchResultCollector collector, boolean excludeLocalDeclarations) { public void search(IWorkspace workspace, ICSearchPattern pattern, ICSearchScope scope, ICSearchResultCollector collector, boolean excludeLocalDeclarations) throws InterruptedException {
if( VERBOSE ) { if( VERBOSE ) {
System.out.println("Searching for " + pattern + " in " + scope); //$NON-NLS-1$//$NON-NLS-2$ System.out.println("Searching for " + pattern + " in " + scope); //$NON-NLS-1$//$NON-NLS-2$
} }
@ -199,7 +197,7 @@ public class SearchEngine implements ICSearchConstants{
matchLocator.setShouldExcludeLocalDeclarations( excludeLocalDeclarations ); matchLocator.setShouldExcludeLocalDeclarations( excludeLocalDeclarations );
if( progressMonitor != null && progressMonitor.isCanceled() ) if( progressMonitor != null && progressMonitor.isCanceled() )
throw new OperationCanceledException(); throw new InterruptedException();
//TODO: BOG Filter Working Copies... //TODO: BOG Filter Working Copies...
matchLocator.locateMatches( pathCollector.getPaths(), workspace, this.workingCopies, matches); matchLocator.locateMatches( pathCollector.getPaths(), workspace, this.workingCopies, matches);

View file

@ -45,6 +45,7 @@ import org.eclipse.cdt.core.parser.ast.IASTFunction;
import org.eclipse.cdt.core.parser.ast.IASTParameterDeclaration; import org.eclipse.cdt.core.parser.ast.IASTParameterDeclaration;
import org.eclipse.cdt.core.parser.ast.IASTSimpleTypeSpecifier; import org.eclipse.cdt.core.parser.ast.IASTSimpleTypeSpecifier;
import org.eclipse.cdt.core.parser.ast.IASTTypeSpecifier; import org.eclipse.cdt.core.parser.ast.IASTTypeSpecifier;
import org.eclipse.cdt.core.search.*;
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.ICSearchScope; import org.eclipse.cdt.core.search.ICSearchScope;

View file

@ -189,7 +189,6 @@ public class FieldDeclarationPattern extends CSearchPattern {
private char [][] decodedQualifications; private char [][] decodedQualifications;
private char [] simpleName; private char [] simpleName;
private char [] decodedSimpleName; private char [] decodedSimpleName;
private char decodedType;
private SearchFor searchFor; private SearchFor searchFor;
} }

View file

@ -41,7 +41,6 @@ public class IncludePattern extends CSearchPattern {
*/ */
protected void decodeIndexEntry(IEntryResult entryResult) { protected void decodeIndexEntry(IEntryResult entryResult) {
char[] word = entryResult.getWord(); char[] word = entryResult.getWord();
int size = word.length;
int firstSlash = CharOperation.indexOf( SEPARATOR, word, 0 ); int firstSlash = CharOperation.indexOf( SEPARATOR, word, 0 );

View file

@ -86,7 +86,6 @@ public class MacroDeclarationPattern extends CSearchPattern {
*/ */
protected void decodeIndexEntry(IEntryResult entryResult) { protected void decodeIndexEntry(IEntryResult entryResult) {
char[] word = entryResult.getWord(); char[] word = entryResult.getWord();
int size = word.length;
int firstSlash = CharOperation.indexOf( SEPARATOR, word, 0 ); int firstSlash = CharOperation.indexOf( SEPARATOR, word, 0 );

View file

@ -89,7 +89,6 @@ import org.eclipse.core.resources.IWorkspaceRoot;
import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.OperationCanceledException;
import org.eclipse.core.runtime.Path; import org.eclipse.core.runtime.Path;
@ -335,7 +334,7 @@ public class MatchLocator implements ISourceElementRequestor, ICSearchConstants
} }
public void locateMatches( String [] paths, IWorkspace workspace, IWorkingCopy[] workingCopies,ArrayList matches ){ public void locateMatches( String [] paths, IWorkspace workspace, IWorkingCopy[] workingCopies,ArrayList matches ) throws InterruptedException{
matchStorage = matches; matchStorage = matches;
workspaceRoot = (workspace != null) ? workspace.getRoot() : null; workspaceRoot = (workspace != null) ? workspace.getRoot() : null;
@ -368,7 +367,7 @@ public class MatchLocator implements ISourceElementRequestor, ICSearchConstants
for( int i = 0; i < length; i++ ){ for( int i = 0; i < length; i++ ){
if( progressMonitor != null ) { if( progressMonitor != null ) {
if( progressMonitor.isCanceled() ){ if( progressMonitor.isCanceled() ){
throw new OperationCanceledException(); throw new InterruptedException();
} else { } else {
progressMonitor.worked( 1 ); progressMonitor.worked( 1 );
} }
@ -482,7 +481,7 @@ public class MatchLocator implements ISourceElementRequestor, ICSearchConstants
if( node instanceof IASTReference ){ if( node instanceof IASTReference ){
IASTReference reference = (IASTReference) node; IASTReference reference = (IASTReference) node;
offset = reference.getOffset(); offset = reference.getOffset();
end = offset + 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 ){
@ -491,7 +490,7 @@ public class MatchLocator implements ISourceElementRequestor, ICSearchConstants
: offsetableElement.getStartingOffset(); : offsetableElement.getStartingOffset();
end = offsetableElement.getNameEndOffset(); end = offsetableElement.getNameEndOffset();
if( end == 0 ){ if( end == 0 ){
end = offset + offsetableElement.getName().length();; end = offset + offsetableElement.getName().length();
} }
if (VERBOSE) if (VERBOSE)

View file

@ -1,3 +1,6 @@
2004-02-13 Andrew Niefer
Updated calls to search to handle InterruptedException
2004-02-16 Alain Magloire 2004-02-16 Alain Magloire
Use ITextEditor instead of CEditor. Use ITextEditor instead of CEditor.

View file

@ -16,8 +16,8 @@ import org.eclipse.cdt.core.search.BasicSearchResultCollector;
import org.eclipse.cdt.core.search.ICSearchConstants; import org.eclipse.cdt.core.search.ICSearchConstants;
import org.eclipse.cdt.core.search.ICSearchScope; import org.eclipse.cdt.core.search.ICSearchScope;
import org.eclipse.cdt.core.search.IMatch; import org.eclipse.cdt.core.search.IMatch;
import org.eclipse.cdt.core.search.OrPattern;
import org.eclipse.cdt.core.search.SearchEngine; import org.eclipse.cdt.core.search.SearchEngine;
import org.eclipse.cdt.internal.core.search.matching.OrPattern;
import org.eclipse.cdt.internal.ui.dialogs.ElementListSelectionDialog; import org.eclipse.cdt.internal.ui.dialogs.ElementListSelectionDialog;
import org.eclipse.cdt.internal.ui.util.EditorUtility; import org.eclipse.cdt.internal.ui.util.EditorUtility;
import org.eclipse.cdt.ui.CSearchResultLabelProvider; import org.eclipse.cdt.ui.CSearchResultLabelProvider;
@ -124,55 +124,59 @@ public class OpenDeclarationsAction extends Action implements IUpdate {
* @see IAction#actionPerformed * @see IAction#actionPerformed
*/ */
public void run() { public void run() {
final String selectedText = getSelectedStringFromEditor(); final String selectedText = getSelectedStringFromEditor();
if(selectedText == null) { if(selectedText == null) {
return; return;
} }
final ArrayList elementsFound = new ArrayList(); final ArrayList elementsFound = new ArrayList();
IRunnableWithProgress runnable = new IRunnableWithProgress() { IRunnableWithProgress runnable = new IRunnableWithProgress()
public void run(IProgressMonitor monitor) { {
BasicSearchResultCollector resultCollector = new BasicSearchResultCollector(monitor); public void run(IProgressMonitor monitor) {
IWorkingCopyManager fManager = CUIPlugin.getDefault().getWorkingCopyManager(); BasicSearchResultCollector resultCollector = new BasicSearchResultCollector(monitor);
ITranslationUnit unit = fManager.getWorkingCopy(fEditor.getEditorInput()); IWorkingCopyManager fManager = CUIPlugin.getDefault().getWorkingCopyManager();
ITranslationUnit unit = fManager.getWorkingCopy(fEditor.getEditorInput());
ICElement[] projectScopeElement = new ICElement[1]; ICElement[] projectScopeElement = new ICElement[1];
projectScopeElement[0] = unit.getCProject();//(ICElement)currentScope.getCProject(); projectScopeElement[0] = unit.getCProject();//(ICElement)currentScope.getCProject();
ICSearchScope scope = SearchEngine.createCSearchScope(projectScopeElement, true); ICSearchScope scope = SearchEngine.createCSearchScope(projectScopeElement, true);
OrPattern orPattern = new OrPattern(); OrPattern orPattern = new OrPattern();
// search for global variables, functions, classes, structs, unions, enums and macros // search for global variables, functions, classes, structs, unions, enums and macros
orPattern.addPattern(SearchEngine.createSearchPattern( selectedText, ICSearchConstants.VAR, ICSearchConstants.DECLARATIONS, true )); orPattern.addPattern(SearchEngine.createSearchPattern( selectedText, ICSearchConstants.VAR, ICSearchConstants.DECLARATIONS, true ));
orPattern.addPattern(SearchEngine.createSearchPattern( selectedText, ICSearchConstants.FUNCTION, ICSearchConstants.DECLARATIONS, true )); orPattern.addPattern(SearchEngine.createSearchPattern( selectedText, ICSearchConstants.FUNCTION, ICSearchConstants.DECLARATIONS, true ));
orPattern.addPattern(SearchEngine.createSearchPattern( selectedText, ICSearchConstants.METHOD, ICSearchConstants.DECLARATIONS, true )); orPattern.addPattern(SearchEngine.createSearchPattern( selectedText, ICSearchConstants.METHOD, ICSearchConstants.DECLARATIONS, true ));
orPattern.addPattern(SearchEngine.createSearchPattern( selectedText, ICSearchConstants.TYPE, ICSearchConstants.DECLARATIONS, true )); orPattern.addPattern(SearchEngine.createSearchPattern( selectedText, ICSearchConstants.TYPE, ICSearchConstants.DECLARATIONS, true ));
orPattern.addPattern(SearchEngine.createSearchPattern( selectedText, ICSearchConstants.ENUM, ICSearchConstants.DECLARATIONS, true )); orPattern.addPattern(SearchEngine.createSearchPattern( selectedText, ICSearchConstants.ENUM, ICSearchConstants.DECLARATIONS, true ));
orPattern.addPattern(SearchEngine.createSearchPattern( selectedText, ICSearchConstants.FIELD, ICSearchConstants.DECLARATIONS, true )); orPattern.addPattern(SearchEngine.createSearchPattern( selectedText, ICSearchConstants.FIELD, ICSearchConstants.DECLARATIONS, true ));
orPattern.addPattern(SearchEngine.createSearchPattern( selectedText, ICSearchConstants.NAMESPACE, ICSearchConstants.DECLARATIONS, true )); orPattern.addPattern(SearchEngine.createSearchPattern( selectedText, ICSearchConstants.NAMESPACE, ICSearchConstants.DECLARATIONS, true ));
orPattern.addPattern(SearchEngine.createSearchPattern( selectedText, ICSearchConstants.MACRO, ICSearchConstants.DECLARATIONS, true )); orPattern.addPattern(SearchEngine.createSearchPattern( selectedText, ICSearchConstants.MACRO, ICSearchConstants.DECLARATIONS, true ));
orPattern.addPattern(SearchEngine.createSearchPattern( selectedText, ICSearchConstants.TYPEDEF, ICSearchConstants.DECLARATIONS, true )); orPattern.addPattern(SearchEngine.createSearchPattern( selectedText, ICSearchConstants.TYPEDEF, ICSearchConstants.DECLARATIONS, true ));
searchEngine.search(CUIPlugin.getWorkspace(), orPattern, scope, resultCollector, true); try {
elementsFound.addAll(resultCollector.getSearchResults()); searchEngine.search(CUIPlugin.getWorkspace(), orPattern, scope, resultCollector, true);
} catch (InterruptedException e) {
}
elementsFound.addAll(resultCollector.getSearchResults());
} }
}; };
try { try {
ProgressMonitorDialog progressMonitor = new ProgressMonitorDialog(getShell()); ProgressMonitorDialog progressMonitor = new ProgressMonitorDialog(getShell());
progressMonitor.run(true, true, runnable); progressMonitor.run(true, true, runnable);
if (elementsFound.isEmpty() == true) { if (elementsFound.isEmpty() == true) {
return; return;
} }
IMatch selected= selectCElement(elementsFound, getShell(), fDialogTitle, fDialogMessage); IMatch selected= selectCElement(elementsFound, getShell(), fDialogTitle, fDialogMessage);
if (selected != null) { if (selected != null) {
open(selected); open(selected);
return; return;
} }
} catch(Exception x) { } catch(Exception x) {
CUIPlugin.getDefault().log(x); CUIPlugin.getDefault().log(x);
} }
} }
protected Shell getShell() { protected Shell getShell() {

View file

@ -12,8 +12,8 @@ package org.eclipse.cdt.internal.ui.opentype;
import org.eclipse.cdt.core.search.ICSearchConstants; import org.eclipse.cdt.core.search.ICSearchConstants;
import org.eclipse.cdt.core.search.ICSearchScope; import org.eclipse.cdt.core.search.ICSearchScope;
import org.eclipse.cdt.core.search.OrPattern;
import org.eclipse.cdt.core.search.SearchEngine; import org.eclipse.cdt.core.search.SearchEngine;
import org.eclipse.cdt.internal.core.search.matching.OrPattern;
import org.eclipse.core.resources.IWorkspace; import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.OperationCanceledException; import org.eclipse.core.runtime.OperationCanceledException;

View file

@ -20,16 +20,14 @@ import java.util.List;
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.ICSearchScope; import org.eclipse.cdt.core.search.ICSearchScope;
import org.eclipse.cdt.core.search.OrPattern;
import org.eclipse.cdt.core.search.SearchEngine; import org.eclipse.cdt.core.search.SearchEngine;
import org.eclipse.cdt.internal.core.search.matching.OrPattern;
import org.eclipse.cdt.internal.ui.CPluginImages; import org.eclipse.cdt.internal.ui.CPluginImages;
import org.eclipse.cdt.ui.CUIPlugin; import org.eclipse.cdt.ui.CUIPlugin;
import org.eclipse.core.resources.IWorkspace; import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jface.operation.IRunnableWithProgress; import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.ui.actions.WorkspaceModifyOperation;
/** /**
* @author aniefer * @author aniefer
@ -78,9 +76,10 @@ public class CSearchOperation implements IRunnableWithProgress,ICSearchConstants
pattern = SearchEngine.createSearchPattern( _stringPattern, (SearchFor)iter.next(), _limitTo, _caseSensitive ); pattern = SearchEngine.createSearchPattern( _stringPattern, (SearchFor)iter.next(), _limitTo, _caseSensitive );
} }
engine.search( _workspace, pattern, _scope, _collector, false ); try {
engine.search( _workspace, pattern, _scope, _collector, false );
} catch (InterruptedException e) {
}
} }
/** /**

View file

@ -20,8 +20,8 @@ import org.eclipse.cdt.core.search.BasicSearchMatch;
import org.eclipse.cdt.core.search.BasicSearchResultCollector; import org.eclipse.cdt.core.search.BasicSearchResultCollector;
import org.eclipse.cdt.core.search.ICSearchConstants; import org.eclipse.cdt.core.search.ICSearchConstants;
import org.eclipse.cdt.core.search.ICSearchScope; import org.eclipse.cdt.core.search.ICSearchScope;
import org.eclipse.cdt.core.search.OrPattern;
import org.eclipse.cdt.core.search.SearchEngine; import org.eclipse.cdt.core.search.SearchEngine;
import org.eclipse.cdt.internal.core.search.matching.OrPattern;
import org.eclipse.cdt.internal.corext.template.ContextType; import org.eclipse.cdt.internal.corext.template.ContextType;
import org.eclipse.cdt.internal.corext.template.ContextTypeRegistry; import org.eclipse.cdt.internal.corext.template.ContextTypeRegistry;
import org.eclipse.cdt.internal.corext.template.ITemplateEditor; import org.eclipse.cdt.internal.corext.template.ITemplateEditor;
@ -546,7 +546,10 @@ public class CCompletionProcessor implements IContentAssistProcessor {
orPattern.addPattern(SearchEngine.createSearchPattern( orPattern.addPattern(SearchEngine.createSearchPattern(
searchPrefix, ICSearchConstants.FUNCTION, ICSearchConstants.DECLARATIONS, false )); searchPrefix, ICSearchConstants.FUNCTION, ICSearchConstants.DECLARATIONS, false ));
} }
searchEngine.search(CUIPlugin.getWorkspace(), orPattern, scope, searchResultCollector, true); try {
searchEngine.search(CUIPlugin.getWorkspace(), orPattern, scope, searchResultCollector, true);
} catch (InterruptedException e) {
}
elementsFound.addAll(searchResultCollector.getSearchResults()); elementsFound.addAll(searchResultCollector.getSearchResults());
sendResultsToCollector(elementsFound.iterator(), offset, length, prefix ); sendResultsToCollector(elementsFound.iterator(), offset, length, prefix );

View file

@ -449,7 +449,10 @@ public class NewClassWizardPage extends WizardPage implements Listener {
elements[0] = cProject; elements[0] = cProject;
ICSearchScope scope = SearchEngine.createCSearchScope(elements, true); ICSearchScope scope = SearchEngine.createCSearchScope(elements, true);
searchEngine.search(CUIPlugin.getWorkspace(), pattern, scope, resultCollector, false); try {
searchEngine.search(CUIPlugin.getWorkspace(), pattern, scope, resultCollector, false);
} catch (InterruptedException e) {
}
elementsFound.addAll(resultCollector.getSearchResults()); elementsFound.addAll(resultCollector.getSearchResults());
} }