diff --git a/core/org.eclipse.cdt.core/index/ChangeLog b/core/org.eclipse.cdt.core/index/ChangeLog index ed5b01eb8e7..a1a25749c99 100644 --- a/core/org.eclipse.cdt.core/index/ChangeLog +++ b/core/org.eclipse.cdt.core/index/ChangeLog @@ -1,3 +1,7 @@ +2004-06-14 Andrew Niefer + - Bugs 66799, 66981 : don't process indexer jobs if the indexer for that project is disabled. + - also fix warnings about deprecated calls and unnecessary else statements + 2004-06-13 Bogdan Gheorghe Fix for Bug 63275 - Ensured that only declarations and references are found for enumerations/enumerators diff --git a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/search/indexing/IndexManager.java b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/search/indexing/IndexManager.java index f96f2a8bf16..c117fc53936 100644 --- a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/search/indexing/IndexManager.java +++ b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/search/indexing/IndexManager.java @@ -175,10 +175,11 @@ public class IndexManager extends JobManager implements IIndexConstants { } public void updateDependencies(IResource resource){ - if (CCorePlugin.getDefault() == null) return; - UpdateDependency job = new UpdateDependency(resource); - - request(job); + if (CCorePlugin.getDefault() == null || !isIndexEnabled( resource.getProject() ) ) + return; + + UpdateDependency job = new UpdateDependency(resource); + request(job); } String computeIndexName(IPath path) { @@ -233,9 +234,8 @@ public class IndexManager extends JobManager implements IIndexConstants { JobManager.verbose("-> cannot reuse existing index: "+indexName+" path: "+path.toOSString()); //$NON-NLS-1$ //$NON-NLS-2$ rebuildIndex(indexName, path); return null; - } else { - index = null; // will fall thru to createIfMissing & create a empty index for the rebuild all job to populate - } + } + index = null; // will fall thru to createIfMissing & create a empty index for the rebuild all job to populate } } if (currentIndexState == SAVED_STATE) { // rebuild index if existing file is missing @@ -388,7 +388,8 @@ public class IndexManager extends JobManager implements IIndexConstants { * Index the content of the given source folder. */ public void indexSourceFolder(IProject project, IPath sourceFolder, final char[][] exclusionPattern) { - + if( !isIndexEnabled( project ) ) + return; if (this.jobEnd > this.jobStart) { // check if a job to index the project is not already in the queue IndexRequest request = new IndexAllProject(project, this); @@ -445,7 +446,8 @@ public class IndexManager extends JobManager implements IIndexConstants { IndexRequest request = null; if (target instanceof IProject) { IProject p = (IProject) target; - request = new IndexAllProject(p, this); + if( p.exists() && isIndexEnabled( p ) ) + request = new IndexAllProject(p, this); } if (request != null) @@ -484,7 +486,9 @@ public class IndexManager extends JobManager implements IIndexConstants { * Note: the actual operation is performed in background */ public void remove(String resourceName, IPath indexedContainer){ - request(new RemoveFromIndex(resourceName, indexedContainer, this)); + IProject project = CCorePlugin.getWorkspace().getRoot().getProject(indexedContainer.toString()); + if( isIndexEnabled( project ) ) + request(new RemoveFromIndex(resourceName, indexedContainer, this)); } /** * Removes the index for a given path. @@ -525,9 +529,12 @@ public class IndexManager extends JobManager implements IIndexConstants { /** * Remove the content of the given source folder from the index. */ - public void removeSourceFolderFromIndex(CProject javaProject, IPath sourceFolder, char[][] exclusionPatterns) { - IProject project = javaProject.getProject(); + public void removeSourceFolderFromIndex(CProject cProject, IPath sourceFolder, char[][] exclusionPatterns) { + IProject project = cProject.getProject(); + if( !isIndexEnabled( project ) ) + return; + if (this.jobEnd > this.jobStart) { // check if a job to index the project is not already in the queue IndexRequest request = new IndexAllProject(project, this); @@ -745,7 +752,7 @@ public class IndexManager extends JobManager implements IIndexConstants { } private Boolean loadIndexerEnabledFromCDescriptor(IProject project) throws CoreException { - ICDescriptor descriptor = CCorePlugin.getDefault().getCProjectDescription(project); + ICDescriptor descriptor = CCorePlugin.getDefault().getCProjectDescription(project, true ); Node child = descriptor.getProjectData(CDT_INDEXER).getFirstChild(); Boolean strBool = null; @@ -761,7 +768,7 @@ public class IndexManager extends JobManager implements IIndexConstants { return strBool; } private Boolean loadIndexerProblemsEnabledFromCDescriptor(IProject project) throws CoreException { - ICDescriptor descriptor = CCorePlugin.getDefault().getCProjectDescription(project); + ICDescriptor descriptor = CCorePlugin.getDefault().getCProjectDescription(project, true); Node child = descriptor.getProjectData(CDT_INDEXER).getFirstChild(); Boolean strBool = null; @@ -790,7 +797,7 @@ public class IndexManager extends JobManager implements IIndexConstants { return Status.OK_STATUS; } - }; + } public void removeAllIndexerProblems( IProject project){ String jobName = "remove markers"; //$NON-NLS-1$ diff --git a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/search/indexing/IndexRequest.java b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/search/indexing/IndexRequest.java index 96aab0b526c..8a5197b5adc 100644 --- a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/search/indexing/IndexRequest.java +++ b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/search/indexing/IndexRequest.java @@ -13,9 +13,11 @@ package org.eclipse.cdt.internal.core.search.indexing; import java.io.IOException; -import org.eclipse.cdt.internal.core.search.processing.IJob; -import org.eclipse.core.runtime.IPath; +import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.internal.core.index.IIndex; +import org.eclipse.cdt.internal.core.search.processing.IJob; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.runtime.IPath; public abstract class IndexRequest implements IJob { protected boolean isCancelled = false; @@ -37,6 +39,10 @@ public abstract class IndexRequest implements IJob { } public boolean isReadyToRun() { + IProject project = CCorePlugin.getWorkspace().getRoot().getProject(indexPath.segment(0)); + if ( !this.manager.isIndexEnabled( project ) ) + return false; + // tag the index as inconsistent this.manager.aboutToUpdateIndex(indexPath, updatedIndexState()); return true; diff --git a/core/org.eclipse.cdt.core/search/org/eclipse/cdt/internal/core/search/processing/JobManager.java b/core/org.eclipse.cdt.core/search/org/eclipse/cdt/internal/core/search/processing/JobManager.java index 2bf6071588f..b57e25ca61f 100644 --- a/core/org.eclipse.cdt.core/search/org/eclipse/cdt/internal/core/search/processing/JobManager.java +++ b/core/org.eclipse.cdt.core/search/org/eclipse/cdt/internal/core/search/processing/JobManager.java @@ -112,7 +112,7 @@ public abstract class JobManager implements Runnable { if (VERBOSE) JobManager.verbose("DISCARD background job family - " + jobFamily); //$NON-NLS-1$ - boolean wasEnabled = ( enabledState() == ENABLED ); + int oldEnabledState = enabledState(); try { IJob currentJob; // cancel current job if it belongs to the given family @@ -161,8 +161,10 @@ public abstract class JobManager implements Runnable { jobEnd = loc; } } finally { - if ( wasEnabled ) + if ( oldEnabledState == ENABLED ) enable(); + else if( oldEnabledState == WAITING ) + pause(); } if (VERBOSE) JobManager.verbose("DISCARD DONE with background job family - " + jobFamily); //$NON-NLS-1$ @@ -452,9 +454,9 @@ public abstract class JobManager implements Runnable { notifyIdle(System.currentTimeMillis() - idlingStart); Thread.sleep(500); continue; - } else { - idlingStart = -1; - } + } + + idlingStart = -1; if (VERBOSE) { JobManager.verbose(awaitingJobsCount() + " awaiting jobs"); //$NON-NLS-1$ JobManager.verbose("STARTING background job - " + job); //$NON-NLS-1$ diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/IndexerOptionDialogPage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/IndexerOptionDialogPage.java index 410507bfb84..efac97fdc8e 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/IndexerOptionDialogPage.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/IndexerOptionDialogPage.java @@ -102,7 +102,7 @@ public class IndexerOptionDialogPage extends DialogPage { try { newProject = project; - descriptor = CCorePlugin.getDefault().getCProjectDescription(newProject); + descriptor = CCorePlugin.getDefault().getCProjectDescription(newProject, true); rootElement = descriptor.getProjectData(IndexManager.CDT_INDEXER); diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/IndexerOptionPropertyPage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/IndexerOptionPropertyPage.java index ff232ab8820..676f4f8608d 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/IndexerOptionPropertyPage.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/IndexerOptionPropertyPage.java @@ -89,6 +89,8 @@ public class IndexerOptionPropertyPage extends PropertyPage { //if indexer is now on send a index all request if( (indexChanged && newIndexerValue) || (problemsChanged && newIndexerProblemsValue && newIndexerValue) ) CCorePlugin.getDefault().getCoreModel().getIndexManager().indexAll(tempProject); + else if( indexChanged && !newIndexerValue ) + CCorePlugin.getDefault().getCoreModel().getIndexManager().discardJobs( tempProject.getName() ); else if( problemsChanged && !newIndexerProblemsValue ){ CCorePlugin.getDefault().getCoreModel().getIndexManager().removeAllIndexerProblems(tempProject); } @@ -161,7 +163,7 @@ public class IndexerOptionPropertyPage extends PropertyPage { * @throws CoreException */ private Boolean loadIndexerEnabledFromCDescriptor(IProject project) throws CoreException { - ICDescriptor descriptor = CCorePlugin.getDefault().getCProjectDescription(project); + ICDescriptor descriptor = CCorePlugin.getDefault().getCProjectDescription(project, true); Node child = descriptor.getProjectData(IndexManager.CDT_INDEXER).getFirstChild(); Boolean strBool = null; @@ -179,7 +181,7 @@ public class IndexerOptionPropertyPage extends PropertyPage { private Boolean loadIndexerProblemsEnabledFromCDescriptor( IProject project ) throws CoreException { - ICDescriptor descriptor = CCorePlugin.getDefault().getCProjectDescription(project); + ICDescriptor descriptor = CCorePlugin.getDefault().getCProjectDescription(project, true); Node child = descriptor.getProjectData(IndexManager.CDT_INDEXER).getFirstChild(); Boolean strBool = null;