Bug 526917 - Allow all indexing to complete before query starts

getJavaElementMatches is doing a Java search - via
the OpenFromClipboardAction.

The SearchEngine tests which have some similar functionality all wait
for the index before trying to do the search. See most of the tests under
org.eclipse.jdt.core.tests.model.AbstractJavaSearchTests.
Code like one of these patterns is common:
1)
 IndexManager indexManager = JavaModelManager.getIndexManager();
 indexManager.indexAll(project.getProject());
 waitUntilIndexesReady();
2)
 JavaModelManager.getIndexManager().waitForIndex(false, null);
3)
 refresh(project);
 waitForAutoBuild();
 waitUntilIndexesReady();

By adding the waitForIndex it is hoped the flaky test becomes stable.

Change-Id: Ic31ed2e5dc9d5541e49f455c87b04bdf7f1e1f7b
Reviewed-on: https://git.eclipse.org/r/c/jdt/eclipse.jdt.debug/+/192113
Tested-by: Sarika Sinha <sarika.sinha@in.ibm.com>
Tested-by: JDT Bot <jdt-bot@eclipse.org>
Reviewed-by: Sarika Sinha <sarika.sinha@in.ibm.com>
1 file changed