[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
[cdt-patch] SearchEngine wait policy and Code Assist wait policy changes
|
Folks,
These two patches address the problem highlighted in PR 51846
and which I've brought up on the development list. This is a
short term solution aimed at the 1.2 branch. The SearchEngine
search API is enhanced with an additional search() method which
contains another parameter to allow the caller to determine what
the waiting policy should be when waiting on the indexer.
The second patch adusts the CCompletion policy to interrupt the
indexer immediately and fish out results. The practical implications
of this are that the user will get a reasonable response time,
though potentially not all of the results that are available (though
all of the results available at that time).
For the ChangeLogs
- Enhanced the SearchEngine search method to allow an additional
parameter which specifies the indexer waiting policy. The default/
original method continues, as it did previously, to wait for the
indexer to finish.
- Adjusted the code completion and dependancy calculator to run
immediately, interrupting the indexing if necessary, to get
results.
--- PATCH START ---
Index: search/org/eclipse/cdt/core/search/SearchEngine.java
===================================================================
RCS
file: /home/tools/org.eclipse.cdt.core/search/org/eclipse/cdt/core/search/Sea
rchEngine.java,v
retrieving revision 1.9.2.2
diff -u -r1.9.2.2 SearchEngine.java
--- search/org/eclipse/cdt/core/search/SearchEngine.java 27 Oct 2003
20:44:57 -0000 1.9.2.2
+++ search/org/eclipse/cdt/core/search/SearchEngine.java 12 Feb 2004
15:44:47 -0000
@@ -156,6 +156,10 @@
* @param _collector
*/
public void search(IWorkspace workspace, ICSearchPattern pattern,
ICSearchScope scope, ICSearchResultCollector collector, boolean
excludeLocalDeclarations) {
+ search(workspace, pattern, scope, collector,
excludeLocalDeclarations, ICSearchConstants.WAIT_UNTIL_READY_TO_SEARCH);
+ }
+
+ public void search(IWorkspace workspace, ICSearchPattern pattern,
ICSearchScope scope, ICSearchResultCollector collector, boolean
excludeLocalDeclarations, int waitingPolicy) {
if( VERBOSE ) {
System.out.println("Searching for " + pattern + "
in " + scope); //$NON-NLS-1$//$NON-NLS-2$
}
@@ -189,7 +193,7 @@
pathCollector,
indexManager
),
- ICSearchConstants.WAIT_UNTIL_READY_TO_SEARCH,
+ waitingPolicy,
subMonitor,
null );
-------------------
Index: src/org/eclipse/cdt/internal/ui/text/CCompletionProcessor.java
===================================================================
RCS
file: /home/tools/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/Att
ic/CCompletionProcessor.java,v
retrieving revision 1.15.2.2
diff -u -r1.15.2.2 CCompletionProcessor.java
--- src/org/eclipse/cdt/internal/ui/text/CCompletionProcessor.java 27
Oct 2003 20:45:06 -0000 1.15.2.2
+++ src/org/eclipse/cdt/internal/ui/text/CCompletionProcessor.java 12
Feb 2004 15:49:43 -0000
@@ -513,7 +513,7 @@
//Get file's dependencies
try {
IndexManager indexMan =
CCorePlugin.getDefault().getCoreModel().getIndexManager();
- indexMan.performConcurrentJob(new
DependencyQueryJob(project, (IFile)actualFile, indexMan, dependencies),
ICSearchConstants.WAIT_UNTIL_READY_TO_SEARCH, null, null);
+ indexMan.performConcurrentJob(new
DependencyQueryJob(project, (IFile)actualFile, indexMan, dependencies),
ICSearchConstants.FORCE_IMMEDIATE_SEARCH, null, null);
} catch (Exception e) {
}
}
@@ -529,8 +529,13 @@
orPattern.addPattern(SearchEngine.createSearchPattern(
prefix, ICSearchConstants.TYPE, ICSearchConstants.DECLARATIONS, false ));
orPattern.addPattern(SearchEngine.createSearchPattern(
prefix, ICSearchConstants.ENUM, ICSearchConstants.DECLARATIONS, false ));
orPattern.addPattern(SearchEngine.createSearchPattern(
prefix, ICSearchConstants.MACRO, ICSearchConstants.DECLARATIONS, false ));
- searchEngine.search(CUIPlugin.getWorkspace(), orPattern,
scope, resultCollector, true);
- elementsFound.addAll(resultCollector.getSearchResults());
+
+ try {
+ searchEngine.search(CUIPlugin.getWorkspace(),
orPattern, scope, resultCollector, true,
ICSearchConstants.FORCE_IMMEDIATE_SEARCH);
+ elementsFound.addAll(resultCollector.getSearchResults
());
+ } catch(Exception ex) {
+ /* Ignore exception, there may be partial results
collected */
+ }
if((currentScope instanceof IMethod) || (currentScope
instanceof IMethodDeclaration) ){
// add the methods and fields of the parent class
--- PATCH END ---
Index: src/org/eclipse/cdt/internal/ui/text/CCompletionProcessor.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/Attic/CCompletionProcessor.java,v
retrieving revision 1.15.2.2
diff -u -r1.15.2.2 CCompletionProcessor.java
--- src/org/eclipse/cdt/internal/ui/text/CCompletionProcessor.java 27 Oct 2003 20:45:06 -0000 1.15.2.2
+++ src/org/eclipse/cdt/internal/ui/text/CCompletionProcessor.java 12 Feb 2004 15:49:43 -0000
@@ -513,7 +513,7 @@
//Get file's dependencies
try {
IndexManager indexMan = CCorePlugin.getDefault().getCoreModel().getIndexManager();
- indexMan.performConcurrentJob(new DependencyQueryJob(project, (IFile)actualFile, indexMan, dependencies), ICSearchConstants.WAIT_UNTIL_READY_TO_SEARCH, null, null);
+ indexMan.performConcurrentJob(new DependencyQueryJob(project, (IFile)actualFile, indexMan, dependencies), ICSearchConstants.FORCE_IMMEDIATE_SEARCH, null, null);
} catch (Exception e) {
}
}
@@ -529,8 +529,13 @@
orPattern.addPattern(SearchEngine.createSearchPattern( prefix, ICSearchConstants.TYPE, ICSearchConstants.DECLARATIONS, false ));
orPattern.addPattern(SearchEngine.createSearchPattern( prefix, ICSearchConstants.ENUM, ICSearchConstants.DECLARATIONS, false ));
orPattern.addPattern(SearchEngine.createSearchPattern( prefix, ICSearchConstants.MACRO, ICSearchConstants.DECLARATIONS, false ));
- searchEngine.search(CUIPlugin.getWorkspace(), orPattern, scope, resultCollector, true);
- elementsFound.addAll(resultCollector.getSearchResults());
+
+ try {
+ searchEngine.search(CUIPlugin.getWorkspace(), orPattern, scope, resultCollector, true, ICSearchConstants.FORCE_IMMEDIATE_SEARCH);
+ elementsFound.addAll(resultCollector.getSearchResults());
+ } catch(Exception ex) {
+ /* Ignore exception, there may be partial results collected */
+ }
if((currentScope instanceof IMethod) || (currentScope instanceof IMethodDeclaration) ){
// add the methods and fields of the parent class
Index: search/org/eclipse/cdt/core/search/SearchEngine.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/search/org/eclipse/cdt/core/search/SearchEngine.java,v
retrieving revision 1.9.2.2
diff -u -r1.9.2.2 SearchEngine.java
--- search/org/eclipse/cdt/core/search/SearchEngine.java 27 Oct 2003 20:44:57 -0000 1.9.2.2
+++ search/org/eclipse/cdt/core/search/SearchEngine.java 12 Feb 2004 15:44:47 -0000
@@ -156,6 +156,10 @@
* @param _collector
*/
public void search(IWorkspace workspace, ICSearchPattern pattern, ICSearchScope scope, ICSearchResultCollector collector, boolean excludeLocalDeclarations) {
+ search(workspace, pattern, scope, collector, excludeLocalDeclarations, ICSearchConstants.WAIT_UNTIL_READY_TO_SEARCH);
+ }
+
+ public void search(IWorkspace workspace, ICSearchPattern pattern, ICSearchScope scope, ICSearchResultCollector collector, boolean excludeLocalDeclarations, int waitingPolicy) {
if( VERBOSE ) {
System.out.println("Searching for " + pattern + " in " + scope); //$NON-NLS-1$//$NON-NLS-2$
}
@@ -189,7 +193,7 @@
pathCollector,
indexManager
),
- ICSearchConstants.WAIT_UNTIL_READY_TO_SEARCH,
+ waitingPolicy,
subMonitor,
null );