private IStatus rebuildIndexCompletely(SubMonitor monitor) throws CorruptIndexException, LockObtainFailedException, IOException, CoreException { MultiStatus multiStatus = new MultiStatus(TasksIndexCore.ID_PLUGIN, 0, null, null); // get indexable tasks from the task list final TaskListState taskListState = new TaskListState(); taskList.run(taskListState, monitor.newChild(0)); monitor.beginTask( Messages.TaskListIndex_task_rebuilding_index, taskListState.indexableTasks.size()); try { IndexWriter writer; try { writer = createIndexWriter(true); } catch (CorruptIndexException e) { if (directory instanceof FSDirectory) { cleanDirectory(((FSDirectory) directory).getFile()); writer = createIndexWriter(true); } else { throw e; } } try { for (ITask task : taskListState.indexableTasks) { if (taskIsIndexable(task, null)) { try { TaskData taskData = dataManager.getTaskData(task); add(writer, task, taskData); } catch (CoreException e) { // an individual task data error should not prevent the index from updating multiStatus.add(e.getStatus()); } } monitor.worked(1); } synchronized (this) { rebuildIndex = false; } } finally { writer.close(); } } finally { monitor.done(); } return multiStatus; }