mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
IIndexManager manager operations can block too long, bug 220149.
This commit is contained in:
parent
71c9367551
commit
aa7ed7ba19
3 changed files with 28 additions and 28 deletions
|
@ -8,7 +8,6 @@
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Markus Schorn - initial API and implementation
|
* Markus Schorn - initial API and implementation
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
package org.eclipse.cdt.internal.core.pdom.indexer;
|
package org.eclipse.cdt.internal.core.pdom.indexer;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -101,19 +100,22 @@ public class PDOMRebuildTask implements IPDOMIndexerTask {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private synchronized void createDelegate(ICProject project, IProgressMonitor monitor) throws CoreException {
|
private void createDelegate(ICProject project, IProgressMonitor monitor) throws CoreException {
|
||||||
boolean allFiles= TRUE.equals(fIndexer.getProperty(IndexerPreferences.KEY_INDEX_ALL_FILES));
|
boolean allFiles= TRUE.equals(fIndexer.getProperty(IndexerPreferences.KEY_INDEX_ALL_FILES));
|
||||||
List<ITranslationUnit> sources= new ArrayList<ITranslationUnit>();
|
List<ITranslationUnit> sources= new ArrayList<ITranslationUnit>();
|
||||||
List<ITranslationUnit> headers= allFiles ? sources : null;
|
List<ITranslationUnit> headers= allFiles ? sources : null;
|
||||||
TranslationUnitCollector collector= new TranslationUnitCollector(sources, headers, monitor);
|
TranslationUnitCollector collector= new TranslationUnitCollector(sources, headers, monitor);
|
||||||
project.accept(collector);
|
project.accept(collector);
|
||||||
ITranslationUnit[] tus= sources.toArray(new ITranslationUnit[sources.size()]);
|
ITranslationUnit[] tus= sources.toArray(new ITranslationUnit[sources.size()]);
|
||||||
fDelegate= fIndexer.createTask(tus, NO_TUS, NO_TUS);
|
IPDOMIndexerTask delegate= fIndexer.createTask(tus, NO_TUS, NO_TUS);
|
||||||
if (fDelegate instanceof PDOMIndexerTask) {
|
if (delegate instanceof PDOMIndexerTask) {
|
||||||
final PDOMIndexerTask delegate = (PDOMIndexerTask) fDelegate;
|
final PDOMIndexerTask pdomIndexerTask = (PDOMIndexerTask) delegate;
|
||||||
delegate.setUpdateFlags(IIndexManager.UPDATE_ALL);
|
pdomIndexerTask.setUpdateFlags(IIndexManager.UPDATE_ALL);
|
||||||
delegate.setParseUpFront();
|
pdomIndexerTask.setParseUpFront();
|
||||||
delegate.setWriteInfoToLog();
|
pdomIndexerTask.setWriteInfoToLog();
|
||||||
|
}
|
||||||
|
synchronized (this) {
|
||||||
|
fDelegate= delegate;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2007 Wind River Systems, Inc. and others.
|
* Copyright (c) 2007, 2008 Wind River Systems, Inc. and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -8,12 +8,10 @@
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Markus Schorn - initial API and implementation
|
* Markus Schorn - initial API and implementation
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
package org.eclipse.cdt.internal.core.pdom.indexer;
|
package org.eclipse.cdt.internal.core.pdom.indexer;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.CCorePlugin;
|
import org.eclipse.cdt.core.CCorePlugin;
|
||||||
|
@ -39,7 +37,7 @@ public class PDOMUpdateTask implements IPDOMIndexerTask {
|
||||||
private final IndexerProgress fProgress;
|
private final IndexerProgress fProgress;
|
||||||
private final int fUpdateOptions;
|
private final int fUpdateOptions;
|
||||||
private volatile IPDOMIndexerTask fDelegate;
|
private volatile IPDOMIndexerTask fDelegate;
|
||||||
private ArrayList fFilesAndFolders= null;
|
private ArrayList<ICElement> fFilesAndFolders= null;
|
||||||
|
|
||||||
public PDOMUpdateTask(IPDOMIndexer indexer, int updateOptions) {
|
public PDOMUpdateTask(IPDOMIndexer indexer, int updateOptions) {
|
||||||
fIndexer= indexer;
|
fIndexer= indexer;
|
||||||
|
@ -77,33 +75,34 @@ public class PDOMUpdateTask implements IPDOMIndexerTask {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private synchronized void createDelegate(ICProject project, IProgressMonitor monitor) throws CoreException {
|
private void createDelegate(ICProject project, IProgressMonitor monitor) throws CoreException {
|
||||||
HashSet set= new HashSet();
|
HashSet<ITranslationUnit> set= new HashSet<ITranslationUnit>();
|
||||||
TranslationUnitCollector collector= new TranslationUnitCollector(set, set, monitor);
|
TranslationUnitCollector collector= new TranslationUnitCollector(set, set, monitor);
|
||||||
if (fFilesAndFolders == null) {
|
if (fFilesAndFolders == null) {
|
||||||
project.accept(collector);
|
project.accept(collector);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
for (Iterator iterator = fFilesAndFolders.iterator(); iterator.hasNext();) {
|
for (ICElement elem : fFilesAndFolders) {
|
||||||
ICElement elem = (ICElement) iterator.next();
|
|
||||||
elem.accept(collector);
|
elem.accept(collector);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ITranslationUnit[] tus= (ITranslationUnit[]) set.toArray(new ITranslationUnit[set.size()]);
|
ITranslationUnit[] tus= set.toArray(new ITranslationUnit[set.size()]);
|
||||||
fDelegate= fIndexer.createTask(tus, NO_TUS, NO_TUS);
|
IPDOMIndexerTask delegate= fIndexer.createTask(tus, NO_TUS, NO_TUS);
|
||||||
if (fDelegate instanceof PDOMIndexerTask) {
|
if (delegate instanceof PDOMIndexerTask) {
|
||||||
final PDOMIndexerTask task = (PDOMIndexerTask) fDelegate;
|
final PDOMIndexerTask task = (PDOMIndexerTask) delegate;
|
||||||
task.setUpdateFlags(fUpdateOptions);
|
task.setUpdateFlags(fUpdateOptions);
|
||||||
}
|
}
|
||||||
|
synchronized (this) {
|
||||||
|
fDelegate= delegate;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public synchronized IndexerProgress getProgressInformation() {
|
public synchronized IndexerProgress getProgressInformation() {
|
||||||
return fDelegate != null ? fDelegate.getProgressInformation() : fProgress;
|
return fDelegate != null ? fDelegate.getProgressInformation() : fProgress;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTranslationUnitSelection(List filesAndFolders) {
|
public void setTranslationUnitSelection(List<ICElement> filesAndFolders) {
|
||||||
fFilesAndFolders= new ArrayList(filesAndFolders.size());
|
fFilesAndFolders= new ArrayList<ICElement>(filesAndFolders.size());
|
||||||
fFilesAndFolders.addAll(filesAndFolders);
|
fFilesAndFolders.addAll(filesAndFolders);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2007 Wind River Systems, Inc. and others.
|
* Copyright (c) 2007, 2008 Wind River Systems, Inc. and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -8,7 +8,6 @@
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Markus Schorn - initial API and implementation
|
* Markus Schorn - initial API and implementation
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
package org.eclipse.cdt.internal.core.pdom.indexer;
|
package org.eclipse.cdt.internal.core.pdom.indexer;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
@ -20,11 +19,11 @@ import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.core.runtime.IProgressMonitor;
|
import org.eclipse.core.runtime.IProgressMonitor;
|
||||||
|
|
||||||
final class TranslationUnitCollector implements ICElementVisitor {
|
final class TranslationUnitCollector implements ICElementVisitor {
|
||||||
private final Collection fSources;
|
private final Collection<ITranslationUnit> fSources;
|
||||||
private final Collection fHeaders;
|
private final Collection<ITranslationUnit> fHeaders;
|
||||||
private final IProgressMonitor fProgressMonitor;
|
private final IProgressMonitor fProgressMonitor;
|
||||||
|
|
||||||
public TranslationUnitCollector(Collection sources, Collection headers, IProgressMonitor pm) {
|
public TranslationUnitCollector(Collection<ITranslationUnit> sources, Collection<ITranslationUnit> headers, IProgressMonitor pm) {
|
||||||
fSources= sources;
|
fSources= sources;
|
||||||
fHeaders= headers;
|
fHeaders= headers;
|
||||||
fProgressMonitor= pm;
|
fProgressMonitor= pm;
|
||||||
|
|
Loading…
Add table
Reference in a new issue