1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-31 12:55:40 +02:00

Help address NPEs in tests.

This commit is contained in:
Doug Schaefer 2006-04-10 14:00:09 +00:00
parent 44ed1e1b35
commit 4bb4cc51dc

View file

@ -33,6 +33,7 @@ import org.eclipse.cdt.core.parser.util.ArrayUtil;
import org.eclipse.cdt.internal.core.index.IndexRequest; import org.eclipse.cdt.internal.core.index.IndexRequest;
import org.eclipse.cdt.internal.core.index.cindexstorage.CIndexStorage; import org.eclipse.cdt.internal.core.index.cindexstorage.CIndexStorage;
import org.eclipse.cdt.internal.core.index.domsourceindexer.DOMSourceIndexer; import org.eclipse.cdt.internal.core.index.domsourceindexer.DOMSourceIndexer;
import org.eclipse.cdt.internal.core.index.nullindexer.NullIndexer;
import org.eclipse.cdt.internal.core.search.processing.IIndexJob; import org.eclipse.cdt.internal.core.search.processing.IIndexJob;
import org.eclipse.cdt.internal.core.search.processing.JobManager; import org.eclipse.cdt.internal.core.search.processing.JobManager;
import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IFile;
@ -46,7 +47,6 @@ import org.eclipse.core.runtime.IExtension;
import org.eclipse.core.runtime.IExtensionPoint; import org.eclipse.core.runtime.IExtensionPoint;
import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.ISafeRunnable;
import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Platform; import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.QualifiedName; import org.eclipse.core.runtime.QualifiedName;
@ -378,7 +378,7 @@ public class IndexManager extends JobManager{
} }
public ICDTIndexer getIndexerForProject(IProject project){ public ICDTIndexer getIndexerForProject(IProject project){
return null; return new NullIndexer();
// ICDTIndexer indexer = null; // ICDTIndexer indexer = null;
// try { // try {
// //Make sure we're not updating list // //Make sure we're not updating list
@ -484,48 +484,50 @@ public class IndexManager extends JobManager{
//Get rid of any jobs scheduled by the old indexer //Get rid of any jobs scheduled by the old indexer
this.discardJobs(project.getName()); this.discardJobs(project.getName());
//Get rid of the old index file return;
ICDTIndexer currentIndexer = getIndexerForProject(project);
if (currentIndexer == null) // //Get rid of the old index file
return; // ICDTIndexer currentIndexer = getIndexerForProject(project);
currentIndexer.indexerRemoved(project); // if (currentIndexer == null)
// return;
IIndexStorage storage = currentIndexer.getIndexStorage(); // currentIndexer.indexerRemoved(project);
if (storage instanceof CIndexStorage) //
((CIndexStorage) storage).removeIndex(project.getFullPath()); // IIndexStorage storage = currentIndexer.getIndexStorage();
// if (storage instanceof CIndexStorage)
monitor.enterWrite(); // ((CIndexStorage) storage).removeIndex(project.getFullPath());
try{ //
//Purge the old indexer from the indexer map // monitor.enterWrite();
indexerMap.remove(project); // try{
} finally { // //Purge the old indexer from the indexer map
monitor.exitWrite(); // indexerMap.remove(project);
final ICDTIndexer indexer = this.getIndexerForProject(project); // } finally {
final IProject finalProject = project; // monitor.exitWrite();
// final ICDTIndexer indexer = this.getIndexerForProject(project);
//Notify new indexer in a job of change // final IProject finalProject = project;
Job job = new Job("Index Change Notification"){ //$NON-NLS-1$ //
protected IStatus run(IProgressMonitor monitor) { // //Notify new indexer in a job of change
Platform.run(new ISafeRunnable() { // Job job = new Job("Index Change Notification"){ //$NON-NLS-1$
public void handleException(Throwable exception) { // protected IStatus run(IProgressMonitor monitor) {
CCorePlugin.log(exception); // Platform.run(new ISafeRunnable() {
} // public void handleException(Throwable exception) {
public void run() throws Exception { // CCorePlugin.log(exception);
indexer.notifyIndexerChange(finalProject); // }
} // public void run() throws Exception {
}); // indexer.notifyIndexerChange(finalProject);
// }
return Status.OK_STATUS; // });
} //
}; // return Status.OK_STATUS;
// }
job.schedule(); // };
//
if( listeners != null ) // job.schedule();
for( int i = 0; i < listeners.length; ++i ) //
if( listeners[i] != null ) // if( listeners != null )
listeners[i].indexerSelectionChanged(project); // for( int i = 0; i < listeners.length; ++i )
} // if( listeners[i] != null )
// listeners[i].indexerSelectionChanged(project);
// }
} }
static private class RemoveIndexMarkersJob extends Job{ static private class RemoveIndexMarkersJob extends Job{