1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-06 16:45:25 +02:00

Patch for Bogdan Gheorghe and Thomas Fletcher.

This is Thomas' patch which causes the completion engine to use the FORCE_IMMEDIATE_SEARCH option 
in the search engine. Test suite run on Windows.
This commit is contained in:
John Camelon 2004-02-15 23:12:40 +00:00
parent bb4821dee3
commit 0470019cbd
6 changed files with 38 additions and 8 deletions

View file

@ -1,3 +1,10 @@
2004-02-13 Bogdan Gheorghe
-Modified CompletionProposalsTest to reset the indexer thread at the
beginning of the test case - this means that the project will be indexed
as soon as it is created. Since completions now use FORCE_IMMEDIATE_SEARCH,
we have to give a bit of time to ensure that the project is indexed before
we try a query.
2004-01-29 John Camelon 2004-01-29 John Camelon
Added ScannerTestCase::testBug50821(). Added ScannerTestCase::testBug50821().

View file

@ -58,6 +58,7 @@ public class CompletionProposalsTest extends TestCase{
} }
protected void setUp() throws Exception { protected void setUp() throws Exception {
(CCorePlugin.getDefault().getCoreModel().getIndexManager()).reset();
monitor = new NullProgressMonitor(); monitor = new NullProgressMonitor();
String pluginRoot=org.eclipse.core.runtime.Platform.getPlugin("org.eclipse.cdt.core.tests").find(new Path("/")).getFile(); String pluginRoot=org.eclipse.core.runtime.Platform.getPlugin("org.eclipse.cdt.core.tests").find(new Path("/")).getFile();
@ -79,8 +80,8 @@ public class CompletionProposalsTest extends TestCase{
} }
// use the new indexer // use the new indexer
IndexManager indexManager = CCorePlugin.getDefault().getCoreModel().getIndexManager(); // IndexManager indexManager = CCorePlugin.getDefault().getCoreModel().getIndexManager();
indexManager.reset(); // indexManager.reset();
} }
@ -110,13 +111,15 @@ public class CompletionProposalsTest extends TestCase{
Document document = new Document(buffer); Document document = new Document(buffer);
int pos = buffer.indexOf(" a ") + 2; int pos = buffer.indexOf(" a ") + 2;
int length = 0; int length = 0;
CCompletionProcessor completionProcessor = new CCompletionProcessor(null);
ICompletionProposal[] results = completionProcessor.evalProposals(document, pos, length, tu);
try { try {
Thread.sleep(MAGIC_NUMBER); Thread.sleep(MAGIC_NUMBER);
} catch (InterruptedException e1) { } catch (InterruptedException e1) {
fail( "Bogdan's hack did not suffice"); fail( "Bogdan's hack did not suffice");
} }
CCompletionProcessor completionProcessor = new CCompletionProcessor(null);
ICompletionProposal[] results = completionProcessor.evalProposals(document, pos, length, tu);
assertEquals(results.length, 7); assertEquals(results.length, 7);
for (int i = 0; i<results.length; i++){ for (int i = 0; i<results.length; i++){
ICompletionProposal proposal = results[i]; ICompletionProposal proposal = results[i];

View file

@ -1,3 +1,7 @@
2004-02-13 Bogdan Gheorghe
- From Thomas: Modified SearchEngine.search to allow for the passing of
a waiting policy
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

@ -156,6 +156,10 @@ public class SearchEngine implements ICSearchConstants{
* @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) {
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 ) { 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$
} }
@ -189,7 +193,7 @@ public class SearchEngine implements ICSearchConstants{
pathCollector, pathCollector,
indexManager indexManager
), ),
ICSearchConstants.WAIT_UNTIL_READY_TO_SEARCH, waitingPolicy,
subMonitor, subMonitor,
null ); null );

View file

@ -1,3 +1,10 @@
2004-02-13 Bogdan Gheorghe
Thomas' patch: Modified CCompletionProcessor to use FORCE_IMMEDIATE_SEARCH
when requesting a dependency query/search.
* src/org/eclipse/cdt/internal/ui/text/CCompletionProcessor.java
2004-02-05 Alain Magloire 2004-02-05 Alain Magloire
PR 51221 PR 51221
Reformat Patch from Bogdan base on Thomas Fletcher original patch Reformat Patch from Bogdan base on Thomas Fletcher original patch

View file

@ -513,7 +513,7 @@ public class CCompletionProcessor implements IContentAssistProcessor {
//Get file's dependencies //Get file's dependencies
try { try {
IndexManager indexMan = CCorePlugin.getDefault().getCoreModel().getIndexManager(); 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) { } catch (Exception e) {
} }
} }
@ -529,8 +529,13 @@ public class CCompletionProcessor implements IContentAssistProcessor {
orPattern.addPattern(SearchEngine.createSearchPattern( prefix, ICSearchConstants.TYPE, ICSearchConstants.DECLARATIONS, false )); 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.ENUM, ICSearchConstants.DECLARATIONS, false ));
orPattern.addPattern(SearchEngine.createSearchPattern( prefix, ICSearchConstants.MACRO, ICSearchConstants.DECLARATIONS, false )); orPattern.addPattern(SearchEngine.createSearchPattern( prefix, ICSearchConstants.MACRO, ICSearchConstants.DECLARATIONS, false ));
searchEngine.search(CUIPlugin.getWorkspace(), orPattern, scope, resultCollector, true);
try {
searchEngine.search(CUIPlugin.getWorkspace(), orPattern, scope, resultCollector, true, ICSearchConstants.FORCE_IMMEDIATE_SEARCH);
elementsFound.addAll(resultCollector.getSearchResults()); elementsFound.addAll(resultCollector.getSearchResults());
} catch(Exception ex) {
/* Ignore exception, there may be partial results collected */
}
if((currentScope instanceof IMethod) || (currentScope instanceof IMethodDeclaration) ){ if((currentScope instanceof IMethod) || (currentScope instanceof IMethodDeclaration) ){
// add the methods and fields of the parent class // add the methods and fields of the parent class