diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/IPDOMIndexerTask.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/IPDOMIndexerTask.java index 7c245a0bfee..053e92fbbd7 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/IPDOMIndexerTask.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/IPDOMIndexerTask.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2009 QNX Software Systems + * Copyright (c) 2005, 2010 QNX Software Systems * 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 @@ -8,6 +8,7 @@ * Contributors: * Doug Schaefer (QNX Software Systems) - initial API and implementation * Markus Schorn (Wind River Systems) + * Sergey Prigogin (Google) *******************************************************************************/ package org.eclipse.cdt.core.dom; @@ -42,4 +43,15 @@ public interface IPDOMIndexerTask { * @noreference This method is not intended to be referenced by clients. */ public IndexerProgress getProgressInformation(); + + /** + * Takes files from another task and adds them to this task in front of all not yet processed + * files. The urgent work my be rejected if this task is not capable of accepting it, or if + * the amount of urgent work is too large compared to the work already assigned to this task. + * @param task the task to add the work from. + * @return {@code true} if the work was accepted, {@code false} if it was rejected. + * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=319330" + * @since 5.3 + */ + public boolean acceptUrgentTask(IPDOMIndexerTask task); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/IndexBasedFileContentProvider.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/IndexBasedFileContentProvider.java index 37f8a4e7fc9..7a7a0b5b9bd 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/IndexBasedFileContentProvider.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/IndexBasedFileContentProvider.java @@ -129,8 +129,7 @@ public final class IndexBasedFileContentProvider extends InternalFileContentProv } catch (NeedToParseException e) { } } - } - catch (CoreException e) { + } catch (CoreException e) { CCorePlugin.log(e); } @@ -224,8 +223,7 @@ public final class IndexBasedFileContentProvider extends InternalFileContentProv fIncludedFiles.add(file.getLocation()); } return new InternalFileContent(GAP, macros, directives, new ArrayList(filesIncluded)); - } - catch (CoreException e) { + } catch (CoreException e) { CCorePlugin.log(e); } return null; @@ -249,7 +247,6 @@ public final class IndexBasedFileContentProvider extends InternalFileContentProv private boolean collectFileContentForGap(IIndexFile from, IIndexFileLocation to, Set filesIncluded, List macros, List directives) throws CoreException { - final IIndexFileLocation ifl= from.getLocation(); if (ifl.equals(to)) { return true; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/AbstractIndexerTask.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/AbstractIndexerTask.java index cd986f37424..f1441e5ba4b 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/AbstractIndexerTask.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/AbstractIndexerTask.java @@ -6,8 +6,9 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Markus Schorn - initial API and implementation - * IBM Corporation + * Markus Schorn - initial API and implementation + * IBM Corporation + * Sergey Prigogin (Google) *******************************************************************************/ package org.eclipse.cdt.internal.core.pdom; @@ -15,6 +16,7 @@ import java.lang.reflect.InvocationTargetException; import java.net.URI; import java.util.ArrayList; import java.util.Arrays; +import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; @@ -24,6 +26,7 @@ import java.util.Map; import java.util.Map.Entry; import org.eclipse.cdt.core.CCorePlugin; +import org.eclipse.cdt.core.dom.IPDOMIndexerTask; import org.eclipse.cdt.core.dom.ast.IASTNode; import org.eclipse.cdt.core.dom.ast.IASTPreprocessorIncludeStatement; import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit; @@ -92,13 +95,17 @@ public abstract class AbstractIndexerTask extends PDOMWriter { } public static class IndexFileContent { - private IIndexFile fIndexFile= null; - private boolean fRequestUpdate= false; + private IIndexFile fIndexFile; + private boolean fRequestUpdate; private boolean fRequestIsCounted= true; - private boolean fIsUpdated= false; + private boolean fIsUpdated; private Object[] fPreprocessingDirectives; private ICPPUsingDirective[] fDirectives; + public IndexFileContent() { + fRequestIsCounted = true; + } + public Object[] getPreprocessingDirectives() throws CoreException { if (fPreprocessingDirectives == null) { if (fIndexFile == null) @@ -131,7 +138,7 @@ public abstract class AbstractIndexerTask extends PDOMWriter { } public static Object[] merge(IIndexInclude[] includes, IIndexMacro[] macros) throws CoreException { - Object[] merged= new Object[includes.length+macros.length]; + Object[] merged= new Object[includes.length + macros.length]; int i= 0; int m= 0; int ioffset= getOffset(includes, i); @@ -162,8 +169,8 @@ public abstract class AbstractIndexerTask extends PDOMWriter { return Integer.MAX_VALUE; } } - - protected enum MessageKind {parsingFileTask, errorWhileParsing, tooManyIndexProblems} + + protected enum MessageKind { parsingFileTask, errorWhileParsing, tooManyIndexProblems } private int fUpdateFlags= IIndexManager.UPDATE_ALL; private UnusedHeaderStrategy fIndexHeadersWithoutContext= UnusedHeaderStrategy.useDefaultLanguage; @@ -182,13 +189,21 @@ public abstract class AbstractIndexerTask extends PDOMWriter { private long fFileSizeLimit= 0; private InternalFileContentProvider fCodeReaderFactory; private int fSwallowOutOfMemoryError= 5; + /** + * A queue of urgent indexing tasks that contribute additional files to this task. + * The files from the urgent tasks are indexed before all not yet processed files. + */ + private final LinkedList fUrgentTasks; + boolean fTaskCompleted; - public AbstractIndexerTask(Object[] filesToUpdate, Object[] filesToRemove, IndexerInputAdapter resolver, boolean fastIndexer) { + public AbstractIndexerTask(Object[] filesToUpdate, Object[] filesToRemove, + IndexerInputAdapter resolver, boolean fastIndexer) { super(resolver); fIsFastIndexer= fastIndexer; fFilesToUpdate= filesToUpdate; - fFilesToRemove.addAll(Arrays.asList(filesToRemove)); + Collections.addAll(fFilesToRemove, filesToRemove); updateRequestedFiles(fFilesToUpdate.length + fFilesToRemove.size()); + fUrgentTasks = new LinkedList(); } public final void setIndexHeadersWithoutContext(UnusedHeaderStrategy mode) { @@ -314,54 +329,126 @@ public abstract class AbstractIndexerTask extends PDOMWriter { } public final void runTask(IProgressMonitor monitor) throws InterruptedException { - if (!fIndexFilesWithoutConfiguration) { - fIndexHeadersWithoutContext= UnusedHeaderStrategy.skip; - } - - fIndex= createIndex(); - if (fIndex == null) { - return; - } - fTodoTaskUpdater= createTodoTaskUpdater(); - - fASTOptions= ILanguage.OPTION_NO_IMAGE_LOCATIONS - | ILanguage.OPTION_SKIP_TRIVIAL_EXPRESSIONS_IN_AGGREGATE_INITIALIZERS; - if (getSkipReferences() == SKIP_ALL_REFERENCES) { - fASTOptions |= ILanguage.OPTION_SKIP_FUNCTION_BODIES; - } - - fIndex.resetCacheCounters(); - fIndex.acquireReadLock(); - try { - try { - // split into sources and headers, remove excluded sources. - final HashMap> files= new HashMap>(); - final ArrayList ifilesToRemove= new ArrayList(); - extractFiles(files, ifilesToRemove, monitor); - - setResume(true); - - // remove files from index - removeFilesInIndex(fFilesToRemove, ifilesToRemove, monitor); - - parseFilesUpFront(monitor); - for (int linkageID : getLinkagesToParse()) { - parseLinkage(linkageID, files, monitor); - } - if (!monitor.isCanceled()) { - setResume(false); - } - } finally { - fIndex.flush(); + if (!fIndexFilesWithoutConfiguration) { + fIndexHeadersWithoutContext= UnusedHeaderStrategy.skip; + } + + fIndex= createIndex(); + if (fIndex == null) { + return; + } + fTodoTaskUpdater= createTodoTaskUpdater(); + + fASTOptions= ILanguage.OPTION_NO_IMAGE_LOCATIONS + | ILanguage.OPTION_SKIP_TRIVIAL_EXPRESSIONS_IN_AGGREGATE_INITIALIZERS; + if (getSkipReferences() == SKIP_ALL_REFERENCES) { + fASTOptions |= ILanguage.OPTION_SKIP_FUNCTION_BODIES; + } + + fIndex.resetCacheCounters(); + fIndex.acquireReadLock(); + + try { + try { + // Split into sources and headers, remove excluded sources. + HashMap> files= new HashMap>(); + final ArrayList indexFilesToRemove= new ArrayList(); + extractFiles(files, indexFilesToRemove, monitor); + + setResume(true); + + // Remove files from index + removeFilesInIndex(fFilesToRemove, indexFilesToRemove, monitor); + + parseFilesUpFront(monitor); + + HashMap> moreFiles= null; + while (true) { + for (int linkageID : getLinkagesToParse()) { + parseLinkage(linkageID, files, monitor); + if (hasUrgentTasks()) + break; + } + synchronized (this) { + if (fUrgentTasks.isEmpty()) { + if (moreFiles == null) { + // No urgent tasks and no more files to parse. We are done. + fTaskCompleted = true; + break; + } else { + files = moreFiles; + moreFiles = null; + } + } + } + AbstractIndexerTask urgentTask; + while ((urgentTask = getUrgentTask()) != null) { + // Move the lists of not yet parsed files from 'files' to 'moreFiles'. + if (moreFiles == null) { + moreFiles = files; + } else { + for (Map.Entry> entry : files.entrySet()) { + List list= moreFiles.get(entry.getKey()); + if (list == null) { + moreFiles.put(entry.getKey(), entry.getValue()); + } else { + list.addAll(0, entry.getValue()); + } + } + } + // Extract files from the urgent task. + files = new HashMap>(); + fFilesToUpdate = urgentTask.fFilesToUpdate; + fForceNumberFiles = urgentTask.fForceNumberFiles; + fFilesToRemove = urgentTask.fFilesToRemove; + extractFiles(files, indexFilesToRemove, monitor); + removeFilesInIndex(fFilesToRemove, indexFilesToRemove, monitor); + } + } + if (!monitor.isCanceled()) { + setResume(false); + } + } finally { + fIndex.flush(); + } + } catch (CoreException e) { + logException(e); + } finally { + fIndex.releaseReadLock(); } - } catch (CoreException e) { - logException(e); } finally { - fIndex.releaseReadLock(); + synchronized (this) { + fTaskCompleted = true; + } } } + /** + * @see IPDOMIndexerTask#acceptUrgentTask(IPDOMIndexerTask) + */ + public synchronized boolean acceptUrgentTask(IPDOMIndexerTask urgentTask) { + if (!(urgentTask instanceof AbstractIndexerTask)) { + return false; + } + AbstractIndexerTask task = (AbstractIndexerTask) urgentTask; + if (!task.fFilesUpFront.isEmpty() || + task.fIsFastIndexer != fIsFastIndexer || + task.fIndexFilesWithoutConfiguration != fIndexFilesWithoutConfiguration || + (fIndexFilesWithoutConfiguration && task.fIndexHeadersWithoutContext != fIndexHeadersWithoutContext) || + fTaskCompleted) { + // Reject the urgent work since this task is not capable of doing it, or it's too late. + return false; + } + if (task.fFilesToUpdate.length > + (fFilesToUpdate != null ? fFilesToUpdate.length : getProgressInformation().fRequestedFilesCount)) { + // Reject the urgent work since it's too heavy for this task. + return false; + } + fUrgentTasks.add(task); + return true; + } + private void setResume(boolean value) throws InterruptedException, CoreException { fIndex.acquireWriteLock(1); try { @@ -371,7 +458,7 @@ public abstract class AbstractIndexerTask extends PDOMWriter { } } - private void extractFiles(Map> files, List iFilesToRemove, + private void extractFiles(HashMap> files, List iFilesToRemove, IProgressMonitor monitor) throws CoreException { final boolean forceAll= (fUpdateFlags & IIndexManager.UPDATE_ALL) != 0; final boolean checkTimestamps= (fUpdateFlags & IIndexManager.UPDATE_CHECK_TIMESTAMPS) != 0; @@ -444,8 +531,10 @@ public abstract class AbstractIndexerTask extends PDOMWriter { } } } - updateRequestedFiles(count - fFilesToUpdate.length); - fFilesToUpdate= null; + synchronized (this) { + updateRequestedFiles(count - fFilesToUpdate.length); + fFilesToUpdate= null; + } } private boolean isModified(boolean checkTimestamps, boolean checkFileContentsHash, IIndexFileLocation ifl, @@ -470,6 +559,7 @@ public abstract class AbstractIndexerTask extends PDOMWriter { } info.fIndexFile= ifile; info.fRequestUpdate= true; + info.fIsUpdated= false; } private void setIndexed(int linkageID, IIndexFileLocation ifl) { @@ -520,7 +610,7 @@ public abstract class AbstractIndexerTask extends PDOMWriter { } } - private void store(Object tu, int linkageID, boolean isSourceUnit, Map> files) { + private void store(Object tu, int linkageID, boolean isSourceUnit, HashMap> files) { Integer key = getFileListKey(linkageID, isSourceUnit); List list= files.get(key); if (list == null) { @@ -535,12 +625,12 @@ public abstract class AbstractIndexerTask extends PDOMWriter { return key; } - private void removeFilesInIndex(List filesToRemove, List ifilesToRemove, + private void removeFilesInIndex(List filesToRemove, List indexFilesToRemove, IProgressMonitor monitor) throws InterruptedException, CoreException { - if (!filesToRemove.isEmpty() || !ifilesToRemove.isEmpty()) { + if (!filesToRemove.isEmpty() || !indexFilesToRemove.isEmpty()) { fIndex.acquireWriteLock(1); try { - for (Object tu : fFilesToRemove) { + for (Object tu : filesToRemove) { if (monitor.isCanceled()) { return; } @@ -553,7 +643,7 @@ public abstract class AbstractIndexerTask extends PDOMWriter { } updateRequestedFiles(-1); } - for (IIndexFragmentFile ifile : ifilesToRemove) { + for (IIndexFragmentFile ifile : indexFilesToRemove) { if (monitor.isCanceled()) { return; } @@ -564,7 +654,7 @@ public abstract class AbstractIndexerTask extends PDOMWriter { fIndex.releaseWriteLock(1); } } - fFilesToRemove.clear(); + filesToRemove.clear(); } private void parseFilesUpFront(IProgressMonitor monitor) throws CoreException { @@ -630,35 +720,38 @@ public abstract class AbstractIndexerTask extends PDOMWriter { private void parseLinkage(int linkageID, Map> fileListMap, IProgressMonitor monitor) throws CoreException, InterruptedException { - // sources + // Sources List files= fileListMap.get(getFileListKey(linkageID, true)); if (files != null) { - for (Object tu : files) { - if (monitor.isCanceled()) + for (Iterator iter = files.iterator(); iter.hasNext();) { + Object tu = iter.next(); + if (monitor.isCanceled() || hasUrgentTasks()) return; + final IIndexFileLocation ifl = fResolver.resolveFile(tu); - if (ifl == null) - continue; - final IndexFileContent info= getFileInfo(linkageID, ifl); - if (info != null && info.fRequestUpdate && !info.fIsUpdated) { - info.fRequestIsCounted= false; - final IScannerInfo scannerInfo= fResolver.getBuildConfiguration(linkageID, tu); - parseFile(tu, linkageID, ifl, scannerInfo, false, monitor); - if (info.fIsUpdated) { - updateFileCount(1, 0, 0); // a source file was parsed + if (ifl != null) { + final IndexFileContent info= getFileInfo(linkageID, ifl); + if (info != null && info.fRequestUpdate && !info.fIsUpdated) { + info.fRequestIsCounted= false; + final IScannerInfo scannerInfo= fResolver.getBuildConfiguration(linkageID, tu); + parseFile(tu, linkageID, ifl, scannerInfo, false, monitor); + if (info.fIsUpdated) { + updateFileCount(1, 0, 0); // a source file was parsed + } } } + iter.remove(); } - files.clear(); } - // headers with context + // Headers with context HashMap contextMap= new HashMap(); files= fileListMap.get(getFileListKey(linkageID, false)); if (files != null) { for (Iterator iter = files.iterator(); iter.hasNext();) { - if (monitor.isCanceled()) + if (monitor.isCanceled() || hasUrgentTasks()) return; + final Object header= iter.next(); final IIndexFileLocation ifl = fResolver.resolveFile(header); final IndexFileContent info= getFileInfo(linkageID, ifl); @@ -676,16 +769,17 @@ public abstract class AbstractIndexerTask extends PDOMWriter { } } } else { - // file was already parsed. + // The file has been parsed already. iter.remove(); } } - // headers without context + // Headers without context contextMap= null; for (Iterator iter = files.iterator(); iter.hasNext();) { - if (monitor.isCanceled()) + if (monitor.isCanceled() || hasUrgentTasks()) return; + final Object header= iter.next(); final IIndexFileLocation ifl = fResolver.resolveFile(header); final IndexFileContent info= getFileInfo(linkageID, ifl); @@ -695,13 +789,25 @@ public abstract class AbstractIndexerTask extends PDOMWriter { parseFile(header, linkageID, ifl, scannerInfo, false, monitor); if (info.fIsUpdated) { updateFileCount(0, 1, 1); // a header was parsed without context - iter.remove(); } } + iter.remove(); } } } + private synchronized boolean hasUrgentTasks() { + return !fUrgentTasks.isEmpty(); + } + + /** + * Retrieves the first urgent task from the queue of urgent tasks. + * @return An urgent task, or {@code null} if there are no urgent tasks. + */ + private synchronized AbstractIndexerTask getUrgentTask() { + return fUrgentTasks.poll(); + } + private static final Object NO_CONTEXT= new Object(); private Object findContext(int linkageID, IIndexFragmentFile ifile, HashMap contextMap) { diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/NotifyCModelManagerTask.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/NotifyCModelManagerTask.java index 9c072395056..ef74efe03e4 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/NotifyCModelManagerTask.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/NotifyCModelManagerTask.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009 Wind River Systems, Inc. and others. + * Copyright (c) 2009, 2010 Wind River Systems, Inc. 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 @@ -23,13 +23,12 @@ import org.eclipse.core.runtime.content.IContentTypeManager.ContentTypeChangeEve /** * Task to notify the CModel manager of changes to the content types. - * */ public class NotifyCModelManagerTask implements IPDOMIndexerTask { private final IProject fProject; - public NotifyCModelManagerTask(IProject prj) { - fProject= prj; + public NotifyCModelManagerTask(IProject project) { + fProject= project; } public IPDOMIndexer getIndexer() { @@ -51,4 +50,8 @@ public class NotifyCModelManagerTask implements IPDOMIndexerTask { }); } } + + public boolean acceptUrgentTask(IPDOMIndexerTask task) { + return false; + } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/PDOMManager.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/PDOMManager.java index 8545bacaed5..e7a914919dc 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/PDOMManager.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/PDOMManager.java @@ -664,8 +664,14 @@ public class PDOMManager implements IWritableIndexManager, IListener { getReferencingProjects(indexer.getProject().getProject(), referencing); } synchronized (fTaskQueue) { + if (fCurrentTask != null && fCurrentTask.acceptUrgentTask(subjob)) { + return; + } int i= 0; for (IPDOMIndexerTask task : fTaskQueue) { + if (task.acceptUrgentTask(subjob)) { + return; + } final IPDOMIndexer ti = task.getIndexer(); if (ti != null && referencing.contains(ti.getProject().getProject())) { fTaskQueue.add(i, subjob); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/indexer/PDOMIndexerTask.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/indexer/PDOMIndexerTask.java index e1cdf3e7770..bd116b09816 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/indexer/PDOMIndexerTask.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/indexer/PDOMIndexerTask.java @@ -170,7 +170,8 @@ public abstract class PDOMIndexerTask extends AbstractIndexerTask implements IPD if (ct != null) { ILanguage l = LanguageManager.getInstance().getLanguage(ct); if (l instanceof AbstractLanguage) { - if (filename.indexOf('.') >= 0 && ct.getId().equals(CCorePlugin.CONTENT_TYPE_CXXHEADER) && l.getLinkageID() == ILinkage.CPP_LINKAGE_ID) { + if (filename.indexOf('.') >= 0 && ct.getId().equals(CCorePlugin.CONTENT_TYPE_CXXHEADER) && + l.getLinkageID() == ILinkage.CPP_LINKAGE_ID) { ILanguage l2= LanguageManager.getInstance().getLanguageForContentTypeID(CCorePlugin.CONTENT_TYPE_CHEADER); if (l2 instanceof AbstractLanguage) { return new AbstractLanguage[] {(AbstractLanguage) l, (AbstractLanguage) l2}; @@ -371,4 +372,14 @@ public abstract class PDOMIndexerTask extends AbstractIndexerTask implements IPD public void setWriteInfoToLog() { fWriteInfoToLog= true; } + + @Override + public synchronized boolean acceptUrgentTask(IPDOMIndexerTask urgentTask) { + final IPDOMIndexer ti = urgentTask.getIndexer(); + if (fIndexer == null || ti == null || + fIndexer.getProject().getProject() != ti.getProject().getProject()) { + return false; + } + return super.acceptUrgentTask(urgentTask); + } } \ No newline at end of file diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/indexer/PDOMRebuildTask.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/indexer/PDOMRebuildTask.java index d712ac50e81..9c93a98cae3 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/indexer/PDOMRebuildTask.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/indexer/PDOMRebuildTask.java @@ -1,12 +1,13 @@ /******************************************************************************* - * Copyright (c) 2007, 2009 Wind River Systems, Inc. and others. + * Copyright (c) 2007, 2010 Wind River Systems, Inc. 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: - * Markus Schorn - initial API and implementation + * Markus Schorn - initial API and implementation + * Sergey Prigogin (Google) *******************************************************************************/ package org.eclipse.cdt.internal.core.pdom.indexer; @@ -94,8 +95,7 @@ public class PDOMRebuildTask implements IPDOMIndexerTask { if (wf instanceof WritablePDOM) { PDOMManager.writeProjectPDOMProperties((WritablePDOM) wf, project.getProject()); } - } - finally { + } finally { index.releaseWriteLock(0); } } @@ -124,4 +124,8 @@ public class PDOMRebuildTask implements IPDOMIndexerTask { public synchronized IndexerProgress getProgressInformation() { return fDelegate != null ? fDelegate.getProgressInformation() : fProgress; } + + public synchronized boolean acceptUrgentTask(IPDOMIndexerTask task) { + return fDelegate != null && fDelegate.acceptUrgentTask(task); + } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/indexer/PDOMUpdateTask.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/indexer/PDOMUpdateTask.java index 65a8362a7ff..34304635d93 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/indexer/PDOMUpdateTask.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/indexer/PDOMUpdateTask.java @@ -6,8 +6,9 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Markus Schorn - initial API and implementation - *******************************************************************************/ + * Markus Schorn - initial API and implementation + * Sergey Prigogin (Google) +******************************************************************************/ package org.eclipse.cdt.internal.core.pdom.indexer; import java.util.ArrayList; @@ -92,8 +93,7 @@ public class PDOMUpdateTask implements IPDOMIndexerTask { boolean haveProject= false; if (fFilesAndFolders == null) { project.accept(collector); - } - else { + } else { for (ICElement elem : fFilesAndFolders) { if (elem.getElementType() == ICElement.C_PROJECT) { haveProject= true; @@ -147,6 +147,10 @@ public class PDOMUpdateTask implements IPDOMIndexerTask { return fDelegate != null ? fDelegate.getProgressInformation() : fProgress; } + public synchronized boolean acceptUrgentTask(IPDOMIndexerTask task) { + return fDelegate != null && fDelegate.acceptUrgentTask(task); + } + public void setTranslationUnitSelection(List filesAndFolders) { fFilesAndFolders= new ArrayList(filesAndFolders.size()); fFilesAndFolders.addAll(filesAndFolders); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/indexer/TriggerNotificationTask.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/indexer/TriggerNotificationTask.java index 7ccd262ffac..ec5ec716d80 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/indexer/TriggerNotificationTask.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/indexer/TriggerNotificationTask.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2009 Wind River Systems, Inc. and others. + * Copyright (c) 2007, 2010 Wind River Systems, Inc. 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 @@ -23,7 +23,6 @@ import org.eclipse.core.runtime.IProgressMonitor; * In this situation the pdom itself does not generate a notification. */ public class TriggerNotificationTask implements IPDOMIndexerTask { - private WritablePDOM fPDOM; private PDOMManager fManager; @@ -45,4 +44,8 @@ public class TriggerNotificationTask implements IPDOMIndexerTask { event.setReloaded(); fManager.handleChange(fPDOM, event); } + + public boolean acceptUrgentTask(IPDOMIndexerTask task) { + return false; + } }