mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-06 17:26:01 +02:00
Patch for Bogda Gheorghe: (44366 & 45324)
- Moved off all dependency calculations to the Indexer thread, created a new UpdateDependency job - Modified CSearchOperation to only lock the workspace when tagging resources with markers.
This commit is contained in:
parent
5df215664c
commit
92669e0062
21 changed files with 1121 additions and 894 deletions
|
@ -1,3 +1,6 @@
|
|||
2003-10-23 Bogdan Gheorghe
|
||||
Updated the indexManager.perfomConcurrentJob call in MakefileGenerator
|
||||
|
||||
2003-10-03 Sean Evoy
|
||||
Fix for critical bug 44134.
|
||||
|
||||
|
|
|
@ -161,7 +161,7 @@ public class MakefileGenerator {
|
|||
pathCollector,
|
||||
indexManager),
|
||||
ICSearchConstants.WAIT_UNTIL_READY_TO_SEARCH,
|
||||
null);
|
||||
null, null);
|
||||
|
||||
// We will get back an array of resource names relative to the workspace
|
||||
String[] deps = pathCollector.getPaths();
|
||||
|
@ -341,7 +341,7 @@ public class MakefileGenerator {
|
|||
// ASk the dep generator to find all the deps for this resource
|
||||
ArrayList dependencies = new ArrayList();
|
||||
try {
|
||||
indexManager.performConcurrentJob(new DependencyQueryJob(project, (IFile)resource, indexManager, dependencies), ICSearchConstants.WAIT_UNTIL_READY_TO_SEARCH, null);
|
||||
indexManager.performConcurrentJob(new DependencyQueryJob(project, (IFile)resource, indexManager, dependencies), ICSearchConstants.WAIT_UNTIL_READY_TO_SEARCH, null, null);
|
||||
} catch (Exception e) {
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -15,7 +15,6 @@ import java.util.Arrays;
|
|||
import java.util.Iterator;
|
||||
import java.util.Set;
|
||||
|
||||
import junit.extensions.TestDecorator;
|
||||
import junit.framework.Test;
|
||||
import junit.framework.TestCase;
|
||||
import junit.framework.TestSuite;
|
||||
|
@ -143,7 +142,7 @@ import org.eclipse.core.runtime.Platform;
|
|||
String[] depTest2Model = {File.separator + "DepTestProject" + File.separator + "d.h", File.separator + "DepTestProject" + File.separator + "DepTest2.h"};
|
||||
|
||||
ArrayList includes = new ArrayList();
|
||||
indexManager.performConcurrentJob(new DependencyQueryJob(testProject,depTest,indexManager,includes),ICSearchConstants.WAIT_UNTIL_READY_TO_SEARCH,null);
|
||||
indexManager.performConcurrentJob(new DependencyQueryJob(testProject,depTest,indexManager,includes),ICSearchConstants.WAIT_UNTIL_READY_TO_SEARCH,null,null);
|
||||
|
||||
String[] depTestModelLocal = convertToLocalPath(depTestModel);
|
||||
String[] depTestIncludes = new String[includes.size()];
|
||||
|
@ -166,7 +165,7 @@ import org.eclipse.core.runtime.Platform;
|
|||
}
|
||||
|
||||
ArrayList includes2 = new ArrayList();
|
||||
indexManager.performConcurrentJob(new DependencyQueryJob(testProject,depTest2,indexManager,includes2),ICSearchConstants.WAIT_UNTIL_READY_TO_SEARCH,null);
|
||||
indexManager.performConcurrentJob(new DependencyQueryJob(testProject,depTest2,indexManager,includes2),ICSearchConstants.WAIT_UNTIL_READY_TO_SEARCH,null,null);
|
||||
|
||||
String[] depTest2ModelLocal = convertToLocalPath(depTest2Model);
|
||||
String[] depTest2Includes = new String[includes2.size()];
|
||||
|
@ -345,7 +344,7 @@ import org.eclipse.core.runtime.Platform;
|
|||
String[] preDepTestModel = {File.separator + "DepTestProject" + File.separator + "DepTest.h", File.separator + "DepTestProject" + File.separator + "Inc1.h", File.separator + "DepTestProject" + File.separator + "a.h", File.separator + "DepTestProject" + File.separator + "c.h", File.separator + "DepTestProject" + File.separator + "d.h"};
|
||||
|
||||
ArrayList includes = new ArrayList();
|
||||
indexManager.performConcurrentJob(new DependencyQueryJob(testProject,depTestC,indexManager,includes),ICSearchConstants.WAIT_UNTIL_READY_TO_SEARCH,null);
|
||||
indexManager.performConcurrentJob(new DependencyQueryJob(testProject,depTestC,indexManager,includes),ICSearchConstants.WAIT_UNTIL_READY_TO_SEARCH,null, null);
|
||||
|
||||
String[] preDepTestModelLocal = convertToLocalPath(preDepTestModel);
|
||||
String[] preDepTestIncludes = new String[includes.size()];
|
||||
|
@ -374,7 +373,7 @@ import org.eclipse.core.runtime.Platform;
|
|||
|
||||
testProject.refreshLocal(IResource.DEPTH_INFINITE,null);
|
||||
|
||||
indexManager.performConcurrentJob(new DependencyQueryJob(testProject,depTestC,indexManager,includes2),ICSearchConstants.WAIT_UNTIL_READY_TO_SEARCH,null);
|
||||
indexManager.performConcurrentJob(new DependencyQueryJob(testProject,depTestC,indexManager,includes2),ICSearchConstants.WAIT_UNTIL_READY_TO_SEARCH,null, null);
|
||||
|
||||
|
||||
String[] postDepTestModelLocal = convertToLocalPath(postDepTestModel);
|
||||
|
@ -412,7 +411,7 @@ import org.eclipse.core.runtime.Platform;
|
|||
String[] preDepTestModel = {File.separator + "DepTestProject" + File.separator + "DepTest3.h", File.separator + "DepTestProject" + File.separator + "a.h", File.separator + "DepTestProject" + File.separator + "c.h"};
|
||||
|
||||
ArrayList includes = new ArrayList();
|
||||
indexManager.performConcurrentJob(new DependencyQueryJob(testProject,depTest3C,indexManager,includes),ICSearchConstants.WAIT_UNTIL_READY_TO_SEARCH,null);
|
||||
indexManager.performConcurrentJob(new DependencyQueryJob(testProject,depTest3C,indexManager,includes),ICSearchConstants.WAIT_UNTIL_READY_TO_SEARCH,null, null);
|
||||
|
||||
String[] preDepTestModelLocal = convertToLocalPath(preDepTestModel);
|
||||
String[] preDepTestIncludes = new String[includes.size()];
|
||||
|
@ -441,7 +440,7 @@ import org.eclipse.core.runtime.Platform;
|
|||
|
||||
testProject.refreshLocal(IResource.DEPTH_INFINITE,null);
|
||||
|
||||
indexManager.performConcurrentJob(new DependencyQueryJob(testProject,depTest3C,indexManager,includes2),ICSearchConstants.WAIT_UNTIL_READY_TO_SEARCH,null);
|
||||
indexManager.performConcurrentJob(new DependencyQueryJob(testProject,depTest3C,indexManager,includes2),ICSearchConstants.WAIT_UNTIL_READY_TO_SEARCH,null, null);
|
||||
|
||||
|
||||
String[] postDepTestModelLocal = convertToLocalPath(postDepTestModel);
|
||||
|
@ -583,7 +582,7 @@ import org.eclipse.core.runtime.Platform;
|
|||
indexManager
|
||||
),
|
||||
ICSearchConstants.WAIT_UNTIL_READY_TO_SEARCH,
|
||||
null );
|
||||
null, null );
|
||||
}
|
||||
|
||||
private void editCode(IFile tempFile, String beforeString, String afterString) throws IOException, CoreException, InterruptedException{
|
||||
|
|
|
@ -124,5 +124,7 @@ public class WorkingCopyTests extends TestCase {
|
|||
// DestroyWorkingCopy
|
||||
wc.destroy();
|
||||
assertFalse(wc.exists());
|
||||
|
||||
Thread.sleep(1000);
|
||||
}
|
||||
}
|
|
@ -24,7 +24,6 @@ import org.eclipse.cdt.core.search.ICSearchPattern;
|
|||
import org.eclipse.cdt.core.search.ICSearchResultCollector;
|
||||
import org.eclipse.cdt.core.search.ICSearchScope;
|
||||
import org.eclipse.cdt.core.search.SearchEngine;
|
||||
import org.eclipse.cdt.internal.core.search.indexing.IndexManager;
|
||||
import org.eclipse.cdt.internal.ui.search.CSearchResultCollector;
|
||||
import org.eclipse.cdt.testplugin.FileManager;
|
||||
import org.eclipse.core.internal.resources.ResourceException;
|
||||
|
|
|
@ -13,19 +13,23 @@
|
|||
*/
|
||||
package org.eclipse.cdt.core.search.tests;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.search.BasicSearchMatch;
|
||||
import org.eclipse.cdt.core.search.ICSearchPattern;
|
||||
import org.eclipse.cdt.core.search.IMatch;
|
||||
import org.eclipse.cdt.core.search.SearchEngine;
|
||||
import org.eclipse.cdt.internal.core.CharOperation;
|
||||
import org.eclipse.cdt.internal.core.search.AcceptMatchOperation;
|
||||
import org.eclipse.cdt.internal.core.search.matching.FieldDeclarationPattern;
|
||||
import org.eclipse.cdt.internal.core.search.matching.MatchLocator;
|
||||
import org.eclipse.cdt.internal.core.search.matching.NamespaceDeclarationPattern;
|
||||
import org.eclipse.cdt.internal.core.search.matching.OrPattern;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.Path;
|
||||
|
||||
/**
|
||||
|
@ -322,9 +326,20 @@ public class OtherPatternTests extends BaseSearchTest {
|
|||
resultCollector.setProgressMonitor( monitor );
|
||||
|
||||
resultCollector.aboutToStart();
|
||||
|
||||
ArrayList matchesList = new ArrayList();
|
||||
MatchLocator matchLocator = new MatchLocator( pattern, resultCollector, scope, monitor );
|
||||
matchLocator.locateMatches( new String [] { path }, workspace, null );
|
||||
resultCollector.done();
|
||||
matchLocator.locateMatches( new String [] { path }, workspace, null, matchesList);
|
||||
|
||||
AcceptMatchOperation acceptMatchOp = new AcceptMatchOperation(resultCollector, matchesList);
|
||||
try {
|
||||
CCorePlugin.getWorkspace().run(acceptMatchOp,null);
|
||||
} catch (CoreException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
//
|
||||
//resultCollector.done();
|
||||
|
||||
Set matches = resultCollector.getSearchResults();
|
||||
assertEquals( matches.size(), 4 );
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
2003-10-23 Bogdan Gheorghe
|
||||
- Added UpdateDependency job
|
||||
|
||||
2003-09-25 Bogdan Gheorghe
|
||||
- As a result of folding the dependency service into the indexer
|
||||
have removed the following files:
|
||||
|
|
|
@ -0,0 +1,101 @@
|
|||
/*
|
||||
* Created on Oct 13, 2003
|
||||
*
|
||||
* To change the template for this generated file go to
|
||||
* Window>Preferences>Java>Code Generation>Code and Comments
|
||||
*/
|
||||
package org.eclipse.cdt.internal.core.sourcedependency;
|
||||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.search.ICSearchConstants;
|
||||
import org.eclipse.cdt.core.search.ICSearchScope;
|
||||
import org.eclipse.cdt.core.search.SearchEngine;
|
||||
import org.eclipse.cdt.internal.core.search.PathCollector;
|
||||
import org.eclipse.cdt.internal.core.search.PatternSearchJob;
|
||||
import org.eclipse.cdt.internal.core.search.indexing.IndexManager;
|
||||
import org.eclipse.cdt.internal.core.search.matching.CSearchPattern;
|
||||
import org.eclipse.cdt.internal.core.search.processing.IJob;
|
||||
import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.core.resources.IResource;
|
||||
import org.eclipse.core.resources.IWorkspaceRoot;
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.core.runtime.Path;
|
||||
|
||||
/**
|
||||
* @author bgheorgh
|
||||
*
|
||||
* To change the template for this generated type comment go to
|
||||
* Window>Preferences>Java>Code Generation>Code and Comments
|
||||
*/
|
||||
public class UpdateDependency implements IJob {
|
||||
PathCollector pathCollector;
|
||||
IResource resource;
|
||||
|
||||
/**
|
||||
* @param resource
|
||||
*/
|
||||
public UpdateDependency(IResource resource) {
|
||||
this.resource = resource;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.search.processing.IJob#belongsTo(java.lang.String)
|
||||
*/
|
||||
public boolean belongsTo(String jobFamily) {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.search.processing.IJob#cancel()
|
||||
*/
|
||||
public void cancel() {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.search.processing.IJob#execute(org.eclipse.core.runtime.IProgressMonitor)
|
||||
*/
|
||||
public boolean execute(IProgressMonitor progress) {
|
||||
PathCollector pathCollector = new PathCollector();
|
||||
//SubProgressMonitor subMonitor = (progressMonitor == null ) ? null : new SubProgressMonitor( progressMonitor, 5 );
|
||||
ICSearchScope scope = SearchEngine.createWorkspaceScope();
|
||||
CSearchPattern pattern = CSearchPattern.createPattern(resource.getLocation().toOSString(),ICSearchConstants.INCLUDE, ICSearchConstants.REFERENCES,ICSearchConstants.EXACT_MATCH,true);
|
||||
IndexManager indexManager = CCorePlugin.getDefault().getCoreModel().getIndexManager();
|
||||
indexManager.performConcurrentJob(
|
||||
new PatternSearchJob(
|
||||
(CSearchPattern) pattern,
|
||||
scope,
|
||||
pathCollector,
|
||||
indexManager
|
||||
),
|
||||
ICSearchConstants.WAIT_UNTIL_READY_TO_SEARCH,
|
||||
null,
|
||||
this );
|
||||
|
||||
String[] iPath = pathCollector.getPaths();
|
||||
for (int i=0;i<iPath.length; i++){
|
||||
IPath pathToReindex = new Path(iPath[i]);
|
||||
IWorkspaceRoot workRoot = resource.getWorkspace().getRoot();
|
||||
IFile fileToReindex = workRoot.getFile(pathToReindex);
|
||||
|
||||
if (fileToReindex!=null && fileToReindex.exists() ) {
|
||||
// if (VERBOSE)
|
||||
// System.out.println("Going to reindex " + fileToReindex.getName());
|
||||
indexManager.addSource(fileToReindex,fileToReindex.getProject().getProject().getFullPath());
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.search.processing.IJob#isReadyToRun()
|
||||
*/
|
||||
public boolean isReadyToRun() {
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,3 +1,8 @@
|
|||
2003-10-22 Bogdan Gheorghe
|
||||
|
||||
Added updateDependencies() to the IndexManager to request
|
||||
a new UpdateDependency job.
|
||||
|
||||
2003-10-01 Bogdan Gheorghe
|
||||
- Modified BlockIndexOutput.addInclude to properly flush an
|
||||
include block once it's full.
|
||||
|
|
|
@ -21,6 +21,7 @@ import java.util.Locale;
|
|||
import java.util.MissingResourceException;
|
||||
import java.util.ResourceBundle;
|
||||
|
||||
import org.eclipse.cdt.internal.core.model.CModelManager;
|
||||
import org.eclipse.core.resources.IContainer;
|
||||
import org.eclipse.core.resources.IResource;
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
|
@ -361,6 +362,37 @@ public class Util {
|
|||
return true;
|
||||
return false;
|
||||
}
|
||||
/**
|
||||
* @param string
|
||||
* @return
|
||||
*/
|
||||
public static boolean isCCFileName(String fileName) {
|
||||
String[] sourceExtensions = CModelManager.sourceExtensions;
|
||||
String[] headerExtensions = CModelManager.headerExtensions;
|
||||
|
||||
int dot =fileName.lastIndexOf(".");
|
||||
|
||||
//No extension, give benefit of doubt
|
||||
if (dot == -1)
|
||||
return true;
|
||||
|
||||
//Extract extension
|
||||
String extension = "";
|
||||
if (dot + 1 <= fileName.length())
|
||||
extension = fileName.substring(dot + 1);
|
||||
|
||||
for (int i=0; i<sourceExtensions.length; i++){
|
||||
if (sourceExtensions[i].equals(extension))
|
||||
return true;
|
||||
}
|
||||
|
||||
for (int i=0; i<headerExtensions.length; i++){
|
||||
if (headerExtensions[i].equals(extension))
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -97,15 +97,14 @@ public class IndexAllProject extends IndexRequest {
|
|||
if (isCancelled) return false;
|
||||
switch(proxy.getType()) {
|
||||
case IResource.FILE :
|
||||
//TODO: BOG Put the file name checking back
|
||||
//if (Util.isCCFileName(proxy.getName())) {
|
||||
if (Util.isCCFileName(proxy.getName())) {
|
||||
IResource resource = proxy.requestResource();
|
||||
if (resource.getLocation() != null && (patterns == null || !Util.isExcluded(resource, patterns))) {
|
||||
String name = new IFileDocument((IFile) resource).getName();
|
||||
indexedFileNames.put(name, resource);
|
||||
}
|
||||
//}
|
||||
// return false;
|
||||
}
|
||||
return false;
|
||||
|
||||
case IResource.FOLDER :
|
||||
if (patterns != null && Util.isExcluded(proxy.requestResource(), patterns))
|
||||
|
|
|
@ -31,8 +31,10 @@ import org.eclipse.cdt.internal.core.search.IndexSelector;
|
|||
import org.eclipse.cdt.internal.core.search.SimpleLookupTable;
|
||||
import org.eclipse.cdt.internal.core.search.processing.IJob;
|
||||
import org.eclipse.cdt.internal.core.search.processing.JobManager;
|
||||
import org.eclipse.cdt.internal.core.sourcedependency.UpdateDependency;
|
||||
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.IPath;
|
||||
|
@ -103,7 +105,6 @@ public class IndexManager extends JobManager implements IIndexConstants {
|
|||
* Note: the actual operation is performed in background
|
||||
*/
|
||||
public void addSource(IFile resource, IPath indexedContainer){
|
||||
|
||||
if (CCorePlugin.getDefault() == null) return;
|
||||
AddCompilationUnitToIndex job = new AddCompilationUnitToIndex(resource, indexedContainer, this);
|
||||
if (this.awaitingJobsCount() < MAX_FILES_IN_MEMORY) {
|
||||
|
@ -113,6 +114,13 @@ public class IndexManager extends JobManager implements IIndexConstants {
|
|||
request(job);
|
||||
}
|
||||
|
||||
public void updateDependencies(IResource resource){
|
||||
if (CCorePlugin.getDefault() == null) return;
|
||||
UpdateDependency job = new UpdateDependency(resource);
|
||||
|
||||
request(job);
|
||||
}
|
||||
|
||||
String computeIndexName(IPath path) {
|
||||
String name = (String) indexNames.get(path);
|
||||
if (name == null) {
|
||||
|
|
|
@ -5,7 +5,6 @@ package org.eclipse.cdt.internal.core.model;
|
|||
* All Rights Reserved.
|
||||
*/
|
||||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.model.CModelException;
|
||||
import org.eclipse.cdt.core.model.CoreModel;
|
||||
import org.eclipse.cdt.core.model.IArchiveContainer;
|
||||
|
@ -15,20 +14,12 @@ import org.eclipse.cdt.core.model.ICElementDelta;
|
|||
import org.eclipse.cdt.core.model.ICModel;
|
||||
import org.eclipse.cdt.core.model.ICProject;
|
||||
import org.eclipse.cdt.core.model.IParent;
|
||||
import org.eclipse.cdt.core.search.ICSearchConstants;
|
||||
import org.eclipse.cdt.core.search.ICSearchScope;
|
||||
import org.eclipse.cdt.core.search.SearchEngine;
|
||||
import org.eclipse.cdt.internal.core.search.PathCollector;
|
||||
import org.eclipse.cdt.internal.core.search.PatternSearchJob;
|
||||
import org.eclipse.cdt.internal.core.search.indexing.IndexManager;
|
||||
import org.eclipse.cdt.internal.core.search.matching.CSearchPattern;
|
||||
import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.resources.IResource;
|
||||
import org.eclipse.core.resources.IResourceDelta;
|
||||
import org.eclipse.core.resources.IWorkspaceRoot;
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
import org.eclipse.core.runtime.Path;
|
||||
|
||||
/**
|
||||
* This class is used by <code>CModelManager</code> to convert
|
||||
|
@ -511,35 +502,8 @@ public class DeltaProcessor {
|
|||
String fileExtension = resource.getFileExtension();
|
||||
|
||||
if ((fileExtension != null) &&
|
||||
(isValidHeader(fileExtension)))
|
||||
{
|
||||
PathCollector pathCollector = new PathCollector();
|
||||
//SubProgressMonitor subMonitor = (progressMonitor == null ) ? null : new SubProgressMonitor( progressMonitor, 5 );
|
||||
ICSearchScope scope = SearchEngine.createWorkspaceScope();
|
||||
CSearchPattern pattern = CSearchPattern.createPattern(resource.getLocation().toOSString(),ICSearchConstants.INCLUDE, ICSearchConstants.REFERENCES,ICSearchConstants.EXACT_MATCH,true);
|
||||
IndexManager indexManager = CCorePlugin.getDefault().getCoreModel().getIndexManager();
|
||||
indexManager.performConcurrentJob(
|
||||
new PatternSearchJob(
|
||||
(CSearchPattern) pattern,
|
||||
scope,
|
||||
pathCollector,
|
||||
indexManager
|
||||
),
|
||||
ICSearchConstants.WAIT_UNTIL_READY_TO_SEARCH,
|
||||
null );
|
||||
|
||||
String[] iPath = pathCollector.getPaths();
|
||||
for (int i=0;i<iPath.length; i++){
|
||||
IPath pathToReindex = new Path(iPath[i]);
|
||||
IWorkspaceRoot workRoot = element.getCProject().getProject().getWorkspace().getRoot();
|
||||
IFile fileToReindex = workRoot.getFile(pathToReindex);
|
||||
|
||||
if (fileToReindex!=null && fileToReindex.exists() ) {
|
||||
if (VERBOSE)
|
||||
System.out.println("Going to reindex " + fileToReindex.getName());
|
||||
this.indexManager.addSource(fileToReindex,fileToReindex.getProject().getProject().getFullPath());
|
||||
}
|
||||
}
|
||||
(isValidHeader(fileExtension))){
|
||||
indexManager.updateDependencies(resource);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,3 +1,20 @@
|
|||
2003-10-23 Bogdan Gheorghe
|
||||
|
||||
- Added AcceptMatchOperation to get around Bug 45324. The search
|
||||
operation is no longer a WorkspaceModifyOperation (which used to
|
||||
lock the workspace for the duration of search). Instead, we now
|
||||
lock the workspace only when we tag the resources with markers.
|
||||
|
||||
- Modified SearchEngine : we now receive a list of matches
|
||||
from the search that we pass into the AcceptMatchOperation.
|
||||
|
||||
- Modified MatchLocator to add matches to passed in list instead
|
||||
of reporting them right away
|
||||
|
||||
- Modified JobManager: -added in jobToIgnore parm to unblock dependency
|
||||
jobs
|
||||
|
||||
|
||||
2003-10-06 Bogdan Gheorghe
|
||||
- added createCFileSearchScope() to SearchEngine.java to improve
|
||||
code complete performance
|
||||
|
|
|
@ -23,6 +23,7 @@ import org.eclipse.cdt.core.model.ICProject;
|
|||
import org.eclipse.cdt.internal.core.Util;
|
||||
import org.eclipse.cdt.internal.core.model.CModelManager;
|
||||
import org.eclipse.cdt.internal.core.model.IWorkingCopy;
|
||||
import org.eclipse.cdt.internal.core.search.AcceptMatchOperation;
|
||||
import org.eclipse.cdt.internal.core.search.CSearchScope;
|
||||
import org.eclipse.cdt.internal.core.search.CWorkspaceScope;
|
||||
import org.eclipse.cdt.internal.core.search.PathCollector;
|
||||
|
@ -32,6 +33,7 @@ import org.eclipse.cdt.internal.core.search.matching.CSearchPattern;
|
|||
import org.eclipse.cdt.internal.core.search.matching.MatchLocator;
|
||||
import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.core.resources.IWorkspace;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.core.runtime.OperationCanceledException;
|
||||
|
@ -164,7 +166,7 @@ public class SearchEngine implements ICSearchConstants{
|
|||
|
||||
/* search is starting */
|
||||
collector.aboutToStart();
|
||||
|
||||
ArrayList matches = new ArrayList();
|
||||
try{
|
||||
//initialize progress monitor
|
||||
IProgressMonitor progressMonitor = collector.getProgressMonitor();
|
||||
|
@ -188,7 +190,8 @@ public class SearchEngine implements ICSearchConstants{
|
|||
indexManager
|
||||
),
|
||||
ICSearchConstants.WAIT_UNTIL_READY_TO_SEARCH,
|
||||
subMonitor );
|
||||
subMonitor,
|
||||
null );
|
||||
|
||||
subMonitor = (progressMonitor == null ) ? null : new SubProgressMonitor( progressMonitor, 95 );
|
||||
|
||||
|
@ -199,9 +202,12 @@ public class SearchEngine implements ICSearchConstants{
|
|||
throw new OperationCanceledException();
|
||||
|
||||
//TODO: BOG Filter Working Copies...
|
||||
matchLocator.locateMatches( pathCollector.getPaths(), workspace, this.workingCopies);
|
||||
matchLocator.locateMatches( pathCollector.getPaths(), workspace, this.workingCopies, matches);
|
||||
} finally {
|
||||
collector.done();
|
||||
AcceptMatchOperation acceptMatchOp = new AcceptMatchOperation(collector, matches);
|
||||
try {
|
||||
CCorePlugin.getWorkspace().run(acceptMatchOp,null);
|
||||
} catch (CoreException e) {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,48 @@
|
|||
/*
|
||||
* Created on Oct 20, 2003
|
||||
*
|
||||
* To change the template for this generated file go to
|
||||
* Window>Preferences>Java>Code Generation>Code and Comments
|
||||
*/
|
||||
package org.eclipse.cdt.internal.core.search;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
|
||||
import org.eclipse.cdt.core.search.ICSearchResultCollector;
|
||||
import org.eclipse.cdt.core.search.IMatch;
|
||||
import org.eclipse.core.resources.IWorkspaceRunnable;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
|
||||
/**
|
||||
* @author bgheorgh
|
||||
*
|
||||
* To change the template for this generated type comment go to
|
||||
* Window>Preferences>Java>Code Generation>Code and Comments
|
||||
*/
|
||||
public class AcceptMatchOperation implements IWorkspaceRunnable {
|
||||
|
||||
ICSearchResultCollector collector;
|
||||
ArrayList matches;
|
||||
/**
|
||||
* @param collector
|
||||
*/
|
||||
public AcceptMatchOperation(ICSearchResultCollector collector, ArrayList matches) {
|
||||
this.collector = collector;
|
||||
this.matches = matches;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.core.resources.IWorkspaceRunnable#run(org.eclipse.core.runtime.IProgressMonitor)
|
||||
*/
|
||||
public void run(IProgressMonitor monitor) throws CoreException {
|
||||
Iterator i = matches.iterator();
|
||||
while (i.hasNext()){
|
||||
IMatch match = (IMatch) i.next();
|
||||
collector.acceptMatch(match);
|
||||
}
|
||||
collector.done();
|
||||
}
|
||||
|
||||
}
|
|
@ -18,6 +18,7 @@ import java.io.FileNotFoundException;
|
|||
import java.io.FileReader;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.Reader;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
|
@ -98,6 +99,8 @@ import org.eclipse.core.runtime.Path;
|
|||
public class MatchLocator implements ISourceElementRequestor, ICSearchConstants {
|
||||
|
||||
|
||||
ArrayList matchStorage;
|
||||
|
||||
public static boolean VERBOSE = false;
|
||||
/**
|
||||
*
|
||||
|
@ -329,7 +332,8 @@ public class MatchLocator implements ISourceElementRequestor, ICSearchConstants
|
|||
}
|
||||
|
||||
|
||||
public void locateMatches( String [] paths, IWorkspace workspace, IWorkingCopy[] workingCopies ){
|
||||
public void locateMatches( String [] paths, IWorkspace workspace, IWorkingCopy[] workingCopies,ArrayList matches ){
|
||||
matchStorage = matches;
|
||||
workspaceRoot = (workspace != null) ? workspace.getRoot() : null;
|
||||
|
||||
HashMap wcPaths = new HashMap();
|
||||
|
@ -495,7 +499,9 @@ public class MatchLocator implements ISourceElementRequestor, ICSearchConstants
|
|||
match = resultCollector.createMatch( currentPath, offset, end, object );
|
||||
}
|
||||
if( match != null ){
|
||||
resultCollector.acceptMatch( match );
|
||||
//Save till later
|
||||
//resultCollector.acceptMatch( match );
|
||||
matchStorage.add(match);
|
||||
}
|
||||
|
||||
} catch (CoreException e) {
|
||||
|
|
|
@ -188,7 +188,8 @@ public abstract class JobManager implements Runnable {
|
|||
public boolean performConcurrentJob(
|
||||
IJob searchJob,
|
||||
int waitingPolicy,
|
||||
IProgressMonitor progress) {
|
||||
IProgressMonitor progress,
|
||||
IJob jobToIgnore) {
|
||||
|
||||
if (VERBOSE)
|
||||
JobManager.verbose("STARTING concurrent job - " + searchJob); //$NON-NLS-1$
|
||||
|
@ -250,7 +251,8 @@ public abstract class JobManager implements Runnable {
|
|||
}
|
||||
this.awaitingClients++;
|
||||
}
|
||||
while ((awaitingWork = awaitingJobsCount()) > 0) {
|
||||
while (((awaitingWork = awaitingJobsCount()) > 0)
|
||||
&& (!jobShouldBeIgnored(jobToIgnore))) {
|
||||
if (subProgress != null && subProgress.isCanceled())
|
||||
throw new OperationCanceledException();
|
||||
currentJob = currentJob();
|
||||
|
@ -295,6 +297,20 @@ public abstract class JobManager implements Runnable {
|
|||
return status;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param jobToIgnore
|
||||
* @return
|
||||
*/
|
||||
private boolean jobShouldBeIgnored(IJob jobToIgnore) {
|
||||
if (jobToIgnore == null)
|
||||
return false;
|
||||
|
||||
if (currentJob() == jobToIgnore)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public abstract String processName();
|
||||
|
||||
public synchronized void request(IJob job) {
|
||||
|
|
|
@ -27,6 +27,7 @@ import org.eclipse.cdt.ui.CUIPlugin;
|
|||
import org.eclipse.core.resources.IWorkspace;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.jface.operation.IRunnableWithProgress;
|
||||
import org.eclipse.jface.resource.ImageDescriptor;
|
||||
import org.eclipse.ui.actions.WorkspaceModifyOperation;
|
||||
|
||||
|
@ -36,7 +37,7 @@ import org.eclipse.ui.actions.WorkspaceModifyOperation;
|
|||
* To change the template for this generated type comment go to
|
||||
* Window>Preferences>Java>Code Generation>Code and Comments
|
||||
*/
|
||||
public class CSearchOperation extends WorkspaceModifyOperation implements ICSearchConstants{
|
||||
public class CSearchOperation implements IRunnableWithProgress,ICSearchConstants{
|
||||
public CSearchOperation(IWorkspace workspace, String pattern, boolean caseSensitive, List searchFor, LimitTo limitTo, ICSearchScope scope, String scopeDescription, CSearchResultCollector collector) {
|
||||
this( workspace, limitTo, scope, scopeDescription, collector );
|
||||
_stringPattern = pattern;
|
||||
|
@ -56,8 +57,7 @@ public class CSearchOperation extends WorkspaceModifyOperation implements ICSear
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.ui.actions.WorkspaceModifyOperation#execute(org.eclipse.core.runtime.IProgressMonitor)
|
||||
*/
|
||||
protected void execute(IProgressMonitor monitor)
|
||||
throws CoreException, InvocationTargetException, InterruptedException
|
||||
public void run(IProgressMonitor monitor)throws InvocationTargetException
|
||||
{
|
||||
_collector.setProgressMonitor( monitor );
|
||||
|
||||
|
@ -79,6 +79,8 @@ public class CSearchOperation extends WorkspaceModifyOperation implements ICSear
|
|||
}
|
||||
|
||||
engine.search( _workspace, pattern, _scope, _collector, false );
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -148,4 +150,5 @@ public class CSearchOperation extends WorkspaceModifyOperation implements ICSear
|
|||
private List _searchFor;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -55,6 +55,7 @@ public class CSearchResultCollector extends BasicSearchResultCollector{
|
|||
|
||||
_view = SearchUI.getSearchResultView();
|
||||
|
||||
|
||||
CSearchResultLabelProvider labelProvider = new CSearchResultLabelProvider();
|
||||
labelProvider.setOrder( CSearchResultLabelProvider.SHOW_PATH );
|
||||
|
||||
|
|
|
@ -513,7 +513,7 @@ public class CCompletionProcessor implements IContentAssistProcessor {
|
|||
//Get file's dependencies
|
||||
try {
|
||||
IndexManager indexMan = CCorePlugin.getDefault().getCoreModel().getIndexManager();
|
||||
indexMan.performConcurrentJob(new DependencyQueryJob(project, (IFile)actualFile, indexMan, dependencies), ICSearchConstants.WAIT_UNTIL_READY_TO_SEARCH, null);
|
||||
indexMan.performConcurrentJob(new DependencyQueryJob(project, (IFile)actualFile, indexMan, dependencies), ICSearchConstants.WAIT_UNTIL_READY_TO_SEARCH, null, null);
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue