1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

Fix for 94988: BaseTestFramework disableIndex() doesn't work

This commit is contained in:
Bogdan Gheorghe 2005-05-12 17:27:54 +00:00
parent 2d27b6de65
commit ee60cb456e
3 changed files with 35 additions and 35 deletions

View file

@ -20,16 +20,18 @@ import java.io.InputStream;
import junit.framework.TestCase;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.ICDescriptor;
import org.eclipse.cdt.core.ICDescriptorOperation;
import org.eclipse.cdt.core.model.ICProject;
import org.eclipse.cdt.core.testplugin.CProjectHelper;
import org.eclipse.cdt.core.testplugin.FileManager;
import org.eclipse.cdt.internal.core.index.sourceindexer.SourceIndexer;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.NullProgressMonitor;
/**
@ -41,8 +43,7 @@ abstract public class BaseTestFramework extends TestCase {
static protected IProject project;
static protected ICProject cproject;
static protected FileManager fileManager;
static final String sourceIndexerID = "org.eclipse.cdt.core.originalsourceindexer"; //$NON-NLS-1$
static protected SourceIndexer sourceIndexer;
static protected boolean indexDisabled=false;
{
if( CCorePlugin.getDefault() != null && CCorePlugin.getDefault().getCoreModel() != null){
//(CCorePlugin.getDefault().getCoreModel().getIndexManager()).reset();
@ -73,23 +74,20 @@ abstract public class BaseTestFramework extends TestCase {
}
}
public void enableIndexing(){
if( CCorePlugin.getDefault() != null && CCorePlugin.getDefault().getCoreModel() != null){
if( project != null )
try {
project.setSessionProperty( SourceIndexer.activationKey, Boolean.TRUE );
} catch ( CoreException e ) { //boo
}
}
}
public void disableIndexing(){
if( CCorePlugin.getDefault() != null && CCorePlugin.getDefault().getCoreModel() != null){
if( project != null )
try {
project.setSessionProperty( SourceIndexer.activationKey, Boolean.FALSE );
} catch ( CoreException e ) { //boo
if ( project != null) {
ICDescriptorOperation op = new ICDescriptorOperation() {
public void execute(ICDescriptor descriptor, IProgressMonitor monitor) throws CoreException {
descriptor.remove(CCorePlugin.INDEXER_UNIQ_ID);
descriptor.create(CCorePlugin.INDEXER_UNIQ_ID,CCorePlugin.NULL_INDEXER_UNIQUE_ID);
}
};
try {
CCorePlugin.getDefault().getCDescriptorManager().runDescriptorOperation(project, op, new NullProgressMonitor());
CCorePlugin.getDefault().getCoreModel().getIndexManager().indexerChangeNotification(project);
indexDisabled=true;
} catch (CoreException e) {}
}
}

View file

@ -23,6 +23,7 @@ import junit.framework.Test;
import junit.framework.TestSuite;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.index.ICDTIndexer;
import org.eclipse.cdt.core.index.IIndexChangeListener;
import org.eclipse.cdt.core.index.IIndexDelta;
import org.eclipse.cdt.core.index.IndexChangeEvent;
@ -69,23 +70,26 @@ public class SearchRegressionTests extends BaseTestFramework implements ICSearch
protected void setUp() throws Exception {
super.setUp();
try{
if (project == null){
cproject = CProjectHelper.createCCProject("RegressionTestProject", "bin"); //$NON-NLS-1$ //$NON-NLS-2$
project = cproject.getProject();
}
project.setSessionProperty(IndexManager.indexerIDKey, sourceIndexerID);
project.setSessionProperty( SourceIndexer.activationKey, new Boolean( true ) );
} catch ( CoreException e ) { //boo
}
TypeCacheManager typeCacheManager = TypeCacheManager.getInstance();
typeCacheManager.setProcessTypeCacheEvents(false);
IndexManager indexManager = CCorePlugin.getDefault().getCoreModel().getIndexManager();
//indexManager.reset();
indexDisabled=false;
ICDTIndexer indexer = CCorePlugin.getDefault().getCoreModel().getIndexManager().getIndexerForProject(project);
if (indexer instanceof SourceIndexer){
((SourceIndexer)indexer).addIndexChangeListener( this );
}
sourceIndexer = (SourceIndexer) CCorePlugin.getDefault().getCoreModel().getIndexManager().getIndexerForProject(project);
sourceIndexer.addIndexChangeListener( this );
}
protected void tearDown() throws Exception {
@ -93,7 +97,7 @@ public class SearchRegressionTests extends BaseTestFramework implements ICSearch
return;
IndexManager indexManager = CCorePlugin.getDefault().getCoreModel().getIndexManager();
sourceIndexer.removeIndexChangeListener( this );
//sourceIndexer.removeIndexChangeListener( this );
try{
project.setSessionProperty( SourceIndexer.activationKey, new Boolean( false ) );
project.delete(true,true,new NullProgressMonitor());
@ -136,10 +140,11 @@ public class SearchRegressionTests extends BaseTestFramework implements ICSearch
indexChanged = false;
IFile file = super.importFile( fileName, contents );
if (!indexDisabled){
while( !indexChanged ){
Thread.sleep( 100 );
}
}
return file;
}

View file

@ -34,7 +34,6 @@ import org.eclipse.cdt.core.parser.tests.CompleteParseBaseTest.FullParseCallback
import org.eclipse.cdt.core.testplugin.CProjectHelper;
import org.eclipse.cdt.internal.core.browser.cache.TypeCacheManager;
import org.eclipse.cdt.internal.core.index.sourceindexer.SourceIndexer;
import org.eclipse.cdt.internal.core.search.indexing.IndexManager;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.NullProgressMonitor;
@ -102,8 +101,6 @@ public class SelectionRegressionTest extends BaseTestFramework {
cproject = CProjectHelper.createCCProject("RegressionTestProject", "bin"); //$NON-NLS-1$ //$NON-NLS-2$
project = cproject.getProject();
}
project.setSessionProperty(IndexManager.indexerIDKey, sourceIndexerID);
project.setSessionProperty( SourceIndexer.activationKey, new Boolean( true ) );
} catch ( CoreException e ) { //boo
}
TypeCacheManager typeCacheManager = TypeCacheManager.getInstance();