From 126b76f5570147e8e9530a4b8f98fd81a6a6e13b Mon Sep 17 00:00:00 2001 From: Doug Schaefer Date: Mon, 24 Apr 2006 18:36:57 +0000 Subject: [PATCH] Clean up the Null indexer's reindexing. --- .../pdom/indexer/nulli/PDOMNullIndexer.java | 4 +- .../pdom/indexer/nulli/PDOMNullReindex.java | 51 +++++++++++++++++++ 2 files changed, 52 insertions(+), 3 deletions(-) create mode 100644 core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/indexer/nulli/PDOMNullReindex.java diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/indexer/nulli/PDOMNullIndexer.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/indexer/nulli/PDOMNullIndexer.java index 653749743c9..892c3460da5 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/indexer/nulli/PDOMNullIndexer.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/indexer/nulli/PDOMNullIndexer.java @@ -34,9 +34,7 @@ public class PDOMNullIndexer implements IPDOMIndexer { } public void reindex() throws CoreException { - // Just clear out the old index - pdom.clear(); - ((PDOM)pdom).fireChange(); + new PDOMNullReindex((PDOM)pdom).schedule(); } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/indexer/nulli/PDOMNullReindex.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/indexer/nulli/PDOMNullReindex.java new file mode 100644 index 00000000000..0e640bbd655 --- /dev/null +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/indexer/nulli/PDOMNullReindex.java @@ -0,0 +1,51 @@ +/******************************************************************************* + * Copyright (c) 2006 QNX Software Systems and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * QNX - Initial API and implementation + *******************************************************************************/ + +package org.eclipse.cdt.internal.core.pdom.indexer.nulli; + +import org.eclipse.cdt.core.CCorePlugin; +import org.eclipse.cdt.internal.core.pdom.PDOM; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Status; +import org.eclipse.core.runtime.jobs.Job; + +/** + * @author Doug Schaefer + * + */ +public class PDOMNullReindex extends Job { + + private final PDOM pdom; + + public PDOMNullReindex(PDOM pdom) { + super("Null Indexer: " + pdom.getProject().getElementName()); + this.pdom = pdom; + setRule(CCorePlugin.getPDOMManager().getIndexerSchedulingRule()); + } + + protected IStatus run(IProgressMonitor monitor) { + try { + pdom.acquireWriteLock(); + pdom.clear(); + pdom.fireChange(); + } catch (CoreException e) { + return e.getStatus(); + } catch (InterruptedException e) { + return Status.CANCEL_STATUS; + } finally { + pdom.releaseWriteLock(); + } + return Status.OK_STATUS; + } + +}