1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00
- Hooked up the Indexer to the dependency tree. Everytime a header file 
gets modified, the including source files get reindexed. 
- Automated dependency calcuations - each time a file gets modified, its 
tree gets updated. 
- Added error logging via the PDE Error Log (Views->PDE Runtime->Error 
Log) - the indexer reports unsuccesful index attempts and the preprocessor 
reports unsuccesful inclusion resolution attempts 

UI 
- Changed the names on the search popup mens
This commit is contained in:
John Camelon 2003-09-09 17:54:02 +00:00
parent 2f62fb6d57
commit 8f627892aa
41 changed files with 682 additions and 141 deletions

View file

@ -28,6 +28,7 @@ import org.eclipse.cdt.core.model.IStructure;
import org.eclipse.cdt.internal.core.model.CElement; import org.eclipse.cdt.internal.core.model.CElement;
import org.eclipse.cdt.internal.core.model.TranslationUnit; import org.eclipse.cdt.internal.core.model.TranslationUnit;
import org.eclipse.cdt.testplugin.CProjectHelper; import org.eclipse.cdt.testplugin.CProjectHelper;
import org.eclipse.core.internal.resources.ResourceException;
import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IProjectDescription; import org.eclipse.core.resources.IProjectDescription;
@ -90,8 +91,12 @@ public class CModelElementsFailedTests extends TestCase {
proj.setDescription(description, monitor); proj.setDescription(description, monitor);
} }
protected void tearDown() throws Exception { protected void tearDown() {
CProjectHelper.delete(fCProject); try{
CProjectHelper.delete(fCProject);
}
catch (ResourceException e) {}
catch (CoreException e) {}
} }
public void testBug36379() { public void testBug36379() {

View file

@ -33,6 +33,7 @@ import org.eclipse.cdt.internal.core.search.indexing.IIndexConstants;
import org.eclipse.cdt.internal.core.search.indexing.IndexManager; import org.eclipse.cdt.internal.core.search.indexing.IndexManager;
import org.eclipse.cdt.internal.core.sourcedependency.DependencyManager; import org.eclipse.cdt.internal.core.sourcedependency.DependencyManager;
import org.eclipse.cdt.internal.core.sourcedependency.DependencyQueryJob; import org.eclipse.cdt.internal.core.sourcedependency.DependencyQueryJob;
import org.eclipse.core.internal.resources.ResourceException;
import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IProjectDescription; import org.eclipse.core.resources.IProjectDescription;
@ -56,6 +57,7 @@ public class IndexManagerTests extends TestCase {
IProject testProject; IProject testProject;
NullProgressMonitor monitor; NullProgressMonitor monitor;
IndexManager indexManager; IndexManager indexManager;
public static final int TIMEOUT = 10000; public static final int TIMEOUT = 10000;
/** /**
* Constructor for IndexManagerTest. * Constructor for IndexManagerTest.
@ -76,15 +78,24 @@ public class IndexManagerTests extends TestCase {
testProject = createProject("IndexerTestProject"); testProject = createProject("IndexerTestProject");
if (testProject==null) if (testProject==null)
fail("Unable to create project"); fail("Unable to create project");
} }
/* /*
* @see TestCase#tearDown() * @see TestCase#tearDown()
*/ */
protected void tearDown() throws Exception { protected void tearDown() {
super.tearDown(); try {
super.tearDown();
} catch (Exception e1) {
}
//Delete project //Delete project
if (testProject.exists()){ if (testProject.exists()){
testProject.delete(true,monitor); try {
testProject.delete(true,monitor);
} catch (ResourceException e) {
} catch (CoreException e) {
}
} }
} }
@ -109,31 +120,39 @@ public class IndexManagerTests extends TestCase {
{ {
IWorkspaceRoot root= ResourcesPlugin.getWorkspace().getRoot(); IWorkspaceRoot root= ResourcesPlugin.getWorkspace().getRoot();
IProject project= root.getProject(projectName); IProject project= root.getProject(projectName);
if (!project.exists()) { IProject cproject = null;
project.create(null); try{
} else { if (!project.exists()) {
project.refreshLocal(IResource.DEPTH_INFINITE, null); 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);
}
} }
if (!project.isOpen()) { catch (CoreException e){
project.open(null); cproject = project;
} cproject.open(null);
}
//Fill out a project description finally{
IPath defaultPath = Platform.getLocation(); return cproject;
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
IProject 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);
} }
return cproject;
} }
private IFile importFile(String fileName, String resourceLocation)throws Exception{ private IFile importFile(String fileName, String resourceLocation)throws Exception{
@ -236,12 +255,26 @@ public class IndexManagerTests extends TestCase {
IIndex ind = indexManager.getIndex(testProjectPath,true,true); IIndex ind = indexManager.getIndex(testProjectPath,true,true);
assertTrue("Index exists for project",ind != null); assertTrue("Index exists for project",ind != null);
//Delete the project //Delete the project
testProject.delete(true,monitor); safeDelete(testProject);
//See if the index is still there //See if the index is still there
ind = indexManager.getIndex(testProjectPath,true,true); ind = indexManager.getIndex(testProjectPath,true,true);
assertTrue("Index deleted",ind == null); assertTrue("Index deleted",ind == null);
} }
/**
* @param testProject
*/
private void safeDelete(IProject testProject) throws InterruptedException, CoreException {
try {
testProject.delete(true,monitor);
} catch (CoreException e) {
Thread.sleep(1000);
testProject.delete(true,monitor);
}
}
public void testRemoveFileFromIndex() throws Exception{ public void testRemoveFileFromIndex() throws Exception{
//Add a file to the project //Add a file to the project
importFile("mail.cpp","resources/indexer/mail.cpp"); importFile("mail.cpp","resources/indexer/mail.cpp");

View file

@ -23,6 +23,7 @@ import org.eclipse.cdt.internal.core.model.TranslationUnit;
import org.eclipse.cdt.internal.core.search.indexing.IndexManager; import org.eclipse.cdt.internal.core.search.indexing.IndexManager;
import org.eclipse.cdt.internal.ui.text.CCompletionProcessor; import org.eclipse.cdt.internal.ui.text.CCompletionProcessor;
import org.eclipse.cdt.testplugin.CProjectHelper; import org.eclipse.cdt.testplugin.CProjectHelper;
import org.eclipse.core.internal.resources.ResourceException;
import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IProjectDescription; import org.eclipse.core.resources.IProjectDescription;
@ -95,8 +96,12 @@ public class CompletionProposalsTest extends TestCase{
proj.setDescription(description, monitor); proj.setDescription(description, monitor);
} }
protected void tearDown() throws Exception { protected void tearDown() {
CProjectHelper.delete(fCProject); try{
CProjectHelper.delete(fCProject);
}
catch (ResourceException e) {}
catch (CoreException e) {}
} }
public void testCompletionProposals(){ public void testCompletionProposals(){

View file

@ -18,6 +18,7 @@ import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.core.model.ICProject; import org.eclipse.cdt.core.model.ICProject;
import org.eclipse.cdt.testplugin.CProjectHelper; import org.eclipse.cdt.testplugin.CProjectHelper;
import org.eclipse.cdt.testplugin.util.ExpectedStrings; import org.eclipse.cdt.testplugin.util.ExpectedStrings;
import org.eclipse.core.internal.resources.ResourceException;
import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IWorkspace; import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.resources.IWorkspaceRoot; import org.eclipse.core.resources.IWorkspaceRoot;
@ -127,8 +128,12 @@ public class ArchiveTests extends TestCase {
* *
* Called after every test case method. * Called after every test case method.
*/ */
protected void tearDown() throws CoreException { protected void tearDown() {
CProjectHelper.delete(testProject); try{
CProjectHelper.delete(testProject);
}
catch (ResourceException e) {}
catch (CoreException e) {}
} }
public static TestSuite suite() { public static TestSuite suite() {

View file

@ -17,6 +17,7 @@ import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.core.model.ICProject; import org.eclipse.cdt.core.model.ICProject;
import org.eclipse.cdt.testplugin.CProjectHelper; import org.eclipse.cdt.testplugin.CProjectHelper;
import org.eclipse.cdt.testplugin.util.ExpectedStrings; import org.eclipse.cdt.testplugin.util.ExpectedStrings;
import org.eclipse.core.internal.resources.ResourceException;
import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IWorkspace; import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.resources.IWorkspaceRoot; import org.eclipse.core.resources.IWorkspaceRoot;
@ -62,9 +63,11 @@ public class BinaryTests extends TestCase {
/** /**
* Make sure we leave the workspace clean for the next set of tests * Make sure we leave the workspace clean for the next set of tests
*/ */
CProjectHelper.delete(testProject); try{
CProjectHelper.delete(testProject);
}
catch (ResourceException e) {}
catch (CoreException e) {}
} }
@ -169,9 +172,12 @@ public class BinaryTests extends TestCase {
protected void tearDown() throws CoreException, InterruptedException { protected void tearDown() throws CoreException, InterruptedException {
/* Let everything settle down before we try to delete the project. /* Let everything settle down before we try to delete the project.
*/ */
Thread.sleep(500); Thread.sleep(500);
CProjectHelper.delete(testProject); try{
CProjectHelper.delete(testProject);
}
catch (ResourceException e) {}
catch (CoreException e) {}
} }

View file

@ -44,6 +44,7 @@ import org.eclipse.cdt.internal.core.model.MethodTemplate;
import org.eclipse.cdt.internal.core.model.StructureTemplate; import org.eclipse.cdt.internal.core.model.StructureTemplate;
import org.eclipse.cdt.internal.core.model.TranslationUnit; import org.eclipse.cdt.internal.core.model.TranslationUnit;
import org.eclipse.cdt.testplugin.CProjectHelper; import org.eclipse.cdt.testplugin.CProjectHelper;
import org.eclipse.core.internal.resources.ResourceException;
import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IProjectDescription; import org.eclipse.core.resources.IProjectDescription;
@ -98,8 +99,12 @@ public class CModelElementsTests extends TestCase {
proj.setDescription(description, monitor); proj.setDescription(description, monitor);
} }
protected void tearDown() throws Exception { protected void tearDown() {
CProjectHelper.delete(fCProject); try{
CProjectHelper.delete(fCProject);
}
catch (ResourceException e) {}
catch (CoreException e) {}
} }
public void testCModelElements(){ public void testCModelElements(){

View file

@ -16,6 +16,7 @@ import org.eclipse.cdt.core.CCProjectNature;
import org.eclipse.cdt.core.model.CoreModel; import org.eclipse.cdt.core.model.CoreModel;
import org.eclipse.cdt.core.model.ICProject; import org.eclipse.cdt.core.model.ICProject;
import org.eclipse.cdt.testplugin.CProjectHelper; import org.eclipse.cdt.testplugin.CProjectHelper;
import org.eclipse.core.internal.resources.ResourceException;
import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IWorkspace; import org.eclipse.core.resources.IWorkspace;
@ -216,7 +217,12 @@ public class CModelTests extends TestCase {
assertTrue("isTranslationUnit", !CoreModel.getDefault().isTranslationUnit(file)); assertTrue("isTranslationUnit", !CoreModel.getDefault().isTranslationUnit(file));
testProject.getProject().delete(true,true,monitor);
try{
testProject.getProject().delete(true,true,monitor);
}
catch (ResourceException e) {}
catch (CoreException e) {}
} }
/**** /****

View file

@ -35,6 +35,7 @@ import org.eclipse.cdt.internal.core.model.IWorkingCopy;
import org.eclipse.cdt.internal.core.model.TranslationUnit; import org.eclipse.cdt.internal.core.model.TranslationUnit;
import org.eclipse.cdt.testplugin.CProjectHelper; import org.eclipse.cdt.testplugin.CProjectHelper;
import org.eclipse.cdt.testplugin.TestPluginLauncher; import org.eclipse.cdt.testplugin.TestPluginLauncher;
import org.eclipse.core.internal.resources.ResourceException;
import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IProjectDescription; import org.eclipse.core.resources.IProjectDescription;
@ -104,8 +105,12 @@ public class ElementDeltaTests extends TestCase implements IElementChangedListen
proj.setDescription(description, monitor); proj.setDescription(description, monitor);
} }
protected void tearDown() throws Exception { protected void tearDown() {
CProjectHelper.delete(fCProject); try{
CProjectHelper.delete(fCProject);
}
catch (ResourceException e) {}
catch (CoreException e) {}
} }

View file

@ -12,6 +12,7 @@ import java.util.Map;
import org.eclipse.cdt.testplugin.CProjectHelper; import org.eclipse.cdt.testplugin.CProjectHelper;
import org.eclipse.cdt.core.model.ICProject; import org.eclipse.cdt.core.model.ICProject;
import org.eclipse.cdt.core.model.ITranslationUnit; import org.eclipse.cdt.core.model.ITranslationUnit;
import org.eclipse.core.internal.resources.ResourceException;
import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IProjectDescription; import org.eclipse.core.resources.IProjectDescription;
@ -81,8 +82,13 @@ public abstract class IntegratedCModelTest extends TestCase {
CCorePlugin.getDefault().setUseNewParser(true); CCorePlugin.getDefault().setUseNewParser(true);
} }
protected void tearDown() throws Exception { protected void tearDown() {
CProjectHelper.delete(fCProject); try{
CProjectHelper.delete(fCProject);
}
catch (ResourceException e) {}
catch (CoreException e) {}
} }
private static void addNatureToProject(IProject proj, String natureId, IProgressMonitor monitor) throws CoreException { private static void addNatureToProject(IProject proj, String natureId, IProgressMonitor monitor) throws CoreException {

View file

@ -17,6 +17,7 @@ import junit.framework.TestCase;
import org.eclipse.cdt.core.model.ICProject; import org.eclipse.cdt.core.model.ICProject;
import org.eclipse.cdt.testplugin.CProjectHelper; import org.eclipse.cdt.testplugin.CProjectHelper;
import org.eclipse.core.internal.resources.ResourceException;
import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IWorkspace; import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.resources.IWorkspaceDescription; import org.eclipse.core.resources.IWorkspaceDescription;
@ -142,9 +143,13 @@ public class TranslationUnitBaseTest extends TestCase
* *
* Called after every test case method. * Called after every test case method.
*/ */
protected void tearDown() throws CoreException protected void tearDown()
{ {
// release resources here and clean-up // release resources here and clean-up
testProject.getProject().delete(true,true,monitor); try {
testProject.getProject().delete(true,true,monitor);
} catch (ResourceException e) {
} catch (CoreException e) {
}
} }
} }

View file

@ -26,6 +26,7 @@ import org.eclipse.cdt.internal.core.model.IWorkingCopy;
import org.eclipse.cdt.internal.core.model.TranslationUnit; import org.eclipse.cdt.internal.core.model.TranslationUnit;
import org.eclipse.cdt.testplugin.CProjectHelper; import org.eclipse.cdt.testplugin.CProjectHelper;
import org.eclipse.cdt.testplugin.TestPluginLauncher; import org.eclipse.cdt.testplugin.TestPluginLauncher;
import org.eclipse.core.internal.resources.ResourceException;
import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IProjectDescription; import org.eclipse.core.resources.IProjectDescription;
@ -89,8 +90,12 @@ public class WorkingCopyTests extends TestCase {
proj.setDescription(description, monitor); proj.setDescription(description, monitor);
} }
protected void tearDown() throws Exception { protected void tearDown() {
CProjectHelper.delete(fCProject); try{
CProjectHelper.delete(fCProject);
}
catch (ResourceException e) {}
catch (CoreException e) {}
} }

View file

@ -24,9 +24,10 @@ import org.eclipse.cdt.core.search.ICSearchPattern;
import org.eclipse.cdt.core.search.ICSearchResultCollector; import org.eclipse.cdt.core.search.ICSearchResultCollector;
import org.eclipse.cdt.core.search.ICSearchScope; import org.eclipse.cdt.core.search.ICSearchScope;
import org.eclipse.cdt.core.search.SearchEngine; import org.eclipse.cdt.core.search.SearchEngine;
import org.eclipse.cdt.internal.core.index.impl.IFileDocument;
import org.eclipse.cdt.internal.core.search.indexing.IndexManager; import org.eclipse.cdt.internal.core.search.indexing.IndexManager;
import org.eclipse.cdt.internal.ui.search.CSearchResultCollector; import org.eclipse.cdt.internal.ui.search.CSearchResultCollector;
import org.eclipse.cdt.testplugin.FileManager;
import org.eclipse.core.internal.resources.ResourceException;
import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IProjectDescription; import org.eclipse.core.resources.IProjectDescription;
@ -51,13 +52,13 @@ public class BaseSearchTest extends TestCase implements ICSearchConstants {
ICSearchScope scope; ICSearchScope scope;
IFile file; IFile file;
IFileDocument fileDoc;
IProject testProject; IProject testProject;
NullProgressMonitor monitor; NullProgressMonitor monitor;
IWorkspace workspace; IWorkspace workspace;
CSearchResultCollector resultCollector; CSearchResultCollector resultCollector;
SearchEngine searchEngine; SearchEngine searchEngine;
FileManager fileManager;
public BaseSearchTest(String name) { public BaseSearchTest(String name) {
super(name); super(name);
} }
@ -75,6 +76,9 @@ public class BaseSearchTest extends TestCase implements ICSearchConstants {
if (testProject == null) if (testProject == null)
fail("Unable to create project"); fail("Unable to create project");
//Create file manager
fileManager = new FileManager();
//Add a file to the project //Add a file to the project
importFile("mail.cpp", "resources/indexer/mail.cpp"); importFile("mail.cpp", "resources/indexer/mail.cpp");
importFile("classDecl.cpp", "resources/search/classDecl.cpp"); importFile("classDecl.cpp", "resources/search/classDecl.cpp");
@ -91,18 +95,28 @@ public class BaseSearchTest extends TestCase implements ICSearchConstants {
searchEngine = new SearchEngine(); searchEngine = new SearchEngine();
} }
protected void tearDown() throws Exception { protected void tearDown() {
super.tearDown(); try {
super.tearDown();
} catch (Exception e1) {
}
//Delete project //Delete project
if (testProject.exists()){ if (testProject.exists()){
testProject.delete( true, monitor ); try {
fileManager.closeAllFiles();
testProject.delete(true,monitor);
} catch (ResourceException e) {
} catch (CoreException e) {
}
} }
} }
private IProject createProject(String projectName) throws CoreException { private IProject createProject(String projectName) {
IWorkspaceRoot root = workspace.getRoot(); IWorkspaceRoot root = workspace.getRoot();
IProject project = root.getProject(projectName); IProject project = root.getProject(projectName);
IProject cproject = null;
try{
if( !project.exists() ) { if( !project.exists() ) {
project.create( null ); project.create( null );
} else { } else {
@ -125,7 +139,7 @@ public class BaseSearchTest extends TestCase implements ICSearchConstants {
description.setLocation(newPath); description.setLocation(newPath);
//Create the project //Create the project
IProject cproject = CCorePlugin.getDefault().createCProject( description, cproject = CCorePlugin.getDefault().createCProject( description,
project, project,
monitor, monitor,
CCorePlugin.PLUGIN_ID + ".make"); CCorePlugin.PLUGIN_ID + ".make");
@ -133,8 +147,15 @@ public class BaseSearchTest extends TestCase implements ICSearchConstants {
if( !project.hasNature(CCProjectNature.CC_NATURE_ID) ){ if( !project.hasNature(CCProjectNature.CC_NATURE_ID) ){
addNatureToProject(project, CCProjectNature.CC_NATURE_ID, null); addNatureToProject(project, CCProjectNature.CC_NATURE_ID, null);
} }
}
catch (CoreException e){
cproject = project;
cproject.open(null);
}
finally{
return cproject; return cproject;
}
} }
private void importFile(String fileName, String resourceLocation)throws Exception{ private void importFile(String fileName, String resourceLocation)throws Exception{
@ -145,8 +166,9 @@ public class BaseSearchTest extends TestCase implements ICSearchConstants {
if (!file.exists()){ if (!file.exists()){
file.create(new FileInputStream(pluginRoot + resourceLocation),false,monitor); file.create(new FileInputStream(pluginRoot + resourceLocation),false,monitor);
fileManager.addFile(file);
} }
fileDoc = new IFileDocument(file);
} }
private void addNatureToProject(IProject proj, String natureId, IProgressMonitor monitor) throws CoreException { private void addNatureToProject(IProject proj, String natureId, IProgressMonitor monitor) throws CoreException {
@ -165,4 +187,5 @@ public class BaseSearchTest extends TestCase implements ICSearchConstants {
resultCollector.setProgressMonitor( monitor ); resultCollector.setProgressMonitor( monitor );
searchEngine.search( workspace, pattern, scope, collector ); searchEngine.search( workspace, pattern, scope, collector );
} }
} }

View file

@ -63,7 +63,22 @@ public class CProjectHelper {
* Removes a ICProject. * Removes a ICProject.
*/ */
public static void delete(ICProject cproject) throws CoreException { public static void delete(ICProject cproject) throws CoreException {
cproject.getProject().delete(true, true, null);
try {
cproject.getProject().delete(true, true, null);
} catch (CoreException e) {
try {
Thread.sleep(1000);
} catch (InterruptedException e1) {
}
finally{
cproject.getProject().delete(true, true, null);
}
}
} }

View file

@ -0,0 +1,55 @@
/*
* Created on Sep 8, 2003
*
* To change the template for this generated file go to
* Window>Preferences>Java>Code Generation>Code and Comments
*/
package org.eclipse.cdt.testplugin;
import java.util.ArrayList;
import java.util.Iterator;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
/**
* @author bgheorgh
*
* To change the template for this generated type comment go to
* Window>Preferences>Java>Code Generation>Code and Comments
*/
public class FileManager {
ArrayList fileHandles;
public FileManager(){
fileHandles = new ArrayList();
}
public void addFile(IFile file){
fileHandles.add(file);
}
public void closeAllFiles() throws CoreException{
Iterator iter = fileHandles.iterator();
while (iter.hasNext()){
IFile tempFile = (IFile) iter.next();
tempFile.refreshLocal(IResource.DEPTH_INFINITE,null);
try {
tempFile.delete(true,null);
} catch (CoreException e) {
try {
Thread.sleep(2000);
} catch (InterruptedException e1) {
}
finally{
tempFile.delete(true,null);
}
}
}
}
}

View file

@ -1,3 +1,11 @@
2003-09-05 Bogdan Gheorghe
Hooked in the dependency checking on file changes in Delta
Processor.java. When a header files' contents change we look
up the referencing files in the dep tree table and reindex them.
* model/org/eclipse/cdt/internal/core/model/DeltaProcessor.java
2003-09-05 Alain Magloire 2003-09-05 Alain Magloire
The PTY classes are using one instance of the master fd for Input/Output/Error The PTY classes are using one instance of the master fd for Input/Output/Error
@ -37,7 +45,6 @@
* src/org/eclipse/cdt/core/ErrorParserManager.java * src/org/eclipse/cdt/core/ErrorParserManager.java
2003-09-01 Alain Magloire 2003-09-01 Alain Magloire
Typo in the class signature. Typo in the class signature.

View file

@ -26,12 +26,12 @@ import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IProgressMonitor;
public class AddFileToDependencyTree extends DependencyRequest { public class AddFileToDependencyTree extends DependencyRequest {
public static final String[] FILE_TYPES= new String[] {"cpp"}; //$NON-NLS-1$ public static final String[] FILE_TYPES= new String[] {"cpp","c", "cc", "cxx"}; //$NON-NLS-1$
IFile resource; IFile resource;
char[] contents; char[] contents;
IScannerInfo buildInfo; IScannerInfo buildInfo;
/** /**
* @param path * @param path
* @param manager * @param manager
@ -57,7 +57,7 @@ public class AddFileToDependencyTree extends DependencyRequest {
monitor.enterWrite(); // ask permission to write monitor.enterWrite(); // ask permission to write
if (!addDocumentToTree(tree)) return false; if (!addDocumentToTree(tree)) return false;
} catch (IOException e) { } catch (IOException e) {
if (JobManager.VERBOSE) { if (DependencyManager.VERBOSE) {
JobManager.verbose("-> failed to calculate dependency for " + this.resource + " because of the following exception:"); //$NON-NLS-1$ //$NON-NLS-2$ JobManager.verbose("-> failed to calculate dependency for " + this.resource + " because of the following exception:"); //$NON-NLS-1$ //$NON-NLS-2$
e.printStackTrace(); e.printStackTrace();
} }
@ -78,8 +78,8 @@ public class AddFileToDependencyTree extends DependencyRequest {
IScannerInfo newInfo = new ScannerInfo((this.buildInfo != null) ? this.buildInfo.getDefinedSymbols() : null,(this.buildInfo != null) ? this.buildInfo.getIncludePaths() : null); 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; ParserLanguage language = CoreModel.getDefault().hasCCNature( resource.getProject() ) ? ParserLanguage.CPP : ParserLanguage.C;
dTree.add(document,docPath,newInfo, resource, language);
dTree.add(document,docPath,newInfo, language);
return true; return true;
} }

View file

@ -15,6 +15,7 @@ import java.io.BufferedWriter;
import java.io.File; import java.io.File;
import java.io.FileWriter; import java.io.FileWriter;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.zip.CRC32; import java.util.zip.CRC32;
@ -40,6 +41,7 @@ public class DependencyManager extends JobManager implements ISourceDependency {
public static int MAX_FILES_IN_MEMORY = 0; public static int MAX_FILES_IN_MEMORY = 0;
public SimpleLookupTable projectNames = new SimpleLookupTable(); public SimpleLookupTable projectNames = new SimpleLookupTable();
public SimpleLookupTable dependencyTable;
private Map dependencyTrees = new HashMap(5); private Map dependencyTrees = new HashMap(5);
/* read write monitors */ /* read write monitors */
@ -58,7 +60,9 @@ public class DependencyManager extends JobManager implements ISourceDependency {
public static Integer UPDATING_STATE = new Integer(1); public static Integer UPDATING_STATE = new Integer(1);
public static Integer UNKNOWN_STATE = new Integer(2); public static Integer UNKNOWN_STATE = new Integer(2);
public static Integer REBUILDING_STATE = new Integer(3); public static Integer REBUILDING_STATE = new Integer(3);
public static boolean VERBOSE = false;
public String processName(){ public String processName(){
//TODO: BOG Add name to .properties file //TODO: BOG Add name to .properties file
return "Dependency Tree"; //org.eclipse.cdt.internal.core.search.Util.bind("process.name"); //$NON-NLS-1$ return "Dependency Tree"; //org.eclipse.cdt.internal.core.search.Util.bind("process.name"); //$NON-NLS-1$
@ -77,6 +81,7 @@ public class DependencyManager extends JobManager implements ISourceDependency {
} }
this.projectNames = new SimpleLookupTable(); this.projectNames = new SimpleLookupTable();
this.dependencyTable = new SimpleLookupTable();
this.ccorePluginLocation = null; this.ccorePluginLocation = null;
} }
/* (non-Javadoc) /* (non-Javadoc)
@ -125,7 +130,7 @@ public class DependencyManager extends JobManager implements ISourceDependency {
} catch (IOException e) { } catch (IOException e) {
// failed to read the existing file or its no longer compatible // 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 (currentDTreeState != REBUILDING_STATE) { // rebuild tree if existing file is corrupt, unless the tree is already being rebuilt
if (VERBOSE) if (DependencyManager.VERBOSE)
JobManager.verbose("-> cannot reuse existing tree: "+ treeName +" path: "+path.toOSString()); //$NON-NLS-1$ //$NON-NLS-2$ JobManager.verbose("-> cannot reuse existing tree: "+ treeName +" path: "+path.toOSString()); //$NON-NLS-1$ //$NON-NLS-2$
rebuildDTree(treeName, path); rebuildDTree(treeName, path);
return null; return null;
@ -167,7 +172,7 @@ public class DependencyManager extends JobManager implements ISourceDependency {
checksumCalculator.reset(); checksumCalculator.reset();
checksumCalculator.update(pathString.getBytes()); checksumCalculator.update(pathString.getBytes());
String fileName = Long.toString(checksumCalculator.getValue()) + ".depTree"; //$NON-NLS-1$ String fileName = Long.toString(checksumCalculator.getValue()) + ".depTree"; //$NON-NLS-1$
if (VERBOSE) if (DependencyManager.VERBOSE)
JobManager.verbose("-> dependency tree name for " + pathString + " is " + fileName); //$NON-NLS-1$ //$NON-NLS-2$ JobManager.verbose("-> dependency tree name for " + pathString + " is " + fileName); //$NON-NLS-1$ //$NON-NLS-2$
name = getCCorePluginWorkingLocation().append(fileName).toOSString(); name = getCCorePluginWorkingLocation().append(fileName).toOSString();
projectNames.put(path, name); projectNames.put(path, name);
@ -209,7 +214,7 @@ public class DependencyManager extends JobManager implements ISourceDependency {
try { try {
return org.eclipse.cdt.internal.core.Util.getFileCharContent(savedDTreesFile, null); return org.eclipse.cdt.internal.core.Util.getFileCharContent(savedDTreesFile, null);
} catch (IOException ignored) { } catch (IOException ignored) {
if (VERBOSE) if (DependencyManager.VERBOSE)
JobManager.verbose("Failed to read saved dTree file names"); //$NON-NLS-1$ JobManager.verbose("Failed to read saved dTree file names"); //$NON-NLS-1$
return new char[0]; return new char[0];
} }
@ -219,7 +224,7 @@ public class DependencyManager extends JobManager implements ISourceDependency {
Object target = org.eclipse.cdt.internal.core.Util.getTarget(ResourcesPlugin.getWorkspace().getRoot(), path, true); Object target = org.eclipse.cdt.internal.core.Util.getTarget(ResourcesPlugin.getWorkspace().getRoot(), path, true);
if (target == null) return; if (target == null) return;
if (VERBOSE) if (DependencyManager.VERBOSE)
JobManager.verbose("-> request to rebuild dTree: "+treeName+" path: "+path.toOSString()); //$NON-NLS-1$ //$NON-NLS-2$ JobManager.verbose("-> request to rebuild dTree: "+treeName+" path: "+path.toOSString()); //$NON-NLS-1$ //$NON-NLS-2$
updateTreeState(treeName, REBUILDING_STATE); updateTreeState(treeName, REBUILDING_STATE);
@ -274,7 +279,7 @@ public class DependencyManager extends JobManager implements ISourceDependency {
} }
} }
} catch (IOException ignored) { } catch (IOException ignored) {
if (VERBOSE) if (DependencyManager.VERBOSE)
JobManager.verbose("Failed to write saved dTree file names"); //$NON-NLS-1$ JobManager.verbose("Failed to write saved dTree file names"); //$NON-NLS-1$
} finally { } finally {
if (writer != null) { if (writer != null) {
@ -283,7 +288,7 @@ public class DependencyManager extends JobManager implements ISourceDependency {
} catch (IOException e) {} } catch (IOException e) {}
} }
} }
if (VERBOSE) { if (DependencyManager.VERBOSE) {
String state = "?"; //$NON-NLS-1$ String state = "?"; //$NON-NLS-1$
if (treeState == SAVED_STATE) state = "SAVED"; //$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 == UPDATING_STATE) state = "UPDATING"; //$NON-NLS-1$
@ -307,13 +312,15 @@ public class DependencyManager extends JobManager implements ISourceDependency {
*/ */
public void remove(String resourceName, IPath indexedContainer){ public void remove(String resourceName, IPath indexedContainer){
//request(new RemoveFromIndex(resourceName, indexedContainer, this)); //request(new RemoveFromIndex(resourceName, indexedContainer, this));
if (DependencyManager.VERBOSE)
JobManager.verbose("remove file from tree " + resourceName);
} }
/** /**
* Removes the tree for a given path. * Removes the tree for a given path.
* This is a no-op if the tree did not exist. * This is a no-op if the tree did not exist.
*/ */
public synchronized void removeTree(IPath path) { public synchronized void removeTree(IPath path) {
if (VERBOSE) if (DependencyManager.VERBOSE)
JobManager.verbose("removing dependency tree " + path); //$NON-NLS-1$ JobManager.verbose("removing dependency tree " + path); //$NON-NLS-1$
String treeName = computeTreeName(path); String treeName = computeTreeName(path);
File indexFile = new File(treeName); File indexFile = new File(treeName);
@ -325,6 +332,50 @@ public class DependencyManager extends JobManager implements ISourceDependency {
this.dependencyTrees.remove(path); this.dependencyTrees.remove(path);
updateTreeState(treeName, null); 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 *TODO: Remove these methods once the depTree is
*fully integrated *fully integrated
@ -363,21 +414,7 @@ public class DependencyManager extends JobManager implements ISourceDependency {
} catch (CoreException e) { } catch (CoreException e) {
} }
} }
/**
* @param file
* @param path
* @param info
*/
public void addSource(IFile file, IPath path, IScannerInfo info) {
if (CCorePlugin.getDefault() == null) return;
AddFileToDependencyTree job = new AddFileToDependencyTree(file, path, this, info);
if (this.awaitingJobsCount() < MAX_FILES_IN_MEMORY) {
// reduces the chance that the file is open later on, preventing it from being deleted
if (!job.initializeContents()) return;
}
request(job);
}
/************ /************
* END OF TEMP D-TREE ENABLE SECTION * END OF TEMP D-TREE ENABLE SECTION
*/ */

View file

@ -6,6 +6,7 @@ package org.eclipse.cdt.internal.core.sourcedependency;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.eclipse.cdt.core.search.SearchEngine;
import org.eclipse.cdt.internal.core.search.processing.IJob; import org.eclipse.cdt.internal.core.search.processing.IJob;
import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IProject;
@ -20,6 +21,7 @@ public class DependencyQueryJob implements IJob {
IFile file; IFile file;
ArrayList includeFiles; ArrayList includeFiles;
DependencyManager depManager; DependencyManager depManager;
protected DependencySelector depSelector;
public DependencyQueryJob(IProject project, IFile file, DependencyManager depMan, List includeFiles) { public DependencyQueryJob(IProject project, IFile file, DependencyManager depMan, List includeFiles) {
this.project = project; this.project = project;
@ -46,18 +48,26 @@ public class DependencyQueryJob implements IJob {
*/ */
public boolean execute(IProgressMonitor progress) { public boolean execute(IProgressMonitor progress) {
if ((project == null) ||(file == null)) return false;
String[] tempFiles = this.depManager.getFileDependencies(project,file); String[] tempFiles = this.depManager.getFileDependencies(project,file);
for (int i=0; i<tempFiles.length; i++){ if (tempFiles != null){
includeFiles.add(tempFiles[i]); for (int i=0; i<tempFiles.length; i++){
includeFiles.add(tempFiles[i]);
}
return true;
} }
return true; return false;
} }
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.search.processing.IJob#isReadyToRun() * @see org.eclipse.cdt.internal.core.search.processing.IJob#isReadyToRun()
*/ */
public boolean isReadyToRun() { public boolean isReadyToRun() {
// TODO Auto-generated method stub if (this.depSelector == null) { // only check once. As long as this job is used, it will keep the same index picture
this.depSelector = new DependencySelector(SearchEngine.createWorkspaceScope(), null, false, this.depManager);
this.depSelector.getIndexes(); // will only cache answer if all indexes were available originally
}
return true; return true;
} }

View file

@ -0,0 +1,114 @@
/*
* Created on Aug 26, 2003
*/
package org.eclipse.cdt.internal.core.sourcedependency;
import java.util.ArrayList;
import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.core.model.ICModel;
import org.eclipse.cdt.core.model.ICProject;
import org.eclipse.cdt.core.search.ICSearchScope;
import org.eclipse.core.resources.IWorkspaceRoot;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.IPath;
/**
* @author bgheorgh
*/
public class DependencySelector {
/**
*
*/
public DependencySelector(
ICSearchScope searchScope,
ICElement focus,
boolean isPolymorphicSearch,
DependencyManager depManager) {
this.searchScope = searchScope;
this.focus = focus;
this.depManager = depManager;
this.isPolymorphicSearch = isPolymorphicSearch;
}
ICSearchScope searchScope;
ICElement focus;
DependencyManager depManager;
IPath[] treeKeys; // cache of the keys for looking index up
boolean isPolymorphicSearch;
/**
* Returns whether elements of the given project can see the given focus (an ICProject)
*/
public static boolean canSeeFocus(ICElement focus, boolean isPolymorphicSearch, IPath projectPath) {
//TODO: BOG Temp - Provide Proper Impl
ICModel model = focus.getCModel();
ICProject project = getCProject(projectPath, model);
return true;
}
/*
* Compute the list of paths which are keying index files.
*/
private void initializeIndexKeys() {
ArrayList requiredIndexKeys = new ArrayList();
IPath[] projects = this.searchScope.enclosingProjects();
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
ICElement projectFocus = this.focus == null ? null : getProject(this.focus);
for (int i = 0; i < projects.length; i++) {
IPath location;
IPath path = projects[i];
if ((!root.getProject(path.lastSegment()).exists()) // if project does not exist
&& path.segmentCount() > 1
&& ((location = root.getFile(path).getLocation()) == null
|| !new java.io.File(location.toOSString()).exists()) // and internal jar file does not exist
&& !new java.io.File(path.toOSString()).exists()) { // and external jar file does not exist
continue;
}
if (projectFocus == null || canSeeFocus(projectFocus, this.isPolymorphicSearch, path)) {
if (requiredIndexKeys.indexOf(path) == -1) {
requiredIndexKeys.add(path);
}
}
}
this.treeKeys = new IPath[requiredIndexKeys.size()];
requiredIndexKeys.toArray(this.treeKeys);
}
public IDependencyTree[] getIndexes() {
if (this.treeKeys == null) {
this.initializeIndexKeys();
}
// acquire the in-memory indexes on the fly
int length = this.treeKeys.length;
IDependencyTree[] indexes = new IDependencyTree[length];
int count = 0;
for (int i = 0; i < length; i++){
// may trigger some index recreation work
IDependencyTree index = depManager.getDependencyTree(treeKeys[i], true /*reuse index file*/, false /*do not create if none*/);
if (index != null) indexes[count++] = index; // only consider indexes which are ready yet
}
if (count != length) {
System.arraycopy(indexes, 0, indexes=new IDependencyTree[count], 0, count);
}
return indexes;
}
/**
* Returns the project that corresponds to the given path.
* Returns null if the path doesn't correspond to a project.
*/
private static ICProject getCProject(IPath path, ICModel model) {
ICProject project = model.getCProject(path.lastSegment());
if (project.exists()) {
return project;
} else {
return null;
}
}
public static ICElement getProject(ICElement element) {
while (!(element instanceof ICProject)) {
element = element.getParent();
}
return element;
}
}

View file

@ -27,14 +27,19 @@ import org.eclipse.cdt.internal.core.index.IQueryResult;
import org.eclipse.cdt.internal.core.index.impl.IndexedFile; 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.InMemoryTree;
import org.eclipse.cdt.internal.core.sourcedependency.impl.IncludeEntry; import org.eclipse.cdt.internal.core.sourcedependency.impl.IncludeEntry;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IPath;
public class DependencyTree implements IDependencyTree { public class DependencyTree implements IDependencyTree {
/**
* Maximum size of the index in memory.
*/
public static final int MAX_FOOTPRINT= 1000000;
protected InMemoryTree addsTree; protected InMemoryTree addsTree;
public DependencyTree(String treeName, String string, boolean b) throws IOException{ public DependencyTree(String treeName, String string, boolean b) throws IOException{
super();
initialize(); initialize();
} }
@ -106,17 +111,20 @@ public class DependencyTree implements IDependencyTree {
* @see org.eclipse.cdt.internal.core.sourcedependency.IDependencyTree#remove(java.lang.String) * @see org.eclipse.cdt.internal.core.sourcedependency.IDependencyTree#remove(java.lang.String)
*/ */
public void remove(String documentName) throws IOException { public void remove(String documentName) throws IOException {
// TODO Auto-generated method stub //IndexedFile file= addsTree.getIndexedFile(documentName);
//if (file != null) {
//}
} }
/** /**
* Add the file that will be preprocessed to the tree, create a new * Add the file that will be preprocessed to the tree, create a new
* preprocessor output and preprocess! * preprocessor output and preprocess!
*/ */
public void add(IDocument document, String docPath, IScannerInfo newInfo, ParserLanguage language) throws IOException { public void add(IDocument document, String docPath, IScannerInfo newInfo, IFile file, ParserLanguage language) throws IOException {
IndexedFile indexedFile= addsTree.getIndexedFile(document.getName()); IndexedFile indexedFile= addsTree.getIndexedFile(document.getName());
//if (indexedFile != null) //if (indexedFile != null)
//remove(indexedFile, 0); //remove(indexedFile, 0);
PreprocessorOutput output= new PreprocessorOutput(addsTree); PreprocessorOutput output= new PreprocessorOutput(addsTree, file);
DependencyRequestor depReq = new DependencyRequestor(output,document); DependencyRequestor depReq = new DependencyRequestor(output,document);
output.addDocument(document); output.addDocument(document);
@ -172,4 +180,12 @@ public class DependencyTree implements IDependencyTree {
} }
} }
/**
* 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);
}
} }

View file

@ -13,7 +13,9 @@ package org.eclipse.cdt.internal.core.sourcedependency;
import java.util.HashSet; import java.util.HashSet;
import org.eclipse.cdt.core.build.managed.ManagedBuildManager; import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.parser.IScannerInfo;
import org.eclipse.cdt.core.parser.IScannerInfoProvider;
import org.eclipse.cdt.internal.core.Util; import org.eclipse.cdt.internal.core.Util;
import org.eclipse.cdt.internal.core.index.IQueryResult; import org.eclipse.cdt.internal.core.index.IQueryResult;
import org.eclipse.cdt.internal.core.index.impl.IFileDocument; import org.eclipse.cdt.internal.core.index.impl.IFileDocument;
@ -160,13 +162,19 @@ public class EntireProjectDependencyTree extends DependencyRequest {
shouldSave = true; shouldSave = true;
if (value == DELETED) if (value == DELETED)
this.manager.remove(name, this.dependencyTreePath); this.manager.remove(name, this.dependencyTreePath);
else else{
this.manager.addSource((IFile) value, this.dependencyTreePath, ManagedBuildManager.getScannerInfo(project)); 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) { } catch (/*IO*/Exception e) {
if (JobManager.VERBOSE) { if (DependencyManager.VERBOSE) {
JobManager.verbose("-> failed to generate tree " + this.project + " because of the following exception:"); //$NON-NLS-1$ //$NON-NLS-2$ JobManager.verbose("-> failed to generate tree " + this.project + " because of the following exception:"); //$NON-NLS-1$ //$NON-NLS-2$
e.printStackTrace(); e.printStackTrace();
} }

View file

@ -18,13 +18,15 @@ import org.eclipse.cdt.core.parser.IScannerInfo;
import org.eclipse.cdt.core.parser.ParserLanguage; import org.eclipse.cdt.core.parser.ParserLanguage;
import org.eclipse.cdt.internal.core.index.IDocument; import org.eclipse.cdt.internal.core.index.IDocument;
import org.eclipse.cdt.internal.core.index.IQueryResult; import org.eclipse.cdt.internal.core.index.IQueryResult;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IPath;
public interface IDependencyTree { public interface IDependencyTree {
/** /**
* Adds the given document to the index. * Adds the given document to the index.
*/ */
void add(IDocument document, String docPath, IScannerInfo newInfo, ParserLanguage language) throws IOException; void add(IDocument document, String docPath, IScannerInfo newInfo, IFile file, ParserLanguage language) throws IOException;
/** /**
* Empties the index. * Empties the index.
*/ */

View file

@ -10,24 +10,32 @@
***********************************************************************/ ***********************************************************************/
package org.eclipse.cdt.internal.core.sourcedependency; 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.core.parser.ast.IASTInclusion;
import org.eclipse.cdt.internal.core.index.IDocument; 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.IndexedFile;
import org.eclipse.cdt.internal.core.sourcedependency.impl.InMemoryTree; import org.eclipse.cdt.internal.core.sourcedependency.impl.InMemoryTree;
import org.eclipse.core.resources.IFile;
public class PreprocessorOutput implements IPreprocessorOutput { public class PreprocessorOutput implements IPreprocessorOutput {
protected InMemoryTree tree; protected InMemoryTree tree;
protected IndexedFile indexedFile; protected IndexedFile indexedFile;
protected IDocument document; protected IDocument document;
protected IFile file;
public PreprocessorOutput(InMemoryTree tree) { public PreprocessorOutput(InMemoryTree tree, IFile file) {
this.tree = tree; this.tree = tree;
this.file = file;
} }
public void addInclude(IASTInclusion inclusion, IASTInclusion parent){ public void addInclude(IASTInclusion inclusion, IASTInclusion parent){
addRef(inclusion.getFullFileName()); addRef(inclusion.getFullFileName());
addRelatives(inclusion.getFullFileName(),(parent != null ) ? parent.getFullFileName() : null); 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) { public void addRelatives(String inclusion, String parent) {

View file

@ -0,0 +1,58 @@
/*
* Created on Sep 5, 2003
*
* To change the template for this generated file go to
* Window>Preferences>Java>Code Generation>Code and Comments
*/
package org.eclipse.cdt.internal.core.sourcedependency;
import java.io.IOException;
import org.eclipse.cdt.internal.core.search.indexing.ReadWriteMonitor;
import org.eclipse.cdt.internal.core.search.processing.JobManager;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
/**
* @author bgheorgh
*
* To change the template for this generated type comment go to
* Window>Preferences>Java>Code Generation>Code and Comments
*/
public class RemoveFromDependencyTree extends DependencyRequest {
String resourceName;
public RemoveFromDependencyTree(String resourceName, IPath dependencyTreePath, DependencyManager manager) {
super(dependencyTreePath, manager);
this.resourceName = resourceName;
}
public boolean execute(IProgressMonitor progressMonitor) {
if (progressMonitor != null && progressMonitor.isCanceled()) return true;
/* ensure no concurrent write access to index */
IDependencyTree depTree = manager.getDependencyTree(this.dependencyTreePath, true, /*reuse index file*/ false /*create if none*/);
if (depTree == null) return true;
ReadWriteMonitor monitor = manager.getMonitorFor(depTree);
if (monitor == null) return true; // index got deleted since acquired
try {
monitor.enterWrite(); // ask permission to write
depTree.remove(resourceName);
} catch (IOException e) {
if (DependencyManager.VERBOSE) {
JobManager.verbose("-> failed to remove " + this.resourceName + " from index because of the following exception:"); //$NON-NLS-1$ //$NON-NLS-2$
e.printStackTrace();
}
return false;
} finally {
monitor.exitWrite(); // free write lock
}
return true;
}
public String toString() {
return "removing " + this.resourceName + " from dep Tree " + this.dependencyTreePath; //$NON-NLS-1$ //$NON-NLS-2$
}
}

View file

@ -140,4 +140,11 @@ public class InMemoryTree {
public IndexedFile[] getIndexedFiles(){ public IndexedFile[] getIndexedFiles(){
return this.files.asArray(); return this.files.asArray();
} }
/**
* Returns the footprint of the index.
*/
public long getFootprint() {
return this.footprint;
}
} }

View file

@ -283,7 +283,7 @@ public abstract class AbstractIndexer implements IIndexer, IIndexConstants, ICSe
pos+=tempName.length; pos+=tempName.length;
} }
if (VERBOSE) if (AbstractIndexer.VERBOSE)
AbstractIndexer.verbose(new String(result)); AbstractIndexer.verbose(new String(result));
return result; return result;
@ -315,7 +315,7 @@ public abstract class AbstractIndexer implements IIndexer, IIndexConstants, ICSe
pos+=tempName.length; pos+=tempName.length;
} }
if (VERBOSE) if (AbstractIndexer.VERBOSE)
AbstractIndexer.verbose(new String(result)); AbstractIndexer.verbose(new String(result));
return result; return result;

View file

@ -37,7 +37,7 @@ public abstract class AddFileToIndex extends IndexRequest {
monitor.enterWrite(); // ask permission to write monitor.enterWrite(); // ask permission to write
if (!indexDocument(index)) return false; if (!indexDocument(index)) return false;
} catch (IOException e) { } catch (IOException e) {
if (JobManager.VERBOSE) { if (IndexManager.VERBOSE) {
JobManager.verbose("-> failed to index " + this.resource + " because of the following exception:"); //$NON-NLS-1$ //$NON-NLS-2$ JobManager.verbose("-> failed to index " + this.resource + " because of the following exception:"); //$NON-NLS-1$ //$NON-NLS-2$
e.printStackTrace(); e.printStackTrace();
} }

View file

@ -75,7 +75,7 @@ class AddFolderToIndex extends IndexRequest {
IResource.NONE IResource.NONE
); );
} catch (CoreException e) { } catch (CoreException e) {
if (JobManager.VERBOSE) { if (IndexManager.VERBOSE) {
JobManager.verbose("-> failed to add " + this.folderPath + " to index because of the following exception:"); //$NON-NLS-1$ //$NON-NLS-2$ JobManager.verbose("-> failed to add " + this.folderPath + " to index because of the following exception:"); //$NON-NLS-1$ //$NON-NLS-2$
e.printStackTrace(); e.printStackTrace();
} }

View file

@ -182,14 +182,14 @@ public class IndexAllProject extends IndexRequest {
this.manager.request(new SaveIndex(this.indexPath, this.manager)); this.manager.request(new SaveIndex(this.indexPath, this.manager));
} catch (CoreException e) { } catch (CoreException e) {
if (JobManager.VERBOSE) { if (IndexManager.VERBOSE) {
JobManager.verbose("-> failed to index " + this.project + " because of the following exception:"); //$NON-NLS-1$ //$NON-NLS-2$ JobManager.verbose("-> failed to index " + this.project + " because of the following exception:"); //$NON-NLS-1$ //$NON-NLS-2$
e.printStackTrace(); e.printStackTrace();
} }
this.manager.removeIndex(this.indexPath); this.manager.removeIndex(this.indexPath);
return false; return false;
} catch (IOException e) { } catch (IOException e) {
if (JobManager.VERBOSE) { if (IndexManager.VERBOSE) {
JobManager.verbose("-> failed to index " + this.project + " because of the following exception:"); //$NON-NLS-1$ //$NON-NLS-2$ JobManager.verbose("-> failed to index " + this.project + " because of the following exception:"); //$NON-NLS-1$ //$NON-NLS-2$
e.printStackTrace(); e.printStackTrace();
} }

View file

@ -65,6 +65,8 @@ public class IndexManager extends JobManager implements IIndexConstants {
public static Integer UNKNOWN_STATE = new Integer(2); public static Integer UNKNOWN_STATE = new Integer(2);
public static Integer REBUILDING_STATE = new Integer(3); public static Integer REBUILDING_STATE = new Integer(3);
public static boolean VERBOSE = false;
public synchronized void aboutToUpdateIndex(IPath path, Integer newIndexState) { public synchronized void aboutToUpdateIndex(IPath path, Integer newIndexState) {
// newIndexState is either UPDATING_STATE or REBUILDING_STATE // newIndexState is either UPDATING_STATE or REBUILDING_STATE
// must tag the index as inconsistent, in case we exit before the update job is started // must tag the index as inconsistent, in case we exit before the update job is started
@ -127,7 +129,7 @@ public class IndexManager extends JobManager implements IIndexConstants {
checksumCalculator.reset(); checksumCalculator.reset();
checksumCalculator.update(pathString.getBytes()); checksumCalculator.update(pathString.getBytes());
String fileName = Long.toString(checksumCalculator.getValue()) + ".index"; //$NON-NLS-1$ String fileName = Long.toString(checksumCalculator.getValue()) + ".index"; //$NON-NLS-1$
if (VERBOSE) if (IndexManager.VERBOSE)
JobManager.verbose("-> index name for " + pathString + " is " + fileName); //$NON-NLS-1$ //$NON-NLS-2$ JobManager.verbose("-> index name for " + pathString + " is " + fileName); //$NON-NLS-1$ //$NON-NLS-2$
name = getCCorePluginWorkingLocation().append(fileName).toOSString(); name = getCCorePluginWorkingLocation().append(fileName).toOSString();
indexNames.put(path, name); indexNames.put(path, name);
@ -168,7 +170,7 @@ public class IndexManager extends JobManager implements IIndexConstants {
} catch (IOException e) { } catch (IOException e) {
// failed to read the existing file or its no longer compatible // failed to read the existing file or its no longer compatible
if (currentIndexState != REBUILDING_STATE) { // rebuild index if existing file is corrupt, unless the index is already being rebuilt if (currentIndexState != REBUILDING_STATE) { // rebuild index if existing file is corrupt, unless the index is already being rebuilt
if (VERBOSE) if (IndexManager.VERBOSE)
JobManager.verbose("-> cannot reuse existing index: "+indexName+" path: "+path.toOSString()); //$NON-NLS-1$ //$NON-NLS-2$ JobManager.verbose("-> cannot reuse existing index: "+indexName+" path: "+path.toOSString()); //$NON-NLS-1$ //$NON-NLS-2$
rebuildIndex(indexName, path); rebuildIndex(indexName, path);
return null; return null;
@ -311,7 +313,7 @@ public class IndexManager extends JobManager implements IIndexConstants {
Object target = org.eclipse.cdt.internal.core.Util.getTarget(ResourcesPlugin.getWorkspace().getRoot(), path, true); Object target = org.eclipse.cdt.internal.core.Util.getTarget(ResourcesPlugin.getWorkspace().getRoot(), path, true);
if (target == null) return; if (target == null) return;
if (VERBOSE) if (IndexManager.VERBOSE)
JobManager.verbose("-> request to rebuild index: "+indexName+" path: "+path.toOSString()); //$NON-NLS-1$ //$NON-NLS-2$ JobManager.verbose("-> request to rebuild index: "+indexName+" path: "+path.toOSString()); //$NON-NLS-1$ //$NON-NLS-2$
updateIndexState(indexName, REBUILDING_STATE); updateIndexState(indexName, REBUILDING_STATE);
@ -344,7 +346,7 @@ public class IndexManager extends JobManager implements IIndexConstants {
// Path is already canonical // Path is already canonical
String indexPath = computeIndexName(path); String indexPath = computeIndexName(path);
if (VERBOSE) if (IndexManager.VERBOSE)
JobManager.verbose("-> recreating index: "+indexPath+" for path: "+path.toOSString()); //$NON-NLS-1$ //$NON-NLS-2$ JobManager.verbose("-> recreating index: "+indexPath+" for path: "+path.toOSString()); //$NON-NLS-1$ //$NON-NLS-2$
index = new Index(indexPath, "Index for " + path.toOSString(), false /*reuse index file*/); //$NON-NLS-1$ index = new Index(indexPath, "Index for " + path.toOSString(), false /*reuse index file*/); //$NON-NLS-1$
indexes.put(path, index); indexes.put(path, index);
@ -352,7 +354,7 @@ public class IndexManager extends JobManager implements IIndexConstants {
return index; return index;
} catch (IOException e) { } catch (IOException e) {
// The file could not be created. Possible reason: the project has been deleted. // The file could not be created. Possible reason: the project has been deleted.
if (VERBOSE) { if (IndexManager.VERBOSE) {
JobManager.verbose("-> failed to recreate index for path: "+path.toOSString()); //$NON-NLS-1$ //$NON-NLS-2$ JobManager.verbose("-> failed to recreate index for path: "+path.toOSString()); //$NON-NLS-1$ //$NON-NLS-2$
e.printStackTrace(); e.printStackTrace();
} }
@ -371,7 +373,7 @@ public class IndexManager extends JobManager implements IIndexConstants {
* This is a no-op if the index did not exist. * This is a no-op if the index did not exist.
*/ */
public synchronized void removeIndex(IPath path) { public synchronized void removeIndex(IPath path) {
if (VERBOSE) if (IndexManager.VERBOSE)
JobManager.verbose("removing index " + path); //$NON-NLS-1$ JobManager.verbose("removing index " + path); //$NON-NLS-1$
String indexName = computeIndexName(path); String indexName = computeIndexName(path);
File indexFile = new File(indexName); File indexFile = new File(indexName);
@ -439,7 +441,7 @@ public class IndexManager extends JobManager implements IIndexConstants {
public void saveIndex(IIndex index) throws IOException { public void saveIndex(IIndex index) throws IOException {
// must have permission to write from the write monitor // must have permission to write from the write monitor
if (index.hasChanged()) { if (index.hasChanged()) {
if (VERBOSE) if (IndexManager.VERBOSE)
JobManager.verbose("-> saving index " + index.getIndexFile()); //$NON-NLS-1$ JobManager.verbose("-> saving index " + index.getIndexFile()); //$NON-NLS-1$
index.save(); index.save();
} }
@ -479,7 +481,7 @@ public class IndexManager extends JobManager implements IIndexConstants {
try { try {
saveIndex(index); saveIndex(index);
} catch(IOException e){ } catch(IOException e){
if (VERBOSE) { if (IndexManager.VERBOSE) {
JobManager.verbose("-> got the following exception while saving:"); //$NON-NLS-1$ JobManager.verbose("-> got the following exception while saving:"); //$NON-NLS-1$
e.printStackTrace(); e.printStackTrace();
} }
@ -493,7 +495,7 @@ public class IndexManager extends JobManager implements IIndexConstants {
} }
public void shutdown() { public void shutdown() {
if (VERBOSE) if (IndexManager.VERBOSE)
JobManager.verbose("Shutdown"); //$NON-NLS-1$ JobManager.verbose("Shutdown"); //$NON-NLS-1$
//Get index entries for all projects in the workspace, store their absolute paths //Get index entries for all projects in the workspace, store their absolute paths
IndexSelector indexSelector = new IndexSelector(new CWorkspaceScope(), null, false, this); IndexSelector indexSelector = new IndexSelector(new CWorkspaceScope(), null, false, this);
@ -523,7 +525,7 @@ public class IndexManager extends JobManager implements IIndexConstants {
for (int i = 0, indexesFilesLength = indexesFiles.length; i < indexesFilesLength; i++) { for (int i = 0, indexesFilesLength = indexesFiles.length; i < indexesFilesLength; i++) {
String fileName = indexesFiles[i].getAbsolutePath(); String fileName = indexesFiles[i].getAbsolutePath();
if (!knownPaths.containsKey(fileName) && fileName.toLowerCase().endsWith(".index")) { //$NON-NLS-1$ if (!knownPaths.containsKey(fileName) && fileName.toLowerCase().endsWith(".index")) { //$NON-NLS-1$
if (VERBOSE) if (IndexManager.VERBOSE)
JobManager.verbose("Deleting index file " + indexesFiles[i]); //$NON-NLS-1$ JobManager.verbose("Deleting index file " + indexesFiles[i]); //$NON-NLS-1$
indexesFiles[i].delete(); indexesFiles[i].delete();
} }
@ -549,7 +551,7 @@ public class IndexManager extends JobManager implements IIndexConstants {
try { try {
return org.eclipse.cdt.internal.core.Util.getFileCharContent(savedIndexNamesFile, null); return org.eclipse.cdt.internal.core.Util.getFileCharContent(savedIndexNamesFile, null);
} catch (IOException ignored) { } catch (IOException ignored) {
if (VERBOSE) if (IndexManager.VERBOSE)
JobManager.verbose("Failed to read saved index file names"); //$NON-NLS-1$ JobManager.verbose("Failed to read saved index file names"); //$NON-NLS-1$
return new char[0]; return new char[0];
} }
@ -577,7 +579,7 @@ public class IndexManager extends JobManager implements IIndexConstants {
} }
} }
} catch (IOException ignored) { } catch (IOException ignored) {
if (VERBOSE) if (IndexManager.VERBOSE)
JobManager.verbose("Failed to write saved index file names"); //$NON-NLS-1$ JobManager.verbose("Failed to write saved index file names"); //$NON-NLS-1$
} finally { } finally {
if (writer != null) { if (writer != null) {
@ -586,7 +588,7 @@ public class IndexManager extends JobManager implements IIndexConstants {
} catch (IOException e) {} } catch (IOException e) {}
} }
} }
if (VERBOSE) { if (IndexManager.VERBOSE) {
String state = "?"; //$NON-NLS-1$ String state = "?"; //$NON-NLS-1$
if (indexState == SAVED_STATE) state = "SAVED"; //$NON-NLS-1$ if (indexState == SAVED_STATE) state = "SAVED"; //$NON-NLS-1$
else if (indexState == UPDATING_STATE) state = "UPDATING"; //$NON-NLS-1$ else if (indexState == UPDATING_STATE) state = "UPDATING"; //$NON-NLS-1$

View file

@ -54,7 +54,7 @@ class RemoveFolderFromIndex extends IndexRequest {
} }
} }
} catch (IOException e) { } catch (IOException e) {
if (JobManager.VERBOSE) { if (IndexManager.VERBOSE) {
JobManager.verbose("-> failed to remove " + this.folderPath + " from index because of the following exception:"); //$NON-NLS-1$ //$NON-NLS-2$ JobManager.verbose("-> failed to remove " + this.folderPath + " from index because of the following exception:"); //$NON-NLS-1$ //$NON-NLS-2$
e.printStackTrace(); e.printStackTrace();
} }

View file

@ -40,7 +40,7 @@ class RemoveFromIndex extends IndexRequest {
monitor.enterWrite(); // ask permission to write monitor.enterWrite(); // ask permission to write
index.remove(resourceName); index.remove(resourceName);
} catch (IOException e) { } catch (IOException e) {
if (JobManager.VERBOSE) { if (IndexManager.VERBOSE) {
JobManager.verbose("-> failed to remove " + this.resourceName + " from index because of the following exception:"); //$NON-NLS-1$ //$NON-NLS-2$ JobManager.verbose("-> failed to remove " + this.resourceName + " from index because of the following exception:"); //$NON-NLS-1$ //$NON-NLS-2$
e.printStackTrace(); e.printStackTrace();
} }

View file

@ -39,7 +39,7 @@ public class SaveIndex extends IndexRequest {
monitor.enterWrite(); // ask permission to write monitor.enterWrite(); // ask permission to write
this.manager.saveIndex(index); this.manager.saveIndex(index);
} catch (IOException e) { } catch (IOException e) {
if (JobManager.VERBOSE) { if (IndexManager.VERBOSE) {
JobManager.verbose("-> failed to save index " + this.indexPath + " because of the following exception:"); //$NON-NLS-1$ //$NON-NLS-2$ JobManager.verbose("-> failed to save index " + this.indexPath + " because of the following exception:"); //$NON-NLS-1$ //$NON-NLS-2$
e.printStackTrace(); e.printStackTrace();
} }

View file

@ -88,7 +88,10 @@ public class SourceIndexer extends AbstractIndexer {
try{ try{
boolean retVal = parser.parse(); boolean retVal = parser.parse();
if (VERBOSE){ if (!retVal)
org.eclipse.cdt.internal.core.model.Util.log(null, "Failed to index " + resourceFile.getFullPath());
if (AbstractIndexer.VERBOSE){
if (!retVal) if (!retVal)
AbstractIndexer.verbose("PARSE FAILED " + resourceFile.getName().toString()); AbstractIndexer.verbose("PARSE FAILED " + resourceFile.getName().toString());
else else

View file

@ -5,6 +5,10 @@ package org.eclipse.cdt.internal.core.model;
* All Rights Reserved. * 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.CModelException;
import org.eclipse.cdt.core.model.CoreModel; import org.eclipse.cdt.core.model.CoreModel;
import org.eclipse.cdt.core.model.IArchiveContainer; import org.eclipse.cdt.core.model.IArchiveContainer;
@ -14,15 +18,19 @@ import org.eclipse.cdt.core.model.ICElementDelta;
import org.eclipse.cdt.core.model.ICModel; import org.eclipse.cdt.core.model.ICModel;
import org.eclipse.cdt.core.model.ICProject; import org.eclipse.cdt.core.model.ICProject;
import org.eclipse.cdt.core.model.IParent; import org.eclipse.cdt.core.model.IParent;
import org.eclipse.cdt.core.parser.IScannerInfo;
import org.eclipse.cdt.core.parser.IScannerInfoProvider;
import org.eclipse.cdt.core.search.ICSearchConstants;
import org.eclipse.cdt.internal.core.search.indexing.IndexManager;
import org.eclipse.cdt.internal.core.sourcedependency.DependencyManager;
import org.eclipse.cdt.internal.core.sourcedependency.DependencyQueryJob;
import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IResourceDelta; import org.eclipse.core.resources.IResourceDelta;
import org.eclipse.core.resources.IWorkspaceRoot;
import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IPath;
import org.eclipse.cdt.internal.core.search.indexing.IndexManager;
import org.eclipse.cdt.internal.core.sourcedependency.DependencyManager;
/** /**
* This class is used by <code>CModelManager</code> to convert * This class is used by <code>CModelManager</code> to convert
* <code>IResourceDelta</code>s into <code>ICElementDelta</code>s. * <code>IResourceDelta</code>s into <code>ICElementDelta</code>s.
@ -424,6 +432,9 @@ public class DeltaProcessor {
if (element != null) { if (element != null) {
elementChanged(element, delta); elementChanged(element, delta);
updateIndexAddResource(element, delta); updateIndexAddResource(element, delta);
//check to see if any projects need to be reindexed
updateDependencies(element);
} }
} else if (resource.getType() == IResource.PROJECT) { } else if (resource.getType() == IResource.PROJECT) {
if ((flags & IResourceDelta.OPEN) != 0) { if ((flags & IResourceDelta.OPEN) != 0) {
@ -462,11 +473,21 @@ public class DeltaProcessor {
switch (element.getElementType()) { switch (element.getElementType()) {
case ICElement.C_PROJECT : case ICElement.C_PROJECT :
this.indexManager.indexAll(element.getCProject().getProject()); this.indexManager.indexAll(element.getCProject().getProject());
this.sourceDependencyManager.generateEntireDependencyTree(element.getCProject().getProject());
break; break;
case ICElement.C_UNIT: case ICElement.C_UNIT:
IFile file = (IFile) delta.getResource(); IFile file = (IFile) delta.getResource();
indexManager.addSource(file, file.getProject().getProject().getFullPath()); IProject filesProject = file.getProject();
indexManager.addSource(file, filesProject.getFullPath());
cleanDependencies(file, filesProject);
IScannerInfo scanInfo = null;
IScannerInfoProvider provider = CCorePlugin.getDefault().getScannerInfoProvider(filesProject);
if (provider != null){
scanInfo = provider.getScannerInformation(filesProject);
}
this.sourceDependencyManager.addSource(file,filesProject.getFullPath(),scanInfo);
break; break;
} }
@ -482,6 +503,7 @@ public class DeltaProcessor {
case ICElement.C_PROJECT : case ICElement.C_PROJECT :
this.indexManager.removeIndexFamily(element.getCProject().getProject().getFullPath()); this.indexManager.removeIndexFamily(element.getCProject().getProject().getFullPath());
// NB: Discarding index jobs belonging to this project was done during PRE_DELETE // NB: Discarding index jobs belonging to this project was done during PRE_DELETE
this.sourceDependencyManager.removeTree(element.getCProject().getProject().getFullPath());
break; break;
// NB: Update of index if project is opened, closed, or its c nature is added or removed // NB: Update of index if project is opened, closed, or its c nature is added or removed
// is done in updateCurrentDeltaAndIndex // is done in updateCurrentDeltaAndIndex
@ -489,9 +511,53 @@ public class DeltaProcessor {
case ICElement.C_UNIT: case ICElement.C_UNIT:
IFile file = (IFile) delta.getResource(); IFile file = (IFile) delta.getResource();
indexManager.remove(file.getFullPath().toString(), file.getProject().getProject().getFullPath()); indexManager.remove(file.getFullPath().toString(), file.getProject().getProject().getFullPath());
sourceDependencyManager.remove(file.getFullPath().toString(),file.getProject().getFullPath());
break; break;
} }
} }
private void updateDependencies(ICElement element){
//Update table
String fileExtension = element.getResource().getFileExtension();
if (fileExtension.equals("h") ||
fileExtension.equals("hh") ||
fileExtension.equals("hpp")){
if (sourceDependencyManager.getProjectDependsForFile(element.getResource().getLocation().toOSString()) == null){
//retrigger dep trees
sourceDependencyManager.performConcurrentJob(new DependencyQueryJob(null,null,sourceDependencyManager,null),ICSearchConstants.WAIT_UNTIL_READY_TO_SEARCH,null);
}
ArrayList projs =sourceDependencyManager.getProjectDependsForFile(element.getResource().getLocation().toOSString());
if (projs != null){
Iterator iter = projs.iterator();
while (iter.hasNext()){
IPath pathToReindex = (IPath) iter.next();
IWorkspaceRoot workRoot = element.getCProject().getProject().getWorkspace().getRoot();
IFile fileToReindex = workRoot.getFileForLocation(pathToReindex);
if (fileToReindex.exists() ) {
if (VERBOSE)
System.out.println("Going to reindex " + fileToReindex.getName());
this.indexManager.addSource(fileToReindex,fileToReindex.getProject().getProject().getFullPath());
}
}
}
}
}
private void cleanDependencies(IFile file, IProject filesProject) {
String[] files = sourceDependencyManager.getFileDependencies(filesProject,file);
if (files != null){
for (int i=0; i<files.length; i++){
if (VERBOSE)
System.out.println("Table Clean Up : " + files[i]+ " removing " + file.getName());
sourceDependencyManager.removeFromTable(files[i],file.getLocation());
}
}
}
} }

View file

@ -1,3 +1,7 @@
2003-09-08 Bogdan Gheorghe
Added ScannerExceptions in Preprocessor.java to PDE Error
Log
2003-09-08 John Camelon 2003-09-08 John Camelon
Made scoping support more robust in CompleteParse mode. Made scoping support more robust in CompleteParse mode.
Refactored ISourceElementRequestor (enter|exit)CodeBlock() to take IASTCodeScope rather than IASTScope. Refactored ISourceElementRequestor (enter|exit)CodeBlock() to take IASTCodeScope rather than IASTScope.
@ -13,6 +17,7 @@
- Added references to variables with pointers in solution - Added references to variables with pointers in solution
of bug#42453:Expression result types not computed of bug#42453:Expression result types not computed
2003-09-05 John Camelon 2003-09-05 John Camelon
Continue to add support for parsing within function bodies. Continue to add support for parsing within function bodies.
Add workaround for 1.2 for inline function declaration-before-use chicken-and-egg. Add workaround for 1.2 for inline function declaration-before-use chicken-and-egg.

View file

@ -48,6 +48,8 @@ public class Preprocessor extends Scanner implements IPreprocessor {
catch( ScannerException se ) catch( ScannerException se )
{ {
// callback IProblem here // callback IProblem here
org.eclipse.cdt.internal.core.model.Util.log(se, "Preprocessor Exception"); //$NON-NLS-1$h
} }
catch( EndOfFile eof ) catch( EndOfFile eof )
{ {

View file

@ -31,6 +31,7 @@ import org.eclipse.cdt.internal.core.model.Util;
import org.eclipse.cdt.internal.core.search.indexing.IndexManager; import org.eclipse.cdt.internal.core.search.indexing.IndexManager;
import org.eclipse.cdt.internal.core.search.indexing.SourceIndexer; import org.eclipse.cdt.internal.core.search.indexing.SourceIndexer;
import org.eclipse.cdt.internal.core.search.matching.MatchLocator; 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.cdt.internal.core.sourcedependency.DependencyManager;
import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IProjectDescription; import org.eclipse.core.resources.IProjectDescription;
@ -845,6 +846,7 @@ public class CCorePlugin extends Plugin {
* Configure the plugin with respect to option settings defined in ".options" file * Configure the plugin with respect to option settings defined in ".options" file
*/ */
public void configurePluginDebugOptions(){ public void configurePluginDebugOptions(){
if(CCorePlugin.getDefault().isDebugging()){ if(CCorePlugin.getDefault().isDebugging()){
String option = Platform.getDebugOption(PARSER); String option = Platform.getDebugOption(PARSER);
if(option != null) Util.VERBOSE_PARSER = option.equalsIgnoreCase("true") ; //$NON-NLS-1$ if(option != null) Util.VERBOSE_PARSER = option.equalsIgnoreCase("true") ; //$NON-NLS-1$
@ -852,11 +854,19 @@ public class CCorePlugin extends Plugin {
option = Platform.getDebugOption(MODEL); option = Platform.getDebugOption(MODEL);
if(option != null) Util.VERBOSE_MODEL = option.equalsIgnoreCase("true") ; //$NON-NLS-1$ if(option != null) Util.VERBOSE_MODEL = option.equalsIgnoreCase("true") ; //$NON-NLS-1$
boolean depFlag = false;
option = Platform.getDebugOption(DEPENDENCY); option = Platform.getDebugOption(DEPENDENCY);
if(option != null) DependencyManager.VERBOSE = option.equalsIgnoreCase("true") ; //$NON-NLS-1$ if(option != null){
depFlag = option.equalsIgnoreCase("true");
DependencyManager.VERBOSE = depFlag;
}//$NON-NLS-1$
boolean indexFlag = false;
option = Platform.getDebugOption(INDEX_MANAGER); option = Platform.getDebugOption(INDEX_MANAGER);
if(option != null) IndexManager.VERBOSE = option.equalsIgnoreCase("true") ; //$NON-NLS-1$ if(option != null) {
indexFlag = option.equalsIgnoreCase("true");
IndexManager.VERBOSE = indexFlag;
} //$NON-NLS-1$
option = Platform.getDebugOption(INDEXER); option = Platform.getDebugOption(INDEXER);
if(option != null) SourceIndexer.VERBOSE = option.equalsIgnoreCase("true") ; //$NON-NLS-1$ if(option != null) SourceIndexer.VERBOSE = option.equalsIgnoreCase("true") ; //$NON-NLS-1$
@ -867,6 +877,10 @@ public class CCorePlugin extends Plugin {
option = Platform.getDebugOption(MATCH_LOCATOR); option = Platform.getDebugOption(MATCH_LOCATOR);
if(option != null) MatchLocator.VERBOSE = option.equalsIgnoreCase("true") ; //$NON-NLS-1$ if(option != null) MatchLocator.VERBOSE = option.equalsIgnoreCase("true") ; //$NON-NLS-1$
if (indexFlag == true ||
depFlag == true){
JobManager.VERBOSE = true;
}
} }
} }
} }

View file

@ -1,3 +1,6 @@
2003-09-08 Bogdan Gheorghe
- Changed search pop up menu in CEditor and CContentOutlinePage
2003-09-08 John Camelon 2003-09-08 John Camelon
Refactored ISourceElementRequestor (enter|exit)CodeBlock() to take IASTCodeScope rather than IASTScope. Refactored ISourceElementRequestor (enter|exit)CodeBlock() to take IASTCodeScope rather than IASTScope.
Added enumerator references to ISourceElementRequestor. Added enumerator references to ISourceElementRequestor.

View file

@ -294,14 +294,14 @@ OpenIncludeAction.dialog.title=Open Include
OpenIncludeAction.dialog.message=Select the file to open OpenIncludeAction.dialog.message=Select the file to open
# ------- SearchForReferencesAction --------------- # ------- SearchForReferencesAction ---------------
SearchForReferencesAction.label=Reference&s SearchForReferencesAction.label=File Search
SearchForReferencesAction.tooltip=Search for References to Name in Workspace SearchForReferencesAction.tooltip=Performs a text based file search for element in workspace
SearchForReferencesAction.description=Searches for references to name in workspace SearchForReferencesAction.description=Performs a text based file search for element in workspace
# ------- SearchDialogAction --------------- # ------- SearchDialogAction ---------------
SearchDialogAction.label=C++ Search Dialog SearchDialogAction.label=C/C++ Search Dialog
SearchDialogAction.tooltip=Opens Search Dialog SearchDialogAction.tooltip=Opens C/C++ Search Dialog
SearchDialogAction.description=Opens Search Dialog SearchDialogAction.description=Opens C/C++ Search Dialog
# ------- LexicalSortingAction------------ # ------- LexicalSortingAction------------

View file

@ -46,7 +46,7 @@ public class SearchForReferencesAction extends Action {
if(provider instanceof CContentOutlinePage) { if(provider instanceof CContentOutlinePage) {
CPluginImages.setImageDescriptors(this, CPluginImages.T_LCL, CPluginImages.IMG_MENU_OPEN_INCLUDE); CPluginImages.setImageDescriptors(this, CPluginImages.T_LCL, CPluginImages.IMG_MENU_OPEN_INCLUDE);
setText("Search for References"); // $NON-NLS //setText("Search for References"); // $NON-NLS
} }
fSelectionProvider= provider; fSelectionProvider= provider;