Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[cdt-patch] Indexer patch


Core
- Hooked up the Indexer to the dependency tree. Everytime a header file gets modified, the including source files get reindexed.
- Automated dependency calcuations - each time a file gets modified, its tree gets updated.
- Added error logging via the PDE Error Log (Views->PDE Runtime->Error Log) - the indexer reports unsuccesful index attempts and the preprocessor reports unsuccesful inclusion resolution attempts

UI
- Changed the names on the search popup mens


Bogdan

Index: ChangeLog
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/ChangeLog,v
retrieving revision 1.143
diff -u -r1.143 ChangeLog
--- ChangeLog	5 Sep 2003 16:23:23 -0000	1.143
+++ ChangeLog	8 Sep 2003 05:30:58 -0000
@@ -1,3 +1,11 @@
+2003-09-05 Bogdan Gheorghe
+
+	Hooked in the dependency checking on file changes in Delta
+	Processor.java. When a header files' contents change we look
+	up the referencing files in the dep tree table and reindex them.
+	
+	* model/org/eclipse/cdt/internal/core/model/DeltaProcessor.java
+	
 2003-09-05 Alain Magloire
 
 	The PTY classes are using one instance of the master fd for Input/Output/Error
@@ -37,7 +45,6 @@
 	
 	* src/org/eclipse/cdt/core/ErrorParserManager.java
 	
-
 2003-09-01 Alain Magloire
 
 	Typo in the class signature.
Index: dependency/ChangeLog
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/dependency/ChangeLog,v
retrieving revision 1.1
diff -u -r1.1 ChangeLog
--- dependency/ChangeLog	24 Jul 2003 14:15:06 -0000	1.1
+++ dependency/ChangeLog	8 Sep 2003 05:30:58 -0000
@@ -1,3 +1,15 @@
+2003-09-03 Bogdan Gheorghe
+	- Modified AddFileToDependencyTree: extended the valid source
+	  file extensions, pass on the resource added to the tree
+	- Modified DependencyManager: added dependencyTable to keep track
+	  of files that reference header files
+	- Modified DependencyQueryJob: changed isReadyToRun to make use of
+	  DependencySelector (needed to trigger dep tree recalculation)
+	- Modified EntireProjectDependency: to get use the new ScannerIndo
+	  mechanism
+	- Modified PreprocessorOutput: to add inclusions to dep table
+	- Added RemoveFromDependencyTree, DependnecySelector
+	  
 2003-07-23 Bogdan Gheorghe
 
 	Added initial dependency implementation
Index: dependency/org/eclipse/cdt/internal/core/sourcedependency/AddFileToDependencyTree.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/dependency/org/eclipse/cdt/internal/core/sourcedependency/AddFileToDependencyTree.java,v
retrieving revision 1.2
diff -u -r1.2 AddFileToDependencyTree.java
--- dependency/org/eclipse/cdt/internal/core/sourcedependency/AddFileToDependencyTree.java	12 Aug 2003 20:20:04 -0000	1.2
+++ dependency/org/eclipse/cdt/internal/core/sourcedependency/AddFileToDependencyTree.java	8 Sep 2003 05:30:58 -0000
@@ -24,12 +24,12 @@
 import org.eclipse.core.runtime.IProgressMonitor;
 
 public class AddFileToDependencyTree extends DependencyRequest {
-	public static final String[] FILE_TYPES= new String[] {"cpp"}; //$NON-NLS-1$
+	public static final String[] FILE_TYPES= new String[] {"cpp","c", "cc", "cxx"}; //$NON-NLS-1$
 
 	IFile resource;
 	char[] contents;
 	IScannerInfo buildInfo;
-
+	
 	/**
 	 * @param path
 	 * @param manager
@@ -55,7 +55,7 @@
 			monitor.enterWrite(); // ask permission to write
 			if (!addDocumentToTree(tree)) return false;
 		} catch (IOException e) {
-			if (JobManager.VERBOSE) {
+			if (DependencyManager.VERBOSE) {
 				JobManager.verbose("-> failed to calculate dependency for " + this.resource + " because of the following exception:"); //$NON-NLS-1$ //$NON-NLS-2$
 				e.printStackTrace();
 			}
@@ -75,7 +75,7 @@
 		String docPath = resource.getLocation().toOSString();
 		IScannerInfo newInfo = new ScannerInfo((this.buildInfo != null) ? this.buildInfo.getDefinedSymbols() : null,(this.buildInfo != null) ? this.buildInfo.getIncludePaths() : null);
 		
-		dTree.add(document,docPath,newInfo);
+		dTree.add(document,docPath,newInfo, resource);
 		return true;
 	}
 	
Index: dependency/org/eclipse/cdt/internal/core/sourcedependency/DependencyManager.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/dependency/org/eclipse/cdt/internal/core/sourcedependency/DependencyManager.java,v
retrieving revision 1.2
diff -u -r1.2 DependencyManager.java
--- dependency/org/eclipse/cdt/internal/core/sourcedependency/DependencyManager.java	12 Aug 2003 20:20:04 -0000	1.2
+++ dependency/org/eclipse/cdt/internal/core/sourcedependency/DependencyManager.java	8 Sep 2003 05:30:58 -0000
@@ -15,6 +15,7 @@
 import java.io.File;
 import java.io.FileWriter;
 import java.io.IOException;
+import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.zip.CRC32;
@@ -40,6 +41,7 @@
 	public static int MAX_FILES_IN_MEMORY = 0;
 
 	public SimpleLookupTable projectNames = new SimpleLookupTable();
+	public SimpleLookupTable dependencyTable;
 	private Map dependencyTrees = new HashMap(5);
 
 	/* read write monitors */
@@ -58,7 +60,9 @@
 	public static Integer UPDATING_STATE = new Integer(1);
 	public static Integer UNKNOWN_STATE = new Integer(2);
 	public static Integer REBUILDING_STATE = new Integer(3);
-
+    
+	public static boolean VERBOSE = false;
+	
 	public String processName(){
 		//TODO: BOG Add name to .properties file
 		return "Dependency Tree"; //org.eclipse.cdt.internal.core.search.Util.bind("process.name"); //$NON-NLS-1$
@@ -77,6 +81,7 @@
 		}
 		
 		this.projectNames = new SimpleLookupTable();
+		this.dependencyTable = new SimpleLookupTable();
 		this.ccorePluginLocation = null;
 	}
 	/* (non-Javadoc)
@@ -125,7 +130,7 @@
 					} catch (IOException e) {
 						//	failed to read the existing file or its no longer compatible
 						 if (currentDTreeState != REBUILDING_STATE) { // rebuild tree if existing file is corrupt, unless the tree is already being rebuilt
-							 if (VERBOSE)
+							 if (DependencyManager.VERBOSE)
 								JobManager.verbose("-> cannot reuse existing tree: "+ treeName +" path: "+path.toOSString()); //$NON-NLS-1$ //$NON-NLS-2$
 							 rebuildDTree(treeName, path);
 							 return null;
@@ -167,7 +172,7 @@
 				checksumCalculator.reset();
 				checksumCalculator.update(pathString.getBytes());
 				String fileName = Long.toString(checksumCalculator.getValue()) + ".depTree"; //$NON-NLS-1$
-				if (VERBOSE)
+				if (DependencyManager.VERBOSE)
 					JobManager.verbose("-> dependency tree name for " + pathString + " is " + fileName); //$NON-NLS-1$ //$NON-NLS-2$
 				name = getCCorePluginWorkingLocation().append(fileName).toOSString();
 				projectNames.put(path, name);
@@ -209,7 +214,7 @@
 		try {
 			return org.eclipse.cdt.internal.core.Util.getFileCharContent(savedDTreesFile, null);
 		} catch (IOException ignored) {
-			if (VERBOSE)
+			if (DependencyManager.VERBOSE)
 				JobManager.verbose("Failed to read saved dTree file names"); //$NON-NLS-1$
 			return new char[0];
 		}
@@ -219,7 +224,7 @@
 		Object target = org.eclipse.cdt.internal.core.Util.getTarget(ResourcesPlugin.getWorkspace().getRoot(), path, true);
 		if (target == null) return;
 	
-		if (VERBOSE)
+		if (DependencyManager.VERBOSE)
 			JobManager.verbose("-> request to rebuild dTree: "+treeName+" path: "+path.toOSString()); //$NON-NLS-1$ //$NON-NLS-2$
 	
 		updateTreeState(treeName, REBUILDING_STATE);
@@ -274,7 +279,7 @@
 				}
 			}
 		} catch (IOException ignored) {
-			if (VERBOSE)
+			if (DependencyManager.VERBOSE)
 				JobManager.verbose("Failed to write saved dTree file names"); //$NON-NLS-1$
 		} finally {
 			if (writer != null) {
@@ -283,7 +288,7 @@
 				} catch (IOException e) {}
 			}
 		}
-		if (VERBOSE) {
+		if (DependencyManager.VERBOSE) {
 			String state = "?"; //$NON-NLS-1$
 			if (treeState == SAVED_STATE) state = "SAVED"; //$NON-NLS-1$
 			else if (treeState == UPDATING_STATE) state = "UPDATING"; //$NON-NLS-1$
@@ -307,13 +312,15 @@
 	 */
 	public void remove(String resourceName, IPath indexedContainer){
 		//request(new RemoveFromIndex(resourceName, indexedContainer, this));
+		if (DependencyManager.VERBOSE)
+		  JobManager.verbose("remove file from tree");
 	}
 	/**
 	 * Removes the tree for a given path. 
 	 * This is a no-op if the tree did not exist.
 	 */
 	public synchronized void removeTree(IPath path) {
-		if (VERBOSE)
+		if (DependencyManager.VERBOSE)
 			JobManager.verbose("removing dependency tree " + path); //$NON-NLS-1$
 		String treeName = computeTreeName(path);
 		File indexFile = new File(treeName);
@@ -325,6 +332,50 @@
 		this.dependencyTrees.remove(path);
 		updateTreeState(treeName, null);
 	}
+	
+	public synchronized void addToTable(String fileName, IFile resource){
+		ArrayList projectContainer = (ArrayList) dependencyTable.get(fileName);
+		if (projectContainer == null) {
+			ArrayList newProjectContainer = new ArrayList();
+			newProjectContainer.add(resource.getLocation());
+			
+			dependencyTable.put(fileName, newProjectContainer);
+		}
+		else {
+		  if (!projectContainer.contains(resource.getLocation())){
+		  	projectContainer.add(resource.getLocation());
+		  }
+		}
+	}
+	
+	public synchronized void removeFromTable(String fileName, IPath refToRemove){
+		ArrayList projectContainer = (ArrayList) dependencyTable.get(fileName);
+		if (projectContainer != null) {
+			int index = projectContainer.indexOf(refToRemove);
+			projectContainer.remove(refToRemove);
+		}
+	}
+	
+	public synchronized ArrayList getProjectDependsForFile(String fileName){
+		ArrayList projectContainer = (ArrayList) dependencyTable.get(fileName);
+		return projectContainer;
+	}	
+	
+	/**
+	 * @param file
+	 * @param path
+	 * @param info
+	 */
+	public void addSource(IFile file, IPath path, IScannerInfo info) {
+		if (CCorePlugin.getDefault() == null) return;	
+			AddFileToDependencyTree job = new AddFileToDependencyTree(file, path, this, info);
+			if (this.awaitingJobsCount() < MAX_FILES_IN_MEMORY) {
+				// reduces the chance that the file is open later on, preventing it from being deleted
+				if (!job.initializeContents()) return;
+			}
+			request(job);
+	}
+	
 	/*************
 	 *TODO: Remove these methods once the depTree is
 	 *fully integrated
@@ -363,21 +414,7 @@
 		} catch (CoreException e) {
 		}
 	}
-	/**
-	 * @param file
-	 * @param path
-	 * @param info
-	 */
-	public void addSource(IFile file, IPath path, IScannerInfo info) {
-		if (CCorePlugin.getDefault() == null) return;	
-			AddFileToDependencyTree job = new AddFileToDependencyTree(file, path, this, info);
-			if (this.awaitingJobsCount() < MAX_FILES_IN_MEMORY) {
-				// reduces the chance that the file is open later on, preventing it from being deleted
-				if (!job.initializeContents()) return;
-			}
-			request(job);
-	}
-	
+
 	/************
 	 * END OF TEMP D-TREE ENABLE SECTION
 	 */
Index: dependency/org/eclipse/cdt/internal/core/sourcedependency/DependencyQueryJob.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/dependency/org/eclipse/cdt/internal/core/sourcedependency/DependencyQueryJob.java,v
retrieving revision 1.1
diff -u -r1.1 DependencyQueryJob.java
--- dependency/org/eclipse/cdt/internal/core/sourcedependency/DependencyQueryJob.java	24 Jul 2003 14:15:06 -0000	1.1
+++ dependency/org/eclipse/cdt/internal/core/sourcedependency/DependencyQueryJob.java	8 Sep 2003 05:30:58 -0000
@@ -6,6 +6,7 @@
 import java.util.ArrayList;
 import java.util.List;
 
+import org.eclipse.cdt.core.search.SearchEngine;
 import org.eclipse.cdt.internal.core.search.processing.IJob;
 import org.eclipse.core.resources.IFile;
 import org.eclipse.core.resources.IProject;
@@ -20,6 +21,7 @@
 	IFile file;
 	ArrayList includeFiles;
 	DependencyManager depManager;
+	protected DependencySelector depSelector;
 	
 	public DependencyQueryJob(IProject project, IFile file, DependencyManager depMan, List includeFiles) {
 		this.project = project;
@@ -46,18 +48,26 @@
 	 */
 	public boolean execute(IProgressMonitor progress) {
 		
+		if ((project == null) ||(file == null)) return false;		
+		
 		String[] tempFiles = this.depManager.getFileDependencies(project,file);
-		for (int i=0; i<tempFiles.length; i++){
-			includeFiles.add(tempFiles[i]);
+		if (tempFiles != null){
+			for (int i=0; i<tempFiles.length; i++){
+						includeFiles.add(tempFiles[i]);
+			}
+			return true;
 		}
-		return true;
+		return false;
 	}
 
 	/* (non-Javadoc)
 	 * @see org.eclipse.cdt.internal.core.search.processing.IJob#isReadyToRun()
 	 */
 	public boolean isReadyToRun() {
-		// TODO Auto-generated method stub
+		if (this.depSelector == null) { // only check once. As long as this job is used, it will keep the same index picture
+			this.depSelector = new DependencySelector(SearchEngine.createWorkspaceScope(), null, false, this.depManager);
+			this.depSelector.getIndexes(); // will only cache answer if all indexes were available originally
+		}
 		return true;
 	}
 
Index: dependency/org/eclipse/cdt/internal/core/sourcedependency/DependencySelector.java
===================================================================
RCS file: dependency/org/eclipse/cdt/internal/core/sourcedependency/DependencySelector.java
diff -N dependency/org/eclipse/cdt/internal/core/sourcedependency/DependencySelector.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ dependency/org/eclipse/cdt/internal/core/sourcedependency/DependencySelector.java	8 Sep 2003 05:30:58 -0000
@@ -0,0 +1,114 @@
+/*
+ * Created on Aug 26, 2003
+ */
+package org.eclipse.cdt.internal.core.sourcedependency;
+
+import java.util.ArrayList;
+
+import org.eclipse.cdt.core.model.ICElement;
+import org.eclipse.cdt.core.model.ICModel;
+import org.eclipse.cdt.core.model.ICProject;
+import org.eclipse.cdt.core.search.ICSearchScope;
+import org.eclipse.core.resources.IWorkspaceRoot;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.IPath;
+
+/**
+ * @author bgheorgh
+ */
+public class DependencySelector {
+
+	/**
+	 * 
+	 */
+	public DependencySelector(
+	ICSearchScope searchScope,
+	ICElement focus,
+	boolean isPolymorphicSearch,
+	DependencyManager depManager) {
+			this.searchScope = searchScope;
+			this.focus = focus;
+			this.depManager = depManager;
+			this.isPolymorphicSearch = isPolymorphicSearch;
+	}
+	    ICSearchScope searchScope;
+		ICElement focus;
+		DependencyManager depManager;
+		IPath[] treeKeys; // cache of the keys for looking index up
+		boolean isPolymorphicSearch;
+
+		/**
+		 * Returns whether elements of the given project can see the given focus (an ICProject) 
+		 */
+		public static boolean canSeeFocus(ICElement focus, boolean isPolymorphicSearch, IPath projectPath) {
+			//TODO: BOG Temp - Provide Proper Impl
+			ICModel model = focus.getCModel();
+			ICProject project = getCProject(projectPath, model);
+			return true;
+		}
+		/*
+		 *  Compute the list of paths which are keying index files.
+		 */
+		private void initializeIndexKeys() {
+		
+			ArrayList requiredIndexKeys = new ArrayList();
+			IPath[] projects = this.searchScope.enclosingProjects();
+			IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
+			ICElement projectFocus = this.focus == null ? null : getProject(this.focus);
+			for (int i = 0; i < projects.length; i++) {
+				IPath location;
+				IPath path = projects[i];
+				if ((!root.getProject(path.lastSegment()).exists()) // if project does not exist
+					&& path.segmentCount() > 1
+					&& ((location = root.getFile(path).getLocation()) == null
+						|| !new java.io.File(location.toOSString()).exists()) // and internal jar file does not exist
+					&& !new java.io.File(path.toOSString()).exists()) { // and external jar file does not exist
+						continue;
+				}
+				if (projectFocus == null || canSeeFocus(projectFocus, this.isPolymorphicSearch, path)) {
+					if (requiredIndexKeys.indexOf(path) == -1) {
+						requiredIndexKeys.add(path);
+					}
+				}
+			}
+			this.treeKeys = new IPath[requiredIndexKeys.size()];
+			requiredIndexKeys.toArray(this.treeKeys);
+		}
+		
+		public IDependencyTree[] getIndexes() {
+			if (this.treeKeys == null) {
+				this.initializeIndexKeys(); 
+			}
+			// acquire the in-memory indexes on the fly
+			int length = this.treeKeys.length;
+			IDependencyTree[] indexes = new IDependencyTree[length];
+			int count = 0;
+			for (int i = 0; i < length; i++){
+				// may trigger some index recreation work
+				IDependencyTree index = depManager.getDependencyTree(treeKeys[i], true /*reuse index file*/, false /*do not create if none*/);
+				if (index != null) indexes[count++] = index; // only consider indexes which are ready yet
+			}
+			if (count != length) {
+				System.arraycopy(indexes, 0, indexes=new IDependencyTree[count], 0, count);
+			}
+			return indexes;
+		}
+		/**
+		 * Returns the project that corresponds to the given path.
+		 * Returns null if the path doesn't correspond to a project.
+		 */
+		private static ICProject getCProject(IPath path, ICModel model) {
+			ICProject project = model.getCProject(path.lastSegment());
+			if (project.exists()) {
+				return project;
+			} else {
+				return null;
+			}
+		}
+		public static ICElement getProject(ICElement element) {
+			while (!(element instanceof ICProject)) {
+				element = element.getParent();
+			}
+			return element;
+		}
+}
Index: dependency/org/eclipse/cdt/internal/core/sourcedependency/DependencyTree.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/dependency/org/eclipse/cdt/internal/core/sourcedependency/DependencyTree.java,v
retrieving revision 1.1
diff -u -r1.1 DependencyTree.java
--- dependency/org/eclipse/cdt/internal/core/sourcedependency/DependencyTree.java	24 Jul 2003 14:15:06 -0000	1.1
+++ dependency/org/eclipse/cdt/internal/core/sourcedependency/DependencyTree.java	8 Sep 2003 05:30:58 -0000
@@ -26,14 +26,19 @@
 import org.eclipse.cdt.internal.core.index.impl.IndexedFile;
 import org.eclipse.cdt.internal.core.sourcedependency.impl.InMemoryTree;
 import org.eclipse.cdt.internal.core.sourcedependency.impl.IncludeEntry;
+import org.eclipse.core.resources.IFile;
 import org.eclipse.core.runtime.IPath;
 
 
 public class DependencyTree implements IDependencyTree {
-	
+	/**
+	 * Maximum size of the index in memory.
+	 */
+	public static final int MAX_FOOTPRINT= 1000000;
 	protected InMemoryTree addsTree;
 	
 	public DependencyTree(String treeName, String string, boolean b) throws IOException{
+		super();
 		initialize();
 	}
 
@@ -105,17 +110,20 @@
 	 * @see org.eclipse.cdt.internal.core.sourcedependency.IDependencyTree#remove(java.lang.String)
 	 */
 	public void remove(String documentName) throws IOException {
-		// TODO Auto-generated method stub
+		//IndexedFile file= addsTree.getIndexedFile(documentName);
+		//if (file != null) {
+		//}
+	
 	}
 	/**
 	 * Add the file that will be preprocessed to the tree, create a new
 	 * preprocessor output and preprocess!
 	 */
-	public void add(IDocument document, String docPath, IScannerInfo newInfo) throws IOException  {
+	public void add(IDocument document, String docPath, IScannerInfo newInfo, IFile file) throws IOException  {
 		IndexedFile indexedFile= addsTree.getIndexedFile(document.getName());
 		//if (indexedFile != null)
 			//remove(indexedFile, 0);
-		PreprocessorOutput output= new PreprocessorOutput(addsTree);
+		PreprocessorOutput output= new PreprocessorOutput(addsTree, file);
 		DependencyRequestor depReq = new DependencyRequestor(output,document);
 		
 		output.addDocument(document);
@@ -170,5 +178,13 @@
 			System.out.println(tempFiles[i].toString());
 		}
 		
+	}
+	
+	/**
+	 * Returns true if the in memory index reaches a critical size, 
+	 * to merge it with the index on the disk.
+	 */
+	protected boolean timeToMerge() {
+		return (addsTree.getFootprint() >= MAX_FOOTPRINT);
 	}
 }
Index: dependency/org/eclipse/cdt/internal/core/sourcedependency/EntireProjectDependencyTree.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/dependency/org/eclipse/cdt/internal/core/sourcedependency/EntireProjectDependencyTree.java,v
retrieving revision 1.2
diff -u -r1.2 EntireProjectDependencyTree.java
--- dependency/org/eclipse/cdt/internal/core/sourcedependency/EntireProjectDependencyTree.java	12 Aug 2003 20:20:04 -0000	1.2
+++ dependency/org/eclipse/cdt/internal/core/sourcedependency/EntireProjectDependencyTree.java	8 Sep 2003 05:30:58 -0000
@@ -13,7 +13,9 @@
 
 import java.util.HashSet;
 
-import org.eclipse.cdt.core.build.managed.ManagedBuildManager;
+import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.core.parser.IScannerInfo;
+import org.eclipse.cdt.core.parser.IScannerInfoProvider;
 import org.eclipse.cdt.internal.core.Util;
 import org.eclipse.cdt.internal.core.index.IQueryResult;
 import org.eclipse.cdt.internal.core.index.impl.IFileDocument;
@@ -160,13 +162,19 @@
 						shouldSave = true;
 					if (value == DELETED)
 							this.manager.remove(name, this.dependencyTreePath);
-					else
-						this.manager.addSource((IFile) value, this.dependencyTreePath, ManagedBuildManager.getScannerInfo(project));
+					else{
+						IScannerInfo scanInfo = null;
+						IScannerInfoProvider provider = CCorePlugin.getDefault().getScannerInfoProvider(project);
+						if (provider != null){
+							scanInfo = provider.getScannerInformation(project);
+						}
+						this.manager.addSource((IFile) value, this.dependencyTreePath, scanInfo);
+					}
 				}
 			  }
 			}
 		} catch (/*IO*/Exception e) {
-			if (JobManager.VERBOSE) {
+			if (DependencyManager.VERBOSE) {
 				JobManager.verbose("-> failed to generate tree " + this.project + " because of the following exception:"); //$NON-NLS-1$ //$NON-NLS-2$
 				e.printStackTrace();
 			}
Index: dependency/org/eclipse/cdt/internal/core/sourcedependency/IDependencyTree.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/dependency/org/eclipse/cdt/internal/core/sourcedependency/IDependencyTree.java,v
retrieving revision 1.1
diff -u -r1.1 IDependencyTree.java
--- dependency/org/eclipse/cdt/internal/core/sourcedependency/IDependencyTree.java	24 Jul 2003 14:15:06 -0000	1.1
+++ dependency/org/eclipse/cdt/internal/core/sourcedependency/IDependencyTree.java	8 Sep 2003 05:30:58 -0000
@@ -17,13 +17,14 @@
 import org.eclipse.cdt.core.parser.IScannerInfo;
 import org.eclipse.cdt.internal.core.index.IDocument;
 import org.eclipse.cdt.internal.core.index.IQueryResult;
+import org.eclipse.core.resources.IFile;
 import org.eclipse.core.runtime.IPath;
 
 public interface IDependencyTree {
 	/**
 	 * Adds the given document to the index.
 	 */
-	void add(IDocument document, String docPath, IScannerInfo newInfo) throws IOException;
+	void add(IDocument document, String docPath, IScannerInfo newInfo, IFile file) throws IOException;
 	/**
 	 * Empties the index.
 	 */
Index: dependency/org/eclipse/cdt/internal/core/sourcedependency/PreprocessorOutput.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/dependency/org/eclipse/cdt/internal/core/sourcedependency/PreprocessorOutput.java,v
retrieving revision 1.1
diff -u -r1.1 PreprocessorOutput.java
--- dependency/org/eclipse/cdt/internal/core/sourcedependency/PreprocessorOutput.java	24 Jul 2003 14:15:06 -0000	1.1
+++ dependency/org/eclipse/cdt/internal/core/sourcedependency/PreprocessorOutput.java	8 Sep 2003 05:30:58 -0000
@@ -10,24 +10,32 @@
 ***********************************************************************/
 
 package org.eclipse.cdt.internal.core.sourcedependency;
+import org.eclipse.cdt.core.CCorePlugin;
 import org.eclipse.cdt.core.parser.ast.IASTInclusion;
 import org.eclipse.cdt.internal.core.index.IDocument;
 import org.eclipse.cdt.internal.core.index.impl.IndexedFile;
 import org.eclipse.cdt.internal.core.sourcedependency.impl.InMemoryTree;
+import org.eclipse.core.resources.IFile;
 
 
 public class PreprocessorOutput implements IPreprocessorOutput {
 	protected InMemoryTree tree;
 	protected IndexedFile indexedFile;
 	protected IDocument document;
+	protected IFile file;
 	
-	public PreprocessorOutput(InMemoryTree tree) {
+	public PreprocessorOutput(InMemoryTree tree, IFile file) {
 		this.tree = tree;
+		this.file = file;
 	}
 
 	public void addInclude(IASTInclusion inclusion, IASTInclusion parent){
 		addRef(inclusion.getFullFileName());
 		addRelatives(inclusion.getFullFileName(),(parent != null ) ? parent.getFullFileName() : null);
+	
+		DependencyManager depMan = CCorePlugin.getDefault().getCoreModel().getDependencyManager();
+		depMan.addToTable(inclusion.getFullFileName(),this.file);	
+		
 	}
 	
 	public void addRelatives(String inclusion, String parent) {
Index: dependency/org/eclipse/cdt/internal/core/sourcedependency/RemoveFromDependencyTree.java
===================================================================
RCS file: dependency/org/eclipse/cdt/internal/core/sourcedependency/RemoveFromDependencyTree.java
diff -N dependency/org/eclipse/cdt/internal/core/sourcedependency/RemoveFromDependencyTree.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ dependency/org/eclipse/cdt/internal/core/sourcedependency/RemoveFromDependencyTree.java	8 Sep 2003 05:30:58 -0000
@@ -0,0 +1,58 @@
+/*
+ * Created on Sep 5, 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 java.io.IOException;
+
+import org.eclipse.cdt.internal.core.search.indexing.ReadWriteMonitor;
+import org.eclipse.cdt.internal.core.search.processing.JobManager;
+import org.eclipse.core.runtime.IPath;
+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 RemoveFromDependencyTree extends DependencyRequest {
+	String resourceName;
+
+		public RemoveFromDependencyTree(String resourceName, IPath dependencyTreePath, DependencyManager manager) {
+			super(dependencyTreePath, manager);
+			this.resourceName = resourceName;
+		}
+	
+		public boolean execute(IProgressMonitor progressMonitor) {
+
+			if (progressMonitor != null && progressMonitor.isCanceled()) return true;
+
+			/* ensure no concurrent write access to index */
+			IDependencyTree depTree = manager.getDependencyTree(this.dependencyTreePath, true, /*reuse index file*/ false /*create if none*/);
+			if (depTree == null) return true;
+			ReadWriteMonitor monitor = manager.getMonitorFor(depTree);
+			if (monitor == null) return true; // index got deleted since acquired
+
+			try {
+				monitor.enterWrite(); // ask permission to write
+				depTree.remove(resourceName);
+			} catch (IOException e) {
+				if (DependencyManager.VERBOSE) {
+					JobManager.verbose("-> failed to remove " + this.resourceName + " from index because of the following exception:"); //$NON-NLS-1$ //$NON-NLS-2$
+					e.printStackTrace();
+				}
+				return false;
+			} finally {
+				monitor.exitWrite(); // free write lock
+			}
+			return true;
+		}
+	
+		public String toString() {
+			return "removing " + this.resourceName + " from dep Tree " + this.dependencyTreePath; //$NON-NLS-1$ //$NON-NLS-2$
+		}
+}
Index: dependency/org/eclipse/cdt/internal/core/sourcedependency/impl/InMemoryTree.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/dependency/org/eclipse/cdt/internal/core/sourcedependency/impl/InMemoryTree.java,v
retrieving revision 1.1
diff -u -r1.1 InMemoryTree.java
--- dependency/org/eclipse/cdt/internal/core/sourcedependency/impl/InMemoryTree.java	24 Jul 2003 14:15:06 -0000	1.1
+++ dependency/org/eclipse/cdt/internal/core/sourcedependency/impl/InMemoryTree.java	8 Sep 2003 05:30:58 -0000
@@ -140,4 +140,11 @@
 	public IndexedFile[] getIndexedFiles(){
 		return this.files.asArray();
 	}
+	
+	/**
+	 * Returns the footprint of the index.
+	 */
+	public long getFootprint() {
+		return this.footprint;
+	}
 }
Index: index/ChangeLog
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/index/ChangeLog,v
retrieving revision 1.15
diff -u -r1.15 ChangeLog
--- index/ChangeLog	5 Sep 2003 18:31:39 -0000	1.15
+++ index/ChangeLog	8 Sep 2003 05:30:58 -0000
@@ -1,3 +1,7 @@
+2003-09-05 Bogdan Gheorghe
+	- Added a separate IndexManager verbose in order to get indepenent
+	  tracing from the DependencyManager (both of which extend JobManager).
+	
 2003-09-05 Andrew Niefer
 	- Modified how AbstractIndexer creates the fully qualified name for an enumerator (spec 7.2-10)
 
Index: index/org/eclipse/cdt/internal/core/search/indexing/AbstractIndexer.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/search/indexing/AbstractIndexer.java,v
retrieving revision 1.15
diff -u -r1.15 AbstractIndexer.java
--- index/org/eclipse/cdt/internal/core/search/indexing/AbstractIndexer.java	5 Sep 2003 18:31:39 -0000	1.15
+++ index/org/eclipse/cdt/internal/core/search/indexing/AbstractIndexer.java	8 Sep 2003 05:30:58 -0000
@@ -273,7 +273,7 @@
 			pos+=tempName.length;				
 		}
 		
-		if (VERBOSE)
+		if (AbstractIndexer.VERBOSE)
 			AbstractIndexer.verbose(new String(result));
 			
 		return result;
@@ -305,7 +305,7 @@
 			pos+=tempName.length;				
 		}
 		
-		if (VERBOSE)
+		if (AbstractIndexer.VERBOSE)
 			AbstractIndexer.verbose(new String(result));
 			
 		return result;
Index: index/org/eclipse/cdt/internal/core/search/indexing/AddFileToIndex.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/search/indexing/AddFileToIndex.java,v
retrieving revision 1.3
diff -u -r1.3 AddFileToIndex.java
--- index/org/eclipse/cdt/internal/core/search/indexing/AddFileToIndex.java	11 Jul 2003 22:12:35 -0000	1.3
+++ index/org/eclipse/cdt/internal/core/search/indexing/AddFileToIndex.java	8 Sep 2003 05:30:59 -0000
@@ -37,7 +37,7 @@
 			monitor.enterWrite(); // ask permission to write
 			if (!indexDocument(index)) return false;
 		} catch (IOException e) {
-			if (JobManager.VERBOSE) {
+			if (IndexManager.VERBOSE) {
 				JobManager.verbose("-> failed to index " + this.resource + " because of the following exception:"); //$NON-NLS-1$ //$NON-NLS-2$
 				e.printStackTrace();
 			}
Index: index/org/eclipse/cdt/internal/core/search/indexing/AddFolderToIndex.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/search/indexing/AddFolderToIndex.java,v
retrieving revision 1.4
diff -u -r1.4 AddFolderToIndex.java
--- index/org/eclipse/cdt/internal/core/search/indexing/AddFolderToIndex.java	12 Aug 2003 20:20:04 -0000	1.4
+++ index/org/eclipse/cdt/internal/core/search/indexing/AddFolderToIndex.java	8 Sep 2003 05:30:59 -0000
@@ -75,7 +75,7 @@
 				IResource.NONE
 			);
 		} catch (CoreException e) {
-			if (JobManager.VERBOSE) {
+			if (IndexManager.VERBOSE) {
 				JobManager.verbose("-> failed to add " + this.folderPath + " to index because of the following exception:"); //$NON-NLS-1$ //$NON-NLS-2$
 				e.printStackTrace();
 			}
Index: index/org/eclipse/cdt/internal/core/search/indexing/IndexAllProject.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/search/indexing/IndexAllProject.java,v
retrieving revision 1.3
diff -u -r1.3 IndexAllProject.java
--- index/org/eclipse/cdt/internal/core/search/indexing/IndexAllProject.java	12 Aug 2003 20:20:04 -0000	1.3
+++ index/org/eclipse/cdt/internal/core/search/indexing/IndexAllProject.java	8 Sep 2003 05:30:59 -0000
@@ -182,14 +182,14 @@
 				this.manager.request(new SaveIndex(this.indexPath, this.manager));
 
 		} catch (CoreException e) {
-			if (JobManager.VERBOSE) {
+			if (IndexManager.VERBOSE) {
 				JobManager.verbose("-> failed to index " + this.project + " because of the following exception:"); //$NON-NLS-1$ //$NON-NLS-2$
 				e.printStackTrace();
 			}
 			this.manager.removeIndex(this.indexPath);
 			return false;
 		} catch (IOException e) {
-			if (JobManager.VERBOSE) {
+			if (IndexManager.VERBOSE) {
 				JobManager.verbose("-> failed to index " + this.project + " because of the following exception:"); //$NON-NLS-1$ //$NON-NLS-2$
 				e.printStackTrace();
 			}
Index: index/org/eclipse/cdt/internal/core/search/indexing/IndexManager.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/search/indexing/IndexManager.java,v
retrieving revision 1.5
diff -u -r1.5 IndexManager.java
--- index/org/eclipse/cdt/internal/core/search/indexing/IndexManager.java	12 Aug 2003 20:20:04 -0000	1.5
+++ index/org/eclipse/cdt/internal/core/search/indexing/IndexManager.java	8 Sep 2003 05:30:59 -0000
@@ -65,6 +65,8 @@
 	public static Integer UNKNOWN_STATE = new Integer(2);
 	public static Integer REBUILDING_STATE = new Integer(3);
 
+	public static boolean VERBOSE = false;
+	
 	public synchronized void aboutToUpdateIndex(IPath path, Integer newIndexState) {
 		// newIndexState is either UPDATING_STATE or REBUILDING_STATE
 		// must tag the index as inconsistent, in case we exit before the update job is started
@@ -127,7 +129,7 @@
 			checksumCalculator.reset();
 			checksumCalculator.update(pathString.getBytes());
 			String fileName = Long.toString(checksumCalculator.getValue()) + ".index"; //$NON-NLS-1$
-			if (VERBOSE)
+			if (IndexManager.VERBOSE)
 				JobManager.verbose("-> index name for " + pathString + " is " + fileName); //$NON-NLS-1$ //$NON-NLS-2$
 			name = getCCorePluginWorkingLocation().append(fileName).toOSString();
 			indexNames.put(path, name);
@@ -168,7 +170,7 @@
 					} catch (IOException e) {
 						// failed to read the existing file or its no longer compatible
 						if (currentIndexState != REBUILDING_STATE) { // rebuild index if existing file is corrupt, unless the index is already being rebuilt
-							if (VERBOSE)
+							if (IndexManager.VERBOSE)
 								JobManager.verbose("-> cannot reuse existing index: "+indexName+" path: "+path.toOSString()); //$NON-NLS-1$ //$NON-NLS-2$
 							rebuildIndex(indexName, path);
 							return null;
@@ -311,7 +313,7 @@
 		Object target = org.eclipse.cdt.internal.core.Util.getTarget(ResourcesPlugin.getWorkspace().getRoot(), path, true);
 		if (target == null) return;
 
-		if (VERBOSE)
+		if (IndexManager.VERBOSE)
 			JobManager.verbose("-> request to rebuild index: "+indexName+" path: "+path.toOSString()); //$NON-NLS-1$ //$NON-NLS-2$
 
 		updateIndexState(indexName, REBUILDING_STATE);
@@ -344,7 +346,7 @@
 
 			// Path is already canonical
 			String indexPath = computeIndexName(path);
-			if (VERBOSE)
+			if (IndexManager.VERBOSE)
 				JobManager.verbose("-> recreating index: "+indexPath+" for path: "+path.toOSString()); //$NON-NLS-1$ //$NON-NLS-2$
 			index = new Index(indexPath, "Index for " + path.toOSString(), false /*reuse index file*/); //$NON-NLS-1$
 			indexes.put(path, index);
@@ -352,7 +354,7 @@
 			return index;
 		} catch (IOException e) {
 			// The file could not be created. Possible reason: the project has been deleted.
-			if (VERBOSE) {
+			if (IndexManager.VERBOSE) {
 				JobManager.verbose("-> failed to recreate index for path: "+path.toOSString()); //$NON-NLS-1$ //$NON-NLS-2$
 				e.printStackTrace();
 			}
@@ -371,7 +373,7 @@
 	 * This is a no-op if the index did not exist.
 	 */
 	public synchronized void removeIndex(IPath path) {
-		if (VERBOSE)
+		if (IndexManager.VERBOSE)
 			JobManager.verbose("removing index " + path); //$NON-NLS-1$
 		String indexName = computeIndexName(path);
 		File indexFile = new File(indexName);
@@ -439,7 +441,7 @@
 	public void saveIndex(IIndex index) throws IOException {
 		// must have permission to write from the write monitor
 		if (index.hasChanged()) {
-			if (VERBOSE)
+			if (IndexManager.VERBOSE)
 				JobManager.verbose("-> saving index " + index.getIndexFile()); //$NON-NLS-1$
 			index.save();
 		}
@@ -479,7 +481,7 @@
 				try {
 					saveIndex(index);
 				} catch(IOException e){
-					if (VERBOSE) {
+					if (IndexManager.VERBOSE) {
 						JobManager.verbose("-> got the following exception while saving:"); //$NON-NLS-1$
 						e.printStackTrace();
 					}
@@ -493,7 +495,7 @@
 	}
 	
 	public void shutdown() {
-		if (VERBOSE)
+		if (IndexManager.VERBOSE)
 			JobManager.verbose("Shutdown"); //$NON-NLS-1$
 		//Get index entries for all projects in the workspace, store their absolute paths
 		IndexSelector indexSelector = new IndexSelector(new CWorkspaceScope(), null, false, this);
@@ -523,7 +525,7 @@
 				for (int i = 0, indexesFilesLength = indexesFiles.length; i < indexesFilesLength; i++) {
 					String fileName = indexesFiles[i].getAbsolutePath();
 					if (!knownPaths.containsKey(fileName) && fileName.toLowerCase().endsWith(".index")) { //$NON-NLS-1$
-						if (VERBOSE)
+						if (IndexManager.VERBOSE)
 							JobManager.verbose("Deleting index file " + indexesFiles[i]); //$NON-NLS-1$
 						indexesFiles[i].delete();
 					}
@@ -549,7 +551,7 @@
 		try {
 			return org.eclipse.cdt.internal.core.Util.getFileCharContent(savedIndexNamesFile, null);
 		} catch (IOException ignored) {
-			if (VERBOSE)
+			if (IndexManager.VERBOSE)
 				JobManager.verbose("Failed to read saved index file names"); //$NON-NLS-1$
 			return new char[0];
 		}
@@ -577,7 +579,7 @@
 				}
 			}
 		} catch (IOException ignored) {
-			if (VERBOSE)
+			if (IndexManager.VERBOSE)
 				JobManager.verbose("Failed to write saved index file names"); //$NON-NLS-1$
 		} finally {
 			if (writer != null) {
@@ -586,7 +588,7 @@
 				} catch (IOException e) {}
 			}
 		}
-		if (VERBOSE) {
+		if (IndexManager.VERBOSE) {
 			String state = "?"; //$NON-NLS-1$
 			if (indexState == SAVED_STATE) state = "SAVED"; //$NON-NLS-1$
 			else if (indexState == UPDATING_STATE) state = "UPDATING"; //$NON-NLS-1$
Index: index/org/eclipse/cdt/internal/core/search/indexing/RemoveFolderFromIndex.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/search/indexing/RemoveFolderFromIndex.java,v
retrieving revision 1.4
diff -u -r1.4 RemoveFolderFromIndex.java
--- index/org/eclipse/cdt/internal/core/search/indexing/RemoveFolderFromIndex.java	12 Aug 2003 20:20:04 -0000	1.4
+++ index/org/eclipse/cdt/internal/core/search/indexing/RemoveFolderFromIndex.java	8 Sep 2003 05:30:59 -0000
@@ -54,7 +54,7 @@
 				}
 			}
 		} catch (IOException e) {
-			if (JobManager.VERBOSE) {
+			if (IndexManager.VERBOSE) {
 				JobManager.verbose("-> failed to remove " + this.folderPath + " from index because of the following exception:"); //$NON-NLS-1$ //$NON-NLS-2$
 				e.printStackTrace();
 			}
Index: index/org/eclipse/cdt/internal/core/search/indexing/RemoveFromIndex.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/search/indexing/RemoveFromIndex.java,v
retrieving revision 1.2
diff -u -r1.2 RemoveFromIndex.java
--- index/org/eclipse/cdt/internal/core/search/indexing/RemoveFromIndex.java	4 Jul 2003 03:02:07 -0000	1.2
+++ index/org/eclipse/cdt/internal/core/search/indexing/RemoveFromIndex.java	8 Sep 2003 05:30:59 -0000
@@ -40,7 +40,7 @@
 			monitor.enterWrite(); // ask permission to write
 			index.remove(resourceName);
 		} catch (IOException e) {
-			if (JobManager.VERBOSE) {
+			if (IndexManager.VERBOSE) {
 				JobManager.verbose("-> failed to remove " + this.resourceName + " from index because of the following exception:"); //$NON-NLS-1$ //$NON-NLS-2$
 				e.printStackTrace();
 			}
Index: index/org/eclipse/cdt/internal/core/search/indexing/SaveIndex.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/search/indexing/SaveIndex.java,v
retrieving revision 1.2
diff -u -r1.2 SaveIndex.java
--- index/org/eclipse/cdt/internal/core/search/indexing/SaveIndex.java	4 Jul 2003 03:02:07 -0000	1.2
+++ index/org/eclipse/cdt/internal/core/search/indexing/SaveIndex.java	8 Sep 2003 05:30:59 -0000
@@ -39,7 +39,7 @@
 			monitor.enterWrite(); // ask permission to write
 			this.manager.saveIndex(index);
 		} catch (IOException e) {
-			if (JobManager.VERBOSE) {
+			if (IndexManager.VERBOSE) {
 				JobManager.verbose("-> failed to save index " + this.indexPath + " because of the following exception:"); //$NON-NLS-1$ //$NON-NLS-2$
 				e.printStackTrace();
 			}
Index: index/org/eclipse/cdt/internal/core/search/indexing/SourceIndexer.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/search/indexing/SourceIndexer.java,v
retrieving revision 1.8
diff -u -r1.8 SourceIndexer.java
--- index/org/eclipse/cdt/internal/core/search/indexing/SourceIndexer.java	26 Aug 2003 19:15:58 -0000	1.8
+++ index/org/eclipse/cdt/internal/core/search/indexing/SourceIndexer.java	8 Sep 2003 05:30:59 -0000
@@ -83,7 +83,10 @@
 		try{
 			boolean retVal = parser.parse();
 			
-			if (VERBOSE){
+			if (!retVal)
+				org.eclipse.cdt.internal.core.model.Util.log(null, "Failed to index " + resourceFile.getFullPath());
+			
+			if (AbstractIndexer.VERBOSE){
 				if (!retVal)
 					AbstractIndexer.verbose("PARSE FAILED " + resourceFile.getName().toString());
 				else
Index: model/org/eclipse/cdt/internal/core/model/DeltaProcessor.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/DeltaProcessor.java,v
retrieving revision 1.13
diff -u -r1.13 DeltaProcessor.java
--- model/org/eclipse/cdt/internal/core/model/DeltaProcessor.java	24 Jul 2003 14:15:06 -0000	1.13
+++ model/org/eclipse/cdt/internal/core/model/DeltaProcessor.java	8 Sep 2003 05:30:59 -0000
@@ -5,6 +5,10 @@
  * All Rights Reserved.
  */
 
+import java.util.ArrayList;
+import java.util.Iterator;
+
+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;
@@ -14,15 +18,19 @@
 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.parser.IScannerInfo;
+import org.eclipse.cdt.core.parser.IScannerInfoProvider;
+import org.eclipse.cdt.core.search.ICSearchConstants;
+import org.eclipse.cdt.internal.core.search.indexing.IndexManager;
+import org.eclipse.cdt.internal.core.sourcedependency.DependencyManager;
+import org.eclipse.cdt.internal.core.sourcedependency.DependencyQueryJob;
 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.cdt.internal.core.search.indexing.IndexManager;
-import org.eclipse.cdt.internal.core.sourcedependency.DependencyManager;
-
 /**
  * This class is used by <code>CModelManager</code> to convert
  * <code>IResourceDelta</code>s into <code>ICElementDelta</code>s.
@@ -424,6 +432,9 @@
 					if (element != null) {
 						elementChanged(element, delta);
 						updateIndexAddResource(element, delta);
+						//check to see if any projects need to be reindexed
+						updateDependencies(element);
+						
 					}
 				} else if (resource.getType() == IResource.PROJECT) {
 					if ((flags & IResourceDelta.OPEN) != 0) {
@@ -462,11 +473,20 @@
 	    switch (element.getElementType()) {
 			case ICElement.C_PROJECT :
 					this.indexManager.indexAll(element.getCProject().getProject());
+					this.sourceDependencyManager.generateEntireDependencyTree(element.getCProject().getProject());
 					break;
 	
 			case ICElement.C_UNIT:
 				IFile file = (IFile) delta.getResource();
-				indexManager.addSource(file, file.getProject().getProject().getFullPath());
+				IProject filesProject = file.getProject();
+				indexManager.addSource(file, filesProject.getFullPath());
+				cleanDependencies(file, filesProject);
+				IScannerInfo scanInfo = null;
+				IScannerInfoProvider provider = CCorePlugin.getDefault().getScannerInfoProvider(filesProject);
+				if (provider != null){
+					scanInfo = provider.getScannerInformation(filesProject);
+				}
+				this.sourceDependencyManager.addSource(file,filesProject.getFullPath(),scanInfo);
 				break;						
 	    }
 		
@@ -482,6 +502,7 @@
 			case ICElement.C_PROJECT :
 						this.indexManager.removeIndexFamily(element.getCProject().getProject().getFullPath());
 						// NB: Discarding index jobs belonging to this project was done during PRE_DELETE
+						this.sourceDependencyManager.removeTree(element.getCProject().getProject().getFullPath());
 						break;
 						// NB: Update of index if project is opened, closed, or its c nature is added or removed
 						//     is done in updateCurrentDeltaAndIndex
@@ -489,9 +510,53 @@
 			case ICElement.C_UNIT:
 						IFile file = (IFile) delta.getResource();
 						indexManager.remove(file.getFullPath().toString(), file.getProject().getProject().getFullPath());
+						sourceDependencyManager.remove(file.getFullPath().toString(),file.getProject().getFullPath());
 						break;				
 		}
 	
 
+	}
+	
+	private void updateDependencies(ICElement element){
+		//Update table
+		String fileExtension = element.getResource().getFileExtension();
+		if (fileExtension.equals("h") ||
+			fileExtension.equals("hh") ||
+			fileExtension.equals("hpp")){
+		
+			if (sourceDependencyManager.getProjectDependsForFile(element.getResource().getLocation().toOSString()) == null){
+				//retrigger dep trees
+				 sourceDependencyManager.performConcurrentJob(new DependencyQueryJob(null,null,sourceDependencyManager,null),ICSearchConstants.WAIT_UNTIL_READY_TO_SEARCH,null);
+			}
+			
+			ArrayList projs =sourceDependencyManager.getProjectDependsForFile(element.getResource().getLocation().toOSString());
+			if (projs != null){
+				Iterator iter = projs.iterator();
+				while (iter.hasNext()){
+					IPath pathToReindex = (IPath) iter.next();
+					
+					IWorkspaceRoot workRoot = element.getCProject().getProject().getWorkspace().getRoot();
+					IFile fileToReindex = workRoot.getFileForLocation(pathToReindex);
+					
+					if (fileToReindex.exists() ) {
+						if (VERBOSE)
+						 System.out.println("Going to reindex " + fileToReindex.getName());
+						this.indexManager.addSource(fileToReindex,fileToReindex.getProject().getProject().getFullPath());
+					}
+				}
+			}
+		}
+	}
+	
+	private void cleanDependencies(IFile file, IProject filesProject) {
+		String[] files = sourceDependencyManager.getFileDependencies(filesProject,file);
+		if (files != null){
+			for (int i=0; i<files.length; i++){
+			 if (VERBOSE)
+			  System.out.println("Table Clean Up : " + files[i]+ " removing " + file.getName());
+			  sourceDependencyManager.removeFromTable(files[i],file.getLocation());
+			}
+		}
+		
 	}
 }
Index: parser/ChangeLog
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/parser/ChangeLog,v
retrieving revision 1.113
diff -u -r1.113 ChangeLog
--- parser/ChangeLog	5 Sep 2003 19:24:11 -0000	1.113
+++ parser/ChangeLog	8 Sep 2003 05:30:59 -0000
@@ -1,3 +1,7 @@
+2003-09-05 Bogdan Gheorghe
+	Added ScannerExceptions in Preprocessor.java to PDE Error 
+	Log
+	
 2003-09-05 John Camelon
 	Continue to add support for parsing within function bodies.  
 	Add workaround for 1.2 for inline function declaration-before-use chicken-and-egg.
Index: parser/org/eclipse/cdt/internal/core/parser/Preprocessor.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/Preprocessor.java,v
retrieving revision 1.5
diff -u -r1.5 Preprocessor.java
--- parser/org/eclipse/cdt/internal/core/parser/Preprocessor.java	18 Jul 2003 16:39:22 -0000	1.5
+++ parser/org/eclipse/cdt/internal/core/parser/Preprocessor.java	8 Sep 2003 05:30:59 -0000
@@ -47,6 +47,8 @@
 		catch( ScannerException se )
 		{
 			// callback IProblem here
+			org.eclipse.cdt.internal.core.model.Util.log(se, "Preprocessor Exception"); //$NON-NLS-1$h
+			
 		}
 		catch( EndOfFile eof )
 		{
Index: src/org/eclipse/cdt/core/CCorePlugin.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/src/org/eclipse/cdt/core/CCorePlugin.java,v
retrieving revision 1.28
diff -u -r1.28 CCorePlugin.java
--- src/org/eclipse/cdt/core/CCorePlugin.java	3 Sep 2003 20:34:14 -0000	1.28
+++ src/org/eclipse/cdt/core/CCorePlugin.java	8 Sep 2003 05:31:00 -0000
@@ -31,6 +31,7 @@
 import org.eclipse.cdt.internal.core.search.indexing.IndexManager;
 import org.eclipse.cdt.internal.core.search.indexing.SourceIndexer;
 import org.eclipse.cdt.internal.core.search.matching.MatchLocator;
+import org.eclipse.cdt.internal.core.search.processing.JobManager;
 import org.eclipse.cdt.internal.core.sourcedependency.DependencyManager;
 import org.eclipse.core.resources.IProject;
 import org.eclipse.core.resources.IProjectDescription;
@@ -845,6 +846,7 @@
 	 * Configure the plugin with respect to option settings defined in ".options" file
 	 */
 	public void configurePluginDebugOptions(){
+		
 		if(CCorePlugin.getDefault().isDebugging()){
 			String option = Platform.getDebugOption(PARSER);
 			if(option != null) Util.VERBOSE_PARSER = option.equalsIgnoreCase("true") ; //$NON-NLS-1$
@@ -852,11 +854,19 @@
 			option = Platform.getDebugOption(MODEL);
 			if(option != null) Util.VERBOSE_MODEL = option.equalsIgnoreCase("true") ; //$NON-NLS-1$
 
+			boolean depFlag = false;
 			option = Platform.getDebugOption(DEPENDENCY);
-			if(option != null) DependencyManager.VERBOSE = option.equalsIgnoreCase("true") ; //$NON-NLS-1$
-		
+			if(option != null){
+				depFlag = option.equalsIgnoreCase("true"); 
+				DependencyManager.VERBOSE = depFlag;
+			}//$NON-NLS-1$
+			
+			boolean indexFlag = false;
 			option = Platform.getDebugOption(INDEX_MANAGER);
-			if(option != null) IndexManager.VERBOSE = option.equalsIgnoreCase("true") ; //$NON-NLS-1$
+			if(option != null) {
+				indexFlag = option.equalsIgnoreCase("true");
+				IndexManager.VERBOSE = indexFlag;
+			} //$NON-NLS-1$
 			
 			option = Platform.getDebugOption(INDEXER);
 			if(option != null) SourceIndexer.VERBOSE = option.equalsIgnoreCase("true") ; //$NON-NLS-1$
@@ -867,6 +877,10 @@
 			option = Platform.getDebugOption(MATCH_LOCATOR);
 			if(option != null) MatchLocator.VERBOSE = option.equalsIgnoreCase("true") ; //$NON-NLS-1$
 			
+			if (indexFlag == true ||
+			    depFlag == true){
+			   JobManager.VERBOSE = true; 	
+			}
 		}
 	}
 }
Index: ChangeLog
===================================================================
RCS file: /home/tools/org.eclipse.cdt.ui/ChangeLog,v
retrieving revision 1.162
diff -u -r1.162 ChangeLog
--- ChangeLog	5 Sep 2003 18:31:52 -0000	1.162
+++ ChangeLog	8 Sep 2003 05:34:23 -0000
@@ -1,3 +1,6 @@
+2003-09-05 Bogdan Gheorghe
+	- Changed search pop up menu in CEditor and CContentOutlinePage
+	
 2003-09-05 Andrew Niefer
 	C++ Search:
 	  - enable Selected Resource Scope
Index: src/org/eclipse/cdt/internal/ui/CPluginResources.properties
===================================================================
RCS file: /home/tools/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CPluginResources.properties,v
retrieving revision 1.19
diff -u -r1.19 CPluginResources.properties
--- src/org/eclipse/cdt/internal/ui/CPluginResources.properties	5 Sep 2003 18:31:52 -0000	1.19
+++ src/org/eclipse/cdt/internal/ui/CPluginResources.properties	8 Sep 2003 05:34:23 -0000
@@ -294,14 +294,14 @@
 OpenIncludeAction.dialog.message=Select the file to open
 
 # ------- SearchForReferencesAction ---------------
-SearchForReferencesAction.label=Reference&s
-SearchForReferencesAction.tooltip=Search for References to Name in Workspace
-SearchForReferencesAction.description=Searches for references to name in workspace
+SearchForReferencesAction.label=File Search
+SearchForReferencesAction.tooltip=Performs a text based file search for element in workspace
+SearchForReferencesAction.description=Performs a text based file search for element in workspace
 
 # ------- SearchDialogAction ---------------
-SearchDialogAction.label=C++ Search Dialog
-SearchDialogAction.tooltip=Opens Search Dialog
-SearchDialogAction.description=Opens Search Dialog
+SearchDialogAction.label=C/C++ Search Dialog
+SearchDialogAction.tooltip=Opens C/C++ Search Dialog
+SearchDialogAction.description=Opens C/C++ Search Dialog
 
 
 # ------- LexicalSortingAction------------
Index: src/org/eclipse/cdt/internal/ui/editor/SearchForReferencesAction.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/SearchForReferencesAction.java,v
retrieving revision 1.4
diff -u -r1.4 SearchForReferencesAction.java
--- src/org/eclipse/cdt/internal/ui/editor/SearchForReferencesAction.java	21 Apr 2003 16:21:00 -0000	1.4
+++ src/org/eclipse/cdt/internal/ui/editor/SearchForReferencesAction.java	8 Sep 2003 05:34:23 -0000
@@ -46,7 +46,7 @@
 		
 		if(provider instanceof CContentOutlinePage) {
 			CPluginImages.setImageDescriptors(this, CPluginImages.T_LCL, CPluginImages.IMG_MENU_OPEN_INCLUDE);
-			setText("Search for References"); // $NON-NLS
+			//setText("Search for References"); // $NON-NLS
 		}
 		
 		fSelectionProvider= provider;

Back to the top