mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-23 22:52:11 +02:00
Bug 319330 - The indexing queue should give preference to the recently changed files
This commit is contained in:
parent
8dc35f6030
commit
0bdbe7ce95
9 changed files with 247 additions and 101 deletions
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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<IIndexFile>(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<IIndexFile> filesIncluded, List<IIndexMacro> macros,
|
||||
List<ICPPUsingDirective> directives) throws CoreException {
|
||||
|
||||
final IIndexFileLocation ifl= from.getLocation();
|
||||
if (ifl.equals(to)) {
|
||||
return true;
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
* Contributors:
|
||||
* 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);
|
||||
|
@ -163,7 +170,7 @@ public abstract class AbstractIndexerTask extends PDOMWriter {
|
|||
}
|
||||
}
|
||||
|
||||
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<AbstractIndexerTask> 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<AbstractIndexerTask>();
|
||||
}
|
||||
|
||||
public final void setIndexHeadersWithoutContext(UnusedHeaderStrategy mode) {
|
||||
|
@ -314,6 +329,7 @@ public abstract class AbstractIndexerTask extends PDOMWriter {
|
|||
}
|
||||
|
||||
public final void runTask(IProgressMonitor monitor) throws InterruptedException {
|
||||
try {
|
||||
if (!fIndexFilesWithoutConfiguration) {
|
||||
fIndexHeadersWithoutContext= UnusedHeaderStrategy.skip;
|
||||
}
|
||||
|
@ -335,19 +351,60 @@ public abstract class AbstractIndexerTask extends PDOMWriter {
|
|||
|
||||
try {
|
||||
try {
|
||||
// split into sources and headers, remove excluded sources.
|
||||
final HashMap<Integer, List<Object>> files= new HashMap<Integer, List<Object>>();
|
||||
final ArrayList<IIndexFragmentFile> ifilesToRemove= new ArrayList<IIndexFragmentFile>();
|
||||
extractFiles(files, ifilesToRemove, monitor);
|
||||
// Split into sources and headers, remove excluded sources.
|
||||
HashMap<Integer, List<Object>> files= new HashMap<Integer, List<Object>>();
|
||||
final ArrayList<IIndexFragmentFile> indexFilesToRemove= new ArrayList<IIndexFragmentFile>();
|
||||
extractFiles(files, indexFilesToRemove, monitor);
|
||||
|
||||
setResume(true);
|
||||
|
||||
// remove files from index
|
||||
removeFilesInIndex(fFilesToRemove, ifilesToRemove, monitor);
|
||||
// Remove files from index
|
||||
removeFilesInIndex(fFilesToRemove, indexFilesToRemove, monitor);
|
||||
|
||||
parseFilesUpFront(monitor);
|
||||
|
||||
HashMap<Integer, List<Object>> 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<Integer, List<Object>> entry : files.entrySet()) {
|
||||
List<Object> 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<Integer, List<Object>>();
|
||||
fFilesToUpdate = urgentTask.fFilesToUpdate;
|
||||
fForceNumberFiles = urgentTask.fForceNumberFiles;
|
||||
fFilesToRemove = urgentTask.fFilesToRemove;
|
||||
extractFiles(files, indexFilesToRemove, monitor);
|
||||
removeFilesInIndex(fFilesToRemove, indexFilesToRemove, monitor);
|
||||
}
|
||||
}
|
||||
if (!monitor.isCanceled()) {
|
||||
setResume(false);
|
||||
|
@ -360,6 +417,36 @@ public abstract class AbstractIndexerTask extends PDOMWriter {
|
|||
} finally {
|
||||
fIndex.releaseReadLock();
|
||||
}
|
||||
} finally {
|
||||
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 {
|
||||
|
@ -371,7 +458,7 @@ public abstract class AbstractIndexerTask extends PDOMWriter {
|
|||
}
|
||||
}
|
||||
|
||||
private void extractFiles(Map<Integer, List<Object>> files, List<IIndexFragmentFile> iFilesToRemove,
|
||||
private void extractFiles(HashMap<Integer, List<Object>> files, List<IIndexFragmentFile> iFilesToRemove,
|
||||
IProgressMonitor monitor) throws CoreException {
|
||||
final boolean forceAll= (fUpdateFlags & IIndexManager.UPDATE_ALL) != 0;
|
||||
final boolean checkTimestamps= (fUpdateFlags & IIndexManager.UPDATE_CHECK_TIMESTAMPS) != 0;
|
||||
|
@ -444,9 +531,11 @@ public abstract class AbstractIndexerTask extends PDOMWriter {
|
|||
}
|
||||
}
|
||||
}
|
||||
synchronized (this) {
|
||||
updateRequestedFiles(count - fFilesToUpdate.length);
|
||||
fFilesToUpdate= null;
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isModified(boolean checkTimestamps, boolean checkFileContentsHash, IIndexFileLocation ifl,
|
||||
Object tu, IIndexFragmentFile file) throws CoreException {
|
||||
|
@ -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<Integer, List<Object>> files) {
|
||||
private void store(Object tu, int linkageID, boolean isSourceUnit, HashMap<Integer, List<Object>> files) {
|
||||
Integer key = getFileListKey(linkageID, isSourceUnit);
|
||||
List<Object> list= files.get(key);
|
||||
if (list == null) {
|
||||
|
@ -535,12 +625,12 @@ public abstract class AbstractIndexerTask extends PDOMWriter {
|
|||
return key;
|
||||
}
|
||||
|
||||
private void removeFilesInIndex(List<Object> filesToRemove, List<IIndexFragmentFile> ifilesToRemove,
|
||||
private void removeFilesInIndex(List<Object> filesToRemove, List<IIndexFragmentFile> 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,15 +720,16 @@ public abstract class AbstractIndexerTask extends PDOMWriter {
|
|||
|
||||
private void parseLinkage(int linkageID, Map<Integer, List<Object>> fileListMap, IProgressMonitor monitor)
|
||||
throws CoreException, InterruptedException {
|
||||
// sources
|
||||
// Sources
|
||||
List<Object> files= fileListMap.get(getFileListKey(linkageID, true));
|
||||
if (files != null) {
|
||||
for (Object tu : files) {
|
||||
if (monitor.isCanceled())
|
||||
for (Iterator<Object> iter = files.iterator(); iter.hasNext();) {
|
||||
Object tu = iter.next();
|
||||
if (monitor.isCanceled() || hasUrgentTasks())
|
||||
return;
|
||||
|
||||
final IIndexFileLocation ifl = fResolver.resolveFile(tu);
|
||||
if (ifl == null)
|
||||
continue;
|
||||
if (ifl != null) {
|
||||
final IndexFileContent info= getFileInfo(linkageID, ifl);
|
||||
if (info != null && info.fRequestUpdate && !info.fIsUpdated) {
|
||||
info.fRequestIsCounted= false;
|
||||
|
@ -649,16 +740,18 @@ public abstract class AbstractIndexerTask extends PDOMWriter {
|
|||
}
|
||||
}
|
||||
}
|
||||
files.clear();
|
||||
iter.remove();
|
||||
}
|
||||
}
|
||||
|
||||
// headers with context
|
||||
// Headers with context
|
||||
HashMap<IIndexFragmentFile, Object> contextMap= new HashMap<IIndexFragmentFile, Object>();
|
||||
files= fileListMap.get(getFileListKey(linkageID, false));
|
||||
if (files != null) {
|
||||
for (Iterator<Object> 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<Object> 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,11 +789,23 @@ 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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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();
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
|
@ -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
|
||||
|
@ -7,6 +7,7 @@
|
|||
*
|
||||
* Contributors:
|
||||
* 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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,7 +7,8 @@
|
|||
*
|
||||
* Contributors:
|
||||
* 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<ICElement> filesAndFolders) {
|
||||
fFilesAndFolders= new ArrayList<ICElement>(filesAndFolders.size());
|
||||
fFilesAndFolders.addAll(filesAndFolders);
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue