1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-01 21:35: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)
return;
currentIndexer.indexerRemoved(project);
IIndexStorage storage = currentIndexer.getIndexStorage(); // //Get rid of the old index file
if (storage instanceof CIndexStorage) // ICDTIndexer currentIndexer = getIndexerForProject(project);
((CIndexStorage) storage).removeIndex(project.getFullPath()); // if (currentIndexer == null)
// return;
monitor.enterWrite(); // currentIndexer.indexerRemoved(project);
try{ //
//Purge the old indexer from the indexer map // IIndexStorage storage = currentIndexer.getIndexStorage();
indexerMap.remove(project); // if (storage instanceof CIndexStorage)
} finally { // ((CIndexStorage) storage).removeIndex(project.getFullPath());
monitor.exitWrite(); //
final ICDTIndexer indexer = this.getIndexerForProject(project); // monitor.enterWrite();
final IProject finalProject = project; // try{
// //Purge the old indexer from the indexer map
//Notify new indexer in a job of change // indexerMap.remove(project);
Job job = new Job("Index Change Notification"){ //$NON-NLS-1$ // } finally {
protected IStatus run(IProgressMonitor monitor) { // monitor.exitWrite();
Platform.run(new ISafeRunnable() { // final ICDTIndexer indexer = this.getIndexerForProject(project);
public void handleException(Throwable exception) { // final IProject finalProject = project;
CCorePlugin.log(exception); //
} // //Notify new indexer in a job of change
public void run() throws Exception { // Job job = new Job("Index Change Notification"){ //$NON-NLS-1$
indexer.notifyIndexerChange(finalProject); // protected IStatus run(IProgressMonitor monitor) {
} // Platform.run(new ISafeRunnable() {
}); // public void handleException(Throwable exception) {
// CCorePlugin.log(exception);
return Status.OK_STATUS; // }
} // public void run() throws Exception {
}; // indexer.notifyIndexerChange(finalProject);
// }
job.schedule(); // });
//
if( listeners != null ) // return Status.OK_STATUS;
for( int i = 0; i < listeners.length; ++i ) // }
if( listeners[i] != null ) // };
listeners[i].indexerSelectionChanged(project); //
} // job.schedule();
//
// if( listeners != null )
// 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{