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.TranslationUnit;
import org.eclipse.cdt.testplugin.CProjectHelper;
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;
@ -90,9 +91,13 @@ public class CModelElementsFailedTests extends TestCase {
proj.setDescription(description, monitor);
}
protected void tearDown() throws Exception {
protected void tearDown() {
try{
CProjectHelper.delete(fCProject);
}
catch (ResourceException e) {}
catch (CoreException e) {}
}
public void testBug36379() {
TranslationUnit tu = new TranslationUnit(fCProject, headerFile);

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.sourcedependency.DependencyManager;
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.IProject;
import org.eclipse.core.resources.IProjectDescription;
@ -56,6 +57,7 @@ public class IndexManagerTests extends TestCase {
IProject testProject;
NullProgressMonitor monitor;
IndexManager indexManager;
public static final int TIMEOUT = 10000;
/**
* Constructor for IndexManagerTest.
@ -76,15 +78,24 @@ public class IndexManagerTests extends TestCase {
testProject = createProject("IndexerTestProject");
if (testProject==null)
fail("Unable to create project");
}
/*
* @see TestCase#tearDown()
*/
protected void tearDown() throws Exception {
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) {
}
}
}
@ -109,6 +120,8 @@ public class IndexManagerTests extends TestCase {
{
IWorkspaceRoot root= ResourcesPlugin.getWorkspace().getRoot();
IProject project= root.getProject(projectName);
IProject cproject = null;
try{
if (!project.exists()) {
project.create(null);
} else {
@ -127,14 +140,20 @@ public class IndexManagerTests extends TestCase {
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);
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);
}
finally{
return cproject;
}
}
private IFile importFile(String fileName, String resourceLocation)throws Exception{
//Obtain file handle
@ -236,12 +255,26 @@ public class IndexManagerTests extends TestCase {
IIndex ind = indexManager.getIndex(testProjectPath,true,true);
assertTrue("Index exists for project",ind != null);
//Delete the project
testProject.delete(true,monitor);
safeDelete(testProject);
//See if the index is still there
ind = indexManager.getIndex(testProjectPath,true,true);
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{
//Add a file to the project
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.ui.text.CCompletionProcessor;
import org.eclipse.cdt.testplugin.CProjectHelper;
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;
@ -95,9 +96,13 @@ public class CompletionProposalsTest extends TestCase{
proj.setDescription(description, monitor);
}
protected void tearDown() throws Exception {
protected void tearDown() {
try{
CProjectHelper.delete(fCProject);
}
catch (ResourceException e) {}
catch (CoreException e) {}
}
public void testCompletionProposals(){
try{

View file

@ -18,6 +18,7 @@ import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.core.model.ICProject;
import org.eclipse.cdt.testplugin.CProjectHelper;
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.IWorkspace;
import org.eclipse.core.resources.IWorkspaceRoot;
@ -127,9 +128,13 @@ public class ArchiveTests extends TestCase {
*
* Called after every test case method.
*/
protected void tearDown() throws CoreException {
protected void tearDown() {
try{
CProjectHelper.delete(testProject);
}
catch (ResourceException e) {}
catch (CoreException e) {}
}
public static TestSuite suite() {
return new TestSuite(ArchiveTests.class);

View file

@ -17,6 +17,7 @@ import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.core.model.ICProject;
import org.eclipse.cdt.testplugin.CProjectHelper;
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.IWorkspace;
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
*/
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 {
/* Let everything settle down before we try to delete the project.
*/
Thread.sleep(500);
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.TranslationUnit;
import org.eclipse.cdt.testplugin.CProjectHelper;
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;
@ -98,9 +99,13 @@ public class CModelElementsTests extends TestCase {
proj.setDescription(description, monitor);
}
protected void tearDown() throws Exception {
protected void tearDown() {
try{
CProjectHelper.delete(fCProject);
}
catch (ResourceException e) {}
catch (CoreException e) {}
}
public void testCModelElements(){
TranslationUnit tu = new TranslationUnit(fCProject, headerFile);

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.ICProject;
import org.eclipse.cdt.testplugin.CProjectHelper;
import org.eclipse.core.internal.resources.ResourceException;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IWorkspace;
@ -216,8 +217,13 @@ public class CModelTests extends TestCase {
assertTrue("isTranslationUnit", !CoreModel.getDefault().isTranslationUnit(file));
try{
testProject.getProject().delete(true,true,monitor);
}
catch (ResourceException e) {}
catch (CoreException e) {}
}
/****
* Some simple tests for isValidTranslationUnitName

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.testplugin.CProjectHelper;
import org.eclipse.cdt.testplugin.TestPluginLauncher;
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;
@ -104,9 +105,13 @@ public class ElementDeltaTests extends TestCase implements IElementChangedListen
proj.setDescription(description, monitor);
}
protected void tearDown() throws Exception {
protected void tearDown() {
try{
CProjectHelper.delete(fCProject);
}
catch (ResourceException e) {}
catch (CoreException e) {}
}
public void testElementDeltas() throws Exception {

View file

@ -12,6 +12,7 @@ import java.util.Map;
import org.eclipse.cdt.testplugin.CProjectHelper;
import org.eclipse.cdt.core.model.ICProject;
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.IProject;
import org.eclipse.core.resources.IProjectDescription;
@ -81,9 +82,14 @@ public abstract class IntegratedCModelTest extends TestCase {
CCorePlugin.getDefault().setUseNewParser(true);
}
protected void tearDown() throws Exception {
protected void tearDown() {
try{
CProjectHelper.delete(fCProject);
}
catch (ResourceException e) {}
catch (CoreException e) {}
}
private static void addNatureToProject(IProject proj, String natureId, IProgressMonitor monitor) throws CoreException {
IProjectDescription description = proj.getDescription();

View file

@ -17,6 +17,7 @@ import junit.framework.TestCase;
import org.eclipse.cdt.core.model.ICProject;
import org.eclipse.cdt.testplugin.CProjectHelper;
import org.eclipse.core.internal.resources.ResourceException;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.resources.IWorkspaceDescription;
@ -142,9 +143,13 @@ public class TranslationUnitBaseTest extends TestCase
*
* Called after every test case method.
*/
protected void tearDown() throws CoreException
protected void tearDown()
{
// release resources here and clean-up
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.testplugin.CProjectHelper;
import org.eclipse.cdt.testplugin.TestPluginLauncher;
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;
@ -89,9 +90,13 @@ public class WorkingCopyTests extends TestCase {
proj.setDescription(description, monitor);
}
protected void tearDown() throws Exception {
protected void tearDown() {
try{
CProjectHelper.delete(fCProject);
}
catch (ResourceException e) {}
catch (CoreException e) {}
}
public void testWorkingCopy() throws Exception {

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.ICSearchScope;
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.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.IProject;
import org.eclipse.core.resources.IProjectDescription;
@ -51,12 +52,12 @@ public class BaseSearchTest extends TestCase implements ICSearchConstants {
ICSearchScope scope;
IFile file;
IFileDocument fileDoc;
IProject testProject;
NullProgressMonitor monitor;
IWorkspace workspace;
CSearchResultCollector resultCollector;
SearchEngine searchEngine;
FileManager fileManager;
public BaseSearchTest(String name) {
super(name);
@ -75,6 +76,9 @@ public class BaseSearchTest extends TestCase implements ICSearchConstants {
if (testProject == null)
fail("Unable to create project");
//Create file manager
fileManager = new FileManager();
//Add a file to the project
importFile("mail.cpp", "resources/indexer/mail.cpp");
importFile("classDecl.cpp", "resources/search/classDecl.cpp");
@ -91,17 +95,27 @@ public class BaseSearchTest extends TestCase implements ICSearchConstants {
searchEngine = new SearchEngine();
}
protected void tearDown() throws Exception {
protected void tearDown() {
try {
super.tearDown();
} catch (Exception e1) {
}
//Delete project
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();
IProject project = root.getProject(projectName);
IProject cproject = null;
try{
if( !project.exists() ) {
project.create( null );
@ -125,7 +139,7 @@ public class BaseSearchTest extends TestCase implements ICSearchConstants {
description.setLocation(newPath);
//Create the project
IProject cproject = CCorePlugin.getDefault().createCProject( description,
cproject = CCorePlugin.getDefault().createCProject( description,
project,
monitor,
CCorePlugin.PLUGIN_ID + ".make");
@ -133,10 +147,17 @@ public class BaseSearchTest extends TestCase implements ICSearchConstants {
if( !project.hasNature(CCProjectNature.CC_NATURE_ID) ){
addNatureToProject(project, CCProjectNature.CC_NATURE_ID, null);
}
}
catch (CoreException e){
cproject = project;
cproject.open(null);
}
finally{
return cproject;
}
}
private void importFile(String fileName, String resourceLocation)throws Exception{
//Obtain file handle
file = testProject.getProject().getFile(fileName);
@ -145,8 +166,9 @@ public class BaseSearchTest extends TestCase implements ICSearchConstants {
if (!file.exists()){
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 {
@ -165,4 +187,5 @@ public class BaseSearchTest extends TestCase implements ICSearchConstants {
resultCollector.setProgressMonitor( monitor );
searchEngine.search( workspace, pattern, scope, collector );
}
}

View file

@ -63,7 +63,22 @@ public class CProjectHelper {
* Removes a ICProject.
*/
public static void delete(ICProject cproject) throws CoreException {
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
The PTY classes are using one instance of the master fd for Input/Output/Error
@ -37,7 +45,6 @@
* src/org/eclipse/cdt/core/ErrorParserManager.java
2003-09-01 Alain Magloire
Typo in the class signature.

View file

@ -26,7 +26,7 @@ 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"}; //$NON-NLS-1$
public static final String[] FILE_TYPES= new String[] {"cpp","c", "cc", "cxx"}; //$NON-NLS-1$
IFile resource;
char[] contents;
@ -57,7 +57,7 @@ public class AddFileToDependencyTree extends DependencyRequest {
monitor.enterWrite(); // ask permission to write
if (!addDocumentToTree(tree)) return false;
} catch (IOException e) {
if (JobManager.VERBOSE) {
if (DependencyManager.VERBOSE) {
JobManager.verbose("-> failed to calculate dependency for " + this.resource + " because of the following exception:"); //$NON-NLS-1$ //$NON-NLS-2$
e.printStackTrace();
}
@ -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);
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;
}

View file

@ -15,6 +15,7 @@ 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;
@ -40,6 +41,7 @@ public class DependencyManager extends JobManager implements ISourceDependency {
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 */
@ -59,6 +61,8 @@ public class DependencyManager extends JobManager implements ISourceDependency {
public static Integer UNKNOWN_STATE = new Integer(2);
public static Integer REBUILDING_STATE = new Integer(3);
public static boolean VERBOSE = false;
public String processName(){
//TODO: BOG Add name to .properties file
return "Dependency Tree"; //org.eclipse.cdt.internal.core.search.Util.bind("process.name"); //$NON-NLS-1$
@ -77,6 +81,7 @@ public class DependencyManager extends JobManager implements ISourceDependency {
}
this.projectNames = new SimpleLookupTable();
this.dependencyTable = new SimpleLookupTable();
this.ccorePluginLocation = null;
}
/* (non-Javadoc)
@ -125,7 +130,7 @@ public class DependencyManager extends JobManager implements ISourceDependency {
} catch (IOException e) {
// failed to read the existing file or its no longer compatible
if (currentDTreeState != REBUILDING_STATE) { // rebuild tree if existing file is corrupt, unless the tree is already being rebuilt
if (VERBOSE)
if (DependencyManager.VERBOSE)
JobManager.verbose("-> cannot reuse existing tree: "+ treeName +" path: "+path.toOSString()); //$NON-NLS-1$ //$NON-NLS-2$
rebuildDTree(treeName, path);
return null;
@ -167,7 +172,7 @@ public class DependencyManager extends JobManager implements ISourceDependency {
checksumCalculator.reset();
checksumCalculator.update(pathString.getBytes());
String fileName = Long.toString(checksumCalculator.getValue()) + ".depTree"; //$NON-NLS-1$
if (VERBOSE)
if (DependencyManager.VERBOSE)
JobManager.verbose("-> dependency tree name for " + pathString + " is " + fileName); //$NON-NLS-1$ //$NON-NLS-2$
name = getCCorePluginWorkingLocation().append(fileName).toOSString();
projectNames.put(path, name);
@ -209,7 +214,7 @@ public class DependencyManager extends JobManager implements ISourceDependency {
try {
return org.eclipse.cdt.internal.core.Util.getFileCharContent(savedDTreesFile, null);
} catch (IOException ignored) {
if (VERBOSE)
if (DependencyManager.VERBOSE)
JobManager.verbose("Failed to read saved dTree file names"); //$NON-NLS-1$
return new char[0];
}
@ -219,7 +224,7 @@ public class DependencyManager extends JobManager implements ISourceDependency {
Object target = org.eclipse.cdt.internal.core.Util.getTarget(ResourcesPlugin.getWorkspace().getRoot(), path, true);
if (target == null) return;
if (VERBOSE)
if (DependencyManager.VERBOSE)
JobManager.verbose("-> request to rebuild dTree: "+treeName+" path: "+path.toOSString()); //$NON-NLS-1$ //$NON-NLS-2$
updateTreeState(treeName, REBUILDING_STATE);
@ -274,7 +279,7 @@ public class DependencyManager extends JobManager implements ISourceDependency {
}
}
} catch (IOException ignored) {
if (VERBOSE)
if (DependencyManager.VERBOSE)
JobManager.verbose("Failed to write saved dTree file names"); //$NON-NLS-1$
} finally {
if (writer != null) {
@ -283,7 +288,7 @@ public class DependencyManager extends JobManager implements ISourceDependency {
} catch (IOException e) {}
}
}
if (VERBOSE) {
if (DependencyManager.VERBOSE) {
String state = "?"; //$NON-NLS-1$
if (treeState == SAVED_STATE) state = "SAVED"; //$NON-NLS-1$
else if (treeState == UPDATING_STATE) state = "UPDATING"; //$NON-NLS-1$
@ -307,13 +312,15 @@ public class DependencyManager extends JobManager implements ISourceDependency {
*/
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 (VERBOSE)
if (DependencyManager.VERBOSE)
JobManager.verbose("removing dependency tree " + path); //$NON-NLS-1$
String treeName = computeTreeName(path);
File indexFile = new File(treeName);
@ -325,6 +332,50 @@ public class DependencyManager extends JobManager implements ISourceDependency {
this.dependencyTrees.remove(path);
updateTreeState(treeName, null);
}
public synchronized void addToTable(String fileName, IFile resource){
ArrayList projectContainer = (ArrayList) dependencyTable.get(fileName);
if (projectContainer == null) {
ArrayList newProjectContainer = new ArrayList();
newProjectContainer.add(resource.getLocation());
dependencyTable.put(fileName, newProjectContainer);
}
else {
if (!projectContainer.contains(resource.getLocation())){
projectContainer.add(resource.getLocation());
}
}
}
public synchronized void removeFromTable(String fileName, IPath refToRemove){
ArrayList projectContainer = (ArrayList) dependencyTable.get(fileName);
if (projectContainer != null) {
int index = projectContainer.indexOf(refToRemove);
projectContainer.remove(refToRemove);
}
}
public synchronized ArrayList getProjectDependsForFile(String fileName){
ArrayList projectContainer = (ArrayList) dependencyTable.get(fileName);
return projectContainer;
}
/**
* @param file
* @param path
* @param info
*/
public void addSource(IFile file, IPath path, IScannerInfo info) {
if (CCorePlugin.getDefault() == null) return;
AddFileToDependencyTree job = new AddFileToDependencyTree(file, path, this, info);
if (this.awaitingJobsCount() < MAX_FILES_IN_MEMORY) {
// reduces the chance that the file is open later on, preventing it from being deleted
if (!job.initializeContents()) return;
}
request(job);
}
/*************
*TODO: Remove these methods once the depTree is
*fully integrated
@ -363,20 +414,6 @@ public class DependencyManager extends JobManager implements ISourceDependency {
} 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

View file

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

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.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();
}
@ -106,17 +111,20 @@ public class DependencyTree implements IDependencyTree {
* @see org.eclipse.cdt.internal.core.sourcedependency.IDependencyTree#remove(java.lang.String)
*/
public void remove(String documentName) throws IOException {
// TODO Auto-generated method stub
//IndexedFile file= addsTree.getIndexedFile(documentName);
//if (file != null) {
//}
}
/**
* Add the file that will be preprocessed to the tree, create a new
* preprocessor output and preprocess!
*/
public void add(IDocument document, String docPath, IScannerInfo newInfo, 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());
//if (indexedFile != null)
//remove(indexedFile, 0);
PreprocessorOutput output= new PreprocessorOutput(addsTree);
PreprocessorOutput output= new PreprocessorOutput(addsTree, file);
DependencyRequestor depReq = new DependencyRequestor(output,document);
output.addDocument(document);
@ -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 org.eclipse.cdt.core.build.managed.ManagedBuildManager;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.parser.IScannerInfo;
import org.eclipse.cdt.core.parser.IScannerInfoProvider;
import org.eclipse.cdt.internal.core.Util;
import org.eclipse.cdt.internal.core.index.IQueryResult;
import org.eclipse.cdt.internal.core.index.impl.IFileDocument;
@ -160,13 +162,19 @@ public class EntireProjectDependencyTree extends DependencyRequest {
shouldSave = true;
if (value == DELETED)
this.manager.remove(name, this.dependencyTreePath);
else
this.manager.addSource((IFile) value, this.dependencyTreePath, ManagedBuildManager.getScannerInfo(project));
else{
IScannerInfo scanInfo = null;
IScannerInfoProvider provider = CCorePlugin.getDefault().getScannerInfoProvider(project);
if (provider != null){
scanInfo = provider.getScannerInformation(project);
}
this.manager.addSource((IFile) value, this.dependencyTreePath, scanInfo);
}
}
}
}
} catch (/*IO*/Exception e) {
if (JobManager.VERBOSE) {
if (DependencyManager.VERBOSE) {
JobManager.verbose("-> failed to generate tree " + this.project + " because of the following exception:"); //$NON-NLS-1$ //$NON-NLS-2$
e.printStackTrace();
}

View file

@ -18,13 +18,15 @@ 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, ParserLanguage language) throws IOException;
void add(IDocument document, String docPath, IScannerInfo newInfo, IFile file, ParserLanguage language) throws IOException;
/**
* Empties the index.
*/

View file

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

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(){
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;
}
if (VERBOSE)
if (AbstractIndexer.VERBOSE)
AbstractIndexer.verbose(new String(result));
return result;
@ -315,7 +315,7 @@ public abstract class AbstractIndexer implements IIndexer, IIndexConstants, ICSe
pos+=tempName.length;
}
if (VERBOSE)
if (AbstractIndexer.VERBOSE)
AbstractIndexer.verbose(new String(result));
return result;

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

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

View file

@ -48,6 +48,8 @@ public class Preprocessor extends Scanner implements IPreprocessor {
catch( ScannerException se )
{
// callback IProblem here
org.eclipse.cdt.internal.core.model.Util.log(se, "Preprocessor Exception"); //$NON-NLS-1$h
}
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.SourceIndexer;
import org.eclipse.cdt.internal.core.search.matching.MatchLocator;
import org.eclipse.cdt.internal.core.search.processing.JobManager;
import org.eclipse.cdt.internal.core.sourcedependency.DependencyManager;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IProjectDescription;
@ -845,6 +846,7 @@ public class CCorePlugin extends Plugin {
* Configure the plugin with respect to option settings defined in ".options" file
*/
public void configurePluginDebugOptions(){
if(CCorePlugin.getDefault().isDebugging()){
String option = Platform.getDebugOption(PARSER);
if(option != null) Util.VERBOSE_PARSER = option.equalsIgnoreCase("true") ; //$NON-NLS-1$
@ -852,11 +854,19 @@ public class CCorePlugin extends Plugin {
option = Platform.getDebugOption(MODEL);
if(option != null) Util.VERBOSE_MODEL = option.equalsIgnoreCase("true") ; //$NON-NLS-1$
boolean depFlag = false;
option = Platform.getDebugOption(DEPENDENCY);
if(option != null) DependencyManager.VERBOSE = option.equalsIgnoreCase("true") ; //$NON-NLS-1$
if(option != null){
depFlag = option.equalsIgnoreCase("true");
DependencyManager.VERBOSE = depFlag;
}//$NON-NLS-1$
boolean indexFlag = false;
option = Platform.getDebugOption(INDEX_MANAGER);
if(option != null) IndexManager.VERBOSE = option.equalsIgnoreCase("true") ; //$NON-NLS-1$
if(option != null) {
indexFlag = option.equalsIgnoreCase("true");
IndexManager.VERBOSE = indexFlag;
} //$NON-NLS-1$
option = Platform.getDebugOption(INDEXER);
if(option != null) SourceIndexer.VERBOSE = option.equalsIgnoreCase("true") ; //$NON-NLS-1$
@ -867,6 +877,10 @@ public class CCorePlugin extends Plugin {
option = Platform.getDebugOption(MATCH_LOCATOR);
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
Refactored ISourceElementRequestor (enter|exit)CodeBlock() to take IASTCodeScope rather than IASTScope.
Added enumerator references to ISourceElementRequestor.

View file

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

View file

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