Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[cdt-patch] Fixes for 43099, 43100, 42400, 42717


This patch integrates the dependency calculator into the indexer. As a result the underlying indexer file storage format has changes so please delete the .metadata folder from your CDT workspace to avoid having any weird results with search/code complete. Lots of detail in the change logs of exactly what changed...

This patch has been tested on Windows and Linux.

43099  -  Dep Tree Persistence
43100 - Dep Tree/Indexer Concurrency Problem
42400 - junit error on linux for indexer tests
42717 - UI: Context menus for search

- Bogdan


Index: ChangeLog
===================================================================
RCS file: /home/tools/org.eclipse.cdt.managedbuilder.core/ChangeLog,v
retrieving revision 1.5
diff -u -r1.5 ChangeLog
--- ChangeLog	25 Sep 2003 03:19:24 -0000	1.5
+++ ChangeLog	25 Sep 2003 23:40:53 -0000
@@ -1,3 +1,11 @@
+2003-09-25 Bogdan Gheorghe
+	Modified ResourceDeltaVisitor.visit() to use the new mechanism to get the
+	projects that dependend a file.
+	
+	Modified addSourceDependencies() to use the new mechanism to perform a DependencyQueryJob
+	
+	* src/org/eclipse/cdt/managedbuilder/internal/core/MakeFileGenerator.java
+	
 2003-09-24 Sean Evoy
 	Changed the implementor of IScannerInfo to answer only absolute paths when asked for 
 	includes paths. Users will specify the includes paths in the managed build UI in such a way
Index: src/org/eclipse/cdt/managedbuilder/internal/core/MakefileGenerator.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/MakefileGenerator.java,v
retrieving revision 1.3
diff -u -r1.3 MakefileGenerator.java
--- src/org/eclipse/cdt/managedbuilder/internal/core/MakefileGenerator.java	22 Sep 2003 02:32:08 -0000	1.3
+++ src/org/eclipse/cdt/managedbuilder/internal/core/MakefileGenerator.java	25 Sep 2003 23:40:54 -0000
@@ -17,14 +17,19 @@
 import java.util.List;
 import java.util.ListIterator;
 
-import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo;
-import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
-import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin;
 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.model.Util;
-import org.eclipse.cdt.internal.core.sourcedependency.DependencyManager;
+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.sourcedependency.DependencyQueryJob;
+import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo;
+import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
+import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin;
 import org.eclipse.core.resources.IContainer;
 import org.eclipse.core.resources.IFile;
 import org.eclipse.core.resources.IFolder;
@@ -160,13 +165,24 @@
 								// Here's the container
 								generator.appendModifiedSubdirectory(resource);
 								// and all the dependents
-								DependencyManager depMgr = CCorePlugin.getDefault().getCoreModel().getDependencyManager();
-								List deps = depMgr.getProjectDependsForFile(resource.getLocation().toOSString());
-								if (deps != null) {
-									ListIterator iter = deps.listIterator();
-									while (iter.hasNext()) {
+								PathCollector pathCollector = new PathCollector();
+								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[] deps = pathCollector.getPaths();
+								 if (deps.length > 0 ) {
+								 	for (int i=0; i<deps.length; i++){
 										generator.appendModifiedSubdirectory(resource);
-									}
+								 	}
 								}
 								// A build should run						
 								generator.shouldRunBuild(true);
@@ -240,7 +256,7 @@
 		// Create the buffer to hold the output for the module and a dep calculator
 		StringBuffer buffer = new StringBuffer();
 		buffer.append(ManagedBuilderCorePlugin.getResourceString(AUTO_DEP) + NEWLINE);
-		DependencyManager dependencyManager = CCorePlugin.getDefault().getCoreModel().getDependencyManager();
+		IndexManager indexManager = CCorePlugin.getDefault().getCoreModel().getIndexManager();
 
 		/*
 		 * Visit each resource in the folder that we have a rule to build.
@@ -264,7 +280,7 @@
 					// ASk the dep generator to find all the deps for this resource
 					ArrayList dependencies = new ArrayList();
 					try {
-						dependencyManager.performConcurrentJob(new DependencyQueryJob(project, (IFile)resource, dependencyManager, dependencies), ICSearchConstants.WAIT_UNTIL_READY_TO_SEARCH, null);
+						indexManager.performConcurrentJob(new DependencyQueryJob(project, (IFile)resource, indexManager, dependencies), ICSearchConstants.WAIT_UNTIL_READY_TO_SEARCH, null);
 					} catch (Exception e) {
 						continue;
 					}
Index: ChangeLog
===================================================================
RCS file: /home/tools/org.eclipse.cdt.ui/ChangeLog,v
retrieving revision 1.191
diff -u -r1.191 ChangeLog
--- ChangeLog	25 Sep 2003 19:51:42 -0000	1.191
+++ ChangeLog	25 Sep 2003 23:41:09 -0000
@@ -1,3 +1,10 @@
+2003-09-25 Bogdan Gheorghe
+	Deleted the remaining CProjectPropertyPage artifacts.
+	
+	* src/org/eclipse/cdt/internal/ui/preferences/CProjectOptionBlock.java
+	* src/org/eclipse/cdt/internal/ui/preferences/CProjectPropertyPage.java
+	* src/org/eclipse/cdt/ui/dialogs/IndexerBlock.java	
+	
 2003-09-25 Hoda Amer
 	Solution to bug#43646: Code Assist won't work if missing end bracket
 
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.23
diff -u -r1.23 CPluginResources.properties
--- src/org/eclipse/cdt/internal/ui/CPluginResources.properties	18 Sep 2003 19:46:12 -0000	1.23
+++ src/org/eclipse/cdt/internal/ui/CPluginResources.properties	25 Sep 2003 23:41:09 -0000
@@ -305,7 +305,7 @@
 
 
 # ------- SearchDialogAction ---------------
-SearchDialogAction.label=C/C++ Search Dialog...
+SearchDialogAction.label=C/C++ Search...
 SearchDialogAction.tooltip=Opens C/C++ Search Dialog
 SearchDialogAction.description=Opens C/C++ Search Dialog
 
Index: src/org/eclipse/cdt/internal/ui/preferences/CProjectOptionBlock.java
===================================================================
RCS file: src/org/eclipse/cdt/internal/ui/preferences/CProjectOptionBlock.java
diff -N src/org/eclipse/cdt/internal/ui/preferences/CProjectOptionBlock.java
--- src/org/eclipse/cdt/internal/ui/preferences/CProjectOptionBlock.java	23 Sep 2003 15:17:20 -0000	1.2
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,25 +0,0 @@
-/*
- * Created on 7-Aug-2003
- *
- * Copyright (c) 2002,2003 QNX Software Systems Ltd.
- * 
- * Contributors: 
- * QNX Software Systems - Initial API and implementation
-***********************************************************************/
-package org.eclipse.cdt.internal.ui.preferences;
-
-import org.eclipse.cdt.ui.dialogs.ICOptionContainer;
-import org.eclipse.cdt.ui.dialogs.IndexerBlock;
-import org.eclipse.cdt.ui.dialogs.TabFolderOptionBlock;
-//TODO: BOG UI Get rid before final 1.2
-public class CProjectOptionBlock extends TabFolderOptionBlock {
-
-	public CProjectOptionBlock(ICOptionContainer parent) {
-		super(parent);
-	}
-
-	protected void addTabs() {
-		addTab(new IndexerBlock());
-	}
-
-}
Index: src/org/eclipse/cdt/internal/ui/preferences/CProjectPropertyPage.java
===================================================================
RCS file: src/org/eclipse/cdt/internal/ui/preferences/CProjectPropertyPage.java
diff -N src/org/eclipse/cdt/internal/ui/preferences/CProjectPropertyPage.java
--- src/org/eclipse/cdt/internal/ui/preferences/CProjectPropertyPage.java	23 Sep 2003 15:17:20 -0000	1.11
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,120 +0,0 @@
-package org.eclipse.cdt.internal.ui.preferences;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import java.lang.reflect.InvocationTargetException;
-
-import org.eclipse.cdt.ui.CUIPlugin;
-import org.eclipse.cdt.ui.dialogs.ICOptionContainer;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.jface.dialogs.ProgressMonitorDialog;
-import org.eclipse.jface.operation.IRunnableWithProgress;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.layout.FillLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.actions.WorkspaceModifyDelegatingOperation;
-import org.eclipse.ui.dialogs.PropertyPage;
-//TODO: BOG UI Get rid before final 1.2
-public class CProjectPropertyPage extends PropertyPage implements ICOptionContainer {
-
-	private CProjectOptionBlock fOptionBlock;
-
-	private static final String MSG_CLOSEDPROJECT = "CProjectPropertyPage.closedproject";
-
-	public CProjectPropertyPage() {
-		super();
-		fOptionBlock = new CProjectOptionBlock(this);
-	}
-
-	protected Control createContents(Composite parent) {
-		Composite composite = new Composite(parent, SWT.NONE);
-		composite.setLayout(new FillLayout());
-
-		IProject project = getProject();
-		if (!project.isOpen()) {
-			contentForClosedProject(composite);
-		} else {
-			contentForCProject(composite);
-		}
-
-		return composite;
-	}
-	private void contentForCProject(Composite parent) {
-		fOptionBlock.createContents(parent);
-		//		WorkbenchHelp.setHelp(parent, ICMakeHelpContextIds.PROJECT_PROPERTY_PAGE);	
-	}
-
-	private void contentForClosedProject(Composite parent) {
-		Label label = new Label(parent, SWT.LEFT);
-		label.setText(CUIPlugin.getResourceString(MSG_CLOSEDPROJECT));
-		label.setFont(parent.getFont());
-
-		noDefaultAndApplyButton();
-	}
-	/**
-		 * @see PreferencePage#performOk
-		 */
-	public boolean performOk() {
-		Shell shell = getControl().getShell();
-		IRunnableWithProgress runnable = new IRunnableWithProgress() {
-			public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
-				fOptionBlock.performApply(monitor);
-			}
-		};
-		IRunnableWithProgress op = new WorkspaceModifyDelegatingOperation(runnable);
-		try {
-			new ProgressMonitorDialog(shell).run(false, true, op);
-		} catch (InvocationTargetException e) {
-			return false;
-		} catch (InterruptedException e) {
-			// cancelled
-			return false;
-		}
-		return true;
-	}
-
-	public IProject getProject() {
-		Object element = getElement();
-		if (element instanceof IProject) {
-			return (IProject) element;
-		}
-		return null;
-	}
-
-	/**
-	 * @see DialogPage#setVisible(boolean)
-	 */
-	public void setVisible(boolean visible) {
-		super.setVisible(visible);
-		fOptionBlock.setVisible(visible);
-	}
-
-	public void updateContainer() {
-		boolean ok = true;
-		ok = fOptionBlock.isValid();
-		if (!ok) {
-			setErrorMessage(fOptionBlock.getErrorMessage());
-		}
-		if (ok) {
-			setErrorMessage(null);
-		}
-		setValid(ok);
-	}
-
-	protected void performDefaults() {
-		fOptionBlock.performDefaults();
-		super.performDefaults();
-	}
-
-	public boolean isValid() {
-		updateContainer();
-		return super.isValid();
-	}
-}
Index: src/org/eclipse/cdt/ui/dialogs/IndexerBlock.java
===================================================================
RCS file: src/org/eclipse/cdt/ui/dialogs/IndexerBlock.java
diff -N src/org/eclipse/cdt/ui/dialogs/IndexerBlock.java
--- src/org/eclipse/cdt/ui/dialogs/IndexerBlock.java	23 Sep 2003 15:17:20 -0000	1.3
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,87 +0,0 @@
-package org.eclipse.cdt.ui.dialogs;
-/***********************************************************************
- * Copyright (c) 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials 
- * are made available under the terms of the Common Public License v0.5 
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
- * 
- * Contributors:
- * QNX Software Systems - Initial API and implementation
-***********************************************************************/
-
-import org.eclipse.cdt.core.CCorePlugin;
-import org.eclipse.cdt.internal.core.search.indexing.IndexManager;
-import org.eclipse.cdt.internal.core.sourcedependency.DependencyManager;
-import org.eclipse.cdt.ui.CUIPlugin;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-//TODO: BOG UI Get rid before final 1.2
-public class IndexerBlock extends AbstractCOptionPage {
-	private static final String PREFIX = "IndexerBlock"; // $NON-NLS-1$
-	private static final String LABEL = PREFIX + ".label"; // $NON-NLS-1$
-	private static final String DESC = PREFIX + ".desc"; // $NON-NLS-1$
-
-	private Button indexerSwitch2;
-	private Button dTreeSwitch;
-
-	public IndexerBlock() {
-		super(CUIPlugin.getResourceString(LABEL));
-		setDescription(CUIPlugin.getResourceString(DESC));
-	}
-
-	public void createControl(Composite parent) {
-		Composite composite = new Composite(parent, SWT.NONE);
-		GridLayout grid = new GridLayout();
-		grid.numColumns = 1;
-		composite.setLayout(grid);
-
-		indexerSwitch2 = new Button(composite, SWT.CHECK | SWT.RIGHT);
-		indexerSwitch2.setAlignment(SWT.LEFT);
-		indexerSwitch2.setText("Enable NEW indexing service for this project");
-
-		dTreeSwitch = new Button(composite, SWT.CHECK | SWT.RIGHT);
-		dTreeSwitch.setAlignment(SWT.LEFT);
-		dTreeSwitch.setText("Enable dependency tree service for this project");
-
-		IProject project = getContainer().getProject();
-		if (project != null) {
-			
-//			IndexManager newIndexer = CCorePlugin.getDefault().getCoreModel().getIndexManager();
-//			
-//			if (indexerSwitch2 != null) {
-//				indexerSwitch2.setSelection(newIndexer.isEnabled(project));
-//			}
-
-//			DependencyManager depManager = CCorePlugin.getDefault().getCoreModel().getDependencyManager();
-//
-//			if (dTreeSwitch != null) {
-//				dTreeSwitch.setSelection(depManager.isEnabled(project));
-//			}
-		}
-		setControl(composite);
-	}
-
-	public void performApply(IProgressMonitor monitor) throws CoreException {
-		IProject project = getContainer().getProject();
-		if (project != null) {
-//			IndexManager newIndexer = CCorePlugin.getDefault().getCoreModel().getIndexManager();
-//			newIndexer.setEnabled(project, indexerSwitch2.getSelection());
-
-//			DependencyManager depManager = CCorePlugin.getDefault().getCoreModel().getDependencyManager();
-//			depManager.setEnabled(project, dTreeSwitch.getSelection());
-		}
-	}
-
-	public void performDefaults() {
-		if (getContainer().getProject() != null) {
-			indexerSwitch2.setSelection(false);
-			dTreeSwitch.setSelection(false);
-		}
-	}
-}
Index: ChangeLog
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core.tests/ChangeLog,v
retrieving revision 1.115
diff -u -r1.115 ChangeLog
--- ChangeLog	25 Sep 2003 19:51:50 -0000	1.115
+++ ChangeLog	25 Sep 2003 23:40:17 -0000
@@ -1,3 +1,15 @@
+2003-09-25 Bogdan Gheorghe
+	- separated dependency tests from the indexer tests
+	- modified the AutomatedIntegrationSuite to include new dependency
+	  tests
+	- added the following tests: 
+	 * testDepTable
+	 * testDepSourceChangeTree
+	 * testDepHeaderChangeTree
+	 * testDepHeaderChangeReindex
+	 * testDepSourceChangeTable
+	 * testDepHeaderChangeTable
+	 
 2003-09-25 Hoda Amer
 	Enabled CompleteParseASTExpressionTest.testPostfixTypenameIdentifier()
 	
Index: indexer/org/eclipse/cdt/core/indexer/tests/DependencyTests.java
===================================================================
RCS file: indexer/org/eclipse/cdt/core/indexer/tests/DependencyTests.java
diff -N indexer/org/eclipse/cdt/core/indexer/tests/DependencyTests.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ indexer/org/eclipse/cdt/core/indexer/tests/DependencyTests.java	25 Sep 2003 23:40:17 -0000
@@ -0,0 +1,713 @@
+/*
+ * Created on Sep 25, 2003
+ */
+package org.eclipse.cdt.core.indexer.tests;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.FileReader;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.util.ArrayList;
+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;
+
+import org.eclipse.cdt.core.CCProjectNature;
+import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.core.search.ICSearchConstants;
+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.IMatch;
+import org.eclipse.cdt.core.search.SearchEngine;
+import org.eclipse.cdt.internal.core.index.impl.IFileDocument;
+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.sourcedependency.DependencyQueryJob;
+import org.eclipse.cdt.internal.ui.search.CSearchResultCollector;
+import org.eclipse.core.internal.resources.ResourceException;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IProjectDescription;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IWorkspace;
+import org.eclipse.core.resources.IWorkspaceRoot;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Platform;
+
+	/**
+ 	* @author bgheorgh
+ 	*/
+	public class DependencyTests extends TestCase {
+	IFile 					file;
+	IFileDocument 			fileDoc;
+	IProject 				testProject;
+	NullProgressMonitor		monitor;
+	IndexManager 			indexManager;
+	IWorkspace 				workspace;
+	CSearchResultCollector	resultCollector;
+	SearchEngine			searchEngine;
+	ICSearchScope 			scope;
+
+	public static Test suite() {
+		TestSuite suite = new TestSuite(DependencyTests.class.getName());
+
+		suite.addTest(new DependencyTests("testDependencyTree"));
+		suite.addTest(new DependencyTests("testDepTable"));
+		suite.addTest(new DependencyTests("testDepSourceChangeTree"));
+		suite.addTest(new DependencyTests("testDepHeaderChangeTree"));
+		suite.addTest(new DependencyTests("testDepHeaderChangeReindex"));
+		suite.addTest(new DependencyTests("testDepSourceChangeTable"));
+		suite.addTest(new DependencyTests("testDepHeaderChangeTable"));
+		return suite;
+	}
+	/**
+	 * @param name
+	 */
+	public DependencyTests(String name) {
+		super(name);
+		// TODO Auto-generated constructor stub
+	}
+	/*
+	 * @see TestCase#setUp()
+	 */
+	protected void setUp() throws Exception {
+		super.setUp();
+		//Create temp project
+		testProject = createProject("DepTestProject");
+		if (testProject==null)
+			fail("Unable to create project");	
+		
+		indexManager = CCorePlugin.getDefault().getCoreModel().getIndexManager();
+		indexManager.reset();
+		
+		workspace = ResourcesPlugin.getWorkspace();
+		
+		scope = SearchEngine.createWorkspaceScope();
+		monitor = new NullProgressMonitor();
+		resultCollector = new CSearchResultCollector();
+		resultCollector.setProgressMonitor( monitor );
+	
+		searchEngine = new SearchEngine();
+	}
+	/*
+	 * @see TestCase#tearDown()
+	 */
+	protected void tearDown() {
+		try {
+			super.tearDown();
+		} catch (Exception e1) {
+		}
+		//Delete project
+		if (testProject.exists()){
+			try {
+				testProject.delete(true,monitor);
+			} catch (ResourceException e) {
+			} catch (CoreException e) {
+			}
+		}
+	}
+	public void testDependencyTree() throws Exception{
+   //Add a file to the project
+   importFile("c.h","resources/dependency/c.h");
+   importFile("a.h","resources/dependency/a.h");
+   importFile("Inc1.h","resources/dependency/Inc1.h");
+   importFile("DepTest.h","resources/dependency/DepTest.h");
+   importFile("d.h","resources/dependency/d.h");
+   importFile("DepTest2.h","resources/dependency/DepTest2.h");
+   IFile depTest = importFile("DepTest.cpp","resources/dependency/DepTest.cpp");
+   IFile depTest2 = importFile("DepTest2.cpp","resources/dependency/DepTest2.cpp");
+   //Enable indexing on the created project
+   //By doing this, we force the Dependency Manager to do a g()
+
+   IndexManager indexManager = CCorePlugin.getDefault().getCoreModel().getIndexManager();
+   //indexManager.setEnabled(testProject,true);
+   
+
+   String[] depTestModel = {File.separator + "DepTestProject" + File.separator + "d.h", File.separator + "DepTestProject" + File.separator + "Inc1.h", File.separator + "DepTestProject" + File.separator + "c.h", File.separator + "DepTestProject" + File.separator + "a.h", File.separator + "DepTestProject" + File.separator + "DepTest.h"};
+   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);
+
+   String[] depTestModelLocal = convertToLocalPath(depTestModel);
+   String[] depTestIncludes = new String[includes.size()];
+   Iterator includesIterator = includes.iterator();
+   int i=0;
+   while(includesIterator.hasNext()){
+	   depTestIncludes[i] = (String) includesIterator.next();
+	   i++;
+   }
+	
+   if (depTestModelLocal.length != depTestIncludes.length)
+		   fail("Number of included files differsfrom model");
+	
+   Arrays.sort(depTestModelLocal);
+   Arrays.sort(depTestIncludes);
+		
+   for (i=0;i<depTestIncludes.length; i++)
+   {
+	   assertEquals(depTestModelLocal[i],depTestIncludes[i]);
+   }
+	
+   ArrayList includes2 = new ArrayList();
+   indexManager.performConcurrentJob(new DependencyQueryJob(testProject,depTest2,indexManager,includes2),ICSearchConstants.WAIT_UNTIL_READY_TO_SEARCH,null);
+   
+   String[] depTest2ModelLocal = convertToLocalPath(depTest2Model);
+   String[] depTest2Includes = new String[includes2.size()];
+   Iterator includes2Iterator = includes2.iterator();
+   i=0;
+   while(includes2Iterator.hasNext()){
+	   depTest2Includes[i] = (String) includes2Iterator.next();
+	   i++;
+   }
+	
+   if (depTest2ModelLocal.length != depTest2Includes.length)
+		   fail("Number of included files differsfrom model");
+	
+   Arrays.sort(depTest2ModelLocal);
+   Arrays.sort(depTest2Includes);
+	
+   for (i=0;i<depTest2Includes.length; i++)
+   {
+	   assertEquals(depTest2ModelLocal[i],depTest2Includes[i]);
+   }
+ }
+
+ public void testDepTable() throws Exception{
+   //Add a file to the project
+   
+   IFile cH = importFile("c.h","resources/dependency/c.h");
+   IFile aH = importFile("a.h","resources/dependency/a.h");
+   IFile Inc1H = importFile("Inc1.h","resources/dependency/Inc1.h");
+   IFile dH = importFile("d.h","resources/dependency/d.h");
+   IFile depTestH = importFile("DepTest.h","resources/dependency/DepTest.h");
+   IFile depTest2H = importFile("DepTest2.h","resources/dependency/DepTest2.h");
+   IFile depTest2C = importFile("DepTest2.cpp","resources/dependency/DepTest2.cpp");
+   IFile depTestC = importFile("DepTest.cpp","resources/dependency/DepTest.cpp");
+   
+   PathCollector pathCollector = new PathCollector();
+   getTableRefs(dH, pathCollector);
+				
+   String[] dHModel = {IPath.SEPARATOR + "DepTestProject" + IPath.SEPARATOR + "DepTest2.cpp", IPath.SEPARATOR + "DepTestProject" + IPath.SEPARATOR + "DepTest.cpp"};
+   String[] iPath = pathCollector.getPaths();
+	
+   if (dHModel.length != iPath.length)
+	   fail("Number of included files differsfrom model");
+	
+   Arrays.sort(dHModel);
+   Arrays.sort(iPath);
+	
+   for (int i=0;i<iPath.length; i++)
+   {
+	   assertEquals(iPath[i],dHModel[i]);
+   }
+	
+   pathCollector = new PathCollector();
+   getTableRefs(Inc1H, pathCollector);
+				
+   String[] Inc1HModel = {IPath.SEPARATOR + "DepTestProject" + IPath.SEPARATOR + "DepTest.cpp"};
+   iPath = pathCollector.getPaths();
+	
+   if (Inc1HModel.length != iPath.length)
+	   fail("Number of included files differsfrom model");
+	
+   Arrays.sort(Inc1HModel);
+   Arrays.sort(iPath);
+	
+   for (int i=0;i<iPath.length; i++)
+   {
+	   assertEquals(iPath[i],Inc1HModel[i]);
+   }
+ }
+  
+ public void testDepSourceChangeTable() throws Exception{
+
+   //Add a file to the project
+   IFile cH = importFile("c.h","resources/dependency/c.h"); 
+   IFile aH = importFile("a.h","resources/dependency/a.h");
+   IFile Inc1H = importFile("Inc1.h","resources/dependency/Inc1.h");
+   IFile dH = importFile("d.h","resources/dependency/d.h");
+   IFile depTestH = importFile("DepTest.h","resources/dependency/DepTest.h");
+   IFile depTestC = importFile("DepTest.cpp","resources/dependency/DepTest.cpp");
+
+   String[] beforeModel = {Path.SEPARATOR + "DepTestProject" + IPath.SEPARATOR + "DepTest.cpp"};
+	
+   PathCollector pathCollector = new PathCollector();
+   getTableRefs(depTestH, pathCollector);
+				
+   String[] iPath = pathCollector.getPaths();
+	
+   compareArrays(iPath,beforeModel);
+	
+   pathCollector = new PathCollector();
+   getTableRefs(dH, pathCollector);
+				
+   iPath = pathCollector.getPaths();
+		
+   compareArrays(iPath,beforeModel);
+	
+   pathCollector = new PathCollector();
+   getTableRefs(Inc1H, pathCollector);
+				
+   iPath = pathCollector.getPaths();
+		
+   compareArrays(iPath,beforeModel);
+	
+   pathCollector = new PathCollector();
+   getTableRefs(aH, pathCollector);
+			
+   iPath = pathCollector.getPaths();
+	
+   compareArrays(iPath,beforeModel);
+	
+   pathCollector = new PathCollector();
+   getTableRefs(cH, pathCollector);
+			
+   iPath = pathCollector.getPaths();
+	
+   compareArrays(iPath,beforeModel);
+	
+   editCode(depTestC,"#include \"DepTest.h\"","//#include \"DepTest.h\"");
+	
+
+   pathCollector = new PathCollector();
+   getTableRefs(depTestH, pathCollector);
+				
+   iPath = pathCollector.getPaths();
+	
+   if (iPath.length != 0)
+	   fail("Number of included files differs from model");
+	
+	
+   pathCollector = new PathCollector();
+   getTableRefs(dH, pathCollector);
+				
+   iPath = pathCollector.getPaths();
+		
+   compareArrays(iPath,beforeModel);
+	
+   pathCollector = new PathCollector();
+   getTableRefs(Inc1H, pathCollector);
+				
+   iPath = pathCollector.getPaths();
+		
+   if (iPath.length != 0)
+	   fail("Number of included files differs from model");
+	
+   pathCollector = new PathCollector();
+   getTableRefs(aH, pathCollector);
+			
+   iPath = pathCollector.getPaths();
+	
+   if (iPath.length != 0)
+	   fail("Number of included files differs from model");
+	
+	
+   pathCollector = new PathCollector();
+   getTableRefs(cH, pathCollector);
+			
+   iPath = pathCollector.getPaths();
+	
+   if (iPath.length != 0)
+	   fail("Number of included files differs from model");
+
+ }
+  
+ public void testDepSourceChangeTree() throws Exception{
+// Add a file to the project
+	 IFile cH = importFile("c.h","resources/dependency/c.h");
+	 IFile aH = importFile("a.h","resources/dependency/a.h");
+	 IFile Inc1H = importFile("Inc1.h","resources/dependency/Inc1.h");
+	 IFile depTestH = importFile("DepTest.h","resources/dependency/DepTest.h");
+	 IFile dH = importFile("d.h","resources/dependency/d.h");
+	 IFile depTest2H = importFile("DepTest2.h","resources/dependency/DepTest2.h");
+	 IFile depTestC = importFile("DepTest.cpp","resources/dependency/DepTest.cpp");
+	 IFile depTest2C = importFile("DepTest2.cpp","resources/dependency/DepTest2.cpp");
+
+	 IndexManager indexManager = CCorePlugin.getDefault().getCoreModel().getIndexManager();
+	  
+	 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);
+
+	 String[] preDepTestModelLocal = convertToLocalPath(preDepTestModel);
+	 String[] preDepTestIncludes = new String[includes.size()];
+	
+	 Iterator includesIterator = includes.iterator();
+	 int i=0;
+	 while(includesIterator.hasNext()){
+		 preDepTestIncludes[i] = (String) includesIterator.next();
+		 i++;
+	 }
+
+	 if (preDepTestModelLocal.length != preDepTestIncludes.length)
+			 fail("Number of included files differs from model");
+
+	 Arrays.sort(preDepTestModelLocal);
+	 Arrays.sort(preDepTestIncludes);
+	
+	 for (i=0;i<preDepTestIncludes.length; i++){
+		 assertEquals(preDepTestModelLocal[i],preDepTestIncludes[i]);
+	 }
+	
+	 editCode(depTestC,"#include \"DepTest.h\"","//#include \"DepTest.h\"");
+	 String[] postDepTestModel = {File.separator + "DepTestProject" + File.separator + "d.h"};
+	
+	 ArrayList includes2 = new ArrayList();
+
+	 testProject.refreshLocal(IResource.DEPTH_INFINITE,null);
+	
+	 indexManager.performConcurrentJob(new DependencyQueryJob(testProject,depTestC,indexManager,includes2),ICSearchConstants.WAIT_UNTIL_READY_TO_SEARCH,null);
+	
+	
+	 String[] postDepTestModelLocal = convertToLocalPath(postDepTestModel);
+	 String[] postDepTestIncludes = new String[includes2.size()];
+	
+	 Iterator includesIterator2 = includes2.iterator();
+	
+	 int j=0;
+	 while(includesIterator2.hasNext()){
+		 postDepTestIncludes[j] = (String) includesIterator2.next();
+		 j++;
+	 }
+
+	 if (postDepTestModelLocal.length != postDepTestIncludes.length)
+			 fail("Number of included files differs from model");
+
+	 Arrays.sort(postDepTestModelLocal);
+	 Arrays.sort(postDepTestIncludes);
+	
+	 for (i=0;i<postDepTestIncludes.length; i++){
+		 assertEquals(postDepTestModelLocal[i],postDepTestIncludes[i]);
+	 }
+	
+ }
+  
+ public void testDepHeaderChangeTree() throws Exception{
+	 //	Add a file to the project
+	 IFile cH = importFile("c.h","resources/dependency/c.h");
+	 IFile aH = importFile("a.h","resources/dependency/a.h");
+	 IFile depTest3H = importFile("DepTest3.h","resources/dependency/DepTest3.h");
+	 IFile depTest3C = importFile("DepTest3.cpp","resources/dependency/DepTest3.cpp");
+
+	 IndexManager indexManager = CCorePlugin.getDefault().getCoreModel().getIndexManager();
+	  
+	 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);
+
+	 String[] preDepTestModelLocal = convertToLocalPath(preDepTestModel);
+	 String[] preDepTestIncludes = new String[includes.size()];
+	
+	 Iterator includesIterator = includes.iterator();
+	 int i=0;
+	 while(includesIterator.hasNext()){
+		 preDepTestIncludes[i] = (String) includesIterator.next();
+		 i++;
+	 }
+
+	 if (preDepTestModelLocal.length != preDepTestIncludes.length)
+			 fail("Number of included files differs from model");
+
+	 Arrays.sort(preDepTestModelLocal);
+	 Arrays.sort(preDepTestIncludes);
+	
+	 for (i=0;i<preDepTestIncludes.length; i++){
+		 assertEquals(preDepTestModelLocal[i],preDepTestIncludes[i]);
+	 }
+	
+	 editCode(aH,"#include \"c.h\"","//#include \"c.h\"");
+	 String[] postDepTestModel = {File.separator + "DepTestProject" + File.separator + "DepTest3.h", File.separator + "DepTestProject" + File.separator + "a.h"};
+	
+	 ArrayList includes2 = new ArrayList();
+
+	 testProject.refreshLocal(IResource.DEPTH_INFINITE,null);
+	
+	 indexManager.performConcurrentJob(new DependencyQueryJob(testProject,depTest3C,indexManager,includes2),ICSearchConstants.WAIT_UNTIL_READY_TO_SEARCH,null);
+	
+	
+	 String[] postDepTestModelLocal = convertToLocalPath(postDepTestModel);
+	 String[] postDepTestIncludes = new String[includes2.size()];
+	
+	 Iterator includesIterator2 = includes2.iterator();
+	
+	 int j=0;
+	 while(includesIterator2.hasNext()){
+		 postDepTestIncludes[j] = (String) includesIterator2.next();
+		 j++;
+	 }
+
+	 if (postDepTestModelLocal.length != postDepTestIncludes.length)
+			 fail("Number of included files differs from model");
+
+	 Arrays.sort(postDepTestModelLocal);
+	 Arrays.sort(postDepTestIncludes);
+	
+	 for (i=0;i<postDepTestIncludes.length; i++){
+		 assertEquals(postDepTestModelLocal[i],postDepTestIncludes[i]);
+	 }
+	
+ }
+  
+ public void testDepHeaderChangeTable() throws Exception{
+   
+	//	Add a file to the project
+	IFile cH = importFile("c.h","resources/dependency/c.h");
+	IFile aH = importFile("a.h","resources/dependency/a.h");
+	IFile depTest3H = importFile("DepTest3.h","resources/dependency/DepTest3.h");
+	IFile depTest3C = importFile("DepTest3.cpp","resources/dependency/DepTest3.cpp");
+	 
+	String[] beforeModel = {Path.SEPARATOR + "DepTestProject" + IPath.SEPARATOR + "DepTest3.cpp"};
+	
+	PathCollector pathCollector = new PathCollector();
+	getTableRefs(depTest3H, pathCollector);
+				
+	String[] iPath = pathCollector.getPaths();
+	
+	compareArrays(iPath,beforeModel);
+	 
+	pathCollector = new PathCollector();
+	getTableRefs(cH, pathCollector);
+				
+	iPath = pathCollector.getPaths();
+	
+	compareArrays(iPath,beforeModel);
+	
+	pathCollector = new PathCollector();
+	getTableRefs(aH, pathCollector);
+				
+	iPath = pathCollector.getPaths();
+	
+	compareArrays(iPath,beforeModel);
+	
+
+   editCode(aH,"#include \"c.h\"","//#include \"c.h\"");
+	
+   pathCollector = new PathCollector();
+   getTableRefs(depTest3H, pathCollector);
+			
+   iPath = pathCollector.getPaths();
+
+   compareArrays(iPath,beforeModel);
+	
+   pathCollector = new PathCollector();
+   getTableRefs(cH, pathCollector);
+			
+   iPath = pathCollector.getPaths();
+
+   if (iPath.length != 0)
+	   fail("Number of included files differs from model");
+	
+   pathCollector = new PathCollector();
+   getTableRefs(aH, pathCollector);
+			
+   iPath = pathCollector.getPaths();
+
+   compareArrays(iPath,beforeModel);
+   
+ }
+  
+
+ public void testDepHeaderChangeReindex() throws Exception{
+   //	Add a file to the project
+   IFile cH = importFile("c.h","resources/dependency/c.h");
+   IFile aH = importFile("a.h","resources/dependency/a.h");
+   IFile depTest3H = importFile("DepTest3.h","resources/dependency/DepTest3.h");
+   IFile depTest3C = importFile("DepTest3.cpp","resources/dependency/DepTest3.cpp");
+ 	
+   ICSearchPattern pattern = SearchEngine.createSearchPattern( "Z", ICSearchConstants.TYPE, ICSearchConstants.DECLARATIONS, true );
+		
+   search(workspace,pattern,scope,resultCollector);
+ 	
+   Set resultSet = resultCollector.getSearchResults();
+   if (resultSet.size() != 1)
+	   fail("Expected 1 match");
+ 	
+   Iterator iter = resultSet.iterator();
+   IMatch match = (IMatch) iter.next();
+   if (!(match.getName().equals("Z")) && 
+	   (match.getElementType() != 64 ))
+	   fail("Wrong search result");
+   
+   editCode(depTest3H,"#include \"a.h\"","//#include \"a.h\"");
+    
+   search(workspace,pattern,scope,resultCollector);
+ 	
+   resultSet = resultCollector.getSearchResults();
+	
+   if (resultSet.size() != 0)
+		   fail("Expected no matches");
+ }
+
+
+   private String[] convertToLocalPath(String[] model) {
+	   IPath defaultPath = Platform.getLocation();
+	   String[] tempLocalArray = new String[model.length];
+	   for (int i=0;i<model.length;i++){
+		   StringBuffer buffer = new StringBuffer();
+		   buffer.append(defaultPath.toOSString());
+		   buffer.append(model[i]);
+		   tempLocalArray[i]=buffer.toString();
+	   }
+	   return tempLocalArray;
+   }
+	
+   private void getTableRefs(IFile tempFile, PathCollector pathCollector) throws InterruptedException{
+	   
+	   ICSearchScope scope = SearchEngine.createWorkspaceScope();
+	   CSearchPattern pattern = CSearchPattern.createPattern(tempFile.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 );
+   }
+	
+   private void editCode(IFile tempFile, String beforeString, String afterString) throws IOException, CoreException, InterruptedException{
+	   FileReader fileReader = null;
+	   try {
+		   fileReader = new FileReader(tempFile.getLocation().toOSString());
+	   } catch (FileNotFoundException e) {
+		   fail(e.getMessage());
+	   }
+	
+	   BufferedReader buff = new BufferedReader(fileReader);
+	   String tempString;
+	   File tempUtilFile= new File(tempFile.getLocation().toOSString() + "TempFile"); 
+	   FileWriter writer = new FileWriter(tempUtilFile);
+
+	   try {
+			  while ((tempString = buff.readLine())!= null ) {
+			   if (tempString.equals(beforeString)){
+				   writer.write(afterString + "\n" );
+				   writer.flush();
+			   }
+			   else{
+				   writer.write(tempString + "\n" );
+				   writer.flush();
+			   }
+				
+			  }
+	   } catch (IOException e1) {
+		   fail(e1.getMessage());
+	   }		  
+	   writer.close();
+	
+	   FileInputStream buff2 = new FileInputStream(tempUtilFile);
+	   tempFile.setContents(buff2,true,false,null);
+	   tempFile.refreshLocal(IResource.DEPTH_INFINITE, null);
+	   //buff2.close();
+		
+		
+   }
+	
+   private void compareArrays(String[] first, String[] second){
+		
+	   if (first.length != second.length)
+			   fail("Number of included files differs from model");
+	
+	   Arrays.sort(first);
+	   Arrays.sort(second);
+
+	   for (int i=0;i<first.length; i++)
+	   {
+		   assertEquals(first[i],second[i]);
+	   }
+   }
+	
+   protected void search(IWorkspace workspace, ICSearchPattern pattern, ICSearchScope scope, ICSearchResultCollector collector) {
+	   resultCollector.setProgressMonitor( monitor );
+	   searchEngine.search( workspace, pattern, scope, collector, false );
+   }
+   
+   /*
+	* Utils
+	*/
+   private IProject createProject(String projectName) throws CoreException
+   {
+	  IWorkspaceRoot root= ResourcesPlugin.getWorkspace().getRoot();
+	  IProject project= root.getProject(projectName);
+	  IProject cproject = null;
+	  try{
+		  if (!project.exists()) {
+			project.create(null);
+		  } else {
+			project.refreshLocal(IResource.DEPTH_INFINITE, null);
+		  }
+		  if (!project.isOpen()) {
+			project.open(null);
+		  }  
+		  
+		  //Fill out a project description
+		  IPath defaultPath = Platform.getLocation();
+		  IPath newPath = project.getFullPath();
+		  if (defaultPath.equals(newPath))
+			newPath = null;
+		  IWorkspace workspace = ResourcesPlugin.getWorkspace();
+		  IProjectDescription description = workspace.newProjectDescription(project.getName());
+		  description.setLocation(newPath);
+		  //Create the project
+		  cproject = CCorePlugin.getDefault().createCProject(description,project,monitor,CCorePlugin.PLUGIN_ID + ".make"); //.getCoreModel().create(project);
+		    
+		  if( !cproject.hasNature(CCProjectNature.CC_NATURE_ID) ){
+			  addNatureToProject(cproject, CCProjectNature.CC_NATURE_ID, null);
+		  }
+	  }
+	  catch (CoreException e){
+		 cproject = project;
+		 cproject.open(null);
+	  }
+	  
+	  return cproject;
+	   
+   }
+	
+   private IFile importFile(String fileName, String resourceLocation)throws Exception{
+	  String testCaseName = this.getName();
+	
+	  //Obtain file handle
+	  file = testProject.getProject().getFile(fileName); 
+	  String pluginRoot=org.eclipse.core.runtime.Platform.getPlugin("org.eclipse.cdt.core.tests").find(new Path("/")).getFile();
+	  //Create file input stream
+	  monitor = new NullProgressMonitor();
+	  if (!file.exists()){
+		file.create(new FileInputStream(pluginRoot + resourceLocation),false,monitor);
+	  }
+	  fileDoc = new IFileDocument(file);
+	  
+	  return file;
+   }
+	
+   private void addNatureToProject(IProject proj, String natureId, IProgressMonitor monitor) throws CoreException {
+		  IProjectDescription description = proj.getDescription();
+		  String[] prevNatures= description.getNatureIds();
+		  String[] newNatures= new String[prevNatures.length + 1];
+		  System.arraycopy(prevNatures, 0, newNatures, 0, prevNatures.length);
+		  newNatures[prevNatures.length]= natureId;
+		  description.setNatureIds(newNatures);
+		  proj.setDescription(description, monitor);
+	}
+}
Index: indexer/org/eclipse/cdt/core/indexer/tests/IndexManagerTests.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core.tests/indexer/org/eclipse/cdt/core/indexer/tests/IndexManagerTests.java,v
retrieving revision 1.18
diff -u -r1.18 IndexManagerTests.java
--- indexer/org/eclipse/cdt/core/indexer/tests/IndexManagerTests.java	23 Sep 2003 15:17:03 -0000	1.18
+++ indexer/org/eclipse/cdt/core/indexer/tests/IndexManagerTests.java	25 Sep 2003 23:40:17 -0000
@@ -14,10 +14,6 @@
 import java.io.FileInputStream;
 import java.io.FileWriter;
 import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Iterator;
-import java.util.Set;
 
 import junit.framework.Test;
 import junit.framework.TestCase;
@@ -25,20 +21,12 @@
 
 import org.eclipse.cdt.core.CCProjectNature;
 import org.eclipse.cdt.core.CCorePlugin;
-import org.eclipse.cdt.core.search.ICSearchConstants;
-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.index.IEntryResult;
 import org.eclipse.cdt.internal.core.index.IIndex;
 import org.eclipse.cdt.internal.core.index.IQueryResult;
 import org.eclipse.cdt.internal.core.index.impl.IFileDocument;
 import org.eclipse.cdt.internal.core.search.indexing.IIndexConstants;
 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.cdt.internal.ui.search.CSearchResultCollector;
 import org.eclipse.core.internal.resources.ResourceException;
 import org.eclipse.core.resources.IFile;
 import org.eclipse.core.resources.IProject;
@@ -63,7 +51,7 @@
 	IProject 				testProject;
 	NullProgressMonitor		monitor;
 	IndexManager 			indexManager;
-	
+
 	public static final int TIMEOUT = 5000;
 	/**
 	 * Constructor for IndexManagerTest.
@@ -80,6 +68,9 @@
 	 */
 	protected void setUp() throws Exception {
 		super.setUp();
+		
+		monitor = new NullProgressMonitor();
+		
 		//Create temp project
 		testProject = createProject("IndexerTestProject");
 		if (testProject==null)
@@ -118,8 +109,7 @@
 		suite.addTest(new IndexManagerTests("testRemoveFileFromIndex"));
 		suite.addTest(new IndexManagerTests("testRemoveProjectFromIndex"));
 		suite.addTest(new IndexManagerTests("testIndexShutdown"));
-		suite.addTest(new IndexManagerTests("testDependencyTree"));
-		
+	
 		return suite;
 	
 	}
@@ -604,86 +594,5 @@
 	  assertEquals(fwdDclRefModel[i],fwdDclRefResults[i].toString());
 	}
   }
-  
-  public void testDependencyTree() throws Exception{
-	//Add a file to the project
-	IFile depTest = importFile("DepTest.cpp","resources/dependency/DepTest.cpp");
-	importFile("DepTest.h","resources/dependency/DepTest.h");
-	importFile("a.h","resources/dependency/a.h");
-	importFile("c.h","resources/dependency/c.h");
-	importFile("d.h","resources/dependency/d.h");
-	importFile("Inc1.h","resources/dependency/Inc1.h");
-	importFile("DepTest2.h","resources/dependency/DepTest2.h");
-	IFile depTest2 = importFile("DepTest2.cpp","resources/dependency/DepTest2.cpp");
-	//Enable indexing on the created project
-	//By doing this, we force the Dependency Manager to do a g()
-	DependencyManager dependencyManager = CCorePlugin.getDefault().getCoreModel().getDependencyManager();
-	//dependencyManager.setEnabled(testProject,true);
-	Thread.sleep(10000);
-	String[] depTestModel = {File.separator + "IndexerTestProject" + File.separator + "d.h", File.separator + "IndexerTestProject" + File.separator + "Inc1.h", File.separator + "IndexerTestProject" + File.separator + "c.h", File.separator + "IndexerTestProject" + File.separator + "a.h", File.separator + "IndexerTestProject" + File.separator + "DepTest.h"};
-	String[] depTest2Model = {File.separator + "IndexerTestProject" + File.separator + "d.h", File.separator + "IndexerTestProject" + File.separator + "DepTest2.h"};
-	
-	ArrayList includes = new ArrayList();
-	dependencyManager.performConcurrentJob(new DependencyQueryJob(testProject,depTest,dependencyManager,includes),ICSearchConstants.WAIT_UNTIL_READY_TO_SEARCH,null);
-	//Thread.sleep(5000);
-	String[] depTestModelLocal = convertToLocalPath(depTestModel);
-	String[] depTestIncludes = new String[includes.size()];
-	Iterator includesIterator = includes.iterator();
-	int i=0;
-	while(includesIterator.hasNext()){
-		depTestIncludes[i] = (String) includesIterator.next();
-		i++;
-	}
-	
-	if (depTestModelLocal.length != depTestIncludes.length)
-			fail("Number of included files differsfrom model");
-	
-	Arrays.sort(depTestModelLocal);
-	Arrays.sort(depTestIncludes);
-		
-	for (i=0;i<depTestIncludes.length; i++)
-	{
-		assertEquals(depTestModelLocal[i],depTestIncludes[i]);
-	}
-	
-	ArrayList includes2 = new ArrayList();
-	dependencyManager.performConcurrentJob(new DependencyQueryJob(testProject,depTest2,dependencyManager,includes2),ICSearchConstants.WAIT_UNTIL_READY_TO_SEARCH,null);
-	//Thread.sleep(5000);
-	String[] depTest2ModelLocal = convertToLocalPath(depTest2Model);
-	String[] depTest2Includes = new String[includes2.size()];
-	Iterator includes2Iterator = includes2.iterator();
-	i=0;
-	while(includes2Iterator.hasNext()){
-		depTest2Includes[i] = (String) includes2Iterator.next();
-		i++;
-	}
-	
-	if (depTest2ModelLocal.length != depTest2Includes.length)
-			fail("Number of included files differsfrom model");
-	
-	Arrays.sort(depTest2ModelLocal);
-	Arrays.sort(depTest2Includes);
-	
-	for (i=0;i<depTest2Includes.length; i++)
-	{
-		assertEquals(depTest2ModelLocal[i],depTest2Includes[i]);
-	}
-  }
 
-	/**
-	 * @param depTestModel
-	 * @return
-	 */
-	private String[] convertToLocalPath(String[] model) {
-		IPath defaultPath = Platform.getLocation();
-		String[] tempLocalArray = new String[model.length];
-		for (int i=0;i<model.length;i++){
-			StringBuffer buffer = new StringBuffer();
-			buffer.append(defaultPath.toOSString());
-			buffer.append(model[i]);
-			tempLocalArray[i]=buffer.toString();
-		}
-		return tempLocalArray;
-	}
-	
 }
Index: resources/dependency/DepTest3.cpp
===================================================================
RCS file: resources/dependency/DepTest3.cpp
diff -N resources/dependency/DepTest3.cpp
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ resources/dependency/DepTest3.cpp	25 Sep 2003 23:40:18 -0000
@@ -0,0 +1,7 @@
+#include "DepTest3.h"
+
+DepTest3::DepTest3()
+{};
+DepTest3::~DepTest3()
+{};
+
Index: resources/dependency/DepTest3.h
===================================================================
RCS file: resources/dependency/DepTest3.h
diff -N resources/dependency/DepTest3.h
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ resources/dependency/DepTest3.h	25 Sep 2003 23:40:18 -0000
@@ -0,0 +1,8 @@
+#include "a.h"
+
+class DepTest3{
+public:
+
+	DepTest3();
+	~DepTest3();
+};
Index: suite/org/eclipse/cdt/core/suite/AutomatedIntegrationSuite.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/suite/AutomatedIntegrationSuite.java,v
retrieving revision 1.20
diff -u -r1.20 AutomatedIntegrationSuite.java
--- suite/org/eclipse/cdt/core/suite/AutomatedIntegrationSuite.java	18 Sep 2003 15:22:42 -0000	1.20
+++ suite/org/eclipse/cdt/core/suite/AutomatedIntegrationSuite.java	25 Sep 2003 23:40:18 -0000
@@ -20,6 +20,7 @@
 import org.eclipse.cdt.core.build.managed.tests.ManagedBuildTests;
 import org.eclipse.cdt.core.build.managed.tests.StandardBuildTests;
 import org.eclipse.cdt.core.codeassist.tests.CompletionProposalsTest;
+import org.eclipse.cdt.core.indexer.tests.DependencyTests;
 import org.eclipse.cdt.core.indexer.tests.IndexManagerTests;
 import org.eclipse.cdt.core.model.failedTests.CModelElementsFailedTests;
 import org.eclipse.cdt.core.model.tests.AllCoreTests;
@@ -85,6 +86,7 @@
 		suite.addTest(WorkingCopyTests.suite());
 		suite.addTest(SearchTestSuite.suite());
 		suite.addTestSuite( CompletionProposalsTest.class);
+		suite.addTest(DependencyTests.suite());
 		//Indexer Tests need to be run after any indexer client tests
 		//as the last test shuts down the indexing thread
 		suite.addTest(IndexManagerTests.suite());
Index: .options
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/.options,v
retrieving revision 1.3
diff -u -r1.3 .options
--- .options	12 Sep 2003 18:51:34 -0000	1.3
+++ .options	25 Sep 2003 23:39:43 -0000
@@ -18,8 +18,5 @@
 # Reports search matches
 org.eclipse.cdt.core/debug/matchlocator=false
 
-# Reports background dependency tree activity
-org.eclipse.cdt.core/debug/dependency=false
-
 # Reports delta processor tree activity
 org.eclipse.cdt.core/debug/deltaprocessor=false
Index: ChangeLog
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/ChangeLog,v
retrieving revision 1.154
diff -u -r1.154 ChangeLog
--- ChangeLog	24 Sep 2003 15:02:44 -0000	1.154
+++ ChangeLog	25 Sep 2003 23:39:44 -0000
@@ -1,3 +1,13 @@
+2003-09-25 Bogdan Gheorghe
+
+	- Got rid of refs to old dependency service; restructured
+	  index request section 
+	
+	* src/org/eclipse/cdt/core/CCorePlugin.java
+	* src/org/eclipse/cdt/core/model/CoreModel.java
+	* src/org/eclipse/cdt/internal/core/model/CModelManager.java
+	* src/org/eclipse/cdt/internal/core/model/DeltaProcessor.java
+	
 2003-09-24 Alain Magloire
 
 	With the removal of the old CDT parser, there was no
Index: dependency/ChangeLog
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/dependency/ChangeLog,v
retrieving revision 1.4
diff -u -r1.4 ChangeLog
--- dependency/ChangeLog	23 Sep 2003 15:17:13 -0000	1.4
+++ dependency/ChangeLog	25 Sep 2003 23:39:44 -0000
@@ -1,3 +1,25 @@
+2003-09-25 Bogdan Gheorghe
+	- As a result of folding the dependency service into the indexer
+	  have removed the following files:
+	  
+	* src/org/eclipse/cdt/internal/core/sourcedependency/AddFileToDependencyTree.java
+	* src/org/eclipse/cdt/internal/core/sourcedependency/DependencyManager.java
+	* src/org/eclipse/cdt/internal/core/sourcedependency/DependencyRequest.java
+	* src/org/eclipse/cdt/internal/core/sourcedependency/DependencyRequestor.java
+	* src/org/eclipse/cdt/internal/core/sourcedependency/DependencySelector.java
+	* src/org/eclipse/cdt/internal/core/sourcedependency/DependencyTree.java
+	* src/org/eclipse/cdt/internal/core/sourcedependency/EntireProjectDependencyTree.java
+	* src/org/eclipse/cdt/internal/core/sourcedependency/IDependencyTree.java
+	* src/org/eclipse/cdt/internal/core/sourcedependency/IPreprocessorOutput.java
+	* src/org/eclipse/cdt/internal/core/sourcedependency/ISourceDependency.java
+	* src/org/eclipse/cdt/internal/core/sourcedependency/PreprocessorOutput.java
+	* src/org/eclipse/cdt/internal/core/sourcedependency/RemoveFromDependencyTree.java
+	* src/org/eclipse/cdt/internal/core/sourcedependency/impl/IncludeEntry.java
+	* src/org/eclipse/cdt/internal/core/sourcedependency/impl/IncludeEntryHashedArray.java
+	* src/org/eclipse/cdt/internal/core/sourcedependency/impl/InMemoryTree.java
+
+	
+	  
 2003-09-22 Bogdan Gheorghe
 	- Took out enable section for DependencyManager
 	
Index: dependency/org/eclipse/cdt/internal/core/sourcedependency/AddFileToDependencyTree.java
===================================================================
RCS file: dependency/org/eclipse/cdt/internal/core/sourcedependency/AddFileToDependencyTree.java
diff -N dependency/org/eclipse/cdt/internal/core/sourcedependency/AddFileToDependencyTree.java
--- dependency/org/eclipse/cdt/internal/core/sourcedependency/AddFileToDependencyTree.java	9 Sep 2003 17:53:51 -0000	1.4
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,116 +0,0 @@
-/**********************************************************************
- * Copyright (c) 2002,2003 Rational Software Corporation and others.
- * All rights reserved.   This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
- * 
- * Contributors: 
- * IBM Rational Software - Initial API and implementation
-***********************************************************************/
-
-package org.eclipse.cdt.internal.core.sourcedependency;
-
-import java.io.IOException;
-
-import org.eclipse.cdt.core.model.CoreModel;
-import org.eclipse.cdt.core.parser.IScannerInfo;
-import org.eclipse.cdt.core.parser.ParserLanguage;
-import org.eclipse.cdt.internal.core.index.IDocument;
-import org.eclipse.cdt.internal.core.index.impl.IFileDocument;
-import org.eclipse.cdt.internal.core.parser.ScannerInfo;
-import org.eclipse.cdt.internal.core.search.indexing.ReadWriteMonitor;
-import org.eclipse.cdt.internal.core.search.processing.JobManager;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IProgressMonitor;
-
-public class AddFileToDependencyTree extends DependencyRequest {
-	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
-	 */
-	public AddFileToDependencyTree(
-		IFile resource,
-		IPath path,
-		DependencyManager manager,
-		IScannerInfo info) {
-		super(path, manager);
-		this.resource = resource;
-		this.buildInfo = info;
-	}
- 
-	public boolean execute(IProgressMonitor progressMonitor) {
-		if (progressMonitor != null && progressMonitor.isCanceled()) return true;
-		/* ensure no concurrent write access to tree */
-		IDependencyTree tree = manager.getDependencyTree(this.dependencyTreePath, true, /*reuse tree file*/ true /*create if none*/);
-		if (tree == null) return true;
-		ReadWriteMonitor monitor = manager.getMonitorFor(tree);
-		if (monitor == null) return true; // tree got deleted since acquired
-		try {
-			monitor.enterWrite(); // ask permission to write
-			if (!addDocumentToTree(tree)) return false;
-		} catch (IOException e) {
-			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();
-			}
-			return false;
-		} finally {
-			monitor.exitWrite(); // free write lock
-		}
-		return true;
-	}
-	
-	protected boolean addDocumentToTree(IDependencyTree dTree) throws IOException {
-		if (!initializeContents()) return false;
-		//Need to create document to get string content...
-		IDocument document = new IFileDocument(resource, this.contents);
-		if (!shouldAddToTree(document)) return false;
-		
-		String docPath = resource.getLocation().toOSString();
-		IScannerInfo newInfo = new ScannerInfo((this.buildInfo != null) ? this.buildInfo.getDefinedSymbols() : null,(this.buildInfo != null) ? this.buildInfo.getIncludePaths() : null);
-		
-		ParserLanguage language = CoreModel.getDefault().hasCCNature( resource.getProject() ) ? ParserLanguage.CPP : ParserLanguage.C;
-		dTree.add(document,docPath,newInfo, resource, language);
-
-		return true;
-	}
-	
-	public boolean initializeContents() {
-		if (this.contents == null) {
-			try {
-				IPath location = resource.getLocation();
-				if (location != null)
-					this.contents = org.eclipse.cdt.internal.core.Util.getFileCharContent(location.toFile(), null);
-			} catch (IOException e) {
-			}
-		}
-		return this.contents != null;
-	}
-
-	public String toString() {
-		return "calculating dependency for:  " + this.resource.getFullPath(); //$NON-NLS-1$
-	}
-	
-	public String[] getFileTypes(){
-		return FILE_TYPES;
-	}
-	
-	public boolean shouldAddToTree(IDocument document) {
-			String type = document.getType();
-			String[] supportedTypes = this.getFileTypes();
-			for (int i = 0; i < supportedTypes.length; ++i) {
-				if (supportedTypes[i].equals(type))
-					return true;
-			}
-			return false;
-	}
-
-}
Index: dependency/org/eclipse/cdt/internal/core/sourcedependency/DependencyManager.java
===================================================================
RCS file: dependency/org/eclipse/cdt/internal/core/sourcedependency/DependencyManager.java
diff -N dependency/org/eclipse/cdt/internal/core/sourcedependency/DependencyManager.java
--- dependency/org/eclipse/cdt/internal/core/sourcedependency/DependencyManager.java	23 Sep 2003 15:17:13 -0000	1.5
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,423 +0,0 @@
-/**********************************************************************
- * Copyright (c) 2002,2003 Rational Software Corporation and others.
- * All rights reserved.   This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
- * 
- * Contributors: 
- * IBM Rational Software - Initial API and implementation
-***********************************************************************/
-
-package org.eclipse.cdt.internal.core.sourcedependency;
-
-import java.io.BufferedWriter;
-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;
-
-import org.eclipse.cdt.core.CCorePlugin;
-import org.eclipse.cdt.core.parser.IScannerInfo;
-import org.eclipse.cdt.internal.core.CharOperation;
-import org.eclipse.cdt.internal.core.search.SimpleLookupTable;
-import org.eclipse.cdt.internal.core.search.indexing.ReadWriteMonitor;
-import org.eclipse.cdt.internal.core.search.processing.JobManager;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.QualifiedName;
-
-/**
- * @author bgheorgh
- */
-public class DependencyManager extends JobManager implements ISourceDependency {
-	/* number of file contents in memory */
-	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 */
-	private Map monitors = new HashMap(5);
-
-	/* need to save ? */
-	private boolean needToSave = false;
-	private static final CRC32 checksumCalculator = new CRC32();
-	private IPath ccorePluginLocation = null;
-
-	/* can only replace a current state if its less than the new one */
-	private SimpleLookupTable dTreeStates = null;
-	private File savedDTreesFile =
-		new File(getCCorePluginWorkingLocation().append("savedDTrees.txt").toOSString()); //$NON-NLS-1$
-	public static Integer SAVED_STATE = new Integer(0);
-	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$
-	}
-	
-	public void reset(){
-		super.reset();
-		
-	    //Get handles on the info providers
-	    //register yourself for updates
-	    
-		if (this.dependencyTrees!= null) {
-			this.dependencyTrees = new HashMap(5);
-			this.monitors = new HashMap(5);
-			this.dTreeStates = null;
-		}
-		
-		this.projectNames = new SimpleLookupTable();
-		this.dependencyTable = new SimpleLookupTable();
-		this.ccorePluginLocation = null;
-	}
-	/* (non-Javadoc)
-	 * @see org.eclipse.cdt.internal.core.sourcedependency.ISourceDependency#getProjects(org.eclipse.core.resources.IFile)
-	 */
-	public IProject[] getProjects(IFile file) {
-		// TODO Auto-generated method stub
-		return null;
-	}
-	/* (non-Javadoc)
-	 * @see org.eclipse.cdt.internal.core.sourcedependency.ISourceDependency#getFileDependencies(org.eclipse.core.resources.IProject, org.eclipse.core.resources.IFile)
-	 */
-	public synchronized String[] getFileDependencies(IProject project, IFile file) {
-		IPath path =project.getFullPath();
-		IDependencyTree dTree= this.getDependencyTree(path,true,false);
-		try{
-			if (dTree != null) { 
-			//dTree.printIncludeEntries();
-			//dTree.printIndexedFiles();
-			String[] files = dTree.getFileDependencies(file.getFullPath());
-			 return files;
-			}
-		}
-		catch(Exception e){}
-		return null;
-	}
-
-	public synchronized IDependencyTree getDependencyTree(IPath path, boolean reuseExistingFile, boolean createIfMissing) {
-		IDependencyTree dTree = (IDependencyTree) dependencyTrees.get(path);
-		if (dTree == null){
-			String treeName = computeTreeName(path);
-			Object state = getTreeStates().get(treeName);
-			Integer currentDTreeState = state == null ? UNKNOWN_STATE : (Integer) state;
-			if (currentDTreeState == UNKNOWN_STATE) {
-				// should only be reachable for query jobs
-					rebuildDTree(treeName, path);
-					return null;
-			}
-			// tree isn't cached, consider reusing an existing tree file
-			if (reuseExistingFile) {
-				File treeFile = new File(treeName);
-				if (treeFile.exists()) { // check before creating tree so as to avoid creating a new empty tree if file is missing
-					try {
-						dTree = new DependencyTree(treeName, "Tree for " + path.toOSString(), true /*reuse tree file*/); //$NON-NLS-1$
-						dependencyTrees.put(path, dTree);
-						monitors.put(dTree, new ReadWriteMonitor());
-						return dTree;
-					} 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 (DependencyManager.VERBOSE)
-								JobManager.verbose("-> cannot reuse existing tree: "+ treeName +" path: "+path.toOSString()); //$NON-NLS-1$ //$NON-NLS-2$
-							 rebuildDTree(treeName, path);
-							 return null;
-						 } else {
-							 dTree = null; // will fall thru to createIfMissing & create a empty tree for the rebuild all job to populate
-						 }
-					}
-				}
-				if (currentDTreeState == SAVED_STATE) { // rebuild tree if existing file is missing
-					rebuildDTree(treeName, path);
-					return null;
-				}
-				
-				if (createIfMissing) {
-					try {
-						if (VERBOSE)
-							JobManager.verbose("-> create empty tree: "+treeName+" path: "+path.toOSString()); //$NON-NLS-1$ //$NON-NLS-2$
-						dTree = new DependencyTree(treeName, "Tree for " + path.toOSString(), false /*do not reuse tree file*/); //$NON-NLS-1$
-						dependencyTrees.put(path, dTree);
-						monitors.put(dTree, new ReadWriteMonitor());
-						return dTree;
-					} catch (IOException e) {
-						if (VERBOSE)
-							JobManager.verbose("-> unable to create empty tree: "+treeName+" path: "+path.toOSString()); //$NON-NLS-1$ //$NON-NLS-2$
-						// The file could not be created. Possible reason: the project has been deleted.
-						return null;
-					}
-				}
-			} 	
-		}
-		
-		return dTree;
-	}
-	
-	String computeTreeName(IPath path) {
-			String name = (String) projectNames.get(path);
-			if (name == null) {
-				String pathString = path.toOSString();
-				checksumCalculator.reset();
-				checksumCalculator.update(pathString.getBytes());
-				String fileName = Long.toString(checksumCalculator.getValue()) + ".depTree"; //$NON-NLS-1$
-				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);
-			}
-			return name;
-	}
-		
-	private IPath getCCorePluginWorkingLocation() {
-		if (this.ccorePluginLocation != null) return this.ccorePluginLocation;
-
-		return this.ccorePluginLocation = CCorePlugin.getDefault().getStateLocation();
-	}
-	/**
-	 * DTree access is controlled through a read-write monitor so as
-	 * to ensure there is no concurrent read and write operations
-	 * (only concurrent reading is allowed).
-	 */
-	public ReadWriteMonitor getMonitorFor(IDependencyTree dTree){
-		return (ReadWriteMonitor) monitors.get(dTree);
-	}
-		
-	private SimpleLookupTable getTreeStates() {
-		if (dTreeStates != null) return dTreeStates;
-	
-		this.dTreeStates = new SimpleLookupTable();
-		char[] savedDTreeNames = readDTreeState();
-		if (savedDTreeNames.length > 0) {
-			char[][] names = CharOperation.splitOn('\n', savedDTreeNames);
-			for (int i = 0, l = names.length; i < l; i++) {
-				char[] name = names[i];
-				if (name.length > 0)
-					this.dTreeStates.put(new String(name), SAVED_STATE);
-			}
-		}
-		return this.dTreeStates;
-	}
-	
-	private char[] readDTreeState() {
-		try {
-			return org.eclipse.cdt.internal.core.Util.getFileCharContent(savedDTreesFile, null);
-		} catch (IOException ignored) {
-			if (DependencyManager.VERBOSE)
-				JobManager.verbose("Failed to read saved dTree file names"); //$NON-NLS-1$
-			return new char[0];
-		}
-	}
-	
-	private void rebuildDTree(String treeName, IPath path) {
-		Object target = org.eclipse.cdt.internal.core.Util.getTarget(ResourcesPlugin.getWorkspace().getRoot(), path, true);
-		if (target == null) return;
-	
-		if (DependencyManager.VERBOSE)
-			JobManager.verbose("-> request to rebuild dTree: "+treeName+" path: "+path.toOSString()); //$NON-NLS-1$ //$NON-NLS-2$
-	
-		updateTreeState(treeName, REBUILDING_STATE);
-		DependencyRequest request = null;
-		if (target instanceof IProject) {
-			IProject p = (IProject) target;
-			request = new EntireProjectDependencyTree(p, this);
-		}
-	
-		if (request != null)
-			request(request);
-	}
-	/**
-	 * Trigger addition of the entire content of a project
-	 * Note: the actual operation is performed in background 
-	 */
-	public void generateEntireDependencyTree(IProject project) {
-		if (CCorePlugin.getDefault() == null) return;
-		
-		 /******
-		 *TODO: BOG Remove these methods once the depTree is
-		 *fully integrated
-		 */
-//		 if (!isEnabled(project)) return;
-
-		// check if the same request is not already in the queue
-		DependencyRequest request = new EntireProjectDependencyTree(project, this);
-		for (int i = this.jobEnd; i > this.jobStart; i--) // NB: don't check job at jobStart, as it may have already started (see http://bugs.eclipse.org/bugs/show_bug.cgi?id=32488)
-			if (request.equals(this.awaitingJobs[i])) return;
-		this.request(request);
-	}
-
-	private void updateTreeState(String treeName, Integer treeState) {
-		getTreeStates(); // ensure the states are initialized
-		if (treeState != null) {
-			if (treeState.equals(dTreeStates.get(treeName))) return; // not changed
-			dTreeStates.put(treeName, treeState);
-		} else {
-			if (!dTreeStates.containsKey(treeName)) return; // did not exist anyway
-			dTreeStates.removeKey(treeName);
-		}
-
-		BufferedWriter writer = null;
-		try {
-			writer = new BufferedWriter(new FileWriter(savedDTreesFile));
-			Object[] indexNames = dTreeStates.keyTable;
-			Object[] states = dTreeStates.valueTable;
-			for (int i = 0, l = states.length; i < l; i++) {
-				if (states[i] == SAVED_STATE) {
-					writer.write((String) indexNames[i]);
-					writer.write('\n');
-				}
-			}
-		} catch (IOException ignored) {
-			if (DependencyManager.VERBOSE)
-				JobManager.verbose("Failed to write saved dTree file names"); //$NON-NLS-1$
-		} finally {
-			if (writer != null) {
-				try {
-					writer.close();
-				} catch (IOException e) {}
-			}
-		}
-		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$
-			else if (treeState == UNKNOWN_STATE) state = "UNKNOWN"; //$NON-NLS-1$
-			else if (treeState == REBUILDING_STATE) state = "REBUILDING"; //$NON-NLS-1$
-			JobManager.verbose("-> dTree state updated to: " + state + " for: "+treeName); //$NON-NLS-1$ //$NON-NLS-2$
-		}
-	}
-	
-	public void jobWasCancelled(IPath path) {
-		Object o = this.dependencyTrees.get(path);
-		if (o instanceof IDependencyTree) {
-			this.monitors.remove(o);
-			this.dependencyTrees.remove(path);
-		}
-		updateTreeState(computeTreeName(path), UNKNOWN_STATE);
-	}
-	/**
-	 * Trigger removal of a resource from a tree
-	 * Note: the actual operation is performed in background
-	 */
-	public void remove(String resourceName, IPath indexedContainer){
-		//request(new RemoveFromIndex(resourceName, indexedContainer, this));
-		if (DependencyManager.VERBOSE)
-		  JobManager.verbose("remove file from tree " + resourceName);
-	}
-	/**
-	 * 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 (DependencyManager.VERBOSE)
-			JobManager.verbose("removing dependency tree " + path); //$NON-NLS-1$
-		String treeName = computeTreeName(path);
-		File indexFile = new File(treeName);
-		if (indexFile.exists())
-			indexFile.delete();
-		Object o = this.dependencyTrees.get(path);
-		if (o instanceof IDependencyTree)
-			this.monitors.remove(o);
-		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
-//	 * START OF TEMP D-TREE ENABLE SECTION
-//	 */
-//	final static String DEP_MODEL_ID = CCorePlugin.PLUGIN_ID + ".dependencytree";
-//	final static String ACTIVATION = "enable";
-//	
-//	static QualifiedName activationKey = new QualifiedName(DEP_MODEL_ID, ACTIVATION);
-//	
-//	public boolean isEnabled(IProject project) {
-//		String prop = null;
-//		try {
-//			if (project != null) {
-//				prop = project.getPersistentProperty(activationKey);
-//			}
-//		} catch (CoreException e) {
-//		}
-//		return ((prop != null) && prop.equalsIgnoreCase("true"));
-//	}
-//	
-//	public void setEnabled(IProject project, boolean on) {
-//		try {
-//			if (project != null) {
-//				Boolean newValue = new Boolean(on);
-//				Boolean oldValue = new Boolean(isEnabled(project));
-//				if (!oldValue.equals(newValue)) {
-//					project.setPersistentProperty(activationKey, newValue.toString());
-//					if (on) {
-//						generateEntireDependencyTree(project);
-//					} else {
-//						//remove(project);
-//					}
-//				}
-//			}
-//		} catch (CoreException e) {
-//		}
-//	}
-//
-//	/************
-//	 * 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.2
diff -u -r1.2 DependencyQueryJob.java
--- dependency/org/eclipse/cdt/internal/core/sourcedependency/DependencyQueryJob.java	9 Sep 2003 17:53:51 -0000	1.2
+++ dependency/org/eclipse/cdt/internal/core/sourcedependency/DependencyQueryJob.java	25 Sep 2003 23:39:44 -0000
@@ -3,14 +3,27 @@
  */
 package org.eclipse.cdt.internal.core.sourcedependency;
 
+import java.io.IOException;
 import java.util.ArrayList;
 import java.util.List;
 
 import org.eclipse.cdt.core.search.SearchEngine;
+import org.eclipse.cdt.internal.core.index.IDocument;
+import org.eclipse.cdt.internal.core.index.IIndex;
+import org.eclipse.cdt.internal.core.index.impl.BlocksIndexInput;
+import org.eclipse.cdt.internal.core.index.impl.IFileDocument;
+import org.eclipse.cdt.internal.core.index.impl.IncludeEntry;
+import org.eclipse.cdt.internal.core.index.impl.IndexInput;
+import org.eclipse.cdt.internal.core.index.impl.IndexedFile;
+import org.eclipse.cdt.internal.core.search.IndexSelector;
+import org.eclipse.cdt.internal.core.search.indexing.IndexManager;
+import org.eclipse.cdt.internal.core.search.indexing.ReadWriteMonitor;
 import org.eclipse.cdt.internal.core.search.processing.IJob;
+import org.eclipse.cdt.internal.core.search.processing.JobManager;
 import org.eclipse.core.resources.IFile;
 import org.eclipse.core.resources.IProject;
 import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.OperationCanceledException;
 
 /**
  * @author bgheorgh
@@ -20,13 +33,14 @@
 	IProject project;
 	IFile file;
 	ArrayList includeFiles;
-	DependencyManager depManager;
-	protected DependencySelector depSelector;
+	IndexManager indexManager;
+	protected IndexSelector indexSelector;
+	protected long executionTime = 0;
 	
-	public DependencyQueryJob(IProject project, IFile file, DependencyManager depMan, List includeFiles) {
+	public DependencyQueryJob(IProject project, IFile file, IndexManager inMan, List includeFiles) {
 		this.project = project;
 		this.file = file;
-		this.depManager = depMan;
+		this.indexManager = inMan;
 		this.includeFiles = (ArrayList) includeFiles;
 	}
 
@@ -46,27 +60,167 @@
 	/* (non-Javadoc)
 	 * @see org.eclipse.cdt.internal.core.search.processing.IJob#execute(org.eclipse.core.runtime.IProgressMonitor)
 	 */
-	public boolean execute(IProgressMonitor progress) {
+	public boolean execute(IProgressMonitor progressMonitor) {
+		if ((project == null) ||(file == null)) return false;
+		//
+		if (progressMonitor != null && progressMonitor.isCanceled())
+					throw new OperationCanceledException();
+				boolean isComplete = COMPLETE;
+				executionTime = 0;
+				if (this.indexSelector == null) {
+					this.indexSelector =
+						new IndexSelector(SearchEngine.createWorkspaceScope(), null, false, this.indexManager);
+				}
+				IIndex[] searchIndexes = this.indexSelector.getIndexes();
+				try {
+					int max = searchIndexes.length;
+					if (progressMonitor != null) {
+						progressMonitor.beginTask("", max); //$NON-NLS-1$
+					}
+					for (int i = 0; i < max; i++) {
+						isComplete &= getFileDeps(searchIndexes[i], progressMonitor);
+						if (progressMonitor != null) {
+							if (progressMonitor.isCanceled()) {
+								throw new OperationCanceledException();
+							} else {
+								progressMonitor.worked(1);
+							}
+						}
+					}
+					if (JobManager.VERBOSE) {
+						JobManager.verbose("-> execution time: " + executionTime + "ms - " + this);//$NON-NLS-1$//$NON-NLS-2$
+					}
+					return isComplete;
+				} finally {
+					if (progressMonitor != null) {
+						progressMonitor.done();
+					}
+				}
+	}
+
+	/**
+	 * @param index
+	 * @param progressMonitor
+	 * @return
+	 */
+	public boolean getFileDeps(IIndex index, IProgressMonitor progressMonitor){
+	
+		if (progressMonitor != null && progressMonitor.isCanceled())
+			throw new OperationCanceledException();
+
+//			IIndex inMemIndex = indexManager.peekAtIndex(new Path(((Index)index).toString.substring("Index for ".length()).replace('\\','/')));
+//			if (inMemIndex != index) {
+//				System.out.println("SANITY CHECK: search job using obsolete index: ["+index+ "] instead of: ["+inMemIndex+"]");
+//			}
+	
+		if (index == null)
+			return COMPLETE;
+		ReadWriteMonitor monitor = indexManager.getMonitorFor(index);
+		if (monitor == null)
+			return COMPLETE; // index got deleted since acquired
+		try {
+			monitor.enterRead(); // ask permission to read
+
+			/* if index has changed, commit these before querying */
+			if (index.hasChanged()) {
+				try {
+					monitor.exitRead(); // free read lock
+					monitor.enterWrite(); // ask permission to write
+					this.indexManager.saveIndex(index);
+				} catch (IOException e) {
+					return FAILED;
+				} finally {
+					monitor.exitWriteEnterRead(); // finished writing and reacquire read permission
+				}
+			}
+			long start = System.currentTimeMillis();
+			//
+			IndexInput input = new BlocksIndexInput(index.getIndexFile());
+			try {
+				input.open();
+				findDep(input);
+			} finally {
+				input.close();
+			}
+			//
+			//String[] tempFiles = this.indexManager.getFileDependencies(project,file);
+//			if (tempFiles != null){
+//				System.out.println("DQJOB File Deps : " + tempFiles.length);
+//				for (int i=0; i<tempFiles.length; i++){
+//							includeFiles.add(tempFiles[i]);
+//				}
+//			}
+			executionTime += System.currentTimeMillis() - start;
+			return COMPLETE;
+		}
+		catch (IOException e){
+			return FAILED;
+		}
+		 finally {
+			monitor.exitRead(); // finished reading
+		}
+	}
+	
+	/**
+	 * @param input
+	 * @param includeFiles
+	 */
+	private void findDep(IndexInput input) throws IOException {
 		
-		if ((project == null) ||(file == null)) return false;		
+		IDocument temp = new IFileDocument(file);
+		IndexedFile dude = input.getIndexedFile(temp);
+		if (dude == null) return;
 		
-		String[] tempFiles = this.depManager.getFileDependencies(project,file);
-		if (tempFiles != null){
-			for (int i=0; i<tempFiles.length; i++){
-						includeFiles.add(tempFiles[i]);
-			}
-			return true;
+		
+		int fileNum =dude.getFileNumber();
+		IncludeEntry[] tempEntries = input.queryIncludeEntries(fileNum);
+		if (tempEntries != null){
+			for (int r=0; r<tempEntries.length; r++){
+			   char[] tempFile = tempEntries[r].getFile();
+			   StringBuffer tempString = new StringBuffer();
+			   tempString.append(tempFile);
+			   includeFiles.add(tempString.toString());
+		   }
 		}
-		return false;
+       
+		
+		//
+//		if (indexFile == null)
+//				 return new String[0];
+//		 
+//				int fileNum = indexFile.getFileNumber();
+//				IncludeEntry[] tempEntries = addsIndex.getIncludeEntries();
+//				for (int i=0; i<tempEntries.length; i++)
+//				{
+//					int[] fileRefs = tempEntries[i].getRefs();
+//					for (int j=0; j<fileRefs.length; j++)
+//					{
+//						if (fileRefs[j] == fileNum)
+//						{ 
+//							//System.out.println(filePath.toString() + " references " + y[i].toString());
+//							char[] tempFile = tempEntries[i].getFile();
+//							StringBuffer tempString = new StringBuffer();
+//							tempString.append(tempFile);
+//							tempFileReturn.add(tempString.toString());
+//							break;
+//						}
+//					}
+//				}
+//				
+		//
+	}
+
+	public String toString() {
+		return "searching for the dependencies of" + file.getName(); //$NON-NLS-1$
 	}
 
 	/* (non-Javadoc)
 	 * @see org.eclipse.cdt.internal.core.search.processing.IJob#isReadyToRun()
 	 */
 	public boolean isReadyToRun() {
-		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
+		if (this.indexSelector == null) { // only check once. As long as this job is used, it will keep the same index picture
+			this.indexSelector = new IndexSelector(SearchEngine.createWorkspaceScope(), null, false, this.indexManager);
+			this.indexSelector.getIndexes(); // will only cache answer if all indexes were available originally
 		}
 		return true;
 	}
Index: dependency/org/eclipse/cdt/internal/core/sourcedependency/DependencyRequest.java
===================================================================
RCS file: dependency/org/eclipse/cdt/internal/core/sourcedependency/DependencyRequest.java
diff -N dependency/org/eclipse/cdt/internal/core/sourcedependency/DependencyRequest.java
--- dependency/org/eclipse/cdt/internal/core/sourcedependency/DependencyRequest.java	24 Jul 2003 14:15:06 -0000	1.1
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,64 +0,0 @@
-/**********************************************************************
- * Copyright (c) 2002,2003 Rational Software Corporation and others.
- * All rights reserved.   This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
- * 
- * Contributors: 
- * IBM Rational Software - Initial API and implementation
-***********************************************************************/
-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.IJob;
-import org.eclipse.core.runtime.IPath;
-
-public abstract class DependencyRequest implements IJob {
-	protected boolean isCancelled = false;
-	protected DependencyManager manager;
-	protected IPath dependencyTreePath;
-		
-	public DependencyRequest(IPath path, DependencyManager manager) {
-		this.dependencyTreePath = path;
-		this.manager = manager;
-	}
-
-	public DependencyRequest(DependencyManager manager) {
-			this.manager = manager;
-	}
-	
-	public boolean belongsTo(String projectName) {
-		return projectName.equals(this.dependencyTreePath.segment(0));
-	}
-	
-	public void cancel() {
-		this.manager.jobWasCancelled(this.dependencyTreePath);
-		this.isCancelled = true;
-	}
-	
-	public boolean isReadyToRun() {
-		return true;
-	}
-	/*
-	 * This code is assumed to be invoked while monitor has read lock
-	 */
-	protected void saveIfNecessary(IDependencyTree tree, ReadWriteMonitor monitor) throws IOException {
-		/* if tree has changed, commit these before querying */
-		if (tree.hasChanged()) {
-			try {
-				monitor.exitRead(); // free read lock
-				monitor.enterWrite(); // ask permission to write
-				//this.manager.saveTree(tree);
-			} finally {
-				monitor.exitWriteEnterRead(); // finished writing and reacquire read permission
-			}
-		}
-	}
-	
-	protected Integer updatedIndexState() {
-		return DependencyManager.UPDATING_STATE;
-	}
-}
Index: dependency/org/eclipse/cdt/internal/core/sourcedependency/DependencyRequestor.java
===================================================================
RCS file: dependency/org/eclipse/cdt/internal/core/sourcedependency/DependencyRequestor.java
diff -N dependency/org/eclipse/cdt/internal/core/sourcedependency/DependencyRequestor.java
--- dependency/org/eclipse/cdt/internal/core/sourcedependency/DependencyRequestor.java	24 Jul 2003 14:15:06 -0000	1.1
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,60 +0,0 @@
-/**********************************************************************
- * Copyright (c) 2002,2003 Rational Software Corporation and others.
- * All rights reserved.   This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
- * 
- * Contributors: 
- * IBM Rational Software - Initial API and implementation
-***********************************************************************/
-package org.eclipse.cdt.internal.core.sourcedependency;
-
-import java.util.LinkedList;
-
-import org.eclipse.cdt.core.parser.ast.IASTInclusion;
-import org.eclipse.cdt.internal.core.index.IDocument;
-import org.eclipse.cdt.internal.core.parser.NullSourceElementRequestor;
-
-public class DependencyRequestor extends NullSourceElementRequestor {
-	PreprocessorOutput preprocessor;
-	IDocument document;
-	private IASTInclusion currentInclude = null;
-	private LinkedList includeStack = new LinkedList();
-
-    public DependencyRequestor(PreprocessorOutput p, IDocument doc){
-    	this.preprocessor = p;
-    	this.document = doc;
-    }
-	
-	public void enterInclusion(IASTInclusion inclusion) {
-		//System.out.println("enterInclusion " + inclusion.getName());
-		//Get parent
-		IASTInclusion parent = peekInclude();
-		preprocessor.addInclude(inclusion, parent);
-		//Push on stack
-		pushInclude(inclusion);
-	}
-	
-	public void exitInclusion(IASTInclusion inclusion) {
-		// TODO Auto-generated method stub
-		//System.out.println("Exit inclusion " + inclusion.getFullFileName());
-		//Pop
-		popInclude();
-	}
-	
-	private void pushInclude( IASTInclusion inclusion ){
-			includeStack.addFirst( currentInclude );
-			currentInclude = inclusion;
-	}
-	
-	private IASTInclusion popInclude(){
-		IASTInclusion oldInclude = currentInclude;
-		currentInclude = (includeStack.size() > 0 ) ? (IASTInclusion) includeStack.removeFirst() : null;
-		return oldInclude;
-	}
-	
-	private IASTInclusion peekInclude(){
-		return currentInclude;
-	}
-}
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
--- dependency/org/eclipse/cdt/internal/core/sourcedependency/DependencySelector.java	9 Sep 2003 17:53:51 -0000	1.1
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,114 +0,0 @@
-/*
- * 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: dependency/org/eclipse/cdt/internal/core/sourcedependency/DependencyTree.java
diff -N dependency/org/eclipse/cdt/internal/core/sourcedependency/DependencyTree.java
--- dependency/org/eclipse/cdt/internal/core/sourcedependency/DependencyTree.java	11 Sep 2003 17:13:03 -0000	1.4
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,195 +0,0 @@
-/**********************************************************************
- * Copyright (c) 2002,2003 Rational Software Corporation and others.
- * All rights reserved.   This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
- * 
- * Contributors: 
- * IBM Rational Software - Initial API and implementation
-***********************************************************************/
-
-package org.eclipse.cdt.internal.core.sourcedependency;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.StringReader;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.cdt.core.parser.IPreprocessor;
-import org.eclipse.cdt.core.parser.IScannerInfo;
-import org.eclipse.cdt.core.parser.ParserLanguage;
-import org.eclipse.cdt.core.parser.ParserFactory;
-import org.eclipse.cdt.core.parser.ParserMode;
-import org.eclipse.cdt.internal.core.index.IDocument;
-import org.eclipse.cdt.internal.core.index.IQueryResult;
-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();
-	}
-
-	public DependencyTree() throws IOException {
-		initialize();
-	}
-	/* (non-Javadoc)
-	 * @see org.eclipse.cdt.internal.core.sourcedependency.IDependencyTree#empty()
-	 */
-	public void empty() throws IOException {
-		// TODO Auto-generated method stub
-	}
-	/* (non-Javadoc)
-	 * @see org.eclipse.cdt.internal.core.sourcedependency.IDependencyTree#getIndexFile()
-	 */
-	public File getIndexFile() {
-		// TODO Auto-generated method stub
-		return null;
-	}
-	/**
-	 * Returns the number of referencing files in this tree. 
-	 */
-	public int getNumDocuments() throws IOException {
-		return addsTree.getNumFiles();
-	}
-	/**
-	 * Returns the number of include entries in this tree.
-	 * @return
-	 * @throws IOException
-	 */
-	public int getNumIncludes() throws IOException {
-		return addsTree.getNumIncludes();
-	}
-	/**
-	 * Returns the path corresponding to a given document number
-	 */
-	public String getPath(int documentNumber) throws IOException {
-		return null;
-	}
-	/* (non-Javadoc)
-	 * @see org.eclipse.cdt.internal.core.sourcedependency.IDependencyTree#hasChanged()
-	 */
-	public boolean hasChanged() {
-		// TODO Auto-generated method stub
-		return false;
-	}
-	/* (non-Javadoc)
-	 * @see org.eclipse.cdt.internal.core.sourcedependency.IDependencyTree#query(java.lang.String)
-	 */
-	public IQueryResult[] query(String word) throws IOException {
-		// TODO Auto-generated method stub
-		return null;
-	}
-	/* (non-Javadoc)
-	 * @see org.eclipse.cdt.internal.core.sourcedependency.IDependencyTree#queryInDocumentNames(java.lang.String)
-	 */
-	public IQueryResult[] queryInDocumentNames(String word)
-		throws IOException {
-		// TODO Auto-generated method stub
-		return null;
-	}
-	/* (non-Javadoc)
-	 * @see org.eclipse.cdt.internal.core.sourcedependency.IDependencyTree#save()
-	 */
-	public void save() throws IOException {
-		// TODO Auto-generated method stub
-	}
-	/* (non-Javadoc)
-	 * @see org.eclipse.cdt.internal.core.sourcedependency.IDependencyTree#remove(java.lang.String)
-	 */
-	public void remove(String documentName) throws IOException {
-		//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, IFile file, ParserLanguage language) throws IOException  {
-		IndexedFile indexedFile= addsTree.getIndexedFile(document.getName());
-		//if (indexedFile != null)
-			//remove(indexedFile, 0);
-		PreprocessorOutput output= new PreprocessorOutput(addsTree, file);
-		DependencyRequestor depReq = new DependencyRequestor(output,document);
-		
-		output.addDocument(document);
-		
-		IPreprocessor preprocessor = ParserFactory.createPreprocessor( new StringReader( document.getStringContent() ),docPath , newInfo, ParserMode.COMPLETE_PARSE, language, depReq);
-		preprocessor.process();
-	}
-	/**
-	 * Initialises the indexGenerator.
-	 */
-	public void initialize() throws IOException {
-		//initialisation of addsTree
-		addsTree= new InMemoryTree();
-	}
-	/* (non-Javadoc)
-	 * @see org.eclipse.cdt.internal.core.sourcedependency.IDependencyTree#getFileDepencies(int)
-	 */
-	public String[] getFileDependencies(IPath filePath) throws IOException {
-		List tempFileReturn = new ArrayList();
-		IndexedFile indexFile = addsTree.getIndexedFile(filePath.toString());
-		
-		if (indexFile == null)
-		 return new String[0];
-		 
-		int fileNum = indexFile.getFileNumber();
-		IncludeEntry[] tempEntries = addsTree.getIncludeEntries();
-		for (int i=0; i<tempEntries.length; i++)
-		{
-			int[] fileRefs = tempEntries[i].getRefs();
-		    for (int j=0; j<fileRefs.length; j++)
-		    {
-		    	if (fileRefs[j] == fileNum)
-		    	{ 
-		    		//System.out.println(filePath.toString() + " references " + y[i].toString());
-		    		char[] tempFile = tempEntries[i].getFile();
-		    		StringBuffer tempString = new StringBuffer();
-		    		tempString.append(tempFile);
-		    		tempFileReturn.add(tempString.toString());
-		    		break;
-		    	}
-		    }
-		}
-		return (String []) tempFileReturn.toArray(new String[tempFileReturn.size()]);
-	}
-	//TODO: BOG Debug Method Take out
-	public void printIncludeEntries(){
-	 IncludeEntry[] tempEntries = addsTree.getIncludeEntries();
-	 for (int i=0; i<tempEntries.length; i++){
-	 	System.out.println(tempEntries[i].toString());
-	 }
-	}
-	//TODO: BOG Debug Method Take out
-	public void printIndexedFiles() {
-		IndexedFile[] tempFiles = addsTree.getIndexedFiles();
-		for (int i=0;i<tempFiles.length;i++){
-			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: dependency/org/eclipse/cdt/internal/core/sourcedependency/EntireProjectDependencyTree.java
diff -N dependency/org/eclipse/cdt/internal/core/sourcedependency/EntireProjectDependencyTree.java
--- dependency/org/eclipse/cdt/internal/core/sourcedependency/EntireProjectDependencyTree.java	9 Sep 2003 17:53:51 -0000	1.3
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,200 +0,0 @@
-/**********************************************************************
- * Copyright (c) 2002,2003 Rational Software Corporation and others.
- * All rights reserved.   This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
- * 
- * Contributors: 
- * IBM Rational Software - Initial API and implementation
-***********************************************************************/
-
-package org.eclipse.cdt.internal.core.sourcedependency;
-
-import java.util.HashSet;
-
-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;
-import org.eclipse.cdt.internal.core.search.SimpleLookupTable;
-import org.eclipse.cdt.internal.core.search.indexing.ReadWriteMonitor;
-import org.eclipse.cdt.internal.core.search.processing.JobManager;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IResourceProxy;
-import org.eclipse.core.resources.IResourceProxyVisitor;
-import org.eclipse.core.resources.IWorkspaceRoot;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IProgressMonitor;
-/**
- * @author bgheorgh
- */
-public class EntireProjectDependencyTree extends DependencyRequest {
-	IProject project;
-	
-	public EntireProjectDependencyTree(IProject project, DependencyManager manager) {
-		super(project.getFullPath(), manager);
-		this.project = project;
-	}
-
-	public boolean equals(Object o) {
-		if (o instanceof EntireProjectDependencyTree)
-			return this.project.equals(((EntireProjectDependencyTree) o).project);
-		return false;
-	}
-	
-	public boolean execute(IProgressMonitor progressMonitor) {
-
-		if (progressMonitor != null && progressMonitor.isCanceled()) return true;
-		if (!project.isAccessible()) return true; // nothing to do
-
-		IDependencyTree dTree = this.manager.getDependencyTree(this.dependencyTreePath, true, /*reuse index file*/ true /*create if none*/);
-		if (dTree == null) return true;
-		ReadWriteMonitor monitor = this.manager.getMonitorFor(dTree);
-		if (monitor == null) return true; // tree got deleted since acquired
-
-		try {
-			monitor.enterRead(); // ask permission to read
-			saveIfNecessary(dTree, monitor);
-
-			IQueryResult[] results = dTree.queryInDocumentNames(""); // get all file names already stored in this project //$NON-NLS-1$
-			int max = results == null ? 0 : results.length;
-			final SimpleLookupTable indexedFileNames = new SimpleLookupTable(max == 0 ? 33 : max + 11);
-			final String OK = "OK"; //$NON-NLS-1$
-			final String DELETED = "DELETED"; //$NON-NLS-1$
-			for (int i = 0; i < max; i++)
-				indexedFileNames.put(results[i].getPath(), DELETED);
-			final long indexLastModified = max == 0 ? 0L : dTree.getIndexFile().lastModified();
-
-			IPath cProjectPath = project.getFullPath();
-		
-			IWorkspaceRoot root = this.project.getWorkspace().getRoot();
-			IResource sourceFolder = root.findMember(cProjectPath);
-		
-			if (this.isCancelled) return false;
-
-			if (sourceFolder != null) {
-					
-				//collect output locations if source is project (see http://bugs.eclipse.org/bugs/show_bug.cgi?id=32041)
-				final HashSet outputs = new HashSet();
-		
-				final boolean hasOutputs = !outputs.isEmpty();
-					
-				final char[][] patterns = null;
-				if (max == 0) {
-					sourceFolder.accept(
-							new IResourceProxyVisitor() {
-								public boolean visit(IResourceProxy proxy) {
-									if (isCancelled) return false;
-									switch(proxy.getType()) {
-										case IResource.FILE :
-//											TODO: BOG Put the file name checking back
-										//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;
-		
-										case IResource.FOLDER :
-												if (patterns != null && Util.isExcluded(proxy.requestResource(), patterns))
-													return false;
-												if (hasOutputs && outputs.contains(proxy.requestFullPath())) {
-													return false;
-												}
-										}
-										return true;
-								 }
-								},
-								IResource.NONE
-							);
-						} else {
-							sourceFolder.accept(
-								new IResourceProxyVisitor() {
-									public boolean visit(IResourceProxy proxy) {
-										if (isCancelled) return false;
-										switch(proxy.getType()) {
-											case IResource.FILE :
-//												TODO: BOG Put the file name checking back
-											//	if (Util.isCCFileName(proxy.getName())) {
-													IResource resource = proxy.requestResource();
-													IPath path = resource.getLocation();
-													if (path != null && (patterns == null || !Util.isExcluded(resource, patterns))) {
-														String name = new IFileDocument((IFile) resource).getName();
-														indexedFileNames.put(name,
-															indexedFileNames.get(name) == null || indexLastModified < path.toFile().lastModified()
-																? (Object) resource
-																: (Object) OK);
-													}
-												//}
-												return false;
-											case IResource.FOLDER :
-												if (patterns != null && Util.isExcluded(proxy.requestResource(), patterns))
-													return false;
-												if (hasOutputs && outputs.contains(proxy.requestFullPath())) {
-													return false;
-												}
-										}
-										return true;
-									}
-								},
-								IResource.NONE
-							);
-						}
-					}
-									
-			Object[] names = indexedFileNames.keyTable;
-			Object[] values = indexedFileNames.valueTable;
-			boolean shouldSave = false;
-			for (int i = 0, length = names.length; i < length; i++) {
-				String name = (String) names[i];
-				if (name != null) {
-					if (this.isCancelled) return false;
-
-					Object value = values[i];
-					if (value != OK) {
-						shouldSave = true;
-					if (value == DELETED)
-							this.manager.remove(name, this.dependencyTreePath);
-					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 (DependencyManager.VERBOSE) {
-				JobManager.verbose("-> failed to generate tree " + this.project + " because of the following exception:"); //$NON-NLS-1$ //$NON-NLS-2$
-				e.printStackTrace();
-			}
-			this.manager.removeTree(this.dependencyTreePath);
-			return false;
-		} finally {
-			monitor.exitRead(); // free read lock
-		}
-	 return true;
-	}
-
-	public int hashCode() {
-		  return this.project.hashCode();
-	}
-	
-    protected Integer updatedIndexState() {
-	  return DependencyManager.REBUILDING_STATE;
-    }
-
-    public String toString() {
-	  return "calculating dependency tree for project " + this.project.getFullPath(); //$NON-NLS-1$
-    }
-}
Index: dependency/org/eclipse/cdt/internal/core/sourcedependency/IDependencyTree.java
===================================================================
RCS file: dependency/org/eclipse/cdt/internal/core/sourcedependency/IDependencyTree.java
diff -N dependency/org/eclipse/cdt/internal/core/sourcedependency/IDependencyTree.java
--- dependency/org/eclipse/cdt/internal/core/sourcedependency/IDependencyTree.java	9 Sep 2003 17:53:51 -0000	1.3
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,85 +0,0 @@
-/**********************************************************************
- * Copyright (c) 2002,2003 Rational Software Corporation and others.
- * All rights reserved.   This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
- * 
- * Contributors: 
- * IBM Rational Software - Initial API and implementation
-***********************************************************************/
-
-package org.eclipse.cdt.internal.core.sourcedependency;
-
-import java.io.File;
-import java.io.IOException;
-
-import org.eclipse.cdt.core.parser.IScannerInfo;
-import org.eclipse.cdt.core.parser.ParserLanguage;
-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, IFile file, ParserLanguage language) throws IOException;
-
-	/**
-	 * Empties the index.
-	 */
-	void empty() throws IOException;
-	/**
-	 * Returns the index file on the disk.
-	 */
-	File getIndexFile();
-	/**
-	 * Returns the number of documents indexed.
-	 */
-	int getNumDocuments() throws IOException;
-	/**
-	 * Returns the number of unique words indexed.
-	 */
-	int getNumIncludes() throws IOException;
-	/**
-	 * Returns the path corresponding to a given document number
-	 */
-	String getPath(int documentNumber) throws IOException;
-	/**
-	 * Ansers true if has some changes to save.
-	 */
-	boolean hasChanged();
-	/**
-	 * Returns the paths of the documents containing the given word.
-	 */
-	IQueryResult[] query(String word) throws IOException;
-	/**
-	 * Returns the paths of the documents whose names contain the given word.
-	 */
-	IQueryResult[] queryInDocumentNames(String word) throws IOException;
-		
-	/**
-	 * Removes the corresponding document from the tree.
-	 */
-	void remove(String documentName) throws IOException;
-	/**
-	 * Saves the index on the disk.
-	 */
-	void save() throws IOException;
-	/**
-	 * Gets the files that are included by the passed in file.
-	 */
-	String[] getFileDependencies(IPath filePath) throws IOException;
-	//	TODO: BOG Debug Method Take out
-	/**
-	 * Prints all of the IncludeEntries for this project.
-	 */
-	public void printIncludeEntries();
-	//	TODO: BOG Debug Method Take out
-	/**
-	 * Prints all of the IndexedFiles for this project.
-	 */
-	public void printIndexedFiles();
-}
Index: dependency/org/eclipse/cdt/internal/core/sourcedependency/IPreprocessorOutput.java
===================================================================
RCS file: dependency/org/eclipse/cdt/internal/core/sourcedependency/IPreprocessorOutput.java
diff -N dependency/org/eclipse/cdt/internal/core/sourcedependency/IPreprocessorOutput.java
--- dependency/org/eclipse/cdt/internal/core/sourcedependency/IPreprocessorOutput.java	24 Jul 2003 14:15:06 -0000	1.1
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,20 +0,0 @@
-/**********************************************************************
- * Copyright (c) 2002,2003 Rational Software Corporation and others.
- * All rights reserved.   This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
- * 
- * Contributors: 
- * IBM Rational Software - Initial API and implementation
-***********************************************************************/
-
-package org.eclipse.cdt.internal.core.sourcedependency;
-
-import org.eclipse.cdt.internal.core.index.IDocument;
-
-public interface IPreprocessorOutput {
-	public void addDocument(IDocument document);
-	public void addRef(char[] word);
-	public void addRef(String word);
-}
Index: dependency/org/eclipse/cdt/internal/core/sourcedependency/ISourceDependency.java
===================================================================
RCS file: dependency/org/eclipse/cdt/internal/core/sourcedependency/ISourceDependency.java
diff -N dependency/org/eclipse/cdt/internal/core/sourcedependency/ISourceDependency.java
--- dependency/org/eclipse/cdt/internal/core/sourcedependency/ISourceDependency.java	24 Jul 2003 14:15:06 -0000	1.1
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,19 +0,0 @@
-/**********************************************************************
- * Copyright (c) 2002,2003 Rational Software Corporation and others.
- * All rights reserved.   This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
- * 
- * Contributors: 
- * IBM Rational Software - Initial API and implementation
-***********************************************************************/
- 
-package org.eclipse.cdt.internal.core.sourcedependency;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IProject;
-
-public interface ISourceDependency {
-	IProject[] getProjects(IFile file);
-	String[] getFileDependencies(IProject project, IFile file);
-}
Index: dependency/org/eclipse/cdt/internal/core/sourcedependency/Node.java
===================================================================
RCS file: dependency/org/eclipse/cdt/internal/core/sourcedependency/Node.java
diff -N dependency/org/eclipse/cdt/internal/core/sourcedependency/Node.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ dependency/org/eclipse/cdt/internal/core/sourcedependency/Node.java	25 Sep 2003 23:39:44 -0000
@@ -0,0 +1,45 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials 
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ * 
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.core.sourcedependency;
+
+/**
+ * @author bgheorgh
+ */
+public class Node {
+
+	int fileRef;
+	int nodeId;
+	
+	public Node(int file, int id){
+		this.fileRef = file;
+		this.nodeId = id;
+	}
+	
+	public int getFileRef(){
+		return fileRef;
+	}
+	
+	public int getNodeId(){
+		return nodeId;
+	}
+	
+	public String toString() {
+	 StringBuffer tempBuffer = new StringBuffer();
+	 tempBuffer.append("[FileRef: ");
+	 tempBuffer.append(fileRef);
+	 tempBuffer.append(", Id: ");
+	 tempBuffer.append(nodeId);	
+	 tempBuffer.append("]");
+	 return tempBuffer.toString();
+	}
+
+}
Index: dependency/org/eclipse/cdt/internal/core/sourcedependency/PreprocessorOutput.java
===================================================================
RCS file: dependency/org/eclipse/cdt/internal/core/sourcedependency/PreprocessorOutput.java
diff -N dependency/org/eclipse/cdt/internal/core/sourcedependency/PreprocessorOutput.java
--- dependency/org/eclipse/cdt/internal/core/sourcedependency/PreprocessorOutput.java	9 Sep 2003 17:53:51 -0000	1.2
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,66 +0,0 @@
-/**********************************************************************
- * Copyright (c) 2002,2003 Rational Software Corporation and others.
- * All rights reserved.   This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
- * 
- * Contributors: 
- * IBM Rational Software - Initial API and implementation
-***********************************************************************/
-
-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, 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) {
-		if (indexedFile == null) {
-					throw new IllegalStateException();
-		}
-		tree.addRelatives(indexedFile, inclusion, parent);	
-	}
-
-	public void addDocument(IDocument document) {
-		if (indexedFile == null) {
-			indexedFile= tree.addDocument(document);
-		} else {
-			throw new IllegalStateException();
-		}
-	}
-
-	public void addRef(char[] word) {
-		if (indexedFile == null) {
-			throw new IllegalStateException();
-		}
-			tree.addRef(indexedFile, word);	
-	}
-
-	public void addRef(String word) {
-		addRef(word.toCharArray());
-	}
-}
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
--- dependency/org/eclipse/cdt/internal/core/sourcedependency/RemoveFromDependencyTree.java	9 Sep 2003 17:53:51 -0000	1.1
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,58 +0,0 @@
-/*
- * 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: dependency/org/eclipse/cdt/internal/core/sourcedependency/impl/InMemoryTree.java
diff -N dependency/org/eclipse/cdt/internal/core/sourcedependency/impl/InMemoryTree.java
--- dependency/org/eclipse/cdt/internal/core/sourcedependency/impl/InMemoryTree.java	9 Sep 2003 17:53:51 -0000	1.2
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,150 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials 
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- * 
- * Contributors:
- *     IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.cdt.internal.core.sourcedependency.impl;
-
-import org.eclipse.cdt.internal.core.index.IDocument;
-import org.eclipse.cdt.internal.core.index.impl.IndexedFile;
-import org.eclipse.cdt.internal.core.index.impl.IndexedFileHashedArray;
-
-public class InMemoryTree {
-
-	/**
-	* hashtable of IncludeEntrys = includeFiles+numbers of the files they appear in.
-	*/
-	protected IncludeEntryHashedArray includes;
-	/**
-	 * List of IndexedFiles = file name + a unique number.
-	 */
-	protected IndexedFileHashedArray files;
-	/**
-	 * Size of the tree.
-	 */
-	protected long footprint;	
-	private int lastId;
-
-	public InMemoryTree() {
-		init();
-	}
-	/**
-	 * Initialises the fields of the tree
-	 */
-	public void init() {
-		includes= new IncludeEntryHashedArray(501);
-		files= new IndexedFileHashedArray(101);
-		footprint= 0;
-		lastId=0;
-	}
-	
-	public IndexedFile addDocument(IDocument document) {
-		IndexedFile indexedFile= this.files.add(document);
-	    this.footprint += indexedFile.footprint() + 4;
-		
-		return indexedFile;
-	}
-	/**
-	 * Adds the references of the include to the tree (reference = number of the file the include belongs to).
-	 */
-	protected void addRef(char[] include, int[] references) {
-		int size= references.length;
-		int i= 0;
-		while (i < size) {
-			if (references[i] != 0)
-				addRef(include, references[i]);
-			i++;
-		}
-	}
-	/**
-	 * Looks if the include already exists to the tree and adds the fileNum to this include.
-	 * If the include does not exist, it adds it to the tree.
-	 */
-	protected void addRef(char[] include, int fileNum) {
-		IncludeEntry entry= (IncludeEntry) this.includes.get(include);
-		if (entry == null) {
-			entry= new IncludeEntry(include, ++lastId);
-			entry.addRef(fileNum);
-			this.includes.add(entry);
-		} else {
-			this.footprint += entry.addRef(fileNum);
-		}
-	}
-
-	public void addRef(IndexedFile indexedFile, char[] include) {
-		addRef(include, indexedFile.getFileNumber());
-	}
-
-	public void addRef(IndexedFile indexedFile, String include) {
-		addRef(include.toCharArray(), indexedFile.getFileNumber());
-	}
-	/**
-	 * Returns the indexed file with the given path, or null if such file does not exist.
-	 */
-	public IndexedFile getIndexedFile(String path) {
-		return files.get(path);
-	}
-	/**
-	 * @see IIndex#getNumDocuments()
-	 */
-	public int getNumFiles() {
-		return files.size();
-	}
-	/**
-	 * @see IIndex#getNumWords()
-	 */
-	public int getNumIncludes() {
-		return includes.elementSize;
-	}
-	
-	/**
-	 * Returns the include entry corresponding to the given include.
-	 */
-	protected IncludeEntry getIncludeEntry(char[] include) {
-		return (IncludeEntry) includes.get(include);
-	}
-
-	public void addRelatives(IndexedFile indexedFile, String inclusion, String parent) {
-		addRelatives(indexedFile.getFileNumber(),inclusion.toCharArray(),(parent != null ) ? parent.toCharArray() : null);
-	}
-	
-    protected void addRelatives(int fileNumber, char[] inclusion, char[] parent) {
-		IncludeEntry childEntry=null;
-		IncludeEntry parentEntry=null;
-		
-		if (inclusion != null)
-			childEntry= (IncludeEntry) this.includes.get(inclusion);
-	
-		if (parent != null)
-			parentEntry= (IncludeEntry) this.includes.get(parent);
-		
-
-		childEntry.addParent(fileNumber,(parentEntry!=null) ? parentEntry.getID() : -1);
-		
-		if (parent!=null)
-			parentEntry.addChild(fileNumber,(childEntry!=null) ? childEntry.getID() : -1);
-	}	
-	/**
-	 * Returns the include entries contained in the hashtable of includes.
-	 */
-	public IncludeEntry[] getIncludeEntries() {
-		return this.includes.asArray();
-	}
-	
-	public IndexedFile[] getIndexedFiles(){
-		return this.files.asArray();
-	}
-	
-	/**
-	 * Returns the footprint of the index.
-	 */
-	public long getFootprint() {
-		return this.footprint;
-	}
-}
Index: dependency/org/eclipse/cdt/internal/core/sourcedependency/impl/IncludeEntry.java
===================================================================
RCS file: dependency/org/eclipse/cdt/internal/core/sourcedependency/impl/IncludeEntry.java
diff -N dependency/org/eclipse/cdt/internal/core/sourcedependency/impl/IncludeEntry.java
--- dependency/org/eclipse/cdt/internal/core/sourcedependency/impl/IncludeEntry.java	12 Aug 2003 20:20:04 -0000	1.2
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,159 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials 
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- * 
- * Contributors:
- *     IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.cdt.internal.core.sourcedependency.impl;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-
-import org.eclipse.cdt.internal.core.CharOperation;
-
-/**
- * @author bgheorgh
- */
-public class IncludeEntry {
-
-  protected char[] fFile;
-  protected int fId;
-  protected int fNumRefs;
-  protected int[] fRefs;
-  //TODO: BOG Consider making these arrays...
-  protected ArrayList fParent;
-  protected ArrayList fChild;
-  protected int fNumParent;
-  protected int fNumChild;
-   
-  public IncludeEntry(int id) {
-	this(CharOperation.NO_CHAR,id);
-  }
-		
-  public IncludeEntry(char[] file, int id) {
-	fFile = file;
-	fNumRefs= 0;
-	fRefs= new int[1];
-	fId=id;
-	
-	fParent = new ArrayList(5);
-	fChild = new ArrayList(5);
-	fNumParent = 0;
-	fNumChild = 0;
-  }
-  /**
-   * Adds a reference and records the change in footprint.
-   */
-    public int addRef(int fileNum) {
-      if (fNumRefs > 0 && fRefs[fNumRefs - 1] == fileNum) {
-	   return 0;
-      }
-      if (fNumRefs < fRefs.length) {
-   	    fRefs[fNumRefs++]= fileNum;
-	    return 0;
-      } 
-
-      int newSize= fNumRefs < 4 ? 4 : fNumRefs * 2; // so will start @ 1, grow to 4, 8, 16, 32, 64 etc.
-	  System.arraycopy(fRefs, 0, fRefs= new int[newSize], 0, fNumRefs);
-	  fRefs[fNumRefs++]= fileNum;
-	  return (newSize - fNumRefs + 1) * 4;
-    }
-	  
-	public void addParent(int fileRef, int parentId){
-		Node newParent = new Node(fileRef,parentId);
-		fParent.add(newParent);
-		fNumParent++;
-	}
-	
-	public void addChild(int fileRef, int parentId){
-		Node newChild = new Node(fileRef,parentId);
-		fChild.add(newChild);
-		fNumChild++;
-	}
-	/**
-	 * Returns the number of references, e.g. the number of files this word appears in.
-	 */
-	public int getNumRefs() {
-		return fNumRefs;
-	}
-	/**
-	 * returns the file number in the i position in the list of references.
-	 */
-	public int getRef(int i) {
-		if (i < fNumRefs) return fRefs[i];
-		throw new IndexOutOfBoundsException();
-	}
-	/**
-	 * Returns the references of the includeEntry (the number of the files it appears in).
-	 */
-	public int[] getRefs() {
-		int[] result= new int[fNumRefs];
-		System.arraycopy(fRefs, 0, result, 0, fNumRefs);
-		return result;
-	}
-	/**
-	 * returns the word of the includeEntry.
-	 */
-	public char[] getFile() {
-		return fFile;
-	}
-	
-	/**
-	 * Clears the includeEntry.
-	 */
-	public void reset(char[] word) {
-		for (int i= fNumRefs; i-- > 0;) {
-			fRefs[i]= 0;
-		}
-		fNumRefs= 0;
-		fFile= word;
-	}
-	
-	public int getID(){
-		return fId;
-	}
-	
-	public String toString() {
-		StringBuffer tempBuffer = new StringBuffer();
-		tempBuffer.append("<Name: ");
-		tempBuffer.append(fFile);
-		tempBuffer.append(", Id: ");
-		tempBuffer.append(fId);
-		tempBuffer.append(", Refs:{");
-		for (int i = 0; i < fRefs.length; i++){
-			if (i > 0) tempBuffer.append(',');
-			tempBuffer.append(' ');
-			tempBuffer.append(fRefs[i]);
-		}
-		tempBuffer.append("}, Parents:{");
-		Iterator x = fParent.iterator();
-		while (x.hasNext())
-		{
-			Node tempNode = (Node) x.next();
-			tempBuffer.append(tempNode.toString());
-			if (x.hasNext()) {
-				tempBuffer.append(',');
-				tempBuffer.append(' ');
-			}
-		}
-		tempBuffer.append("}, Children:{");
-		Iterator y = fChild.iterator();
-		while (y.hasNext())
-		{
-			Node tempNode = (Node) y.next();
-			tempBuffer.append(tempNode.toString());
-			if (y.hasNext()) {
-				tempBuffer.append(',');
-				tempBuffer.append(' ');
-			}
-		}
-		tempBuffer.append("} >");
-		return tempBuffer.toString();
-	}
-	
-}
Index: dependency/org/eclipse/cdt/internal/core/sourcedependency/impl/IncludeEntryHashedArray.java
===================================================================
RCS file: dependency/org/eclipse/cdt/internal/core/sourcedependency/impl/IncludeEntryHashedArray.java
diff -N dependency/org/eclipse/cdt/internal/core/sourcedependency/impl/IncludeEntryHashedArray.java
--- dependency/org/eclipse/cdt/internal/core/sourcedependency/impl/IncludeEntryHashedArray.java	12 Aug 2003 20:20:04 -0000	1.2
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,84 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials 
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- * 
- * Contributors:
- *     IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.cdt.internal.core.sourcedependency.impl;
-
-import org.eclipse.cdt.internal.core.CharOperation;
-
-public final class IncludeEntryHashedArray {
-
-	public IncludeEntry elements[];
-	public int elementSize; // number of elements in the table
-	public int threshold;
-	
-	public IncludeEntryHashedArray(int size) {
-		if (size < 7) size = 7;
-		this.elements = new IncludeEntry[2 * size + 1];
-		this.elementSize = 0;
-		this.threshold = size + 1; // size is the expected number of elements
-	}
-	
-	public IncludeEntry add(IncludeEntry entry) {
-		int length = elements.length;
-		char[] word = entry.getFile();
-		int index = CharOperation.hashCode(word) % length;
-		IncludeEntry current;
-		while ((current = elements[index]) != null) {
-			if (CharOperation.equals(current.getFile(), word)) return elements[index] = entry;
-			if (++index == length) index = 0;
-		}
-		elements[index] = entry;
-	
-		// assumes the threshold is never equal to the size of the table
-		if (++elementSize > threshold) grow();
-		return entry;
-	}
-	
-	public IncludeEntry[] asArray() {
-		IncludeEntry[] array = new IncludeEntry[elementSize];
-		for (int i = 0, j = 0, length = elements.length; i < length; i++) {
-			IncludeEntry current = elements[i];
-			if (current != null) array[j++] = current;
-		}
-		return array;
-	}
-	
-	public IncludeEntry get(char[] word) {
-		int length = elements.length;
-		int index = CharOperation.hashCode(word) % length;
-		IncludeEntry current;
-		while ((current = elements[index]) != null) {
-			if (CharOperation.equals(current.getFile(), word)) return current;
-			if (++index == length) index = 0;
-		}
-		return null;
-	}
-	
-	private void grow() {
-		IncludeEntryHashedArray newArray = new IncludeEntryHashedArray(elementSize * 2); // double the number of expected elements
-		for (int i = 0, length = elements.length; i < length; i++)
-			if (elements[i] != null)
-				newArray.add(elements[i]);
-	
-		this.elements = newArray.elements;
-		this.elementSize = newArray.elementSize;
-		this.threshold = newArray.threshold;
-	}
-	
-	public String toString() {
-		String s = ""; //$NON-NLS-1$
-		IncludeEntry[] entries = asArray();
-		for (int i = 0, length = entries.length; i < length; i++)
-			s += entries[i].toString() + "\n"; 	//$NON-NLS-1$
-		return s;
-	}
-
-}
Index: dependency/org/eclipse/cdt/internal/core/sourcedependency/impl/Node.java
===================================================================
RCS file: dependency/org/eclipse/cdt/internal/core/sourcedependency/impl/Node.java
diff -N dependency/org/eclipse/cdt/internal/core/sourcedependency/impl/Node.java
--- dependency/org/eclipse/cdt/internal/core/sourcedependency/impl/Node.java	24 Jul 2003 14:15:06 -0000	1.1
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,45 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials 
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- * 
- * Contributors:
- *     IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.cdt.internal.core.sourcedependency.impl;
-
-/**
- * @author bgheorgh
- */
-public class Node {
-
-	int fileRef;
-	int nodeId;
-	
-	public Node(int file, int id){
-		this.fileRef = file;
-		this.nodeId = id;
-	}
-	
-	public int getFileRef(){
-		return fileRef;
-	}
-	
-	public int getNodeId(){
-		return nodeId;
-	}
-	
-	public String toString() {
-	 StringBuffer tempBuffer = new StringBuffer();
-	 tempBuffer.append("[FileRef: ");
-	 tempBuffer.append(fileRef);
-	 tempBuffer.append(", Id: ");
-	 tempBuffer.append(nodeId);	
-	 tempBuffer.append("]");
-	 return tempBuffer.toString();
-	}
-
-}
Index: index/ChangeLog
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/index/ChangeLog,v
retrieving revision 1.20
diff -u -r1.20 ChangeLog
--- index/ChangeLog	23 Sep 2003 15:17:13 -0000	1.20
+++ index/ChangeLog	25 Sep 2003 23:39:44 -0000
@@ -1,3 +1,35 @@
+2003-09-25 Bogdan Gheorghe
+	Integrated the dependency service into the indexer. Changes
+	as follows:
+	
+	org.eclipse.cdt.internal.core.index.impl:
+	* IIndex - added getFileDependencies methods
+	* IIndexerOutput - modified to allow dep inputs into the index
+	* BlocksIndexInput - modified to allow the reading of the new index (which includes dep entries)
+	* BlocksIndexOutput - added facilities to write includes to the index
+	* GammaCompressedIndexBlock - modified with addIncludeEntry() and nextEntry()
+	* IncludeEntry - new file
+	* IncludeEntryHashedArray - new file
+	* Index - Added getFileDepenendencies to query includeEntries from the index
+	* IndexBlock - modified to reflect changes in GammaCompressedIndexBlock
+	* IndexerOutput - added new methods from IIndexerOutput
+	* IndexInput - modified to allow reading of includes from index files
+	* IndexSummary - modified to save/read new format which contains include info
+	* InMemoryIndex - modified InMemoryIndex to keep track of includes
+	* MergeFactory - modified MergeFactory to accomodate new index file format
+	* SimpleIndexInput - modified to use the new functions for includes in InMemoryIndex
+	* Util - Added a quickSort for includeEntry[]
+	
+	org.eclipse.cdt.internal.core.search.indexing:
+	* AbstractIndexer - modified to getResourceFile being indexed, added bestIncludePrefix 
+	  to find include table entries, addInclude() which accepts IASTInclusion node and adds it
+	  to the index
+	* IIndexConstants - added includeRef constant
+	* IndexManager - got rid of all dependency table references
+	* SourceIndexer - modified to return resource being indexed
+	* SourceIndexerRequestor - Added inclusion handling code; stack for includes
+	
+	
 2003-09-22 Bogdan Gheorghe
 	
 	Took out the old CTags Indexer. Modified IndexAllProject to get
Index: index/org/eclipse/cdt/internal/core/index/IIndex.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/IIndex.java,v
retrieving revision 1.2
diff -u -r1.2 IIndex.java
--- index/org/eclipse/cdt/internal/core/index/IIndex.java	4 Jul 2003 03:02:07 -0000	1.2
+++ index/org/eclipse/cdt/internal/core/index/IIndex.java	25 Sep 2003 23:39:44 -0000
@@ -13,6 +13,9 @@
 import java.io.File;
 import java.io.IOException;
 
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.IPath;
+
 /**
  * An IIndex is the interface used to generate an index file, and to make queries on
  * this index.
@@ -71,5 +74,11 @@
 		 * Saves the index on the disk.
 		 */
 		void save() throws IOException;
+		/**
+		 * @param path
+		 * @return
+		 */
+		String[] getFileDependencies(IPath path) throws IOException;
+	    String[] getFileDependencies(IFile file) throws IOException;
 
 }
Index: index/org/eclipse/cdt/internal/core/index/IIndexerOutput.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/IIndexerOutput.java,v
retrieving revision 1.2
diff -u -r1.2 IIndexerOutput.java
--- index/org/eclipse/cdt/internal/core/index/IIndexerOutput.java	4 Jul 2003 03:02:07 -0000	1.2
+++ index/org/eclipse/cdt/internal/core/index/IIndexerOutput.java	25 Sep 2003 23:39:44 -0000
@@ -19,4 +19,8 @@
 	public void addDocument(IDocument document);
 	public void addRef(char[] word);
 	public void addRef(String word);
+	//For Dep Tree
+	public void addIncludeRef(char[] word);
+	public void addIncludeRef(String word);
+	public void addRelatives(String inclusion, String parent);
 }
Index: index/org/eclipse/cdt/internal/core/index/impl/BlocksIndexInput.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/impl/BlocksIndexInput.java,v
retrieving revision 1.3
diff -u -r1.3 BlocksIndexInput.java
--- index/org/eclipse/cdt/internal/core/index/impl/BlocksIndexInput.java	12 Aug 2003 20:20:04 -0000	1.3
+++ index/org/eclipse/cdt/internal/core/index/impl/BlocksIndexInput.java	25 Sep 2003 23:39:44 -0000
@@ -31,6 +31,7 @@
 	protected int currentFileListBlockNum;
 	protected int currentIndexBlockNum;
 	protected IndexBlock currentIndexBlock;
+	protected IndexBlock currentIncludeIndexBlock;
 	private RandomAccessFile raf;
 	protected File indexFile;
 	protected LRUCache blockCache;
@@ -157,6 +158,12 @@
 		return summary.getNumWords();
 	}
 	/**
+	 * @see IndexInput#getNumIncludes()
+	 */
+	public int getNumIncludes() {
+		return summary.getNumIncludes();
+	}
+	/**
 	 * @see IndexInput#getSource()
 	 */
 	public Object getSource() {
@@ -169,6 +176,7 @@
 		clearCache();
 		setFirstFile();
 		setFirstWord();
+		setFirstInclude();
 	}
 	/**
 	 * @see IndexInput#moveToNextFile()
@@ -388,4 +396,79 @@
 			currentIndexBlock.nextEntry(currentWordEntry);
 		}
 	}
+
+	/* (non-Javadoc)
+	 * @see org.eclipse.cdt.internal.core.index.impl.IndexInput#moveToNextIncludeEntry()
+	 */
+	public void moveToNextIncludeEntry() throws IOException {
+		includePosition++;
+		if (!hasMoreIncludes()) {
+			return;
+		}
+		//if end of the current block, we load the next one.
+		boolean endOfBlock= !currentIncludeIndexBlock.nextEntry(currentIncludeEntry);
+		if (endOfBlock) {
+			currentIncludeIndexBlock= getIndexBlock(++currentIndexBlockNum);
+			currentIncludeIndexBlock.nextEntry(currentWordEntry);
+		}
+	}
+	/* (non-Javadoc)
+	 * @see org.eclipse.cdt.internal.core.index.impl.IndexInput#setFirstInclude()
+	 */
+	protected void setFirstInclude() throws IOException {
+		includePosition= 1;
+		if (getNumIncludes() > 0) {
+			currentIndexBlockNum= summary.getFirstIncludeBlockNum();
+			currentIncludeIndexBlock= getIndexBlock(currentIndexBlockNum);
+			currentIncludeEntry= new IncludeEntry(0);
+			currentIncludeIndexBlock.reset();
+			currentIncludeIndexBlock.nextEntry(currentIncludeEntry);
+		}
+	}
+	/* (non-Javadoc)
+	 * @see org.eclipse.cdt.internal.core.index.impl.IndexInput#queryIncludeEntries()
+	 */
+	public IncludeEntry[] queryIncludeEntries() {
+		// TODO Auto-generated method stub
+		return null;
+	}
+	/* (non-Javadoc)
+	 * @see org.eclipse.cdt.internal.core.index.impl.IndexInput#queryIncludeEntries(int)
+	 */
+	public IncludeEntry[] queryIncludeEntries(int fileNum) throws IOException {
+		open();
+		
+		if (fileNum < 0) return null;
+		int[] blockNums = null;
+		blockNums = summary.getBlockNumsForIncludes();
+		
+		if (blockNums == null || blockNums.length == 0)	return null;
+				
+		IncludeEntry[] entries = new IncludeEntry[5];
+		int count = 0;
+		for (int i = 0, max = blockNums.length; i < max; i++) {
+			IndexBlock block = getIndexBlock(blockNums[i]);
+			block.reset();
+			boolean found = false;
+			IncludeEntry entry = new IncludeEntry(0);
+			
+			while (block.nextEntry(entry)) {
+				if (count == entries.length){
+					System.arraycopy(entries, 0, entries = new IncludeEntry[count*2], 0, count);
+				}
+				for (int j=0; j<entry.getNumRefs(); j++){
+					if (entry.getRef(j) == fileNum){
+						entries[count++] = new IncludeEntry(entry.getFile(),entry.getID());
+						break; 
+					}
+				}
+			}
+		}
+		if (count == 0) return null;
+		if (count != entries.length){
+			System.arraycopy(entries, 0, entries = new IncludeEntry[count], 0, count);
+		}
+		return entries;
+	}
+
 }
Index: index/org/eclipse/cdt/internal/core/index/impl/BlocksIndexOutput.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/impl/BlocksIndexOutput.java,v
retrieving revision 1.2
diff -u -r1.2 BlocksIndexOutput.java
--- index/org/eclipse/cdt/internal/core/index/impl/BlocksIndexOutput.java	4 Jul 2003 03:02:07 -0000	1.2
+++ index/org/eclipse/cdt/internal/core/index/impl/BlocksIndexOutput.java	25 Sep 2003 23:39:44 -0000
@@ -23,18 +23,25 @@
  */
 
 public class BlocksIndexOutput extends IndexOutput {
+
 	protected RandomAccessFile indexOut;
 	protected int blockNum;
 	protected boolean opened= false;
 	protected File indexFile;
+	
 	protected FileListBlock fileListBlock;
 	protected IndexBlock indexBlock;
+	protected IndexBlock includeIndexBlock;
+	
 	protected int numWords= 0;
-	protected IndexSummary summary;
 	protected int numFiles= 0;
+	protected int numIncludes= 0;
+	protected IndexSummary summary;
+	
 	protected boolean firstInBlock;
 	protected boolean firstIndexBlock;
 	protected boolean firstFileListBlock;
+	protected boolean firstIncludeIndexBlock;
 
 	public BlocksIndexOutput(File indexFile) {
 		this.indexFile= indexFile;
@@ -43,6 +50,7 @@
 		firstInBlock= true;
 		firstIndexBlock= true;
 		firstFileListBlock= true;
+		firstIncludeIndexBlock=true;
 	}
 	/**
 	 * @see IndexOutput#addFile
@@ -93,6 +101,31 @@
 		}
 	}
 	/**
+	 * @see IndexOutput#addInclude
+	 */
+	public void addInclude(IncludeEntry entry) throws IOException {
+		if (firstIncludeIndexBlock) {
+			includeIndexBlock= new GammaCompressedIndexBlock(IIndexConstants.BLOCK_SIZE);
+			firstInBlock= true;
+			firstIncludeIndexBlock= false;
+		}
+		if (entry.getNumRefs() == 0)
+			return;
+		if (includeIndexBlock.addIncludeEntry(entry)) {
+			if (firstInBlock) {
+				summary.addFirstIncludeInBlock(entry.getFile(), blockNum);
+				firstInBlock= false;
+			}
+			numIncludes++;
+		} else {
+			if (includeIndexBlock.isEmpty()) {
+				return;
+			}
+			flushWords();
+			addInclude(entry);
+		}
+	}
+	/**
 	 * @see IndexOutput#close
 	 */
 	public void close() throws IOException {
@@ -110,6 +143,7 @@
 		
 		summary.setNumFiles(numFiles);
 		summary.setNumWords(numWords);
+		summary.setNumIncludes(numIncludes);
 		indexOut.seek(blockNum * (long) IIndexConstants.BLOCK_SIZE);
 		summary.write(indexOut);
 		indexOut.seek(0);
@@ -143,6 +177,19 @@
 		}
 	}
 	/**
+	 * 
+	 */
+	public void flushIncludes() throws IOException {
+		if (!firstInBlock 
+			&& includeIndexBlock != null) { // could have added a document without any indexed word, no block created yet
+		includeIndexBlock.flush();
+		includeIndexBlock.write(indexOut, blockNum++);
+		includeIndexBlock.clear();
+		firstInBlock= true;
+	}
+		
+	}
+	/**
 	 * @see IndexOutput#getDestination
 	 */
 	public Object getDestination() {
@@ -156,10 +203,12 @@
 			summary= new IndexSummary();
 			numFiles= 0;
 			numWords= 0;
+			numIncludes=0;
 			blockNum= 1;
 			firstInBlock= true;
 			firstIndexBlock= true;
 			firstFileListBlock= true;
+			firstIncludeIndexBlock=true;
 			indexOut= new SafeRandomAccessFile(this.indexFile, "rw"); //$NON-NLS-1$
 			opened= true;
 		}
Index: index/org/eclipse/cdt/internal/core/index/impl/GammaCompressedIndexBlock.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/impl/GammaCompressedIndexBlock.java,v
retrieving revision 1.2
diff -u -r1.2 GammaCompressedIndexBlock.java
--- index/org/eclipse/cdt/internal/core/index/impl/GammaCompressedIndexBlock.java	4 Jul 2003 03:02:07 -0000	1.2
+++ index/org/eclipse/cdt/internal/core/index/impl/GammaCompressedIndexBlock.java	25 Sep 2003 23:39:44 -0000
@@ -57,6 +57,43 @@
 		}
 	}
 	/**
+	 * @see IndexBlock#addEntry
+	 */
+	public boolean addIncludeEntry(IncludeEntry entry) {
+		writeCodeStream.reset();
+		encodeEntry(entry, prevWord, writeCodeStream);
+		if (offset + writeCodeStream.byteLength() > this.blockSize - 2) {
+			return false;
+		}
+		byte[] bytes= writeCodeStream.toByteArray();
+		field.put(offset, bytes);
+		offset += bytes.length;
+		prevWord= entry.getFile();
+		return true;
+	}
+	/**
+	 * @param entry
+	 * @param prevWord
+	 * @param writeCodeStream
+	 */
+	protected void encodeEntry(IncludeEntry entry, char[] prevWord, CodeByteStream codeStream) {
+		char[] file= entry.getFile();
+		int prefixLen= prevWord == null ? 0 : Util.prefixLength(prevWord, file);
+		codeStream.writeByte(prefixLen);
+		codeStream.writeUTF(file, prefixLen, file.length);
+		int n= entry.getNumRefs();
+		codeStream.writeGamma(n);
+		int prevRef= 0;
+		for (int i= 0; i < n; ++i) {
+			int ref= entry.getRef(i);
+			if (ref <= prevRef)
+				throw new IllegalArgumentException();
+			codeStream.writeGamma(ref - prevRef);
+			prevRef= ref;
+		}
+		
+	}
+	/**
 	 * @see IndexBlock#flush
 	 */
 	public void flush() {
@@ -107,6 +144,40 @@
 		}
 	}
 	/**
+	 * @see IndexBlock#nextEntry
+	 */
+	public boolean nextEntry(IncludeEntry entry) {
+		try {
+			readCodeStream.reset(field.buffer(), offset);
+			int prefixLength= readCodeStream.readByte();
+			char[] file= readCodeStream.readUTF();
+			if (prevWord != null && prefixLength > 0) {
+				char[] temp= new char[prefixLength + file.length];
+				System.arraycopy(prevWord, 0, temp, 0, prefixLength);
+				System.arraycopy(file, 0, temp, prefixLength, file.length);
+				file= temp;
+			}
+			if (file.length == 0) {
+				return false;
+			}
+			entry.reset(file);
+			int n= readCodeStream.readGamma();
+			int prevRef= 0;
+			for (int i= 0; i < n; ++i) {
+				int ref= prevRef + readCodeStream.readGamma();
+				if (ref < prevRef)
+					throw new InternalError();
+				entry.addRef(ref);
+				prevRef= ref;
+			}
+			offset= readCodeStream.byteLength();
+			prevWord= file;
+			return true;
+		} catch (UTFDataFormatException e) {
+			return false;
+		}
+	}
+	/**
 	 * @see IndexBlock#reset
 	 */
 	public void reset() {
@@ -114,5 +185,6 @@
 		offset= 0;
 		prevWord= null;
 	}
+	
 }
 
Index: index/org/eclipse/cdt/internal/core/index/impl/InMemoryIndex.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/impl/InMemoryIndex.java,v
retrieving revision 1.2
diff -u -r1.2 InMemoryIndex.java
--- index/org/eclipse/cdt/internal/core/index/impl/InMemoryIndex.java	4 Jul 2003 03:02:07 -0000	1.2
+++ index/org/eclipse/cdt/internal/core/index/impl/InMemoryIndex.java	25 Sep 2003 23:39:44 -0000
@@ -23,6 +23,10 @@
 public class InMemoryIndex {
 
 	/**
+	* hashtable of IncludeEntrys = includeFiles+numbers of the files they appear in.
+	*/
+	protected IncludeEntryHashedArray includes;
+	/**
 	 * hashtable of WordEntrys = words+numbers of the files they appear in.
 	 */
 	protected WordEntryHashedArray words;
@@ -35,9 +39,14 @@
 	 */
 	protected long footprint;
 
+	private IncludeEntry[] sortedIncludeEntries;
 	private WordEntry[] sortedWordEntries;
 	private IndexedFile[] sortedFiles;
+
+	private int lastId;
+	
 	public InMemoryIndex() {
+		includes= new IncludeEntryHashedArray(501);
 		init();
 	}
 
@@ -47,6 +56,46 @@
 		this.sortedFiles = null;
 		return indexedFile;
 	}
+	
+	public void addIncludeRef(IndexedFile indexedFile, char[] include) {
+		addIncludeRef(include, indexedFile.getFileNumber());
+	}
+	
+	public void addIncludeRef(IndexedFile indexedFile, String include) {
+		addIncludeRef(include.toCharArray(), indexedFile.getFileNumber());
+	}
+	
+	/**
+		 * Adds the references of the include to the tree (reference = number of the file the include belongs to).
+		 */
+		protected void addIncludeRef(char[] include, int[] references) {
+			int size= references.length;
+			int i= 0;
+			while (i < size) {
+				if (references[i] != 0)
+					addIncludeRef(include, references[i]);
+				i++;
+			}
+		}
+		/**
+		 * Looks if the include already exists to the tree and adds the fileNum to this include.
+		 * If the include does not exist, it adds it to the tree.
+		 */
+		protected void addIncludeRef(char[] include, int fileNum) {
+			IncludeEntry entry= (IncludeEntry) this.includes.get(include);
+			if (entry == null) {
+				entry= new IncludeEntry(include, ++lastId);
+				entry.addRef(fileNum);
+				this.includes.add(entry);
+				this.sortedIncludeEntries= null;
+				//TODO: BOG FIGURE OUT FOOTPRINT
+				//this.footprint += entry.getClass(); //footprint();
+				//
+			} else {
+				this.footprint += entry.addRef(fileNum);
+			}
+		}
+
 	/**
 	 * Adds the references of the word to the index (reference = number of the file the word belongs to).
 	 */
@@ -83,6 +132,27 @@
 	public void addRef(IndexedFile indexedFile, String word) {
 		addRef(word.toCharArray(), indexedFile.getFileNumber());
 	}
+	
+	public void addRelatives(IndexedFile indexedFile, String inclusion, String parent) {
+		addRelatives(indexedFile.getFileNumber(),inclusion.toCharArray(),(parent != null ) ? parent.toCharArray() : null);
+	}
+	
+	protected void addRelatives(int fileNumber, char[] inclusion, char[] parent) {
+		IncludeEntry childEntry=null;
+		IncludeEntry parentEntry=null;
+		
+		if (inclusion != null)
+			childEntry= (IncludeEntry) this.includes.get(inclusion);
+	
+		if (parent != null)
+			parentEntry= (IncludeEntry) this.includes.get(parent);
+		
+
+		childEntry.addParent(fileNumber,(parentEntry!=null) ? parentEntry.getID() : -1);
+		
+		if (parent!=null)
+			parentEntry.addChild(fileNumber,(childEntry!=null) ? childEntry.getID() : -1);
+	}	
 	/**
 	 * Returns the footprint of the index.
 	 */
@@ -90,12 +160,30 @@
 		return this.footprint;
 	}
 	/**
+	 * Returns the indexed files contained in the hashtable of includes.
+	 */
+	public IndexedFile[] getIndexedFiles(){
+		return this.files.asArray();
+	}
+	/**
 	 * Returns the indexed file with the given path, or null if such file does not exist.
 	 */
 	public IndexedFile getIndexedFile(String path) {
 		return files.get(path);
 	}
 	/**
+	 * Returns the include entries contained in the hashtable of includes.
+	 */
+	public IncludeEntry[] getIncludeEntries() {
+		return this.includes.asArray();
+	}
+	/**
+	 * Returns the include entry corresponding to the given include.
+	 */
+	protected IncludeEntry getIncludeEntry(char[] include) {
+		return (IncludeEntry) includes.get(include);
+	}
+	/**
 	 * @see IIndex#getNumDocuments()
 	 */
 	public int getNumFiles() {
@@ -107,6 +195,11 @@
 	public int getNumWords() {
 		return words.elementSize;
 	}
+	
+	public int getNumIncludes() {
+		return includes.elementSize;
+	}
+	
 	/**
 	 * Returns the words contained in the hashtable of words, sorted by alphabetical order.
 	 */
@@ -130,6 +223,17 @@
 		return this.sortedWordEntries;
 	}
 	/**
+	 * Returns the include entries contained in the hashtable of includeas, sorted by alphabetical order.
+	 */
+	protected IncludeEntry[] getSortedIncludeEntries() {
+		if (this.sortedIncludeEntries == null) {
+			IncludeEntry[] includes= this.includes.asArray();
+			Util.sort(includes);
+			this.sortedIncludeEntries= includes;
+		}
+		return this.sortedIncludeEntries;
+	}
+	/**
 	 * Returns the word entry corresponding to the given word.
 	 */
 	protected WordEntry getWordEntry(char[] word) {
@@ -139,11 +243,14 @@
 	 * Initialises the fields of the index
 	 */
 	public void init() {
+		includes= new IncludeEntryHashedArray(501);
 		words= new WordEntryHashedArray(501);
 		files= new IndexedFileHashedArray(101);
 		footprint= 0;
+		lastId=0;
 		sortedWordEntries= null;
 		sortedFiles= null;
+		sortedIncludeEntries=null;
 	}
 	/**
 	 * Saves the index in the given file.
Index: index/org/eclipse/cdt/internal/core/index/impl/IncludeEntry.java
===================================================================
RCS file: index/org/eclipse/cdt/internal/core/index/impl/IncludeEntry.java
diff -N index/org/eclipse/cdt/internal/core/index/impl/IncludeEntry.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ index/org/eclipse/cdt/internal/core/index/impl/IncludeEntry.java	25 Sep 2003 23:39:44 -0000
@@ -0,0 +1,223 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials 
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ * 
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.core.index.impl;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+
+import org.eclipse.cdt.internal.core.CharOperation;
+import org.eclipse.cdt.internal.core.sourcedependency.Node;
+
+/**
+ * @author bgheorgh
+ */
+public class IncludeEntry {
+
+  protected char[] fFile;
+  protected int fId;
+  protected int fNumRefs;
+  protected int[] fRefs;
+  //TODO: BOG Consider making these arrays...
+  protected ArrayList fParent;
+  protected ArrayList fChild;
+  protected int fNumParent;
+  protected int fNumChild;
+     
+  public IncludeEntry(int id) {
+	this(CharOperation.NO_CHAR,id);
+  }
+		
+  public IncludeEntry(char[] file, int id) {
+	fFile = file;
+	fNumRefs= 0;
+	fRefs= new int[1];
+	fId=id;
+	
+	fParent = new ArrayList(5);
+	fChild = new ArrayList(5);
+	fNumParent = 0;
+	fNumChild = 0;
+  }
+  /**
+   * Adds a reference and records the change in footprint.
+   */
+    public int addRef(int fileNum) {
+      if (fNumRefs > 0 && fRefs[fNumRefs - 1] == fileNum) {
+	   return 0;
+      }
+      if (fNumRefs < fRefs.length) {
+   	    fRefs[fNumRefs++]= fileNum;
+	    return 0;
+      } 
+
+      int newSize= fNumRefs < 4 ? 4 : fNumRefs * 2; // so will start @ 1, grow to 4, 8, 16, 32, 64 etc.
+	  System.arraycopy(fRefs, 0, fRefs= new int[newSize], 0, fNumRefs);
+	  fRefs[fNumRefs++]= fileNum;
+	  return (newSize - fNumRefs + 1) * 4;
+    }
+	  
+	public void addParent(int fileRef, int parentId){
+		Node newParent = new Node(fileRef,parentId);
+		fParent.add(newParent);
+		fNumParent++;
+	}
+	/**
+	 * @param is
+	 */
+	public void addRefs(int[] refs) {
+		int[] newRefs= new int[fNumRefs + refs.length];
+		int pos1= 0;
+		int pos2= 0;
+		int posNew= 0;
+		int compare;
+		int r1= 0;
+		int r2= 0;
+		while (pos1 < fNumRefs || pos2 < refs.length) {
+			if (pos1 >= fNumRefs) {
+				r2= refs[pos2];
+				compare= -1;
+			} else if (pos2 >= refs.length) {
+				compare= 1;
+				r1= fRefs[pos1];
+			} else {
+				r1= fRefs[pos1];
+				r2= refs[pos2];
+				compare= r2 - r1;
+			}
+			if (compare > 0) {
+				newRefs[posNew]= r1;
+				posNew++;
+				pos1++;
+			} else {
+				if (r2 != 0) {
+					newRefs[posNew]= r2;
+					posNew++;
+				}
+				pos2++;
+			}
+		}
+		fRefs= newRefs;
+		fNumRefs= posNew;
+		/*for (int i = 0; i < refs.length; i++)
+		addRef(refs[i]);
+		int[] newRefs = new int[fNumRefs];
+		System.arraycopy(fRefs, 0, newRefs, 0, fNumRefs);
+		fRefs = newRefs;
+		Util.sort(fRefs);*/
+		
+	}
+	
+	public void addChild(int fileRef, int parentId){
+		Node newChild = new Node(fileRef,parentId);
+		fChild.add(newChild);
+		fNumChild++;
+	}
+	/**
+	 * Returns the number of references, e.g. the number of files this word appears in.
+	 */
+	public int getNumRefs() {
+		return fNumRefs;
+	}
+	/**
+	 * returns the file number in the i position in the list of references.
+	 */
+	public int getRef(int i) {
+		if (i < fNumRefs) return fRefs[i];
+		throw new IndexOutOfBoundsException();
+	}
+	/**
+	 * Returns the references of the includeEntry (the number of the files it appears in).
+	 */
+	public int[] getRefs() {
+		int[] result= new int[fNumRefs];
+		System.arraycopy(fRefs, 0, result, 0, fNumRefs);
+		return result;
+	}
+	/**
+	 * returns the word of the includeEntry.
+	 */
+	public char[] getFile() {
+		return fFile;
+	}
+	/**
+	 * Changes the references of the wordEntry to match the mapping. For example,<br>
+	 * if the current references are [1 3 4]<br>
+	 * and mapping is [1 2 3 4 5]<br>
+	 * in references 1 becomes mapping[1] = 2, 3->4, and 4->5<br>
+	 * => references = [2 4 5].<br>
+	 */
+	public void mapRefs(int[] mappings) {
+		int position= 0;
+		for (int i= 0; i < fNumRefs; i++) {
+			int map= mappings[fRefs[i]];
+			if (map != -1 && map != 0)
+				fRefs[position++]= map;
+		}
+		fNumRefs= position;
+
+		//to be changed!
+		System.arraycopy(fRefs, 0, (fRefs= new int[fNumRefs]), 0, fNumRefs);
+		Util.sort(fRefs);
+	}
+	/**
+	 * Clears the includeEntry.
+	 */
+	public void reset(char[] word) {
+		for (int i= fNumRefs; i-- > 0;) {
+			fRefs[i]= 0;
+		}
+		fNumRefs= 0;
+		fFile= word;
+	}
+	
+	public int getID(){
+		return fId;
+	}
+	
+	public String toString() {
+		StringBuffer tempBuffer = new StringBuffer();
+		tempBuffer.append("<Name: ");
+		tempBuffer.append(fFile);
+		tempBuffer.append(", Id: ");
+		tempBuffer.append(fId);
+		tempBuffer.append(", Refs:{");
+		for (int i = 0; i < fRefs.length; i++){
+			if (i > 0) tempBuffer.append(',');
+			tempBuffer.append(' ');
+			tempBuffer.append(fRefs[i]);
+		}
+		tempBuffer.append("}, Parents:{");
+		Iterator x = fParent.iterator();
+		while (x.hasNext())
+		{
+			Node tempNode = (Node) x.next();
+			tempBuffer.append(tempNode.toString());
+			if (x.hasNext()) {
+				tempBuffer.append(',');
+				tempBuffer.append(' ');
+			}
+		}
+		tempBuffer.append("}, Children:{");
+		Iterator y = fChild.iterator();
+		while (y.hasNext())
+		{
+			Node tempNode = (Node) y.next();
+			tempBuffer.append(tempNode.toString());
+			if (y.hasNext()) {
+				tempBuffer.append(',');
+				tempBuffer.append(' ');
+			}
+		}
+		tempBuffer.append("} >");
+		return tempBuffer.toString();
+	}
+}
Index: index/org/eclipse/cdt/internal/core/index/impl/IncludeEntryHashedArray.java
===================================================================
RCS file: index/org/eclipse/cdt/internal/core/index/impl/IncludeEntryHashedArray.java
diff -N index/org/eclipse/cdt/internal/core/index/impl/IncludeEntryHashedArray.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ index/org/eclipse/cdt/internal/core/index/impl/IncludeEntryHashedArray.java	25 Sep 2003 23:39:44 -0000
@@ -0,0 +1,84 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials 
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ * 
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.core.index.impl;
+
+import org.eclipse.cdt.internal.core.CharOperation;
+
+public final class IncludeEntryHashedArray {
+
+	public IncludeEntry elements[];
+	public int elementSize; // number of elements in the table
+	public int threshold;
+	
+	public IncludeEntryHashedArray(int size) {
+		if (size < 7) size = 7;
+		this.elements = new IncludeEntry[2 * size + 1];
+		this.elementSize = 0;
+		this.threshold = size + 1; // size is the expected number of elements
+	}
+	
+	public IncludeEntry add(IncludeEntry entry) {
+		int length = elements.length;
+		char[] word = entry.getFile();
+		int index = CharOperation.hashCode(word) % length;
+		IncludeEntry current;
+		while ((current = elements[index]) != null) {
+			if (CharOperation.equals(current.getFile(), word)) return elements[index] = entry;
+			if (++index == length) index = 0;
+		}
+		elements[index] = entry;
+	
+		// assumes the threshold is never equal to the size of the table
+		if (++elementSize > threshold) grow();
+		return entry;
+	}
+	
+	public IncludeEntry[] asArray() {
+		IncludeEntry[] array = new IncludeEntry[elementSize];
+		for (int i = 0, j = 0, length = elements.length; i < length; i++) {
+			IncludeEntry current = elements[i];
+			if (current != null) array[j++] = current;
+		}
+		return array;
+	}
+	
+	public IncludeEntry get(char[] word) {
+		int length = elements.length;
+		int index = CharOperation.hashCode(word) % length;
+		IncludeEntry current;
+		while ((current = elements[index]) != null) {
+			if (CharOperation.equals(current.getFile(), word)) return current;
+			if (++index == length) index = 0;
+		}
+		return null;
+	}
+	
+	private void grow() {
+		IncludeEntryHashedArray newArray = new IncludeEntryHashedArray(elementSize * 2); // double the number of expected elements
+		for (int i = 0, length = elements.length; i < length; i++)
+			if (elements[i] != null)
+				newArray.add(elements[i]);
+	
+		this.elements = newArray.elements;
+		this.elementSize = newArray.elementSize;
+		this.threshold = newArray.threshold;
+	}
+	
+	public String toString() {
+		String s = ""; //$NON-NLS-1$
+		IncludeEntry[] entries = asArray();
+		for (int i = 0, length = entries.length; i < length; i++)
+			s += entries[i].toString() + "\n"; 	//$NON-NLS-1$
+		return s;
+	}
+
+}
Index: index/org/eclipse/cdt/internal/core/index/impl/Index.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/impl/Index.java,v
retrieving revision 1.2
diff -u -r1.2 Index.java
--- index/org/eclipse/cdt/internal/core/index/impl/Index.java	4 Jul 2003 03:02:07 -0000	1.2
+++ index/org/eclipse/cdt/internal/core/index/impl/Index.java	25 Sep 2003 23:39:45 -0000
@@ -12,7 +12,9 @@
 
 import java.io.File;
 import java.io.IOException;
+import java.util.ArrayList;
 import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
 
 import org.eclipse.cdt.internal.core.index.IDocument;
@@ -20,6 +22,8 @@
 import org.eclipse.cdt.internal.core.index.IIndex;
 import org.eclipse.cdt.internal.core.index.IIndexer;
 import org.eclipse.cdt.internal.core.index.IQueryResult;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.IPath;
 
 /**
  * An Index is used to create an index on the disk, and to make queries. It uses a set of 
@@ -168,6 +172,19 @@
 		}		
 	}
 	/**
+	 * @see IIndex#getNumWords
+	 */
+	public int getNumIncludes() throws IOException {
+		//save();
+		IndexInput input= new BlocksIndexInput(indexFile);
+		try {
+			input.open();
+			return input.getNumIncludes();
+		} finally {
+			input.close();
+		}		
+	}
+	/**
 	 * Returns the path corresponding to a given document number
 	 */
 	public String getPath(int documentNumber) throws IOException {
@@ -302,6 +319,63 @@
 			input.close();
 		}
 	}
+	
+	/* (non-Javadoc)
+	 * @see org.eclipse.cdt.internal.core.sourcedependency.IDependencyTree#getFileDepencies(int)
+	 */
+	public String[] getFileDependencies(IPath filePath) throws IOException {
+//		List tempFileReturn = new ArrayList();
+//		
+//		IndexedFile indexFile = addsIndex.getIndexedFile(filePath.toString());
+//
+//		if (indexFile == null)
+//		 return new String[0];
+//		 
+//		int fileNum = indexFile.getFileNumber();
+//		IncludeEntry[] tempEntries = addsIndex.getIncludeEntries();
+//		for (int i=0; i<tempEntries.length; i++)
+//		{
+//			int[] fileRefs = tempEntries[i].getRefs();
+//			for (int j=0; j<fileRefs.length; j++)
+//			{
+//				if (fileRefs[j] == fileNum)
+//				{ 
+//					char[] tempFile = tempEntries[i].getFile();
+//					StringBuffer tempString = new StringBuffer();
+//					tempString.append(tempFile);
+//					tempFileReturn.add(tempString.toString());
+//					break;
+//				}
+//			}
+//		}
+//		return (String []) tempFileReturn.toArray(new String[tempFileReturn.size()]);
+		return null;
+	}
+	/* (non-Javadoc)
+	 * @see org.eclipse.cdt.internal.core.index.IIndex#getFileDependencies(org.eclipse.core.resources.IFile)
+	 */
+	public String[] getFileDependencies(IFile file) throws IOException  {
+		IndexInput input= new BlocksIndexInput(indexFile);
+		int fileNum=0;
+		List tempFileReturn = new ArrayList();
+		try {
+			IDocument temp = new IFileDocument(file);
+			input.open();
+			IndexedFile inFile = input.getIndexedFile(temp);
+			fileNum =inFile.getFileNumber();
+	
+			IncludeEntry[] tempEntries = input.queryIncludeEntries(fileNum);
+			for (int i=0; i<tempEntries.length; i++)
+			{
+				char[] tempFile = tempEntries[i].getFile();
+				StringBuffer tempString = new StringBuffer();
+				tempString.append(tempFile);
+				tempFileReturn.add(tempString.toString());
+			}
+		}
+		finally{input.close();}
+		return (String []) tempFileReturn.toArray(new String[tempFileReturn.size()]);
+	}
 	/**
 	 * @see IIndex#remove
 	 */
@@ -361,4 +435,6 @@
 	str += "(length: "+ getIndexFile().length() +")"; //$NON-NLS-1$ //$NON-NLS-2$
 	return str;
 }
+
+	
 }
Index: index/org/eclipse/cdt/internal/core/index/impl/IndexBlock.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/impl/IndexBlock.java,v
retrieving revision 1.3
diff -u -r1.3 IndexBlock.java
--- index/org/eclipse/cdt/internal/core/index/impl/IndexBlock.java	12 Aug 2003 20:20:04 -0000	1.3
+++ index/org/eclipse/cdt/internal/core/index/impl/IndexBlock.java	25 Sep 2003 23:39:45 -0000
@@ -25,6 +25,10 @@
 	 */
 	public abstract boolean addEntry(WordEntry entry);
 	/**
+	 * Adds the given wordEntry to the indexBlock.
+	 */
+	public abstract boolean addIncludeEntry(IncludeEntry entry);
+	/**
 	 * @see Block#clear()
 	 */
 	public void clear() {
@@ -69,6 +73,9 @@
 	 * Finds the next wordEntry and stores it in the given entry.
 	 */
 	public abstract boolean nextEntry(WordEntry entry);
+	public abstract boolean nextEntry(IncludeEntry entry);
+	
 	public void reset() {
 	}
+	
 }
Index: index/org/eclipse/cdt/internal/core/index/impl/IndexInput.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/impl/IndexInput.java,v
retrieving revision 1.3
diff -u -r1.3 IndexInput.java
--- index/org/eclipse/cdt/internal/core/index/impl/IndexInput.java	11 Jul 2003 22:12:35 -0000	1.3
+++ index/org/eclipse/cdt/internal/core/index/impl/IndexInput.java	25 Sep 2003 23:39:45 -0000
@@ -29,12 +29,14 @@
 	protected int filePosition;
 	protected WordEntry currentWordEntry;
 	protected int wordPosition;
-
+	protected IncludeEntry currentIncludeEntry;
+	protected int includePosition;
 
 	public IndexInput() {
 		super();
 		wordPosition= 1;
 		filePosition= 1;
+		includePosition= 1;
 	}
 	/**
 	 * clears the cache of this indexInput, if it keeps track of the information already read.
@@ -58,6 +60,14 @@
 		return currentWordEntry;
 	}
 	/**
+	 * Returns the current file the indexInput is pointing to in the index.
+	 */
+	public IncludeEntry getCurrentIncludeEntry() throws IOException {
+		if (!hasMoreIncludes())
+			return null;
+		return currentIncludeEntry;
+	}
+	/**
 	 * Returns the position of the current file the input is pointing to in the index.
 	 */
 	public int getFilePosition() {
@@ -83,6 +93,10 @@
 	 */
 	public abstract int getNumWords();
 	/**
+	 * Returns the number of unique words in the index.
+	 */
+	public abstract int getNumIncludes();
+	/**
 	 * Returns the Object the input is reading from. It can be an IIndex,
 	 * a File, ...
 	 */
@@ -100,6 +114,12 @@
 		return wordPosition <= getNumWords();
 	}
 	/**
+	 * Returns true if the input has not reached the end of the index for the files.
+	 */
+	public boolean hasMoreIncludes() {
+		return includePosition <= getNumIncludes();
+	}
+	/**
 	 * Moves the pointer on the current file to the next file in the index.
 	 */
 	public abstract void moveToNextFile() throws IOException;
@@ -108,6 +128,10 @@
 	 */
 	public abstract void moveToNextWordEntry() throws IOException;
 	/**
+	 * Moves the pointer on the current include entry to the next file in the index.
+	 */
+	public abstract void moveToNextIncludeEntry() throws IOException;
+	/**
 	 * Open the Source where the input gets the information from.
 	 */
 	public abstract void open() throws IOException;
@@ -122,6 +146,15 @@
 	 */
 	public abstract IQueryResult[] queryInDocumentNames(String word) throws IOException;
 	/**
+	 * Returns the list of the files whose name contain the given word in the index.
+	 */
+	public abstract IncludeEntry[] queryIncludeEntries();
+	/**
+	 * @param fileNum
+	 * @return
+	 */
+	public abstract IncludeEntry[] queryIncludeEntries(int fileNum) throws IOException;
+	/**
 	 * Set the pointer on the current file to the first file of the index.
 	 */
 	protected abstract void setFirstFile() throws IOException;
@@ -129,4 +162,10 @@
 	 * Set the pointer on the current word to the first word of the index.
 	 */
 	protected abstract void setFirstWord() throws IOException;
+	/**
+	 * Set the pointer on the current include to the first include of the index.
+	 */
+	protected abstract void setFirstInclude() throws IOException;
+
+	
 }
Index: index/org/eclipse/cdt/internal/core/index/impl/IndexSummary.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/impl/IndexSummary.java,v
retrieving revision 1.3
diff -u -r1.3 IndexSummary.java
--- index/org/eclipse/cdt/internal/core/index/impl/IndexSummary.java	12 Aug 2003 20:20:04 -0000	1.3
+++ index/org/eclipse/cdt/internal/core/index/impl/IndexSummary.java	25 Sep 2003 23:39:45 -0000
@@ -32,6 +32,10 @@
 	 */
 	protected ArrayList firstWordsInBlocks= new ArrayList();
 	/**
+	 * First include for each block.
+	 */
+	protected ArrayList firstIncludesInBlocks= new ArrayList();
+	/**
 	 * Number of files in the index.
 	 */
 	protected int numFiles;
@@ -39,7 +43,11 @@
 	 * Number of words in the index.
 	 */
 	protected int numWords;
-
+	/**
+	 * Number of includes in the index.
+	 */
+	protected int numIncludes;
+	
 	static class FirstFileInBlock {
 		IndexedFile indexedFile;
 		int blockNum;
@@ -53,8 +61,19 @@
 		}
 	}
 
+	static class FirstIncludeInBlock {
+		char[] file;
+		int blockNum;
+		public String toString(){
+			return "FirstIncludeInBlock: " + new String(file) + ", blockNum: " + blockNum; //$NON-NLS-1$ //$NON-NLS-2$
+		}
+	}
+	
 	protected int firstWordBlockNum;
 	protected boolean firstWordAdded= true;
+	
+	protected int firstIncludeBlockNum;
+	protected boolean firstIncludeBlockAdded= true;
 	/**
 	 * Adds the given file as the first file for the given Block number. 
 	 */
@@ -78,6 +97,19 @@
 		firstWordsInBlocks.add(entry);
 	}
 	/**
+	 * Adds the given include as the first include for the given Block number. 
+	 */
+	public void addFirstIncludeInBlock(char[] file, int blockNum) {
+		if (firstIncludeBlockAdded) {
+			firstIncludeBlockNum= blockNum;
+			firstIncludeBlockAdded= false;
+		}
+		FirstIncludeInBlock entry= new FirstIncludeInBlock();
+		entry.file = file;
+		entry.blockNum= blockNum;
+		firstIncludesInBlocks.add(entry);
+	}
+	/**
 	 * Returns the numbers of all the blocks
 	 */
 	public int[] getAllBlockNums() {
@@ -187,6 +219,14 @@
 		}
 		return result;
 	}
+	public int[] getBlockNumsForIncludes() {
+		int max = firstIncludesInBlocks.size();
+		int[] blockNums = new int[max];
+		for (int i = 0; i < max; i++){
+			blockNums[i] = ((FirstIncludeInBlock)firstIncludesInBlocks.get(i)).blockNum;
+		}
+		return blockNums;
+	}
 	public int getFirstBlockLocationForPrefix(char[] prefix) {
 		int min = 0;
 		int size = firstWordsInBlocks.size();
@@ -229,6 +269,12 @@
 	public int getFirstWordBlockNum() {
 		return firstWordBlockNum;
 	}
+	/**
+	 * Returns the number of the first IndexBlock (containing words).
+	 */
+	public int getFirstIncludeBlockNum() {
+		return firstIncludeBlockNum;
+	}
 	/** 
 	 * Blocks are contiguous, so the next one is a potential candidate if its first word starts with
 	 * the given prefix
@@ -253,12 +299,20 @@
 		return numWords;
 	}
 	/**
+	 * Returns the number of words contained in the index.
+	 */
+	public int getNumIncludes() {
+		return numIncludes;
+	}
+	/**
 	 * Loads the summary in memory.
 	 */
 	public void read(RandomAccessFile raf) throws IOException {
 		numFiles= raf.readInt();
 		numWords= raf.readInt();
+		numIncludes= raf.readInt();
 		firstWordBlockNum= raf.readInt();
+		firstIncludeBlockNum= raf.readInt();
 		int numFirstFiles= raf.readInt();
 		for (int i= 0; i < numFirstFiles; ++i) {
 			FirstFileInBlock entry= new FirstFileInBlock();
@@ -275,6 +329,13 @@
 			entry.blockNum= raf.readInt();
 			firstWordsInBlocks.add(entry);
 		}
+		int numIncludes = raf.readInt();
+		for (int i= 0; i < numIncludes; ++i) {
+			FirstIncludeInBlock entry= new FirstIncludeInBlock();
+			entry.file= raf.readUTF().toCharArray();
+			entry.blockNum= raf.readInt();
+			firstIncludesInBlocks.add(entry);
+		}
 	}
 	/**
 	 * Sets the number of files of the index.
@@ -291,12 +352,20 @@
 		this.numWords= numWords;
 	}
 	/**
+	 * Sets the number of includes of the index.
+	 */
+	public void setNumIncludes(int numIncs) {
+		this.numIncludes= numIncs;
+	}
+	/**
 	 * Saves the summary on the disk.
 	 */
 	public void write(RandomAccessFile raf) throws IOException {
 		raf.writeInt(numFiles);
 		raf.writeInt(numWords);
+		raf.writeInt(numIncludes);
 		raf.writeInt(firstWordBlockNum);
+		raf.writeInt(firstIncludeBlockNum);
 		raf.writeInt(firstFilesInBlocks.size());
 		for (int i= 0, size= firstFilesInBlocks.size(); i < size; ++i) {
 			FirstFileInBlock entry= (FirstFileInBlock) firstFilesInBlocks.get(i);
@@ -308,6 +377,12 @@
 		for (int i= 0, size= firstWordsInBlocks.size(); i < size; ++i) {
 			FirstWordInBlock entry= (FirstWordInBlock) firstWordsInBlocks.get(i);
 			raf.writeUTF(new String(entry.word));
+			raf.writeInt(entry.blockNum);
+		}
+		raf.writeInt(firstIncludesInBlocks.size());
+		for (int i= 0, size= firstIncludesInBlocks.size(); i < size; ++i) {
+			FirstIncludeInBlock entry= (FirstIncludeInBlock) firstIncludesInBlocks.get(i);
+			raf.writeUTF(new String(entry.file));
 			raf.writeInt(entry.blockNum);
 		}
 	}
Index: index/org/eclipse/cdt/internal/core/index/impl/IndexerOutput.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/impl/IndexerOutput.java,v
retrieving revision 1.3
diff -u -r1.3 IndexerOutput.java
--- index/org/eclipse/cdt/internal/core/index/impl/IndexerOutput.java	11 Jul 2003 22:12:35 -0000	1.3
+++ index/org/eclipse/cdt/internal/core/index/impl/IndexerOutput.java	25 Sep 2003 23:39:45 -0000
@@ -55,4 +55,23 @@
 	public void addRef(String word) {
 		addRef(word.toCharArray());
 	}
+		
+	public void addRelatives(String inclusion, String parent) {
+		if (indexedFile == null) {
+					throw new IllegalStateException();
+		}
+		index.addRelatives(indexedFile, inclusion, parent);	
+	}
+
+	public void addIncludeRef(char[] word) {
+		if (indexedFile == null) {
+			throw new IllegalStateException();
+		}
+			index.addIncludeRef(indexedFile, word);	
+	}
+
+	public void addIncludeRef(String word) {
+		addIncludeRef(word.toCharArray());
+	}
+	
 }
Index: index/org/eclipse/cdt/internal/core/index/impl/MergeFactory.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/impl/MergeFactory.java,v
retrieving revision 1.2
diff -u -r1.2 MergeFactory.java
--- index/org/eclipse/cdt/internal/core/index/impl/MergeFactory.java	4 Jul 2003 03:02:07 -0000	1.2
+++ index/org/eclipse/cdt/internal/core/index/impl/MergeFactory.java	25 Sep 2003 23:39:45 -0000
@@ -79,6 +79,7 @@
 			//findChanges();
 			mergeFiles();
 			mergeReferences();
+			mergeIncludes();
 			mergeOutput.flush();
 		} finally {
 			//closes everything
@@ -96,6 +97,7 @@
 	protected void mergeFiles() throws IOException {
 		int positionInMerge= 1;
 		int compare;
+
 		while (oldInput.hasMoreFiles() || addsInput.hasMoreFiles()) {
 			IndexedFile file1= oldInput.getCurrentFile();
 			IndexedFile file2= addsInput.getCurrentFile();
@@ -184,6 +186,45 @@
 			}
 		}
 		mergeOutput.flushWords();
+	}
+	/**
+	 * Merges the files of the 2 indexes in the new index, according to the changes
+	 * recorded during mergeFiles().
+	 */
+	protected void mergeIncludes() throws IOException {
+		int compare;
+		
+		while (oldInput.hasMoreIncludes() || addsInput.hasMoreIncludes()) {
+			IncludeEntry inc1= oldInput.getCurrentIncludeEntry();
+			IncludeEntry inc2= addsInput.getCurrentIncludeEntry();
+
+			if (inc1 == null && inc2 == null)
+				break;
+			
+			if (inc1 == null)
+				compare= 1;
+			else if (inc2 == null)
+				compare= -1;
+			else
+				compare= Util.compare(inc1.getFile(), inc2.getFile());
+			if (compare < 0) {
+				inc1.mapRefs(mappingOld);
+				mergeOutput.addInclude(inc1);
+				oldInput.moveToNextIncludeEntry();
+			} else if (compare > 0) {
+				inc2.mapRefs(mappingAdds);
+				mergeOutput.addInclude(inc2);
+				addsInput.moveToNextIncludeEntry();
+			} else {
+				inc1.mapRefs(mappingOld);
+				inc2.mapRefs(mappingAdds);
+				inc1.addRefs(inc2.getRefs());
+				mergeOutput.addInclude(inc1);
+				addsInput.moveToNextIncludeEntry();
+				oldInput.moveToNextIncludeEntry();
+			}
+		}
+		mergeOutput.flushIncludes();
 	}
 	/**
 	 * Records the deletion of one file.
Index: index/org/eclipse/cdt/internal/core/index/impl/SimpleIndexInput.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/impl/SimpleIndexInput.java,v
retrieving revision 1.2
diff -u -r1.2 SimpleIndexInput.java
--- index/org/eclipse/cdt/internal/core/index/impl/SimpleIndexInput.java	4 Jul 2003 03:02:07 -0000	1.2
+++ index/org/eclipse/cdt/internal/core/index/impl/SimpleIndexInput.java	25 Sep 2003 23:39:45 -0000
@@ -23,6 +23,7 @@
 
 public class SimpleIndexInput extends IndexInput {
 	protected WordEntry[] sortedWordEntries;
+	protected IncludeEntry[] sortedIncludes;
 	protected IndexedFile currentFile;
 	protected IndexedFile[] sortedFiles;
 	protected InMemoryIndex index;
@@ -78,6 +79,12 @@
 		return index.getNumFiles();
 	}
 	/**
+	 * @see IndexInput#getNumIncludes()
+	 */
+	public int getNumIncludes() {
+		return sortedIncludes.length;
+	}
+	/**
 	 * @see IndexInput#getNumWords()
 	 */
 	public int getNumWords() {
@@ -112,15 +119,26 @@
 			currentWordEntry= sortedWordEntries[wordPosition - 1];
 	}
 	/**
+	 * @see IndexInput#moveToNextIncludeEntry()
+	 */
+	public void moveToNextIncludeEntry() throws IOException {
+		includePosition++;
+		if (hasMoreIncludes())
+			currentIncludeEntry= sortedIncludes[includePosition - 1];
+	}
+	/**
 	 * @see IndexInput#open()
 	 */
 	public void open() throws IOException {
 		sortedWordEntries= index.getSortedWordEntries();
 		sortedFiles= index.getSortedFiles();
+		sortedIncludes = index.getSortedIncludeEntries();
 		filePosition= 1;
 		wordPosition= 1;
+		includePosition=1;
 		setFirstFile();
 		setFirstWord();
+		setFirstInclude();
 	}
 	/**
 	 * @see IndexInput#query(String)
@@ -172,6 +190,20 @@
 		wordPosition= 1;
 		if (sortedWordEntries.length > 0)
 			currentWordEntry= sortedWordEntries[0];
+	}
+	/**
+	 * @see IndexInput#setFirstInclude()
+	 */
+	protected void setFirstInclude() throws IOException {
+		includePosition=1;
+		if (sortedIncludes.length >0)
+			currentIncludeEntry=sortedIncludes[0];
+	}
+	public IncludeEntry[] queryIncludeEntries() {
+		return null;
+	}
+	public IncludeEntry[] queryIncludeEntries(int fileNum) throws IOException {
+		return null;
 	}
 }
 
Index: index/org/eclipse/cdt/internal/core/index/impl/Util.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/impl/Util.java,v
retrieving revision 1.2
diff -u -r1.2 Util.java
--- index/org/eclipse/cdt/internal/core/index/impl/Util.java	4 Jul 2003 03:02:07 -0000	1.2
+++ index/org/eclipse/cdt/internal/core/index/impl/Util.java	25 Sep 2003 23:39:45 -0000
@@ -195,6 +195,32 @@
 			quickSort(list, left, original_right);
 		}
 	}
+	private static void quickSort(IncludeEntry[] list, int left, int right) {
+			int original_left= left;
+			int original_right= right;
+			char[] mid= list[(left + right) / 2].fFile;
+			do {
+				while (compare(list[left].fFile, mid) < 0) {
+					left++;
+				}
+				while (compare(mid, list[right].fFile) < 0) {
+					right--;
+				}
+				if (left <= right) {
+					IncludeEntry tmp= list[left];
+					list[left]= list[right];
+					list[right]= tmp;
+					left++;
+					right--;
+				}
+			} while (left <= right);
+			if (original_left < right) {
+				quickSort(list, original_left, right);
+			}
+			if (left < original_right) {
+				quickSort(list, left, original_right);
+			}
+		}
 	/**
 	 * Reads in a string from the specified data input stream. The 
 	 * string has been encoded using a modified UTF-8 format. 
@@ -288,6 +314,10 @@
 			quickSort(list, 0, list.length - 1);
 	}
 	public static void sort(WordEntry[] list) {
+		if (list.length > 1)
+			quickSort(list, 0, list.length - 1);
+	}
+	public static void sort(IncludeEntry[] list) {
 		if (list.length > 1)
 			quickSort(list, 0, list.length - 1);
 	}
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.19
diff -u -r1.19 AbstractIndexer.java
--- index/org/eclipse/cdt/internal/core/search/indexing/AbstractIndexer.java	18 Sep 2003 15:15:08 -0000	1.19
+++ index/org/eclipse/cdt/internal/core/search/indexing/AbstractIndexer.java	25 Sep 2003 23:39:45 -0000
@@ -21,6 +21,7 @@
 import org.eclipse.cdt.core.parser.ast.IASTEnumerator;
 import org.eclipse.cdt.core.parser.ast.IASTField;
 import org.eclipse.cdt.core.parser.ast.IASTFunction;
+import org.eclipse.cdt.core.parser.ast.IASTInclusion;
 import org.eclipse.cdt.core.parser.ast.IASTMacro;
 import org.eclipse.cdt.core.parser.ast.IASTMethod;
 import org.eclipse.cdt.core.parser.ast.IASTNamespaceDefinition;
@@ -33,6 +34,7 @@
 import org.eclipse.cdt.internal.core.index.IDocument;
 import org.eclipse.cdt.internal.core.index.IIndexer;
 import org.eclipse.cdt.internal.core.index.IIndexerOutput;
+import org.eclipse.core.resources.IFile;
 
 public abstract class AbstractIndexer implements IIndexer, IIndexConstants, ICSearchConstants {
 	
@@ -340,6 +342,10 @@
 	 */
 	public abstract String[] getFileTypes();
 	/**
+	 * Returns the file types being indexed.
+	 */
+	public abstract IFile getResourceFile();
+	/**
 	 * @see IIndexer#index(IDocument document, IIndexerOutput output)
 	 */
 	public void index(IDocument document, IIndexerOutput output) throws IOException {
@@ -620,6 +626,34 @@
 		}
 		
 		return bestPrefix( prefix,  (char)0, macroName, null, matchMode, isCaseSenstive );	
+	}
+	
+	/**
+	 * @param _limitTo
+	 * @param simpleName
+	 * @param _matchMode
+	 * @param _caseSensitive
+	 * @return
+	 */
+	public static final char[] bestIncludePrefix( LimitTo limitTo, char[] incName, int matchMode, boolean isCaseSenstive ){
+		//since we only index macro declarations we already know the prefix
+		char [] prefix = null;
+		if( limitTo == REFERENCES ){
+			prefix = INCLUDE_REF;
+		} else {
+			return null;
+		}
+		
+		return bestPrefix( prefix,  (char)0, incName, null, matchMode, isCaseSenstive );	
+	}
+	
+	public void addInclude(IASTInclusion inclusion, IASTInclusion parent){
+		this.output.addIncludeRef(inclusion.getFullFileName());
+		this.output.addRelatives(inclusion.getFullFileName(),(parent != null ) ? parent.getFullFileName() : null);
+		//Add Dep Table entry
+		String[] incName = new String[1];
+		incName[0] = inclusion.getFullFileName();
+		this.output.addRef(encodeEntry(incName, INCLUDE_REF, INCLUDE_REF_LENGTH));
 	}
 }
 
Index: index/org/eclipse/cdt/internal/core/search/indexing/IIndexConstants.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/search/indexing/IIndexConstants.java,v
retrieving revision 1.7
diff -u -r1.7 IIndexConstants.java
--- index/org/eclipse/cdt/internal/core/search/indexing/IIndexConstants.java	15 Sep 2003 17:31:23 -0000	1.7
+++ index/org/eclipse/cdt/internal/core/search/indexing/IIndexConstants.java	25 Sep 2003 23:39:45 -0000
@@ -62,6 +62,9 @@
 	
 	char[] MACRO_DECL = "macroDecl/".toCharArray();
 	int MACRO_DECL_LENGTH = 10;
+	
+	char[] INCLUDE_REF = "includeRef/".toCharArray();
+	int INCLUDE_REF_LENGTH = 11;
 	//a Var REF will be treated as  a typeREF
 	//char[] VAR_REF= "varRef/".toCharArray(); //$NON-NLS-1$
 	
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.5
diff -u -r1.5 IndexAllProject.java
--- index/org/eclipse/cdt/internal/core/search/indexing/IndexAllProject.java	23 Sep 2003 15:17:13 -0000	1.5
+++ index/org/eclipse/cdt/internal/core/search/indexing/IndexAllProject.java	25 Sep 2003 23:39:45 -0000
@@ -14,6 +14,12 @@
 import java.io.IOException;
 import java.util.HashSet;
 
+import org.eclipse.cdt.internal.core.Util;
+import org.eclipse.cdt.internal.core.index.IIndex;
+import org.eclipse.cdt.internal.core.index.IQueryResult;
+import org.eclipse.cdt.internal.core.index.impl.IFileDocument;
+import org.eclipse.cdt.internal.core.search.SimpleLookupTable;
+import org.eclipse.cdt.internal.core.search.processing.JobManager;
 import org.eclipse.core.resources.IFile;
 import org.eclipse.core.resources.IProject;
 import org.eclipse.core.resources.IResource;
@@ -23,16 +29,6 @@
 import org.eclipse.core.runtime.CoreException;
 import org.eclipse.core.runtime.IPath;
 import org.eclipse.core.runtime.IProgressMonitor;
-import  org.eclipse.cdt.core.model.ICProject;
-import org.eclipse.cdt.internal.core.Util;
-import org.eclipse.cdt.internal.core.index.IIndex;
-import org.eclipse.cdt.internal.core.index.IQueryResult;
-import org.eclipse.cdt.internal.core.index.impl.IFileDocument;
-import org.eclipse.cdt.internal.core.search.processing.JobManager;
-import org.eclipse.cdt.internal.core.search.SimpleLookupTable;
-import org.eclipse.cdt.internal.core.model.CModel;
-import org.eclipse.cdt.internal.core.model.CModelManager;
-import org.eclipse.cdt.core.model.ICElement;
 
 
 public class IndexAllProject extends IndexRequest {
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.7
diff -u -r1.7 IndexManager.java
--- index/org/eclipse/cdt/internal/core/search/indexing/IndexManager.java	23 Sep 2003 15:17:13 -0000	1.7
+++ index/org/eclipse/cdt/internal/core/search/indexing/IndexManager.java	25 Sep 2003 23:39:45 -0000
@@ -35,9 +35,7 @@
 import org.eclipse.core.resources.IProject;
 import org.eclipse.core.resources.IWorkspace;
 import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
 import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.QualifiedName;
 
 
 public class IndexManager extends JobManager implements IIndexConstants {
@@ -106,13 +104,6 @@
 	 */
 	public void addSource(IFile resource, IPath indexedContainer){
 	
-		/******
-		*TODO: BOG Remove these methods once the new indexer is
-		*fully integrated
-		*/
-//		IProject project= resource.getProject();
-//		if (!isEnabled(project)) return;
-
 		if (CCorePlugin.getDefault() == null) return;	
 		AddCompilationUnitToIndex job = new AddCompilationUnitToIndex(resource, indexedContainer, this);
 		if (this.awaitingJobsCount() < MAX_FILES_IN_MEMORY) {
@@ -240,13 +231,7 @@
 	 */
 	public void indexAll(IProject project) {
 		if (CCorePlugin.getDefault() == null) return;
-		
-		 /******
-		 *TODO: BOG Remove these methods once the new indexer is
-		 *fully integrated
-		 */
-//		 if (!isEnabled(project)) return;
-
+	
 		// check if the same request is not already in the queue
 		IndexRequest request = new IndexAllProject(project, this);
 		for (int i = this.jobEnd; i > this.jobStart; i--) // NB: don't check job at jobStart, as it may have already started (see http://bugs.eclipse.org/bugs/show_bug.cgi?id=32488)
@@ -258,11 +243,6 @@
 	 */
 	public void indexSourceFolder(CProject javaProject, IPath sourceFolder, final char[][] exclusionPattern) {
 		IProject project = javaProject.getProject();
-		/******
-		*TODO: BOG Remove these methods once the new indexer is
-		*fully integrated
-		*/
-//		if (!isEnabled(project)) return;
 
 		if (this.jobEnd > this.jobStart) {
 			// check if a job to index the project is not already in the queue
@@ -320,14 +300,7 @@
 		IndexRequest request = null;
 		if (target instanceof IProject) {
 			IProject p = (IProject) target;
-			/******
-			*TODO: BOG Remove these methods once the new indexer is
-			*fully integrated
-			*/
-//			if (!isEnabled(p)) return;
-
-			//if (JavaProject.hasJavaNature(p))
-				request = new IndexAllProject(p, this);
+			request = new IndexAllProject(p, this);
 		}
 	
 		if (request != null)
@@ -409,12 +382,7 @@
 	 */
 	public void removeSourceFolderFromIndex(CProject javaProject, IPath sourceFolder, char[][] exclusionPatterns) {
 		IProject project = javaProject.getProject();
-		/******
-		*TODO: BOG Remove these methods once the new indexer is
-		*fully integrated
-		*/
-//		if (!isEnabled(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);
@@ -596,49 +564,5 @@
 			else if (indexState == REBUILDING_STATE) state = "REBUILDING"; //$NON-NLS-1$
 			JobManager.verbose("-> index state updated to: " + state + " for: "+indexName); //$NON-NLS-1$ //$NON-NLS-2$
 		}
-	}
-
-	/*************
-	 *TODO: BOG Remove these methods once the new indexer is
-	 *fully integrated
-	 * START OF TEMP INDEXER ENABLE SECTION
-	 */
-//	final static String INDEX_MODEL_ID = CCorePlugin.PLUGIN_ID + ".newindexmodel";
-//	final static String ACTIVATION = "enable";
-//	
-//	static QualifiedName activationKey = new QualifiedName(INDEX_MODEL_ID, ACTIVATION);
-//	
-//	public boolean isEnabled(IProject project) {
-//		String prop = null;
-//		try {
-//			if (project != null) {
-//				prop = project.getPersistentProperty(activationKey);
-//			}
-//		} catch (CoreException e) {
-//		}
-//		return ((prop != null) && prop.equalsIgnoreCase("true"));
-//	}
-//	
-//	public void setEnabled(IProject project, boolean on) {
-//		try {
-//			if (project != null) {
-//				Boolean newValue = new Boolean(on);
-//				Boolean oldValue = new Boolean(isEnabled(project));
-//				if (!oldValue.equals(newValue)) {
-//					project.setPersistentProperty(activationKey, newValue.toString());
-//					if (on) {
-//						indexAll(project);
-//					} else {
-//						//remove(project);
-//					}
-//				}
-//			}
-//		} catch (CoreException e) {
-//		}
-//	}
-	
-	/************
-	 * END OF TEMP INDEXER ENABLE SECTION
-	 */
-		
+	}	
 }
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.10
diff -u -r1.10 SourceIndexer.java
--- index/org/eclipse/cdt/internal/core/search/indexing/SourceIndexer.java	9 Sep 2003 17:53:51 -0000	1.10
+++ index/org/eclipse/cdt/internal/core/search/indexing/SourceIndexer.java	25 Sep 2003 23:39:45 -0000
@@ -108,4 +108,10 @@
 	 */
 	
 	public void setFileTypes(String[] fileTypes){}
+	/* (non-Javadoc)
+	 * @see org.eclipse.cdt.internal.core.search.indexing.AbstractIndexer#getResourceFile()
+	 */
+	public IFile getResourceFile() {
+		return resourceFile;
+	}
 }
Index: index/org/eclipse/cdt/internal/core/search/indexing/SourceIndexerRequestor.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/search/indexing/SourceIndexerRequestor.java,v
retrieving revision 1.19
diff -u -r1.19 SourceIndexerRequestor.java
--- index/org/eclipse/cdt/internal/core/search/indexing/SourceIndexerRequestor.java	18 Sep 2003 15:15:08 -0000	1.19
+++ index/org/eclipse/cdt/internal/core/search/indexing/SourceIndexerRequestor.java	25 Sep 2003 23:39:46 -0000
@@ -15,6 +15,8 @@
 * @author bgheorgh
 */
 
+import java.util.LinkedList;
+
 import org.eclipse.cdt.core.parser.IProblem;
 import org.eclipse.cdt.core.parser.ISourceElementRequestor;
 import org.eclipse.cdt.core.parser.ast.IASTASMDefinition;
@@ -69,6 +71,9 @@
 	int depth = 0;
 	int methodDepth = 0;
 	
+	private IASTInclusion currentInclude = null;
+	private LinkedList includeStack = new LinkedList();
+	
 	public SourceIndexerRequestor(SourceIndexer indexer, IDocument document) {
 		super();
 		this.indexer = indexer;
@@ -180,9 +185,10 @@
 	public void enterInclusion(IASTInclusion inclusion) {
 		// TODO Auto-generated method stub
 		
-		//System.out.println("NEW INCLUSION \nInclusion short name: " + inclusion.getName()); 
-		//System.out.println("Inclusion Long Name: " + inclusion.getFullFileName());
-		//System.out.println("enterInclusion");
+		IASTInclusion parent = peekInclude();
+		indexer.addInclude(inclusion, parent);
+		//Push on stack
+		pushInclude(inclusion);
 	}
 
 	/* (non-Javadoc)
@@ -342,8 +348,7 @@
 	 */
 	public void exitInclusion(IASTInclusion inclusion) {
 		// TODO Auto-generated method stub
-		//System.out.println("exitInclusion");
-
+		popInclude();
 	}
 
 	/* (non-Javadoc)
@@ -455,4 +460,19 @@
         	indexer.addParameterReference( (IASTParameterDeclaration) reference.getReferencedElement() );
         
     }
+    
+	private void pushInclude( IASTInclusion inclusion ){
+		includeStack.addFirst( currentInclude );
+		currentInclude = inclusion;
+	}
+	
+	private IASTInclusion popInclude(){
+		IASTInclusion oldInclude = currentInclude;
+		currentInclude = (includeStack.size() > 0 ) ? (IASTInclusion) includeStack.removeFirst() : null;
+		return oldInclude;
+	}
+	
+	private IASTInclusion peekInclude(){
+		return currentInclude;
+	}
 }
Index: model/org/eclipse/cdt/core/model/CoreModel.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/CoreModel.java,v
retrieving revision 1.14
diff -u -r1.14 CoreModel.java
--- model/org/eclipse/cdt/core/model/CoreModel.java	24 Jul 2003 14:15:06 -0000	1.14
+++ model/org/eclipse/cdt/core/model/CoreModel.java	25 Sep 2003 23:39:46 -0000
@@ -9,7 +9,6 @@
 import org.eclipse.cdt.internal.core.model.BatchOperation;
 import org.eclipse.cdt.internal.core.model.CModelManager;
 import org.eclipse.cdt.internal.core.search.indexing.IndexManager;
-import org.eclipse.cdt.internal.core.sourcedependency.DependencyManager;
 import org.eclipse.core.resources.IFile;
 import org.eclipse.core.resources.IFolder;
 import org.eclipse.core.resources.IProject;
@@ -225,13 +224,5 @@
 	
 	public IndexManager getIndexManager(){
 		return manager.getIndexManager();
-	}
-	
-	public void startDependencyService() {
-		manager.getSourceDependencyManager().reset();
-	}
-	
-	public DependencyManager getDependencyManager(){
-		return manager.getSourceDependencyManager();
 	}
 }
Index: model/org/eclipse/cdt/internal/core/model/CModelManager.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CModelManager.java,v
retrieving revision 1.32
diff -u -r1.32 CModelManager.java
--- model/org/eclipse/cdt/internal/core/model/CModelManager.java	12 Aug 2003 14:29:07 -0000	1.32
+++ model/org/eclipse/cdt/internal/core/model/CModelManager.java	25 Sep 2003 23:39:46 -0000
@@ -28,6 +28,7 @@
 import org.eclipse.cdt.core.model.ICProject;
 import org.eclipse.cdt.core.model.IElementChangedListener;
 import org.eclipse.cdt.core.model.IParent;
+import org.eclipse.cdt.internal.core.search.indexing.IndexManager;
 import org.eclipse.core.resources.IFile;
 import org.eclipse.core.resources.IFolder;
 import org.eclipse.core.resources.IProject;
@@ -42,8 +43,6 @@
 import org.eclipse.core.runtime.CoreException;
 import org.eclipse.core.runtime.IPath;
 import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.cdt.internal.core.search.indexing.IndexManager;
-import org.eclipse.cdt.internal.core.sourcedependency.DependencyManager;
 
 public class CModelManager implements IResourceChangeListener {
 
@@ -782,10 +781,5 @@
 	public void deleting(IProject project){
 		//	discard all indexing jobs for this project
 		this.getIndexManager().discardJobs(project.getName());
-	}
-	
-	
-	public DependencyManager getSourceDependencyManager() {
-		return this.fDeltaProcessor.sourceDependencyManager;
 	}
 }
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.15
diff -u -r1.15 DeltaProcessor.java
--- model/org/eclipse/cdt/internal/core/model/DeltaProcessor.java	12 Sep 2003 18:51:18 -0000	1.15
+++ model/org/eclipse/cdt/internal/core/model/DeltaProcessor.java	25 Sep 2003 23:39:46 -0000
@@ -5,9 +5,6 @@
  * 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;
@@ -18,18 +15,20 @@
 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.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.sourcedependency.DependencyManager;
-import org.eclipse.cdt.internal.core.sourcedependency.DependencyQueryJob;
+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
@@ -46,8 +45,6 @@
 	
 	protected IndexManager indexManager = new IndexManager();
 	
-	protected DependencyManager sourceDependencyManager = new DependencyManager();
-	
 	/* The C element that was last created (see createElement(IResource). 
 	 * This is used as a stack of C elements (using getParent() to pop it, and 
 	 * using the various get*(...) to push it. */
@@ -465,37 +462,26 @@
 	}
 
 	protected void updateIndexAddResource(ICElement element, IResourceDelta delta) {
-		//CModelManager.getDefault().getIndexManager().addResource(delta.getResource());
 	
 		if (indexManager == null)
 			return;
 		
 	    switch (element.getElementType()) {
 			case ICElement.C_PROJECT :
-					this.indexManager.indexAll(element.getCProject().getProject());
-					this.sourceDependencyManager.generateEntireDependencyTree(element.getCProject().getProject());
-					break;
+				this.indexManager.indexAll(element.getCProject().getProject());
+				break;
 	
 			case ICElement.C_UNIT:
 				IFile file = (IFile) delta.getResource();
 				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;						
 	    }
 		
 	}
 
 	protected void updateIndexRemoveResource(ICElement element, IResourceDelta delta) {
-		//CModelManager.getDefault().getIndexManager().removeResource(delta.getResource());
-	
+		
 		if (indexManager == null)
 						return;
 
@@ -503,7 +489,6 @@
 			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
@@ -511,7 +496,6 @@
 			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;				
 		}
 	
@@ -519,7 +503,7 @@
 	}
 	
 	private void updateDependencies(ICElement element){
-		//Update table
+	
 		IResource resource = element.getResource();
 		if (resource == null)
 		 return;
@@ -529,41 +513,35 @@
 		if ((fileExtension != null) &&
 			(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());
-					}
+			fileExtension.equals("hpp")))
+		{
+			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());
 				}
 			}
 		}
-	}
-	
-	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: search/ChangeLog
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/search/ChangeLog,v
retrieving revision 1.28
diff -u -r1.28 ChangeLog
--- search/ChangeLog	25 Sep 2003 19:51:46 -0000	1.28
+++ search/ChangeLog	25 Sep 2003 23:39:46 -0000
@@ -1,3 +1,10 @@
+2003-09-25 Bogdan Gheorghe
+	- added SearchFor INCLUDE in ICSearchConstants
+	- added acceptIncludeDeclaration to IIndexSearchRequestor
+	- modified PathCollector to acceptIncludeDeclarations
+	- modified CSearchPattern to create an IncludePattern
+	- added IncludePattern.java
+	
 2003-09-25 Andrew Niefer
 	- partial fix for 43664	Modify Matchlocator to not try and create a link if we have no 
 	resource, instead just use the path
Index: search/org/eclipse/cdt/core/search/ICSearchConstants.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/search/org/eclipse/cdt/core/search/ICSearchConstants.java,v
retrieving revision 1.7
diff -u -r1.7 ICSearchConstants.java
--- search/org/eclipse/cdt/core/search/ICSearchConstants.java	15 Sep 2003 17:31:22 -0000	1.7
+++ search/org/eclipse/cdt/core/search/ICSearchConstants.java	25 Sep 2003 23:39:46 -0000
@@ -96,9 +96,12 @@
 	public static final SearchFor MACRO = new SearchFor( 10 );
 	
 	public static final SearchFor CLASS_STRUCT = new SearchFor( 11 );
-	
+
 	public static final SearchFor TYPEDEF = new SearchFor( 12 );
 	
+	public static final SearchFor INCLUDE = new SearchFor( 13 );
+	
+
 	/* Nature of match */
 	
 	/**
Index: search/org/eclipse/cdt/internal/core/search/IIndexSearchRequestor.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/search/org/eclipse/cdt/internal/core/search/IIndexSearchRequestor.java,v
retrieving revision 1.3
diff -u -r1.3 IIndexSearchRequestor.java
--- search/org/eclipse/cdt/internal/core/search/IIndexSearchRequestor.java	12 Aug 2003 14:29:07 -0000	1.3
+++ search/org/eclipse/cdt/internal/core/search/IIndexSearchRequestor.java	25 Sep 2003 23:39:46 -0000
@@ -82,4 +82,6 @@
 
 void acceptMacroDeclaration(String resourcePath, char[] decodedSimpleName);
 
+void acceptIncludeDeclaration(String resourcePath, char[] decodedSimpleName);
+
 }
Index: search/org/eclipse/cdt/internal/core/search/PathCollector.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/search/org/eclipse/cdt/internal/core/search/PathCollector.java,v
retrieving revision 1.3
diff -u -r1.3 PathCollector.java
--- search/org/eclipse/cdt/internal/core/search/PathCollector.java	12 Aug 2003 14:29:07 -0000	1.3
+++ search/org/eclipse/cdt/internal/core/search/PathCollector.java	25 Sep 2003 23:39:47 -0000
@@ -156,6 +156,12 @@
 	public void acceptMacroDeclaration(String resourcePath, char[] decodedSimpleName) {
 		this.paths.add(resourcePath);
 	}
+	/* (non-Javadoc)
+	 * @see org.eclipse.cdt.internal.core.search.IIndexSearchRequestor#acceptIncludeDeclaration(java.lang.String, char[])
+	 */
+	public void acceptIncludeDeclaration(String resourcePath, char[] decodedSimpleName) {
+		this.paths.add(resourcePath);
+	}
 
 	
 
Index: search/org/eclipse/cdt/internal/core/search/matching/CSearchPattern.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/search/org/eclipse/cdt/internal/core/search/matching/CSearchPattern.java,v
retrieving revision 1.23
diff -u -r1.23 CSearchPattern.java
--- search/org/eclipse/cdt/internal/core/search/matching/CSearchPattern.java	24 Sep 2003 13:36:40 -0000	1.23
+++ search/org/eclipse/cdt/internal/core/search/matching/CSearchPattern.java	25 Sep 2003 23:39:47 -0000
@@ -23,8 +23,8 @@
 import org.eclipse.cdt.core.parser.IQuickParseCallback;
 import org.eclipse.cdt.core.parser.IScanner;
 import org.eclipse.cdt.core.parser.IToken;
-import org.eclipse.cdt.core.parser.ParserLanguage;
 import org.eclipse.cdt.core.parser.ParserFactory;
+import org.eclipse.cdt.core.parser.ParserLanguage;
 import org.eclipse.cdt.core.parser.ParserMode;
 import org.eclipse.cdt.core.parser.ScannerException;
 import org.eclipse.cdt.core.parser.ast.ASTClassKind;
@@ -103,9 +103,25 @@
 			pattern = createNamespacePattern( patternString, limitTo, matchMode, caseSensitive );
 		} else if ( searchFor == MACRO ){
 			pattern = createMacroPattern( patternString, limitTo, matchMode, caseSensitive );
+		} else if ( searchFor == INCLUDE){
+			pattern = createIncludePattern( patternString, limitTo, matchMode, caseSensitive);
 		}
 	
 		return pattern;
+	}
+
+	/**
+	 * @param patternString
+	 * @param limitTo
+	 * @param matchMode
+	 * @param caseSensitive
+	 * @return
+	 */
+	private static CSearchPattern createIncludePattern(String patternString, LimitTo limitTo, int matchMode, boolean caseSensitive) {
+		if( limitTo != REFERENCES )
+			return null;
+			
+		return new IncludePattern ( patternString.toCharArray(), matchMode, limitTo, caseSensitive );	
 	}
 
 	/**
Index: search/org/eclipse/cdt/internal/core/search/matching/IncludePattern.java
===================================================================
RCS file: search/org/eclipse/cdt/internal/core/search/matching/IncludePattern.java
diff -N search/org/eclipse/cdt/internal/core/search/matching/IncludePattern.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ search/org/eclipse/cdt/internal/core/search/matching/IncludePattern.java	25 Sep 2003 23:39:47 -0000
@@ -0,0 +1,105 @@
+/**********************************************************************
+ * Copyright (c) 2002,2003 Rational Software Corporation and others.
+ * All rights reserved.   This program and the accompanying materials
+ * are made available under the terms of the Common Public License v0.5
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v05.html
+ * 
+ * Contributors: 
+ * IBM Rational Software - Initial API and implementation
+***********************************************************************/
+
+package org.eclipse.cdt.internal.core.search.matching;
+
+import java.io.IOException;
+
+import org.eclipse.cdt.core.parser.ISourceElementCallbackDelegate;
+import org.eclipse.cdt.core.search.ICSearchScope;
+import org.eclipse.cdt.internal.core.CharOperation;
+import org.eclipse.cdt.internal.core.index.IEntryResult;
+import org.eclipse.cdt.internal.core.index.impl.IndexInput;
+import org.eclipse.cdt.internal.core.index.impl.IndexedFile;
+import org.eclipse.cdt.internal.core.search.IIndexSearchRequestor;
+import org.eclipse.cdt.internal.core.search.indexing.AbstractIndexer;
+
+/**
+ * @author bgheorgh
+ */
+public class IncludePattern extends CSearchPattern {
+	protected char [] simpleName;
+	protected char [] decodedSimpleName;
+	/**
+	 * 
+	 */
+	public IncludePattern(char[] name, int matchMode, LimitTo limitTo, boolean caseSensitive) {
+		super( matchMode, caseSensitive, limitTo );	
+		simpleName = name;
+	}
+
+	/* (non-Javadoc)
+	 * @see org.eclipse.cdt.internal.core.search.matching.CSearchPattern#decodeIndexEntry(org.eclipse.cdt.internal.core.index.IEntryResult)
+	 */
+	protected void decodeIndexEntry(IEntryResult entryResult) {
+		char[] word = entryResult.getWord();
+		int size = word.length;
+	
+		int firstSlash = CharOperation.indexOf( SEPARATOR, word, 0 );
+
+		this.decodedSimpleName = CharOperation.subarray(word, firstSlash + 1, -1);
+	}
+		
+	/* (non-Javadoc)
+	 * @see org.eclipse.cdt.internal.core.search.matching.CSearchPattern#feedIndexRequestor(org.eclipse.cdt.internal.core.search.IIndexSearchRequestor, int, int[], org.eclipse.cdt.internal.core.index.impl.IndexInput, org.eclipse.cdt.core.search.ICSearchScope)
+	 */
+	public void feedIndexRequestor(IIndexSearchRequestor requestor, int detailLevel, int[] references, IndexInput input, ICSearchScope scope) throws IOException {
+		for (int i = 0, max = references.length; i < max; i++) {
+			IndexedFile file = input.getIndexedFile(references[i]);
+			String path;
+			if (file != null && scope.encloses(path =file.getPath())) {
+				requestor.acceptIncludeDeclaration(path, decodedSimpleName);
+			}
+		}	
+	}
+
+	/* (non-Javadoc)
+	 * @see org.eclipse.cdt.internal.core.search.matching.CSearchPattern#resetIndexInfo()
+	 */
+	protected void resetIndexInfo() {
+		decodedSimpleName = null;
+	}
+
+
+	/* (non-Javadoc)
+	 * @see org.eclipse.cdt.internal.core.search.matching.CSearchPattern#indexEntryPrefix()
+	 */
+	public char[] indexEntryPrefix() {
+		return AbstractIndexer.bestIncludePrefix(
+							_limitTo,
+							simpleName,
+							_matchMode, _caseSensitive
+			);
+	}
+
+	/* (non-Javadoc)
+	 * @see org.eclipse.cdt.internal.core.search.matching.CSearchPattern#matchIndexEntry()
+	 */
+	protected boolean matchIndexEntry() {
+		/* check simple name matches */
+		if (simpleName != null){
+			if( ! matchesName( simpleName, decodedSimpleName ) ){
+				return false; 
+			}
+		}
+		
+		return true;
+	}
+
+	/* (non-Javadoc)
+	 * @see org.eclipse.cdt.core.search.ICSearchPattern#matchLevel(org.eclipse.cdt.core.parser.ISourceElementCallbackDelegate, org.eclipse.cdt.core.search.ICSearchConstants.LimitTo)
+	 */
+	public int matchLevel(ISourceElementCallbackDelegate node, LimitTo limit) {
+		// TODO Auto-generated method stub
+		return 0;
+	}
+
+}
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.33
diff -u -r1.33 CCorePlugin.java
--- src/org/eclipse/cdt/core/CCorePlugin.java	23 Sep 2003 15:17:13 -0000	1.33
+++ src/org/eclipse/cdt/core/CCorePlugin.java	25 Sep 2003 23:39:47 -0000
@@ -32,7 +32,6 @@
 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;
 import org.eclipse.core.resources.IWorkspace;
@@ -230,9 +229,6 @@
 		//Fired up the indexer
 		fCoreModel.startIndexing();
 		
-		//Fire up dependency manager
-		fCoreModel.startDependencyService();
-		
 		fDescriptorManager = new CDescriptorManager();
 		fDescriptorManager.startup();
 	}
@@ -765,7 +761,6 @@
 	private static final String SEARCH  = CCorePlugin.PLUGIN_ID + "/debug/search" ; //$NON-NLS-1$
 	private static final String MATCH_LOCATOR  = CCorePlugin.PLUGIN_ID + "/debug/matchlocator" ; //$NON-NLS-1$
 	private static final String PARSER = CCorePlugin.PLUGIN_ID + "/debug/parser" ; //$NON-NLS-1$
-	private static final String DEPENDENCY = CCorePlugin.PLUGIN_ID + "/debug/dependency" ; //$NON-NLS-1$
 	private static final String DELTA = CCorePlugin.PLUGIN_ID + "/debug/deltaprocessor" ;
 	/**
 	 * Configure the plugin with respect to option settings defined in ".options" file
@@ -779,13 +774,6 @@
 			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){
-				depFlag = option.equalsIgnoreCase("true"); 
-				DependencyManager.VERBOSE = depFlag;
-			}//$NON-NLS-1$
-			
 			boolean indexFlag = false;
 			option = Platform.getDebugOption(INDEX_MANAGER);
 			if(option != null) {
@@ -805,8 +793,7 @@
 			option = Platform.getDebugOption(MATCH_LOCATOR);
 			if(option != null) MatchLocator.VERBOSE = option.equalsIgnoreCase("true") ; //$NON-NLS-1$
 			
-			if (indexFlag == true ||
-			    depFlag == true){
+			if (indexFlag == true){
 			   JobManager.VERBOSE = true; 	
 			}
 		}

Back to the top