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

Completed optimization #2 in PR 91801: [Indexer] Optimize header file visiting/indexing. Encountered headers are removed before instead of after indexing the whole project, thus enabling 'index external headers only once' optimization to be applied for file/directory indexing.

This commit is contained in:
Vladimir Hirsl 2005-06-20 20:35:42 +00:00
parent 7475da7bda
commit 77121513be
3 changed files with 16 additions and 25 deletions

View file

@ -1,3 +1,12 @@
2005-06-20 Vladimir Hirsl
Completed optimization #2 in PR 91801: [Indexer] Optimize header file visiting/indexing
Encountered headers are removed before instead of after indexing the whole project, thus
enabling 'index external headers only once' optimization to be applied for file/directory
indexing.
* index/org/eclipse/cdt/internal/core/index/domsourceindexer/DOMAddFolderToIndex.java
* index/org/eclipse/cdt/internal/core/index/domsourceindexer/DOMIndexAllProject.java
2005-06-17 Vladimir Hirsl 2005-06-17 Vladimir Hirsl
Fix for 95174: [Search Engine][DOM AST Indexer] does not find definition of a method Fix for 95174: [Search Engine][DOM AST Indexer] does not find definition of a method

View file

@ -34,7 +34,6 @@ public class DOMAddFolderToIndex extends DOMIndexRequest {
char[][] exclusionPattern; char[][] exclusionPattern;
ArrayList sourceFilesToIndex; ArrayList sourceFilesToIndex;
ArrayList headerFilesToIndex; ArrayList headerFilesToIndex;
boolean cleanEncouteredHeaders;
public DOMAddFolderToIndex(IPath folderPath, IProject project, char[][] exclusionPattern, DOMSourceIndexer indexer) { public DOMAddFolderToIndex(IPath folderPath, IProject project, char[][] exclusionPattern, DOMSourceIndexer indexer) {
super(project.getFullPath(), indexer); super(project.getFullPath(), indexer);
@ -43,17 +42,6 @@ public class DOMAddFolderToIndex extends DOMIndexRequest {
this.exclusionPattern = exclusionPattern; this.exclusionPattern = exclusionPattern;
this.sourceFilesToIndex = new ArrayList(); this.sourceFilesToIndex = new ArrayList();
this.headerFilesToIndex = new ArrayList(); this.headerFilesToIndex = new ArrayList();
this.cleanEncouteredHeaders = false;
}
public DOMAddFolderToIndex(IPath folderPath, IProject project, char[][] exclusionPattern, DOMSourceIndexer indexer, boolean cleanEncounteredHeaders) {
super(project.getFullPath(), indexer);
this.folderPath = folderPath;
this.project = project;
this.exclusionPattern = exclusionPattern;
this.sourceFilesToIndex = new ArrayList();
this.headerFilesToIndex = new ArrayList();
this.cleanEncouteredHeaders = cleanEncounteredHeaders;
} }
public boolean execute(IProgressMonitor progressMonitor) { public boolean execute(IProgressMonitor progressMonitor) {
@ -72,7 +60,7 @@ public class DOMAddFolderToIndex extends DOMIndexRequest {
try { try {
monitor.enterRead(); // ask permission to read monitor.enterRead(); // ask permission to read
final IPath container = this.indexPath; // final IPath container = this.indexPath;
//final IndexManager indexManager = this.manager; //final IndexManager indexManager = this.manager;
final char[][] pattern = exclusionPattern; final char[][] pattern = exclusionPattern;
folder.accept( folder.accept(
@ -119,11 +107,6 @@ public class DOMAddFolderToIndex extends DOMIndexRequest {
for (int i=0;i<headerFilesToIndex.size(); i++) for (int i=0;i<headerFilesToIndex.size(); i++)
this.indexer.addSource((IFile)headerFilesToIndex.get(i), this.indexPath, true); this.indexer.addSource((IFile)headerFilesToIndex.get(i), this.indexPath, true);
if (cleanEncouteredHeaders){
CleanEncounteredHeaders cleanHeaders = new CleanEncounteredHeaders(this.indexer);
this.indexer.request(cleanHeaders);
}
} }
public String toString() { public String toString() {

View file

@ -54,8 +54,6 @@ public class DOMIndexAllProject extends DOMIndexRequest {
if (progressMonitor != null && progressMonitor.isCanceled()) return true; if (progressMonitor != null && progressMonitor.isCanceled()) return true;
if (!project.isAccessible()) return true; // nothing to do if (!project.isAccessible()) return true; // nothing to do
String test = this.indexPath.toOSString();
IIndex index = indexer.getIndex(this.indexPath, true, /*reuse index file*/ true /*create if none*/); IIndex index = indexer.getIndex(this.indexPath, true, /*reuse index file*/ true /*create if none*/);
if (index == null) return true; if (index == null) return true;
ReadWriteMonitor monitor = indexer.getMonitorFor(index); ReadWriteMonitor monitor = indexer.getMonitorFor(index);
@ -86,20 +84,21 @@ public class DOMIndexAllProject extends DOMIndexRequest {
if (cProject == null) if (cProject == null)
return false; return false;
// first clean encountered headers
CleanEncounteredHeaders cleanHeaders = new CleanEncounteredHeaders(this.indexer);
this.indexer.request(cleanHeaders);
//Get the source roots for this project //Get the source roots for this project
ISourceRoot[] sourceRoot = cProject.getSourceRoots(); ISourceRoot[] sourceRoot = cProject.getSourceRoots();
for (int i=0;i<sourceRoot.length;i++){ for (int i=0;i<sourceRoot.length;i++){
if (sourceRoot[i] instanceof SourceRoot){ if (sourceRoot[i] instanceof SourceRoot){
ISourceEntry tempEntry = ((SourceRoot) sourceRoot[i]).getSourceEntry(); ISourceEntry tempEntry = ((SourceRoot) sourceRoot[i]).getSourceEntry();
if ((i+1) != sourceRoot.length) indexer.request(new DOMAddFolderToIndex(sourceRoot[i].getPath(), project, tempEntry.fullExclusionPatternChars(), indexer));
indexer.request(new DOMAddFolderToIndex(sourceRoot[i].getPath(), project, tempEntry.fullExclusionPatternChars(), indexer));
else
indexer.request(new DOMAddFolderToIndex(sourceRoot[i].getPath(), project, tempEntry.fullExclusionPatternChars(),indexer,true));
} }
} }
// request to save index when all cus have been indexed // request to save index when all cus have been indexed
indexer.request(new DOMSaveIndex(this.indexPath, indexer)); indexer.request(new DOMSaveIndex(this.indexPath, indexer));
} catch (CoreException e) { } catch (CoreException e) {
if (IndexManager.VERBOSE) { if (IndexManager.VERBOSE) {