mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-07 17:56:01 +02:00
bugs 66981, 66799 - don't do indexer requests if the indexer is turned off
for that project. Also, when turning off the indexer, discard the queued up jobs for that project.
This commit is contained in:
parent
d0de77fc60
commit
7f8eb9fbd2
6 changed files with 46 additions and 25 deletions
|
@ -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
|
||||
|
||||
|
|
|
@ -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$
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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$
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Add table
Reference in a new issue