1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-07 17:56:01 +02:00

Patch for Bogdan Gheorghe:

This patch integrates the dependency calculator into
the indexer. As a result the underlying indexer file storage
format has changes. Lots of detail in the change logs of
exactly what changed...
This commit is contained in:
Doug Schaefer 2003-09-26 17:53:45 +00:00
parent 9da38c042c
commit 3b2b1c6a42
65 changed files with 2003 additions and 2129 deletions

View file

@ -41,6 +41,14 @@
* src/org/eclipse/cdt/managedbuilder/internal/core/ToolReference.java * src/org/eclipse/cdt/managedbuilder/internal/core/ToolReference.java
2003-09-25 Bogdan Gheorghe
Modified ResourceDeltaVisitor.visit() to use the new mechanism to get the
projects that dependend a file.
Modified addSourceDependencies() to use the new mechanism to perform a DependencyQueryJob
* src/org/eclipse/cdt/managedbuilder/internal/core/MakeFileGenerator.java
2003-09-24 Sean Evoy 2003-09-24 Sean Evoy
Changed the implementor of IScannerInfo to answer only absolute paths when asked for Changed the implementor of IScannerInfo to answer only absolute paths when asked for
includes paths. Users will specify the includes paths in the managed build UI in such a way includes paths. Users will specify the includes paths in the managed build UI in such a way

View file

@ -17,14 +17,19 @@ import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.ListIterator; import java.util.ListIterator;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.search.ICSearchConstants;
import org.eclipse.cdt.core.search.ICSearchScope;
import org.eclipse.cdt.core.search.SearchEngine;
import org.eclipse.cdt.internal.core.model.Util;
import org.eclipse.cdt.internal.core.search.PathCollector;
import org.eclipse.cdt.internal.core.search.PatternSearchJob;
import org.eclipse.cdt.internal.core.search.indexing.IndexManager;
import org.eclipse.cdt.internal.core.search.matching.CSearchPattern;
import org.eclipse.cdt.internal.core.sourcedependency.DependencyQueryJob;
import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo; import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo;
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager; import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin; import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.search.ICSearchConstants;
import org.eclipse.cdt.internal.core.model.Util;
import org.eclipse.cdt.internal.core.sourcedependency.DependencyManager;
import org.eclipse.cdt.internal.core.sourcedependency.DependencyQueryJob;
import org.eclipse.core.resources.IContainer; import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IFolder; import org.eclipse.core.resources.IFolder;
@ -160,11 +165,22 @@ public class MakefileGenerator {
// Here's the container // Here's the container
generator.appendModifiedSubdirectory(resource); generator.appendModifiedSubdirectory(resource);
// and all the dependents // and all the dependents
DependencyManager depMgr = CCorePlugin.getDefault().getCoreModel().getDependencyManager(); PathCollector pathCollector = new PathCollector();
List deps = depMgr.getProjectDependsForFile(resource.getLocation().toOSString()); ICSearchScope scope = SearchEngine.createWorkspaceScope();
if (deps != null) { CSearchPattern pattern = CSearchPattern.createPattern(resource.getLocation().toOSString(),ICSearchConstants.INCLUDE, ICSearchConstants.REFERENCES,ICSearchConstants.EXACT_MATCH,true);
ListIterator iter = deps.listIterator(); IndexManager indexManager = CCorePlugin.getDefault().getCoreModel().getIndexManager();
while (iter.hasNext()) { indexManager.performConcurrentJob(
new PatternSearchJob(
(CSearchPattern) pattern,
scope,
pathCollector,
indexManager
),
ICSearchConstants.WAIT_UNTIL_READY_TO_SEARCH,
null );
String[] deps = pathCollector.getPaths();
if (deps.length > 0 ) {
for (int i=0; i<deps.length; i++){
generator.appendModifiedSubdirectory(resource); generator.appendModifiedSubdirectory(resource);
} }
} }
@ -240,7 +256,7 @@ public class MakefileGenerator {
// Create the buffer to hold the output for the module and a dep calculator // Create the buffer to hold the output for the module and a dep calculator
StringBuffer buffer = new StringBuffer(); StringBuffer buffer = new StringBuffer();
buffer.append(ManagedBuilderCorePlugin.getResourceString(AUTO_DEP) + NEWLINE); buffer.append(ManagedBuilderCorePlugin.getResourceString(AUTO_DEP) + NEWLINE);
DependencyManager dependencyManager = CCorePlugin.getDefault().getCoreModel().getDependencyManager(); IndexManager indexManager = CCorePlugin.getDefault().getCoreModel().getIndexManager();
/* /*
* Visit each resource in the folder that we have a rule to build. * Visit each resource in the folder that we have a rule to build.
@ -264,7 +280,7 @@ public class MakefileGenerator {
// ASk the dep generator to find all the deps for this resource // ASk the dep generator to find all the deps for this resource
ArrayList dependencies = new ArrayList(); ArrayList dependencies = new ArrayList();
try { try {
dependencyManager.performConcurrentJob(new DependencyQueryJob(project, (IFile)resource, dependencyManager, dependencies), ICSearchConstants.WAIT_UNTIL_READY_TO_SEARCH, null); indexManager.performConcurrentJob(new DependencyQueryJob(project, (IFile)resource, indexManager, dependencies), ICSearchConstants.WAIT_UNTIL_READY_TO_SEARCH, null);
} catch (Exception e) { } catch (Exception e) {
continue; continue;
} }

View file

@ -5,6 +5,18 @@
* resources/search/classDecl.cpp * resources/search/classDecl.cpp
* search/org/eclipse/cdt/core/search/tests/OtherPatternTests.java * search/org/eclipse/cdt/core/search/tests/OtherPatternTests.java
2003-09-25 Bogdan Gheorghe
- separated dependency tests from the indexer tests
- modified the AutomatedIntegrationSuite to include new dependency
tests
- added the following tests:
* testDepTable
* testDepSourceChangeTree
* testDepHeaderChangeTree
* testDepHeaderChangeReindex
* testDepSourceChangeTable
* testDepHeaderChangeTable
2003-09-25 Hoda Amer 2003-09-25 Hoda Amer
Enabled CompleteParseASTExpressionTest.testPostfixTypenameIdentifier() Enabled CompleteParseASTExpressionTest.testPostfixTypenameIdentifier()

View file

@ -0,0 +1,713 @@
/*
* Created on Sep 25, 2003
*/
package org.eclipse.cdt.core.indexer.tests;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.Set;
import junit.extensions.TestDecorator;
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
import org.eclipse.cdt.core.CCProjectNature;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.search.ICSearchConstants;
import org.eclipse.cdt.core.search.ICSearchPattern;
import org.eclipse.cdt.core.search.ICSearchResultCollector;
import org.eclipse.cdt.core.search.ICSearchScope;
import org.eclipse.cdt.core.search.IMatch;
import org.eclipse.cdt.core.search.SearchEngine;
import org.eclipse.cdt.internal.core.index.impl.IFileDocument;
import org.eclipse.cdt.internal.core.search.PathCollector;
import org.eclipse.cdt.internal.core.search.PatternSearchJob;
import org.eclipse.cdt.internal.core.search.indexing.IndexManager;
import org.eclipse.cdt.internal.core.search.matching.CSearchPattern;
import org.eclipse.cdt.internal.core.sourcedependency.DependencyQueryJob;
import org.eclipse.cdt.internal.ui.search.CSearchResultCollector;
import org.eclipse.core.internal.resources.ResourceException;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IProjectDescription;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.resources.IWorkspaceRoot;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Platform;
/**
* @author bgheorgh
*/
public class DependencyTests extends TestCase {
IFile file;
IFileDocument fileDoc;
IProject testProject;
NullProgressMonitor monitor;
IndexManager indexManager;
IWorkspace workspace;
CSearchResultCollector resultCollector;
SearchEngine searchEngine;
ICSearchScope scope;
public static Test suite() {
TestSuite suite = new TestSuite(DependencyTests.class.getName());
suite.addTest(new DependencyTests("testDependencyTree"));
suite.addTest(new DependencyTests("testDepTable"));
suite.addTest(new DependencyTests("testDepSourceChangeTree"));
suite.addTest(new DependencyTests("testDepHeaderChangeTree"));
suite.addTest(new DependencyTests("testDepHeaderChangeReindex"));
suite.addTest(new DependencyTests("testDepSourceChangeTable"));
suite.addTest(new DependencyTests("testDepHeaderChangeTable"));
return suite;
}
/**
* @param name
*/
public DependencyTests(String name) {
super(name);
// TODO Auto-generated constructor stub
}
/*
* @see TestCase#setUp()
*/
protected void setUp() throws Exception {
super.setUp();
//Create temp project
testProject = createProject("DepTestProject");
if (testProject==null)
fail("Unable to create project");
indexManager = CCorePlugin.getDefault().getCoreModel().getIndexManager();
indexManager.reset();
workspace = ResourcesPlugin.getWorkspace();
scope = SearchEngine.createWorkspaceScope();
monitor = new NullProgressMonitor();
resultCollector = new CSearchResultCollector();
resultCollector.setProgressMonitor( monitor );
searchEngine = new SearchEngine();
}
/*
* @see TestCase#tearDown()
*/
protected void tearDown() {
try {
super.tearDown();
} catch (Exception e1) {
}
//Delete project
if (testProject.exists()){
try {
testProject.delete(true,monitor);
} catch (ResourceException e) {
} catch (CoreException e) {
}
}
}
public void testDependencyTree() throws Exception{
//Add a file to the project
importFile("c.h","resources/dependency/c.h");
importFile("a.h","resources/dependency/a.h");
importFile("Inc1.h","resources/dependency/Inc1.h");
importFile("DepTest.h","resources/dependency/DepTest.h");
importFile("d.h","resources/dependency/d.h");
importFile("DepTest2.h","resources/dependency/DepTest2.h");
IFile depTest = importFile("DepTest.cpp","resources/dependency/DepTest.cpp");
IFile depTest2 = importFile("DepTest2.cpp","resources/dependency/DepTest2.cpp");
//Enable indexing on the created project
//By doing this, we force the Dependency Manager to do a g()
IndexManager indexManager = CCorePlugin.getDefault().getCoreModel().getIndexManager();
//indexManager.setEnabled(testProject,true);
String[] depTestModel = {File.separator + "DepTestProject" + File.separator + "d.h", File.separator + "DepTestProject" + File.separator + "Inc1.h", File.separator + "DepTestProject" + File.separator + "c.h", File.separator + "DepTestProject" + File.separator + "a.h", File.separator + "DepTestProject" + File.separator + "DepTest.h"};
String[] depTest2Model = {File.separator + "DepTestProject" + File.separator + "d.h", File.separator + "DepTestProject" + File.separator + "DepTest2.h"};
ArrayList includes = new ArrayList();
indexManager.performConcurrentJob(new DependencyQueryJob(testProject,depTest,indexManager,includes),ICSearchConstants.WAIT_UNTIL_READY_TO_SEARCH,null);
String[] depTestModelLocal = convertToLocalPath(depTestModel);
String[] depTestIncludes = new String[includes.size()];
Iterator includesIterator = includes.iterator();
int i=0;
while(includesIterator.hasNext()){
depTestIncludes[i] = (String) includesIterator.next();
i++;
}
if (depTestModelLocal.length != depTestIncludes.length)
fail("Number of included files differsfrom model");
Arrays.sort(depTestModelLocal);
Arrays.sort(depTestIncludes);
for (i=0;i<depTestIncludes.length; i++)
{
assertEquals(depTestModelLocal[i],depTestIncludes[i]);
}
ArrayList includes2 = new ArrayList();
indexManager.performConcurrentJob(new DependencyQueryJob(testProject,depTest2,indexManager,includes2),ICSearchConstants.WAIT_UNTIL_READY_TO_SEARCH,null);
String[] depTest2ModelLocal = convertToLocalPath(depTest2Model);
String[] depTest2Includes = new String[includes2.size()];
Iterator includes2Iterator = includes2.iterator();
i=0;
while(includes2Iterator.hasNext()){
depTest2Includes[i] = (String) includes2Iterator.next();
i++;
}
if (depTest2ModelLocal.length != depTest2Includes.length)
fail("Number of included files differsfrom model");
Arrays.sort(depTest2ModelLocal);
Arrays.sort(depTest2Includes);
for (i=0;i<depTest2Includes.length; i++)
{
assertEquals(depTest2ModelLocal[i],depTest2Includes[i]);
}
}
public void testDepTable() throws Exception{
//Add a file to the project
IFile cH = importFile("c.h","resources/dependency/c.h");
IFile aH = importFile("a.h","resources/dependency/a.h");
IFile Inc1H = importFile("Inc1.h","resources/dependency/Inc1.h");
IFile dH = importFile("d.h","resources/dependency/d.h");
IFile depTestH = importFile("DepTest.h","resources/dependency/DepTest.h");
IFile depTest2H = importFile("DepTest2.h","resources/dependency/DepTest2.h");
IFile depTest2C = importFile("DepTest2.cpp","resources/dependency/DepTest2.cpp");
IFile depTestC = importFile("DepTest.cpp","resources/dependency/DepTest.cpp");
PathCollector pathCollector = new PathCollector();
getTableRefs(dH, pathCollector);
String[] dHModel = {IPath.SEPARATOR + "DepTestProject" + IPath.SEPARATOR + "DepTest2.cpp", IPath.SEPARATOR + "DepTestProject" + IPath.SEPARATOR + "DepTest.cpp"};
String[] iPath = pathCollector.getPaths();
if (dHModel.length != iPath.length)
fail("Number of included files differsfrom model");
Arrays.sort(dHModel);
Arrays.sort(iPath);
for (int i=0;i<iPath.length; i++)
{
assertEquals(iPath[i],dHModel[i]);
}
pathCollector = new PathCollector();
getTableRefs(Inc1H, pathCollector);
String[] Inc1HModel = {IPath.SEPARATOR + "DepTestProject" + IPath.SEPARATOR + "DepTest.cpp"};
iPath = pathCollector.getPaths();
if (Inc1HModel.length != iPath.length)
fail("Number of included files differsfrom model");
Arrays.sort(Inc1HModel);
Arrays.sort(iPath);
for (int i=0;i<iPath.length; i++)
{
assertEquals(iPath[i],Inc1HModel[i]);
}
}
public void testDepSourceChangeTable() throws Exception{
//Add a file to the project
IFile cH = importFile("c.h","resources/dependency/c.h");
IFile aH = importFile("a.h","resources/dependency/a.h");
IFile Inc1H = importFile("Inc1.h","resources/dependency/Inc1.h");
IFile dH = importFile("d.h","resources/dependency/d.h");
IFile depTestH = importFile("DepTest.h","resources/dependency/DepTest.h");
IFile depTestC = importFile("DepTest.cpp","resources/dependency/DepTest.cpp");
String[] beforeModel = {Path.SEPARATOR + "DepTestProject" + IPath.SEPARATOR + "DepTest.cpp"};
PathCollector pathCollector = new PathCollector();
getTableRefs(depTestH, pathCollector);
String[] iPath = pathCollector.getPaths();
compareArrays(iPath,beforeModel);
pathCollector = new PathCollector();
getTableRefs(dH, pathCollector);
iPath = pathCollector.getPaths();
compareArrays(iPath,beforeModel);
pathCollector = new PathCollector();
getTableRefs(Inc1H, pathCollector);
iPath = pathCollector.getPaths();
compareArrays(iPath,beforeModel);
pathCollector = new PathCollector();
getTableRefs(aH, pathCollector);
iPath = pathCollector.getPaths();
compareArrays(iPath,beforeModel);
pathCollector = new PathCollector();
getTableRefs(cH, pathCollector);
iPath = pathCollector.getPaths();
compareArrays(iPath,beforeModel);
editCode(depTestC,"#include \"DepTest.h\"","//#include \"DepTest.h\"");
pathCollector = new PathCollector();
getTableRefs(depTestH, pathCollector);
iPath = pathCollector.getPaths();
if (iPath.length != 0)
fail("Number of included files differs from model");
pathCollector = new PathCollector();
getTableRefs(dH, pathCollector);
iPath = pathCollector.getPaths();
compareArrays(iPath,beforeModel);
pathCollector = new PathCollector();
getTableRefs(Inc1H, pathCollector);
iPath = pathCollector.getPaths();
if (iPath.length != 0)
fail("Number of included files differs from model");
pathCollector = new PathCollector();
getTableRefs(aH, pathCollector);
iPath = pathCollector.getPaths();
if (iPath.length != 0)
fail("Number of included files differs from model");
pathCollector = new PathCollector();
getTableRefs(cH, pathCollector);
iPath = pathCollector.getPaths();
if (iPath.length != 0)
fail("Number of included files differs from model");
}
public void testDepSourceChangeTree() throws Exception{
// Add a file to the project
IFile cH = importFile("c.h","resources/dependency/c.h");
IFile aH = importFile("a.h","resources/dependency/a.h");
IFile Inc1H = importFile("Inc1.h","resources/dependency/Inc1.h");
IFile depTestH = importFile("DepTest.h","resources/dependency/DepTest.h");
IFile dH = importFile("d.h","resources/dependency/d.h");
IFile depTest2H = importFile("DepTest2.h","resources/dependency/DepTest2.h");
IFile depTestC = importFile("DepTest.cpp","resources/dependency/DepTest.cpp");
IFile depTest2C = importFile("DepTest2.cpp","resources/dependency/DepTest2.cpp");
IndexManager indexManager = CCorePlugin.getDefault().getCoreModel().getIndexManager();
String[] preDepTestModel = {File.separator + "DepTestProject" + File.separator + "DepTest.h", File.separator + "DepTestProject" + File.separator + "Inc1.h", File.separator + "DepTestProject" + File.separator + "a.h", File.separator + "DepTestProject" + File.separator + "c.h", File.separator + "DepTestProject" + File.separator + "d.h"};
ArrayList includes = new ArrayList();
indexManager.performConcurrentJob(new DependencyQueryJob(testProject,depTestC,indexManager,includes),ICSearchConstants.WAIT_UNTIL_READY_TO_SEARCH,null);
String[] preDepTestModelLocal = convertToLocalPath(preDepTestModel);
String[] preDepTestIncludes = new String[includes.size()];
Iterator includesIterator = includes.iterator();
int i=0;
while(includesIterator.hasNext()){
preDepTestIncludes[i] = (String) includesIterator.next();
i++;
}
if (preDepTestModelLocal.length != preDepTestIncludes.length)
fail("Number of included files differs from model");
Arrays.sort(preDepTestModelLocal);
Arrays.sort(preDepTestIncludes);
for (i=0;i<preDepTestIncludes.length; i++){
assertEquals(preDepTestModelLocal[i],preDepTestIncludes[i]);
}
editCode(depTestC,"#include \"DepTest.h\"","//#include \"DepTest.h\"");
String[] postDepTestModel = {File.separator + "DepTestProject" + File.separator + "d.h"};
ArrayList includes2 = new ArrayList();
testProject.refreshLocal(IResource.DEPTH_INFINITE,null);
indexManager.performConcurrentJob(new DependencyQueryJob(testProject,depTestC,indexManager,includes2),ICSearchConstants.WAIT_UNTIL_READY_TO_SEARCH,null);
String[] postDepTestModelLocal = convertToLocalPath(postDepTestModel);
String[] postDepTestIncludes = new String[includes2.size()];
Iterator includesIterator2 = includes2.iterator();
int j=0;
while(includesIterator2.hasNext()){
postDepTestIncludes[j] = (String) includesIterator2.next();
j++;
}
if (postDepTestModelLocal.length != postDepTestIncludes.length)
fail("Number of included files differs from model");
Arrays.sort(postDepTestModelLocal);
Arrays.sort(postDepTestIncludes);
for (i=0;i<postDepTestIncludes.length; i++){
assertEquals(postDepTestModelLocal[i],postDepTestIncludes[i]);
}
}
public void testDepHeaderChangeTree() throws Exception{
// Add a file to the project
IFile cH = importFile("c.h","resources/dependency/c.h");
IFile aH = importFile("a.h","resources/dependency/a.h");
IFile depTest3H = importFile("DepTest3.h","resources/dependency/DepTest3.h");
IFile depTest3C = importFile("DepTest3.cpp","resources/dependency/DepTest3.cpp");
IndexManager indexManager = CCorePlugin.getDefault().getCoreModel().getIndexManager();
String[] preDepTestModel = {File.separator + "DepTestProject" + File.separator + "DepTest3.h", File.separator + "DepTestProject" + File.separator + "a.h", File.separator + "DepTestProject" + File.separator + "c.h"};
ArrayList includes = new ArrayList();
indexManager.performConcurrentJob(new DependencyQueryJob(testProject,depTest3C,indexManager,includes),ICSearchConstants.WAIT_UNTIL_READY_TO_SEARCH,null);
String[] preDepTestModelLocal = convertToLocalPath(preDepTestModel);
String[] preDepTestIncludes = new String[includes.size()];
Iterator includesIterator = includes.iterator();
int i=0;
while(includesIterator.hasNext()){
preDepTestIncludes[i] = (String) includesIterator.next();
i++;
}
if (preDepTestModelLocal.length != preDepTestIncludes.length)
fail("Number of included files differs from model");
Arrays.sort(preDepTestModelLocal);
Arrays.sort(preDepTestIncludes);
for (i=0;i<preDepTestIncludes.length; i++){
assertEquals(preDepTestModelLocal[i],preDepTestIncludes[i]);
}
editCode(aH,"#include \"c.h\"","//#include \"c.h\"");
String[] postDepTestModel = {File.separator + "DepTestProject" + File.separator + "DepTest3.h", File.separator + "DepTestProject" + File.separator + "a.h"};
ArrayList includes2 = new ArrayList();
testProject.refreshLocal(IResource.DEPTH_INFINITE,null);
indexManager.performConcurrentJob(new DependencyQueryJob(testProject,depTest3C,indexManager,includes2),ICSearchConstants.WAIT_UNTIL_READY_TO_SEARCH,null);
String[] postDepTestModelLocal = convertToLocalPath(postDepTestModel);
String[] postDepTestIncludes = new String[includes2.size()];
Iterator includesIterator2 = includes2.iterator();
int j=0;
while(includesIterator2.hasNext()){
postDepTestIncludes[j] = (String) includesIterator2.next();
j++;
}
if (postDepTestModelLocal.length != postDepTestIncludes.length)
fail("Number of included files differs from model");
Arrays.sort(postDepTestModelLocal);
Arrays.sort(postDepTestIncludes);
for (i=0;i<postDepTestIncludes.length; i++){
assertEquals(postDepTestModelLocal[i],postDepTestIncludes[i]);
}
}
public void testDepHeaderChangeTable() throws Exception{
// Add a file to the project
IFile cH = importFile("c.h","resources/dependency/c.h");
IFile aH = importFile("a.h","resources/dependency/a.h");
IFile depTest3H = importFile("DepTest3.h","resources/dependency/DepTest3.h");
IFile depTest3C = importFile("DepTest3.cpp","resources/dependency/DepTest3.cpp");
String[] beforeModel = {Path.SEPARATOR + "DepTestProject" + IPath.SEPARATOR + "DepTest3.cpp"};
PathCollector pathCollector = new PathCollector();
getTableRefs(depTest3H, pathCollector);
String[] iPath = pathCollector.getPaths();
compareArrays(iPath,beforeModel);
pathCollector = new PathCollector();
getTableRefs(cH, pathCollector);
iPath = pathCollector.getPaths();
compareArrays(iPath,beforeModel);
pathCollector = new PathCollector();
getTableRefs(aH, pathCollector);
iPath = pathCollector.getPaths();
compareArrays(iPath,beforeModel);
editCode(aH,"#include \"c.h\"","//#include \"c.h\"");
pathCollector = new PathCollector();
getTableRefs(depTest3H, pathCollector);
iPath = pathCollector.getPaths();
compareArrays(iPath,beforeModel);
pathCollector = new PathCollector();
getTableRefs(cH, pathCollector);
iPath = pathCollector.getPaths();
if (iPath.length != 0)
fail("Number of included files differs from model");
pathCollector = new PathCollector();
getTableRefs(aH, pathCollector);
iPath = pathCollector.getPaths();
compareArrays(iPath,beforeModel);
}
public void testDepHeaderChangeReindex() throws Exception{
// Add a file to the project
IFile cH = importFile("c.h","resources/dependency/c.h");
IFile aH = importFile("a.h","resources/dependency/a.h");
IFile depTest3H = importFile("DepTest3.h","resources/dependency/DepTest3.h");
IFile depTest3C = importFile("DepTest3.cpp","resources/dependency/DepTest3.cpp");
ICSearchPattern pattern = SearchEngine.createSearchPattern( "Z", ICSearchConstants.TYPE, ICSearchConstants.DECLARATIONS, true );
search(workspace,pattern,scope,resultCollector);
Set resultSet = resultCollector.getSearchResults();
if (resultSet.size() != 1)
fail("Expected 1 match");
Iterator iter = resultSet.iterator();
IMatch match = (IMatch) iter.next();
if (!(match.getName().equals("Z")) &&
(match.getElementType() != 64 ))
fail("Wrong search result");
editCode(depTest3H,"#include \"a.h\"","//#include \"a.h\"");
search(workspace,pattern,scope,resultCollector);
resultSet = resultCollector.getSearchResults();
if (resultSet.size() != 0)
fail("Expected no matches");
}
private String[] convertToLocalPath(String[] model) {
IPath defaultPath = Platform.getLocation();
String[] tempLocalArray = new String[model.length];
for (int i=0;i<model.length;i++){
StringBuffer buffer = new StringBuffer();
buffer.append(defaultPath.toOSString());
buffer.append(model[i]);
tempLocalArray[i]=buffer.toString();
}
return tempLocalArray;
}
private void getTableRefs(IFile tempFile, PathCollector pathCollector) throws InterruptedException{
ICSearchScope scope = SearchEngine.createWorkspaceScope();
CSearchPattern pattern = CSearchPattern.createPattern(tempFile.getLocation().toOSString(),ICSearchConstants.INCLUDE, ICSearchConstants.REFERENCES,ICSearchConstants.EXACT_MATCH,true);
IndexManager indexManager = CCorePlugin.getDefault().getCoreModel().getIndexManager();
indexManager.performConcurrentJob(
new PatternSearchJob(
(CSearchPattern) pattern,
scope,
pathCollector,
indexManager
),
ICSearchConstants.WAIT_UNTIL_READY_TO_SEARCH,
null );
}
private void editCode(IFile tempFile, String beforeString, String afterString) throws IOException, CoreException, InterruptedException{
FileReader fileReader = null;
try {
fileReader = new FileReader(tempFile.getLocation().toOSString());
} catch (FileNotFoundException e) {
fail(e.getMessage());
}
BufferedReader buff = new BufferedReader(fileReader);
String tempString;
File tempUtilFile= new File(tempFile.getLocation().toOSString() + "TempFile");
FileWriter writer = new FileWriter(tempUtilFile);
try {
while ((tempString = buff.readLine())!= null ) {
if (tempString.equals(beforeString)){
writer.write(afterString + "\n" );
writer.flush();
}
else{
writer.write(tempString + "\n" );
writer.flush();
}
}
} catch (IOException e1) {
fail(e1.getMessage());
}
writer.close();
FileInputStream buff2 = new FileInputStream(tempUtilFile);
tempFile.setContents(buff2,true,false,null);
tempFile.refreshLocal(IResource.DEPTH_INFINITE, null);
//buff2.close();
}
private void compareArrays(String[] first, String[] second){
if (first.length != second.length)
fail("Number of included files differs from model");
Arrays.sort(first);
Arrays.sort(second);
for (int i=0;i<first.length; i++)
{
assertEquals(first[i],second[i]);
}
}
protected void search(IWorkspace workspace, ICSearchPattern pattern, ICSearchScope scope, ICSearchResultCollector collector) {
resultCollector.setProgressMonitor( monitor );
searchEngine.search( workspace, pattern, scope, collector, false );
}
/*
* Utils
*/
private IProject createProject(String projectName) throws CoreException
{
IWorkspaceRoot root= ResourcesPlugin.getWorkspace().getRoot();
IProject project= root.getProject(projectName);
IProject cproject = null;
try{
if (!project.exists()) {
project.create(null);
} else {
project.refreshLocal(IResource.DEPTH_INFINITE, null);
}
if (!project.isOpen()) {
project.open(null);
}
//Fill out a project description
IPath defaultPath = Platform.getLocation();
IPath newPath = project.getFullPath();
if (defaultPath.equals(newPath))
newPath = null;
IWorkspace workspace = ResourcesPlugin.getWorkspace();
IProjectDescription description = workspace.newProjectDescription(project.getName());
description.setLocation(newPath);
//Create the project
cproject = CCorePlugin.getDefault().createCProject(description,project,monitor,CCorePlugin.PLUGIN_ID + ".make"); //.getCoreModel().create(project);
if( !cproject.hasNature(CCProjectNature.CC_NATURE_ID) ){
addNatureToProject(cproject, CCProjectNature.CC_NATURE_ID, null);
}
}
catch (CoreException e){
cproject = project;
cproject.open(null);
}
return cproject;
}
private IFile importFile(String fileName, String resourceLocation)throws Exception{
String testCaseName = this.getName();
//Obtain file handle
file = testProject.getProject().getFile(fileName);
String pluginRoot=org.eclipse.core.runtime.Platform.getPlugin("org.eclipse.cdt.core.tests").find(new Path("/")).getFile();
//Create file input stream
monitor = new NullProgressMonitor();
if (!file.exists()){
file.create(new FileInputStream(pluginRoot + resourceLocation),false,monitor);
}
fileDoc = new IFileDocument(file);
return file;
}
private void addNatureToProject(IProject proj, String natureId, IProgressMonitor monitor) throws CoreException {
IProjectDescription description = proj.getDescription();
String[] prevNatures= description.getNatureIds();
String[] newNatures= new String[prevNatures.length + 1];
System.arraycopy(prevNatures, 0, newNatures, 0, prevNatures.length);
newNatures[prevNatures.length]= natureId;
description.setNatureIds(newNatures);
proj.setDescription(description, monitor);
}
}

View file

@ -14,10 +14,6 @@ import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.io.FileWriter; import java.io.FileWriter;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.Set;
import junit.framework.Test; import junit.framework.Test;
import junit.framework.TestCase; import junit.framework.TestCase;
@ -25,20 +21,12 @@ import junit.framework.TestSuite;
import org.eclipse.cdt.core.CCProjectNature; import org.eclipse.cdt.core.CCProjectNature;
import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.search.ICSearchConstants;
import org.eclipse.cdt.core.search.ICSearchPattern;
import org.eclipse.cdt.core.search.ICSearchResultCollector;
import org.eclipse.cdt.core.search.ICSearchScope;
import org.eclipse.cdt.core.search.SearchEngine;
import org.eclipse.cdt.internal.core.index.IEntryResult; import org.eclipse.cdt.internal.core.index.IEntryResult;
import org.eclipse.cdt.internal.core.index.IIndex; import org.eclipse.cdt.internal.core.index.IIndex;
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;
import org.eclipse.cdt.internal.core.search.indexing.IIndexConstants; 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.DependencyQueryJob;
import org.eclipse.cdt.internal.ui.search.CSearchResultCollector;
import org.eclipse.core.internal.resources.ResourceException; 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;
@ -80,6 +68,9 @@ public class IndexManagerTests extends TestCase {
*/ */
protected void setUp() throws Exception { protected void setUp() throws Exception {
super.setUp(); super.setUp();
monitor = new NullProgressMonitor();
//Create temp project //Create temp project
testProject = createProject("IndexerTestProject"); testProject = createProject("IndexerTestProject");
if (testProject==null) if (testProject==null)
@ -118,7 +109,6 @@ public class IndexManagerTests extends TestCase {
suite.addTest(new IndexManagerTests("testRemoveFileFromIndex")); suite.addTest(new IndexManagerTests("testRemoveFileFromIndex"));
suite.addTest(new IndexManagerTests("testRemoveProjectFromIndex")); suite.addTest(new IndexManagerTests("testRemoveProjectFromIndex"));
suite.addTest(new IndexManagerTests("testIndexShutdown")); suite.addTest(new IndexManagerTests("testIndexShutdown"));
suite.addTest(new IndexManagerTests("testDependencyTree"));
return suite; return suite;
@ -605,85 +595,4 @@ public class IndexManagerTests extends TestCase {
} }
} }
public void testDependencyTree() throws Exception{
//Add a file to the project
IFile depTest = importFile("DepTest.cpp","resources/dependency/DepTest.cpp");
importFile("DepTest.h","resources/dependency/DepTest.h");
importFile("a.h","resources/dependency/a.h");
importFile("c.h","resources/dependency/c.h");
importFile("d.h","resources/dependency/d.h");
importFile("Inc1.h","resources/dependency/Inc1.h");
importFile("DepTest2.h","resources/dependency/DepTest2.h");
IFile depTest2 = importFile("DepTest2.cpp","resources/dependency/DepTest2.cpp");
//Enable indexing on the created project
//By doing this, we force the Dependency Manager to do a g()
DependencyManager dependencyManager = CCorePlugin.getDefault().getCoreModel().getDependencyManager();
//dependencyManager.setEnabled(testProject,true);
Thread.sleep(10000);
String[] depTestModel = {File.separator + "IndexerTestProject" + File.separator + "d.h", File.separator + "IndexerTestProject" + File.separator + "Inc1.h", File.separator + "IndexerTestProject" + File.separator + "c.h", File.separator + "IndexerTestProject" + File.separator + "a.h", File.separator + "IndexerTestProject" + File.separator + "DepTest.h"};
String[] depTest2Model = {File.separator + "IndexerTestProject" + File.separator + "d.h", File.separator + "IndexerTestProject" + File.separator + "DepTest2.h"};
ArrayList includes = new ArrayList();
dependencyManager.performConcurrentJob(new DependencyQueryJob(testProject,depTest,dependencyManager,includes),ICSearchConstants.WAIT_UNTIL_READY_TO_SEARCH,null);
//Thread.sleep(5000);
String[] depTestModelLocal = convertToLocalPath(depTestModel);
String[] depTestIncludes = new String[includes.size()];
Iterator includesIterator = includes.iterator();
int i=0;
while(includesIterator.hasNext()){
depTestIncludes[i] = (String) includesIterator.next();
i++;
}
if (depTestModelLocal.length != depTestIncludes.length)
fail("Number of included files differsfrom model");
Arrays.sort(depTestModelLocal);
Arrays.sort(depTestIncludes);
for (i=0;i<depTestIncludes.length; i++)
{
assertEquals(depTestModelLocal[i],depTestIncludes[i]);
}
ArrayList includes2 = new ArrayList();
dependencyManager.performConcurrentJob(new DependencyQueryJob(testProject,depTest2,dependencyManager,includes2),ICSearchConstants.WAIT_UNTIL_READY_TO_SEARCH,null);
//Thread.sleep(5000);
String[] depTest2ModelLocal = convertToLocalPath(depTest2Model);
String[] depTest2Includes = new String[includes2.size()];
Iterator includes2Iterator = includes2.iterator();
i=0;
while(includes2Iterator.hasNext()){
depTest2Includes[i] = (String) includes2Iterator.next();
i++;
}
if (depTest2ModelLocal.length != depTest2Includes.length)
fail("Number of included files differsfrom model");
Arrays.sort(depTest2ModelLocal);
Arrays.sort(depTest2Includes);
for (i=0;i<depTest2Includes.length; i++)
{
assertEquals(depTest2ModelLocal[i],depTest2Includes[i]);
}
}
/**
* @param depTestModel
* @return
*/
private String[] convertToLocalPath(String[] model) {
IPath defaultPath = Platform.getLocation();
String[] tempLocalArray = new String[model.length];
for (int i=0;i<model.length;i++){
StringBuffer buffer = new StringBuffer();
buffer.append(defaultPath.toOSString());
buffer.append(model[i]);
tempLocalArray[i]=buffer.toString();
}
return tempLocalArray;
}
} }

View file

@ -0,0 +1,7 @@
#include "DepTest3.h"
DepTest3::DepTest3()
{};
DepTest3::~DepTest3()
{};

View file

@ -0,0 +1,8 @@
#include "a.h"
class DepTest3{
public:
DepTest3();
~DepTest3();
};

View file

@ -20,6 +20,7 @@ import junit.textui.TestRunner;
import org.eclipse.cdt.core.build.managed.tests.ManagedBuildTests; import org.eclipse.cdt.core.build.managed.tests.ManagedBuildTests;
import org.eclipse.cdt.core.build.managed.tests.StandardBuildTests; import org.eclipse.cdt.core.build.managed.tests.StandardBuildTests;
import org.eclipse.cdt.core.codeassist.tests.CompletionProposalsTest; import org.eclipse.cdt.core.codeassist.tests.CompletionProposalsTest;
import org.eclipse.cdt.core.indexer.tests.DependencyTests;
import org.eclipse.cdt.core.indexer.tests.IndexManagerTests; import org.eclipse.cdt.core.indexer.tests.IndexManagerTests;
import org.eclipse.cdt.core.model.failedTests.CModelElementsFailedTests; import org.eclipse.cdt.core.model.failedTests.CModelElementsFailedTests;
import org.eclipse.cdt.core.model.tests.AllCoreTests; import org.eclipse.cdt.core.model.tests.AllCoreTests;
@ -85,6 +86,7 @@ public class AutomatedIntegrationSuite extends TestSuite
suite.addTest(WorkingCopyTests.suite()); suite.addTest(WorkingCopyTests.suite());
suite.addTest(SearchTestSuite.suite()); suite.addTest(SearchTestSuite.suite());
suite.addTestSuite( CompletionProposalsTest.class); suite.addTestSuite( CompletionProposalsTest.class);
suite.addTest(DependencyTests.suite());
//Indexer Tests need to be run after any indexer client tests //Indexer Tests need to be run after any indexer client tests
//as the last test shuts down the indexing thread //as the last test shuts down the indexing thread
suite.addTest(IndexManagerTests.suite()); suite.addTest(IndexManagerTests.suite());

View file

@ -18,8 +18,5 @@ org.eclipse.cdt.core/debug/indexer=false
# Reports search matches # Reports search matches
org.eclipse.cdt.core/debug/matchlocator=false org.eclipse.cdt.core/debug/matchlocator=false
# Reports background dependency tree activity
org.eclipse.cdt.core/debug/dependency=false
# Reports delta processor tree activity # Reports delta processor tree activity
org.eclipse.cdt.core/debug/deltaprocessor=false org.eclipse.cdt.core/debug/deltaprocessor=false

View file

@ -1,3 +1,13 @@
2003-09-25 Bogdan Gheorghe
- Got rid of refs to old dependency service; restructured
index request section
* src/org/eclipse/cdt/core/CCorePlugin.java
* src/org/eclipse/cdt/core/model/CoreModel.java
* src/org/eclipse/cdt/internal/core/model/CModelManager.java
* src/org/eclipse/cdt/internal/core/model/DeltaProcessor.java
2003-09-24 Alain Magloire 2003-09-24 Alain Magloire
With the removal of the old CDT parser, there was no With the removal of the old CDT parser, there was no

View file

@ -1,3 +1,25 @@
2003-09-25 Bogdan Gheorghe
- As a result of folding the dependency service into the indexer
have removed the following files:
* src/org/eclipse/cdt/internal/core/sourcedependency/AddFileToDependencyTree.java
* src/org/eclipse/cdt/internal/core/sourcedependency/DependencyManager.java
* src/org/eclipse/cdt/internal/core/sourcedependency/DependencyRequest.java
* src/org/eclipse/cdt/internal/core/sourcedependency/DependencyRequestor.java
* src/org/eclipse/cdt/internal/core/sourcedependency/DependencySelector.java
* src/org/eclipse/cdt/internal/core/sourcedependency/DependencyTree.java
* src/org/eclipse/cdt/internal/core/sourcedependency/EntireProjectDependencyTree.java
* src/org/eclipse/cdt/internal/core/sourcedependency/IDependencyTree.java
* src/org/eclipse/cdt/internal/core/sourcedependency/IPreprocessorOutput.java
* src/org/eclipse/cdt/internal/core/sourcedependency/ISourceDependency.java
* src/org/eclipse/cdt/internal/core/sourcedependency/PreprocessorOutput.java
* src/org/eclipse/cdt/internal/core/sourcedependency/RemoveFromDependencyTree.java
* src/org/eclipse/cdt/internal/core/sourcedependency/impl/IncludeEntry.java
* src/org/eclipse/cdt/internal/core/sourcedependency/impl/IncludeEntryHashedArray.java
* src/org/eclipse/cdt/internal/core/sourcedependency/impl/InMemoryTree.java
2003-09-22 Bogdan Gheorghe 2003-09-22 Bogdan Gheorghe
- Took out enable section for DependencyManager - Took out enable section for DependencyManager

View file

@ -1,116 +0,0 @@
/**********************************************************************
* Copyright (c) 2002,2003 Rational Software Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v0.5
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v05.html
*
* Contributors:
* IBM Rational Software - Initial API and implementation
***********************************************************************/
package org.eclipse.cdt.internal.core.sourcedependency;
import java.io.IOException;
import org.eclipse.cdt.core.model.CoreModel;
import org.eclipse.cdt.core.parser.IScannerInfo;
import org.eclipse.cdt.core.parser.ParserLanguage;
import org.eclipse.cdt.internal.core.index.IDocument;
import org.eclipse.cdt.internal.core.index.impl.IFileDocument;
import org.eclipse.cdt.internal.core.parser.ScannerInfo;
import org.eclipse.cdt.internal.core.search.indexing.ReadWriteMonitor;
import org.eclipse.cdt.internal.core.search.processing.JobManager;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
public class AddFileToDependencyTree extends DependencyRequest {
public static final String[] FILE_TYPES= new String[] {"cpp","c", "cc", "cxx"}; //$NON-NLS-1$
IFile resource;
char[] contents;
IScannerInfo buildInfo;
/**
* @param path
* @param manager
*/
public AddFileToDependencyTree(
IFile resource,
IPath path,
DependencyManager manager,
IScannerInfo info) {
super(path, manager);
this.resource = resource;
this.buildInfo = info;
}
public boolean execute(IProgressMonitor progressMonitor) {
if (progressMonitor != null && progressMonitor.isCanceled()) return true;
/* ensure no concurrent write access to tree */
IDependencyTree tree = manager.getDependencyTree(this.dependencyTreePath, true, /*reuse tree file*/ true /*create if none*/);
if (tree == null) return true;
ReadWriteMonitor monitor = manager.getMonitorFor(tree);
if (monitor == null) return true; // tree got deleted since acquired
try {
monitor.enterWrite(); // ask permission to write
if (!addDocumentToTree(tree)) return false;
} catch (IOException e) {
if (DependencyManager.VERBOSE) {
JobManager.verbose("-> failed to calculate dependency for " + this.resource + " because of the following exception:"); //$NON-NLS-1$ //$NON-NLS-2$
e.printStackTrace();
}
return false;
} finally {
monitor.exitWrite(); // free write lock
}
return true;
}
protected boolean addDocumentToTree(IDependencyTree dTree) throws IOException {
if (!initializeContents()) return false;
//Need to create document to get string content...
IDocument document = new IFileDocument(resource, this.contents);
if (!shouldAddToTree(document)) return false;
String docPath = resource.getLocation().toOSString();
IScannerInfo newInfo = new ScannerInfo((this.buildInfo != null) ? this.buildInfo.getDefinedSymbols() : null,(this.buildInfo != null) ? this.buildInfo.getIncludePaths() : null);
ParserLanguage language = CoreModel.getDefault().hasCCNature( resource.getProject() ) ? ParserLanguage.CPP : ParserLanguage.C;
dTree.add(document,docPath,newInfo, resource, language);
return true;
}
public boolean initializeContents() {
if (this.contents == null) {
try {
IPath location = resource.getLocation();
if (location != null)
this.contents = org.eclipse.cdt.internal.core.Util.getFileCharContent(location.toFile(), null);
} catch (IOException e) {
}
}
return this.contents != null;
}
public String toString() {
return "calculating dependency for: " + this.resource.getFullPath(); //$NON-NLS-1$
}
public String[] getFileTypes(){
return FILE_TYPES;
}
public boolean shouldAddToTree(IDocument document) {
String type = document.getType();
String[] supportedTypes = this.getFileTypes();
for (int i = 0; i < supportedTypes.length; ++i) {
if (supportedTypes[i].equals(type))
return true;
}
return false;
}
}

View file

@ -1,423 +0,0 @@
/**********************************************************************
* Copyright (c) 2002,2003 Rational Software Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v0.5
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v05.html
*
* Contributors:
* IBM Rational Software - Initial API and implementation
***********************************************************************/
package org.eclipse.cdt.internal.core.sourcedependency;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import java.util.zip.CRC32;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.parser.IScannerInfo;
import org.eclipse.cdt.internal.core.CharOperation;
import org.eclipse.cdt.internal.core.search.SimpleLookupTable;
import org.eclipse.cdt.internal.core.search.indexing.ReadWriteMonitor;
import org.eclipse.cdt.internal.core.search.processing.JobManager;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.QualifiedName;
/**
* @author bgheorgh
*/
public class DependencyManager extends JobManager implements ISourceDependency {
/* number of file contents in memory */
public static int MAX_FILES_IN_MEMORY = 0;
public SimpleLookupTable projectNames = new SimpleLookupTable();
public SimpleLookupTable dependencyTable;
private Map dependencyTrees = new HashMap(5);
/* read write monitors */
private Map monitors = new HashMap(5);
/* need to save ? */
private boolean needToSave = false;
private static final CRC32 checksumCalculator = new CRC32();
private IPath ccorePluginLocation = null;
/* can only replace a current state if its less than the new one */
private SimpleLookupTable dTreeStates = null;
private File savedDTreesFile =
new File(getCCorePluginWorkingLocation().append("savedDTrees.txt").toOSString()); //$NON-NLS-1$
public static Integer SAVED_STATE = new Integer(0);
public static Integer UPDATING_STATE = new Integer(1);
public static Integer UNKNOWN_STATE = new Integer(2);
public static Integer REBUILDING_STATE = new Integer(3);
public static boolean VERBOSE = false;
public String processName(){
//TODO: BOG Add name to .properties file
return "Dependency Tree"; //org.eclipse.cdt.internal.core.search.Util.bind("process.name"); //$NON-NLS-1$
}
public void reset(){
super.reset();
//Get handles on the info providers
//register yourself for updates
if (this.dependencyTrees!= null) {
this.dependencyTrees = new HashMap(5);
this.monitors = new HashMap(5);
this.dTreeStates = null;
}
this.projectNames = new SimpleLookupTable();
this.dependencyTable = new SimpleLookupTable();
this.ccorePluginLocation = null;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.sourcedependency.ISourceDependency#getProjects(org.eclipse.core.resources.IFile)
*/
public IProject[] getProjects(IFile file) {
// TODO Auto-generated method stub
return null;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.sourcedependency.ISourceDependency#getFileDependencies(org.eclipse.core.resources.IProject, org.eclipse.core.resources.IFile)
*/
public synchronized String[] getFileDependencies(IProject project, IFile file) {
IPath path =project.getFullPath();
IDependencyTree dTree= this.getDependencyTree(path,true,false);
try{
if (dTree != null) {
//dTree.printIncludeEntries();
//dTree.printIndexedFiles();
String[] files = dTree.getFileDependencies(file.getFullPath());
return files;
}
}
catch(Exception e){}
return null;
}
public synchronized IDependencyTree getDependencyTree(IPath path, boolean reuseExistingFile, boolean createIfMissing) {
IDependencyTree dTree = (IDependencyTree) dependencyTrees.get(path);
if (dTree == null){
String treeName = computeTreeName(path);
Object state = getTreeStates().get(treeName);
Integer currentDTreeState = state == null ? UNKNOWN_STATE : (Integer) state;
if (currentDTreeState == UNKNOWN_STATE) {
// should only be reachable for query jobs
rebuildDTree(treeName, path);
return null;
}
// tree isn't cached, consider reusing an existing tree file
if (reuseExistingFile) {
File treeFile = new File(treeName);
if (treeFile.exists()) { // check before creating tree so as to avoid creating a new empty tree if file is missing
try {
dTree = new DependencyTree(treeName, "Tree for " + path.toOSString(), true /*reuse tree file*/); //$NON-NLS-1$
dependencyTrees.put(path, dTree);
monitors.put(dTree, new ReadWriteMonitor());
return dTree;
} catch (IOException e) {
// failed to read the existing file or its no longer compatible
if (currentDTreeState != REBUILDING_STATE) { // rebuild tree if existing file is corrupt, unless the tree is already being rebuilt
if (DependencyManager.VERBOSE)
JobManager.verbose("-> cannot reuse existing tree: "+ treeName +" path: "+path.toOSString()); //$NON-NLS-1$ //$NON-NLS-2$
rebuildDTree(treeName, path);
return null;
} else {
dTree = null; // will fall thru to createIfMissing & create a empty tree for the rebuild all job to populate
}
}
}
if (currentDTreeState == SAVED_STATE) { // rebuild tree if existing file is missing
rebuildDTree(treeName, path);
return null;
}
if (createIfMissing) {
try {
if (VERBOSE)
JobManager.verbose("-> create empty tree: "+treeName+" path: "+path.toOSString()); //$NON-NLS-1$ //$NON-NLS-2$
dTree = new DependencyTree(treeName, "Tree for " + path.toOSString(), false /*do not reuse tree file*/); //$NON-NLS-1$
dependencyTrees.put(path, dTree);
monitors.put(dTree, new ReadWriteMonitor());
return dTree;
} catch (IOException e) {
if (VERBOSE)
JobManager.verbose("-> unable to create empty tree: "+treeName+" path: "+path.toOSString()); //$NON-NLS-1$ //$NON-NLS-2$
// The file could not be created. Possible reason: the project has been deleted.
return null;
}
}
}
}
return dTree;
}
String computeTreeName(IPath path) {
String name = (String) projectNames.get(path);
if (name == null) {
String pathString = path.toOSString();
checksumCalculator.reset();
checksumCalculator.update(pathString.getBytes());
String fileName = Long.toString(checksumCalculator.getValue()) + ".depTree"; //$NON-NLS-1$
if (DependencyManager.VERBOSE)
JobManager.verbose("-> dependency tree name for " + pathString + " is " + fileName); //$NON-NLS-1$ //$NON-NLS-2$
name = getCCorePluginWorkingLocation().append(fileName).toOSString();
projectNames.put(path, name);
}
return name;
}
private IPath getCCorePluginWorkingLocation() {
if (this.ccorePluginLocation != null) return this.ccorePluginLocation;
return this.ccorePluginLocation = CCorePlugin.getDefault().getStateLocation();
}
/**
* DTree access is controlled through a read-write monitor so as
* to ensure there is no concurrent read and write operations
* (only concurrent reading is allowed).
*/
public ReadWriteMonitor getMonitorFor(IDependencyTree dTree){
return (ReadWriteMonitor) monitors.get(dTree);
}
private SimpleLookupTable getTreeStates() {
if (dTreeStates != null) return dTreeStates;
this.dTreeStates = new SimpleLookupTable();
char[] savedDTreeNames = readDTreeState();
if (savedDTreeNames.length > 0) {
char[][] names = CharOperation.splitOn('\n', savedDTreeNames);
for (int i = 0, l = names.length; i < l; i++) {
char[] name = names[i];
if (name.length > 0)
this.dTreeStates.put(new String(name), SAVED_STATE);
}
}
return this.dTreeStates;
}
private char[] readDTreeState() {
try {
return org.eclipse.cdt.internal.core.Util.getFileCharContent(savedDTreesFile, null);
} catch (IOException ignored) {
if (DependencyManager.VERBOSE)
JobManager.verbose("Failed to read saved dTree file names"); //$NON-NLS-1$
return new char[0];
}
}
private void rebuildDTree(String treeName, IPath path) {
Object target = org.eclipse.cdt.internal.core.Util.getTarget(ResourcesPlugin.getWorkspace().getRoot(), path, true);
if (target == null) return;
if (DependencyManager.VERBOSE)
JobManager.verbose("-> request to rebuild dTree: "+treeName+" path: "+path.toOSString()); //$NON-NLS-1$ //$NON-NLS-2$
updateTreeState(treeName, REBUILDING_STATE);
DependencyRequest request = null;
if (target instanceof IProject) {
IProject p = (IProject) target;
request = new EntireProjectDependencyTree(p, this);
}
if (request != null)
request(request);
}
/**
* Trigger addition of the entire content of a project
* Note: the actual operation is performed in background
*/
public void generateEntireDependencyTree(IProject project) {
if (CCorePlugin.getDefault() == null) return;
/******
*TODO: BOG Remove these methods once the depTree is
*fully integrated
*/
// if (!isEnabled(project)) return;
// check if the same request is not already in the queue
DependencyRequest request = new EntireProjectDependencyTree(project, this);
for (int i = this.jobEnd; i > this.jobStart; i--) // NB: don't check job at jobStart, as it may have already started (see http://bugs.eclipse.org/bugs/show_bug.cgi?id=32488)
if (request.equals(this.awaitingJobs[i])) return;
this.request(request);
}
private void updateTreeState(String treeName, Integer treeState) {
getTreeStates(); // ensure the states are initialized
if (treeState != null) {
if (treeState.equals(dTreeStates.get(treeName))) return; // not changed
dTreeStates.put(treeName, treeState);
} else {
if (!dTreeStates.containsKey(treeName)) return; // did not exist anyway
dTreeStates.removeKey(treeName);
}
BufferedWriter writer = null;
try {
writer = new BufferedWriter(new FileWriter(savedDTreesFile));
Object[] indexNames = dTreeStates.keyTable;
Object[] states = dTreeStates.valueTable;
for (int i = 0, l = states.length; i < l; i++) {
if (states[i] == SAVED_STATE) {
writer.write((String) indexNames[i]);
writer.write('\n');
}
}
} catch (IOException ignored) {
if (DependencyManager.VERBOSE)
JobManager.verbose("Failed to write saved dTree file names"); //$NON-NLS-1$
} finally {
if (writer != null) {
try {
writer.close();
} catch (IOException e) {}
}
}
if (DependencyManager.VERBOSE) {
String state = "?"; //$NON-NLS-1$
if (treeState == SAVED_STATE) state = "SAVED"; //$NON-NLS-1$
else if (treeState == UPDATING_STATE) state = "UPDATING"; //$NON-NLS-1$
else if (treeState == UNKNOWN_STATE) state = "UNKNOWN"; //$NON-NLS-1$
else if (treeState == REBUILDING_STATE) state = "REBUILDING"; //$NON-NLS-1$
JobManager.verbose("-> dTree state updated to: " + state + " for: "+treeName); //$NON-NLS-1$ //$NON-NLS-2$
}
}
public void jobWasCancelled(IPath path) {
Object o = this.dependencyTrees.get(path);
if (o instanceof IDependencyTree) {
this.monitors.remove(o);
this.dependencyTrees.remove(path);
}
updateTreeState(computeTreeName(path), UNKNOWN_STATE);
}
/**
* Trigger removal of a resource from a tree
* Note: the actual operation is performed in background
*/
public void remove(String resourceName, IPath indexedContainer){
//request(new RemoveFromIndex(resourceName, indexedContainer, this));
if (DependencyManager.VERBOSE)
JobManager.verbose("remove file from tree " + resourceName);
}
/**
* Removes the tree for a given path.
* This is a no-op if the tree did not exist.
*/
public synchronized void removeTree(IPath path) {
if (DependencyManager.VERBOSE)
JobManager.verbose("removing dependency tree " + path); //$NON-NLS-1$
String treeName = computeTreeName(path);
File indexFile = new File(treeName);
if (indexFile.exists())
indexFile.delete();
Object o = this.dependencyTrees.get(path);
if (o instanceof IDependencyTree)
this.monitors.remove(o);
this.dependencyTrees.remove(path);
updateTreeState(treeName, null);
}
public synchronized void addToTable(String fileName, IFile resource){
ArrayList projectContainer = (ArrayList) dependencyTable.get(fileName);
if (projectContainer == null) {
ArrayList newProjectContainer = new ArrayList();
newProjectContainer.add(resource.getLocation());
dependencyTable.put(fileName, newProjectContainer);
}
else {
if (!projectContainer.contains(resource.getLocation())){
projectContainer.add(resource.getLocation());
}
}
}
public synchronized void removeFromTable(String fileName, IPath refToRemove){
ArrayList projectContainer = (ArrayList) dependencyTable.get(fileName);
if (projectContainer != null) {
int index = projectContainer.indexOf(refToRemove);
projectContainer.remove(refToRemove);
}
}
public synchronized ArrayList getProjectDependsForFile(String fileName){
ArrayList projectContainer = (ArrayList) dependencyTable.get(fileName);
return projectContainer;
}
/**
* @param file
* @param path
* @param info
*/
public void addSource(IFile file, IPath path, IScannerInfo info) {
if (CCorePlugin.getDefault() == null) return;
AddFileToDependencyTree job = new AddFileToDependencyTree(file, path, this, info);
if (this.awaitingJobsCount() < MAX_FILES_IN_MEMORY) {
// reduces the chance that the file is open later on, preventing it from being deleted
if (!job.initializeContents()) return;
}
request(job);
}
// /*************
// *TODO: Remove these methods once the depTree is
// *fully integrated
// * START OF TEMP D-TREE ENABLE SECTION
// */
// final static String DEP_MODEL_ID = CCorePlugin.PLUGIN_ID + ".dependencytree";
// final static String ACTIVATION = "enable";
//
// static QualifiedName activationKey = new QualifiedName(DEP_MODEL_ID, ACTIVATION);
//
// public boolean isEnabled(IProject project) {
// String prop = null;
// try {
// if (project != null) {
// prop = project.getPersistentProperty(activationKey);
// }
// } catch (CoreException e) {
// }
// return ((prop != null) && prop.equalsIgnoreCase("true"));
// }
//
// public void setEnabled(IProject project, boolean on) {
// try {
// if (project != null) {
// Boolean newValue = new Boolean(on);
// Boolean oldValue = new Boolean(isEnabled(project));
// if (!oldValue.equals(newValue)) {
// project.setPersistentProperty(activationKey, newValue.toString());
// if (on) {
// generateEntireDependencyTree(project);
// } else {
// //remove(project);
// }
// }
// }
// } catch (CoreException e) {
// }
// }
//
// /************
// * END OF TEMP D-TREE ENABLE SECTION
// */
}

View file

@ -3,14 +3,27 @@
*/ */
package org.eclipse.cdt.internal.core.sourcedependency; package org.eclipse.cdt.internal.core.sourcedependency;
import java.io.IOException;
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.core.search.SearchEngine;
import org.eclipse.cdt.internal.core.index.IDocument;
import org.eclipse.cdt.internal.core.index.IIndex;
import org.eclipse.cdt.internal.core.index.impl.BlocksIndexInput;
import org.eclipse.cdt.internal.core.index.impl.IFileDocument;
import org.eclipse.cdt.internal.core.index.impl.IncludeEntry;
import org.eclipse.cdt.internal.core.index.impl.IndexInput;
import org.eclipse.cdt.internal.core.index.impl.IndexedFile;
import org.eclipse.cdt.internal.core.search.IndexSelector;
import org.eclipse.cdt.internal.core.search.indexing.IndexManager;
import org.eclipse.cdt.internal.core.search.indexing.ReadWriteMonitor;
import org.eclipse.cdt.internal.core.search.processing.IJob; import org.eclipse.cdt.internal.core.search.processing.IJob;
import org.eclipse.cdt.internal.core.search.processing.JobManager;
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.runtime.IProgressMonitor; import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.OperationCanceledException;
/** /**
* @author bgheorgh * @author bgheorgh
@ -20,13 +33,14 @@ public class DependencyQueryJob implements IJob {
IProject project; IProject project;
IFile file; IFile file;
ArrayList includeFiles; ArrayList includeFiles;
DependencyManager depManager; IndexManager indexManager;
protected DependencySelector depSelector; protected IndexSelector indexSelector;
protected long executionTime = 0;
public DependencyQueryJob(IProject project, IFile file, DependencyManager depMan, List includeFiles) { public DependencyQueryJob(IProject project, IFile file, IndexManager inMan, List includeFiles) {
this.project = project; this.project = project;
this.file = file; this.file = file;
this.depManager = depMan; this.indexManager = inMan;
this.includeFiles = (ArrayList) includeFiles; this.includeFiles = (ArrayList) includeFiles;
} }
@ -46,27 +60,167 @@ public class DependencyQueryJob implements IJob {
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.search.processing.IJob#execute(org.eclipse.core.runtime.IProgressMonitor) * @see org.eclipse.cdt.internal.core.search.processing.IJob#execute(org.eclipse.core.runtime.IProgressMonitor)
*/ */
public boolean execute(IProgressMonitor progress) { public boolean execute(IProgressMonitor progressMonitor) {
if ((project == null) ||(file == null)) return false; if ((project == null) ||(file == null)) return false;
//
if (progressMonitor != null && progressMonitor.isCanceled())
throw new OperationCanceledException();
boolean isComplete = COMPLETE;
executionTime = 0;
if (this.indexSelector == null) {
this.indexSelector =
new IndexSelector(SearchEngine.createWorkspaceScope(), null, false, this.indexManager);
}
IIndex[] searchIndexes = this.indexSelector.getIndexes();
try {
int max = searchIndexes.length;
if (progressMonitor != null) {
progressMonitor.beginTask("", max); //$NON-NLS-1$
}
for (int i = 0; i < max; i++) {
isComplete &= getFileDeps(searchIndexes[i], progressMonitor);
if (progressMonitor != null) {
if (progressMonitor.isCanceled()) {
throw new OperationCanceledException();
} else {
progressMonitor.worked(1);
}
}
}
if (JobManager.VERBOSE) {
JobManager.verbose("-> execution time: " + executionTime + "ms - " + this);//$NON-NLS-1$//$NON-NLS-2$
}
return isComplete;
} finally {
if (progressMonitor != null) {
progressMonitor.done();
}
}
}
String[] tempFiles = this.depManager.getFileDependencies(project,file); /**
if (tempFiles != null){ * @param index
for (int i=0; i<tempFiles.length; i++){ * @param progressMonitor
includeFiles.add(tempFiles[i]); * @return
*/
public boolean getFileDeps(IIndex index, IProgressMonitor progressMonitor){
if (progressMonitor != null && progressMonitor.isCanceled())
throw new OperationCanceledException();
// IIndex inMemIndex = indexManager.peekAtIndex(new Path(((Index)index).toString.substring("Index for ".length()).replace('\\','/')));
// if (inMemIndex != index) {
// System.out.println("SANITY CHECK: search job using obsolete index: ["+index+ "] instead of: ["+inMemIndex+"]");
// }
if (index == null)
return COMPLETE;
ReadWriteMonitor monitor = indexManager.getMonitorFor(index);
if (monitor == null)
return COMPLETE; // index got deleted since acquired
try {
monitor.enterRead(); // ask permission to read
/* if index has changed, commit these before querying */
if (index.hasChanged()) {
try {
monitor.exitRead(); // free read lock
monitor.enterWrite(); // ask permission to write
this.indexManager.saveIndex(index);
} catch (IOException e) {
return FAILED;
} finally {
monitor.exitWriteEnterRead(); // finished writing and reacquire read permission
} }
return true;
} }
return false; long start = System.currentTimeMillis();
//
IndexInput input = new BlocksIndexInput(index.getIndexFile());
try {
input.open();
findDep(input);
} finally {
input.close();
}
//
//String[] tempFiles = this.indexManager.getFileDependencies(project,file);
// if (tempFiles != null){
// System.out.println("DQJOB File Deps : " + tempFiles.length);
// for (int i=0; i<tempFiles.length; i++){
// includeFiles.add(tempFiles[i]);
// }
// }
executionTime += System.currentTimeMillis() - start;
return COMPLETE;
}
catch (IOException e){
return FAILED;
}
finally {
monitor.exitRead(); // finished reading
}
}
/**
* @param input
* @param includeFiles
*/
private void findDep(IndexInput input) throws IOException {
IDocument temp = new IFileDocument(file);
IndexedFile dude = input.getIndexedFile(temp);
if (dude == null) return;
int fileNum =dude.getFileNumber();
IncludeEntry[] tempEntries = input.queryIncludeEntries(fileNum);
if (tempEntries != null){
for (int r=0; r<tempEntries.length; r++){
char[] tempFile = tempEntries[r].getFile();
StringBuffer tempString = new StringBuffer();
tempString.append(tempFile);
includeFiles.add(tempString.toString());
}
}
//
// if (indexFile == null)
// return new String[0];
//
// int fileNum = indexFile.getFileNumber();
// IncludeEntry[] tempEntries = addsIndex.getIncludeEntries();
// for (int i=0; i<tempEntries.length; i++)
// {
// int[] fileRefs = tempEntries[i].getRefs();
// for (int j=0; j<fileRefs.length; j++)
// {
// if (fileRefs[j] == fileNum)
// {
// //System.out.println(filePath.toString() + " references " + y[i].toString());
// char[] tempFile = tempEntries[i].getFile();
// StringBuffer tempString = new StringBuffer();
// tempString.append(tempFile);
// tempFileReturn.add(tempString.toString());
// break;
// }
// }
// }
//
//
}
public String toString() {
return "searching for the dependencies of" + file.getName(); //$NON-NLS-1$
} }
/* (non-Javadoc) /* (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() {
if (this.depSelector == null) { // only check once. As long as this job is used, it will keep the same index picture if (this.indexSelector == 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.indexSelector = new IndexSelector(SearchEngine.createWorkspaceScope(), null, false, this.indexManager);
this.depSelector.getIndexes(); // will only cache answer if all indexes were available originally this.indexSelector.getIndexes(); // will only cache answer if all indexes were available originally
} }
return true; return true;
} }

View file

@ -1,64 +0,0 @@
/**********************************************************************
* Copyright (c) 2002,2003 Rational Software Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v0.5
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v05.html
*
* Contributors:
* IBM Rational Software - Initial API and implementation
***********************************************************************/
package org.eclipse.cdt.internal.core.sourcedependency;
import java.io.IOException;
import org.eclipse.cdt.internal.core.search.indexing.ReadWriteMonitor;
import org.eclipse.cdt.internal.core.search.processing.IJob;
import org.eclipse.core.runtime.IPath;
public abstract class DependencyRequest implements IJob {
protected boolean isCancelled = false;
protected DependencyManager manager;
protected IPath dependencyTreePath;
public DependencyRequest(IPath path, DependencyManager manager) {
this.dependencyTreePath = path;
this.manager = manager;
}
public DependencyRequest(DependencyManager manager) {
this.manager = manager;
}
public boolean belongsTo(String projectName) {
return projectName.equals(this.dependencyTreePath.segment(0));
}
public void cancel() {
this.manager.jobWasCancelled(this.dependencyTreePath);
this.isCancelled = true;
}
public boolean isReadyToRun() {
return true;
}
/*
* This code is assumed to be invoked while monitor has read lock
*/
protected void saveIfNecessary(IDependencyTree tree, ReadWriteMonitor monitor) throws IOException {
/* if tree has changed, commit these before querying */
if (tree.hasChanged()) {
try {
monitor.exitRead(); // free read lock
monitor.enterWrite(); // ask permission to write
//this.manager.saveTree(tree);
} finally {
monitor.exitWriteEnterRead(); // finished writing and reacquire read permission
}
}
}
protected Integer updatedIndexState() {
return DependencyManager.UPDATING_STATE;
}
}

View file

@ -1,60 +0,0 @@
/**********************************************************************
* Copyright (c) 2002,2003 Rational Software Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v0.5
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v05.html
*
* Contributors:
* IBM Rational Software - Initial API and implementation
***********************************************************************/
package org.eclipse.cdt.internal.core.sourcedependency;
import java.util.LinkedList;
import org.eclipse.cdt.core.parser.ast.IASTInclusion;
import org.eclipse.cdt.internal.core.index.IDocument;
import org.eclipse.cdt.internal.core.parser.NullSourceElementRequestor;
public class DependencyRequestor extends NullSourceElementRequestor {
PreprocessorOutput preprocessor;
IDocument document;
private IASTInclusion currentInclude = null;
private LinkedList includeStack = new LinkedList();
public DependencyRequestor(PreprocessorOutput p, IDocument doc){
this.preprocessor = p;
this.document = doc;
}
public void enterInclusion(IASTInclusion inclusion) {
//System.out.println("enterInclusion " + inclusion.getName());
//Get parent
IASTInclusion parent = peekInclude();
preprocessor.addInclude(inclusion, parent);
//Push on stack
pushInclude(inclusion);
}
public void exitInclusion(IASTInclusion inclusion) {
// TODO Auto-generated method stub
//System.out.println("Exit inclusion " + inclusion.getFullFileName());
//Pop
popInclude();
}
private void pushInclude( IASTInclusion inclusion ){
includeStack.addFirst( currentInclude );
currentInclude = inclusion;
}
private IASTInclusion popInclude(){
IASTInclusion oldInclude = currentInclude;
currentInclude = (includeStack.size() > 0 ) ? (IASTInclusion) includeStack.removeFirst() : null;
return oldInclude;
}
private IASTInclusion peekInclude(){
return currentInclude;
}
}

View file

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

View file

@ -1,195 +0,0 @@
/**********************************************************************
* Copyright (c) 2002,2003 Rational Software Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v0.5
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v05.html
*
* Contributors:
* IBM Rational Software - Initial API and implementation
***********************************************************************/
package org.eclipse.cdt.internal.core.sourcedependency;
import java.io.File;
import java.io.IOException;
import java.io.StringReader;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.cdt.core.parser.IPreprocessor;
import org.eclipse.cdt.core.parser.IScannerInfo;
import org.eclipse.cdt.core.parser.ParserLanguage;
import org.eclipse.cdt.core.parser.ParserFactory;
import org.eclipse.cdt.core.parser.ParserMode;
import org.eclipse.cdt.internal.core.index.IDocument;
import org.eclipse.cdt.internal.core.index.IQueryResult;
import org.eclipse.cdt.internal.core.index.impl.IndexedFile;
import org.eclipse.cdt.internal.core.sourcedependency.impl.InMemoryTree;
import org.eclipse.cdt.internal.core.sourcedependency.impl.IncludeEntry;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.IPath;
public class DependencyTree implements IDependencyTree {
/**
* Maximum size of the index in memory.
*/
public static final int MAX_FOOTPRINT= 1000000;
protected InMemoryTree addsTree;
public DependencyTree(String treeName, String string, boolean b) throws IOException{
super();
initialize();
}
public DependencyTree() throws IOException {
initialize();
}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.sourcedependency.IDependencyTree#empty()
*/
public void empty() throws IOException {
// TODO Auto-generated method stub
}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.sourcedependency.IDependencyTree#getIndexFile()
*/
public File getIndexFile() {
// TODO Auto-generated method stub
return null;
}
/**
* Returns the number of referencing files in this tree.
*/
public int getNumDocuments() throws IOException {
return addsTree.getNumFiles();
}
/**
* Returns the number of include entries in this tree.
* @return
* @throws IOException
*/
public int getNumIncludes() throws IOException {
return addsTree.getNumIncludes();
}
/**
* Returns the path corresponding to a given document number
*/
public String getPath(int documentNumber) throws IOException {
return null;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.sourcedependency.IDependencyTree#hasChanged()
*/
public boolean hasChanged() {
// TODO Auto-generated method stub
return false;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.sourcedependency.IDependencyTree#query(java.lang.String)
*/
public IQueryResult[] query(String word) throws IOException {
// TODO Auto-generated method stub
return null;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.sourcedependency.IDependencyTree#queryInDocumentNames(java.lang.String)
*/
public IQueryResult[] queryInDocumentNames(String word)
throws IOException {
// TODO Auto-generated method stub
return null;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.sourcedependency.IDependencyTree#save()
*/
public void save() throws IOException {
// TODO Auto-generated method stub
}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.sourcedependency.IDependencyTree#remove(java.lang.String)
*/
public void remove(String documentName) throws IOException {
//IndexedFile file= addsTree.getIndexedFile(documentName);
//if (file != null) {
//}
}
/**
* Add the file that will be preprocessed to the tree, create a new
* preprocessor output and preprocess!
*/
public void add(IDocument document, String docPath, IScannerInfo newInfo, IFile file, ParserLanguage language) throws IOException {
IndexedFile indexedFile= addsTree.getIndexedFile(document.getName());
//if (indexedFile != null)
//remove(indexedFile, 0);
PreprocessorOutput output= new PreprocessorOutput(addsTree, file);
DependencyRequestor depReq = new DependencyRequestor(output,document);
output.addDocument(document);
IPreprocessor preprocessor = ParserFactory.createPreprocessor( new StringReader( document.getStringContent() ),docPath , newInfo, ParserMode.COMPLETE_PARSE, language, depReq);
preprocessor.process();
}
/**
* Initialises the indexGenerator.
*/
public void initialize() throws IOException {
//initialisation of addsTree
addsTree= new InMemoryTree();
}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.sourcedependency.IDependencyTree#getFileDepencies(int)
*/
public String[] getFileDependencies(IPath filePath) throws IOException {
List tempFileReturn = new ArrayList();
IndexedFile indexFile = addsTree.getIndexedFile(filePath.toString());
if (indexFile == null)
return new String[0];
int fileNum = indexFile.getFileNumber();
IncludeEntry[] tempEntries = addsTree.getIncludeEntries();
for (int i=0; i<tempEntries.length; i++)
{
int[] fileRefs = tempEntries[i].getRefs();
for (int j=0; j<fileRefs.length; j++)
{
if (fileRefs[j] == fileNum)
{
//System.out.println(filePath.toString() + " references " + y[i].toString());
char[] tempFile = tempEntries[i].getFile();
StringBuffer tempString = new StringBuffer();
tempString.append(tempFile);
tempFileReturn.add(tempString.toString());
break;
}
}
}
return (String []) tempFileReturn.toArray(new String[tempFileReturn.size()]);
}
//TODO: BOG Debug Method Take out
public void printIncludeEntries(){
IncludeEntry[] tempEntries = addsTree.getIncludeEntries();
for (int i=0; i<tempEntries.length; i++){
System.out.println(tempEntries[i].toString());
}
}
//TODO: BOG Debug Method Take out
public void printIndexedFiles() {
IndexedFile[] tempFiles = addsTree.getIndexedFiles();
for (int i=0;i<tempFiles.length;i++){
System.out.println(tempFiles[i].toString());
}
}
/**
* Returns true if the in memory index reaches a critical size,
* to merge it with the index on the disk.
*/
protected boolean timeToMerge() {
return (addsTree.getFootprint() >= MAX_FOOTPRINT);
}
}

View file

@ -1,200 +0,0 @@
/**********************************************************************
* Copyright (c) 2002,2003 Rational Software Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v0.5
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v05.html
*
* Contributors:
* IBM Rational Software - Initial API and implementation
***********************************************************************/
package org.eclipse.cdt.internal.core.sourcedependency;
import java.util.HashSet;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.parser.IScannerInfo;
import org.eclipse.cdt.core.parser.IScannerInfoProvider;
import org.eclipse.cdt.internal.core.Util;
import org.eclipse.cdt.internal.core.index.IQueryResult;
import org.eclipse.cdt.internal.core.index.impl.IFileDocument;
import org.eclipse.cdt.internal.core.search.SimpleLookupTable;
import org.eclipse.cdt.internal.core.search.indexing.ReadWriteMonitor;
import org.eclipse.cdt.internal.core.search.processing.JobManager;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IResourceProxy;
import org.eclipse.core.resources.IResourceProxyVisitor;
import org.eclipse.core.resources.IWorkspaceRoot;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
/**
* @author bgheorgh
*/
public class EntireProjectDependencyTree extends DependencyRequest {
IProject project;
public EntireProjectDependencyTree(IProject project, DependencyManager manager) {
super(project.getFullPath(), manager);
this.project = project;
}
public boolean equals(Object o) {
if (o instanceof EntireProjectDependencyTree)
return this.project.equals(((EntireProjectDependencyTree) o).project);
return false;
}
public boolean execute(IProgressMonitor progressMonitor) {
if (progressMonitor != null && progressMonitor.isCanceled()) return true;
if (!project.isAccessible()) return true; // nothing to do
IDependencyTree dTree = this.manager.getDependencyTree(this.dependencyTreePath, true, /*reuse index file*/ true /*create if none*/);
if (dTree == null) return true;
ReadWriteMonitor monitor = this.manager.getMonitorFor(dTree);
if (monitor == null) return true; // tree got deleted since acquired
try {
monitor.enterRead(); // ask permission to read
saveIfNecessary(dTree, monitor);
IQueryResult[] results = dTree.queryInDocumentNames(""); // get all file names already stored in this project //$NON-NLS-1$
int max = results == null ? 0 : results.length;
final SimpleLookupTable indexedFileNames = new SimpleLookupTable(max == 0 ? 33 : max + 11);
final String OK = "OK"; //$NON-NLS-1$
final String DELETED = "DELETED"; //$NON-NLS-1$
for (int i = 0; i < max; i++)
indexedFileNames.put(results[i].getPath(), DELETED);
final long indexLastModified = max == 0 ? 0L : dTree.getIndexFile().lastModified();
IPath cProjectPath = project.getFullPath();
IWorkspaceRoot root = this.project.getWorkspace().getRoot();
IResource sourceFolder = root.findMember(cProjectPath);
if (this.isCancelled) return false;
if (sourceFolder != null) {
//collect output locations if source is project (see http://bugs.eclipse.org/bugs/show_bug.cgi?id=32041)
final HashSet outputs = new HashSet();
final boolean hasOutputs = !outputs.isEmpty();
final char[][] patterns = null;
if (max == 0) {
sourceFolder.accept(
new IResourceProxyVisitor() {
public boolean visit(IResourceProxy proxy) {
if (isCancelled) return false;
switch(proxy.getType()) {
case IResource.FILE :
// TODO: BOG Put the file name checking back
//if (Util.isCCFileName(proxy.getName())) {
IResource resource = proxy.requestResource();
if (resource.getLocation() != null && (patterns == null || !Util.isExcluded(resource, patterns))) {
String name = new IFileDocument((IFile) resource).getName();
indexedFileNames.put(name, resource);
}
//}
return false;
case IResource.FOLDER :
if (patterns != null && Util.isExcluded(proxy.requestResource(), patterns))
return false;
if (hasOutputs && outputs.contains(proxy.requestFullPath())) {
return false;
}
}
return true;
}
},
IResource.NONE
);
} else {
sourceFolder.accept(
new IResourceProxyVisitor() {
public boolean visit(IResourceProxy proxy) {
if (isCancelled) return false;
switch(proxy.getType()) {
case IResource.FILE :
// TODO: BOG Put the file name checking back
// if (Util.isCCFileName(proxy.getName())) {
IResource resource = proxy.requestResource();
IPath path = resource.getLocation();
if (path != null && (patterns == null || !Util.isExcluded(resource, patterns))) {
String name = new IFileDocument((IFile) resource).getName();
indexedFileNames.put(name,
indexedFileNames.get(name) == null || indexLastModified < path.toFile().lastModified()
? (Object) resource
: (Object) OK);
}
//}
return false;
case IResource.FOLDER :
if (patterns != null && Util.isExcluded(proxy.requestResource(), patterns))
return false;
if (hasOutputs && outputs.contains(proxy.requestFullPath())) {
return false;
}
}
return true;
}
},
IResource.NONE
);
}
}
Object[] names = indexedFileNames.keyTable;
Object[] values = indexedFileNames.valueTable;
boolean shouldSave = false;
for (int i = 0, length = names.length; i < length; i++) {
String name = (String) names[i];
if (name != null) {
if (this.isCancelled) return false;
Object value = values[i];
if (value != OK) {
shouldSave = true;
if (value == DELETED)
this.manager.remove(name, this.dependencyTreePath);
else{
IScannerInfo scanInfo = null;
IScannerInfoProvider provider = CCorePlugin.getDefault().getScannerInfoProvider(project);
if (provider != null){
scanInfo = provider.getScannerInformation(project);
}
this.manager.addSource((IFile) value, this.dependencyTreePath, scanInfo);
}
}
}
}
} catch (/*IO*/Exception e) {
if (DependencyManager.VERBOSE) {
JobManager.verbose("-> failed to generate tree " + this.project + " because of the following exception:"); //$NON-NLS-1$ //$NON-NLS-2$
e.printStackTrace();
}
this.manager.removeTree(this.dependencyTreePath);
return false;
} finally {
monitor.exitRead(); // free read lock
}
return true;
}
public int hashCode() {
return this.project.hashCode();
}
protected Integer updatedIndexState() {
return DependencyManager.REBUILDING_STATE;
}
public String toString() {
return "calculating dependency tree for project " + this.project.getFullPath(); //$NON-NLS-1$
}
}

View file

@ -1,85 +0,0 @@
/**********************************************************************
* Copyright (c) 2002,2003 Rational Software Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v0.5
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v05.html
*
* Contributors:
* IBM Rational Software - Initial API and implementation
***********************************************************************/
package org.eclipse.cdt.internal.core.sourcedependency;
import java.io.File;
import java.io.IOException;
import org.eclipse.cdt.core.parser.IScannerInfo;
import org.eclipse.cdt.core.parser.ParserLanguage;
import org.eclipse.cdt.internal.core.index.IDocument;
import org.eclipse.cdt.internal.core.index.IQueryResult;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.IPath;
public interface IDependencyTree {
/**
* Adds the given document to the index.
*/
void add(IDocument document, String docPath, IScannerInfo newInfo, IFile file, ParserLanguage language) throws IOException;
/**
* Empties the index.
*/
void empty() throws IOException;
/**
* Returns the index file on the disk.
*/
File getIndexFile();
/**
* Returns the number of documents indexed.
*/
int getNumDocuments() throws IOException;
/**
* Returns the number of unique words indexed.
*/
int getNumIncludes() throws IOException;
/**
* Returns the path corresponding to a given document number
*/
String getPath(int documentNumber) throws IOException;
/**
* Ansers true if has some changes to save.
*/
boolean hasChanged();
/**
* Returns the paths of the documents containing the given word.
*/
IQueryResult[] query(String word) throws IOException;
/**
* Returns the paths of the documents whose names contain the given word.
*/
IQueryResult[] queryInDocumentNames(String word) throws IOException;
/**
* Removes the corresponding document from the tree.
*/
void remove(String documentName) throws IOException;
/**
* Saves the index on the disk.
*/
void save() throws IOException;
/**
* Gets the files that are included by the passed in file.
*/
String[] getFileDependencies(IPath filePath) throws IOException;
// TODO: BOG Debug Method Take out
/**
* Prints all of the IncludeEntries for this project.
*/
public void printIncludeEntries();
// TODO: BOG Debug Method Take out
/**
* Prints all of the IndexedFiles for this project.
*/
public void printIndexedFiles();
}

View file

@ -1,20 +0,0 @@
/**********************************************************************
* Copyright (c) 2002,2003 Rational Software Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v0.5
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v05.html
*
* Contributors:
* IBM Rational Software - Initial API and implementation
***********************************************************************/
package org.eclipse.cdt.internal.core.sourcedependency;
import org.eclipse.cdt.internal.core.index.IDocument;
public interface IPreprocessorOutput {
public void addDocument(IDocument document);
public void addRef(char[] word);
public void addRef(String word);
}

View file

@ -1,19 +0,0 @@
/**********************************************************************
* Copyright (c) 2002,2003 Rational Software Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v0.5
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v05.html
*
* Contributors:
* IBM Rational Software - Initial API and implementation
***********************************************************************/
package org.eclipse.cdt.internal.core.sourcedependency;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
public interface ISourceDependency {
IProject[] getProjects(IFile file);
String[] getFileDependencies(IProject project, IFile file);
}

View file

@ -9,7 +9,7 @@
* IBM Corporation - initial API and implementation * IBM Corporation - initial API and implementation
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.core.sourcedependency.impl; package org.eclipse.cdt.internal.core.sourcedependency;
/** /**
* @author bgheorgh * @author bgheorgh

View file

@ -1,66 +0,0 @@
/**********************************************************************
* Copyright (c) 2002,2003 Rational Software Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v0.5
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v05.html
*
* Contributors:
* IBM Rational Software - Initial API and implementation
***********************************************************************/
package org.eclipse.cdt.internal.core.sourcedependency;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.parser.ast.IASTInclusion;
import org.eclipse.cdt.internal.core.index.IDocument;
import org.eclipse.cdt.internal.core.index.impl.IndexedFile;
import org.eclipse.cdt.internal.core.sourcedependency.impl.InMemoryTree;
import org.eclipse.core.resources.IFile;
public class PreprocessorOutput implements IPreprocessorOutput {
protected InMemoryTree tree;
protected IndexedFile indexedFile;
protected IDocument document;
protected IFile file;
public PreprocessorOutput(InMemoryTree tree, IFile file) {
this.tree = tree;
this.file = file;
}
public void addInclude(IASTInclusion inclusion, IASTInclusion parent){
addRef(inclusion.getFullFileName());
addRelatives(inclusion.getFullFileName(),(parent != null ) ? parent.getFullFileName() : null);
DependencyManager depMan = CCorePlugin.getDefault().getCoreModel().getDependencyManager();
depMan.addToTable(inclusion.getFullFileName(),this.file);
}
public void addRelatives(String inclusion, String parent) {
if (indexedFile == null) {
throw new IllegalStateException();
}
tree.addRelatives(indexedFile, inclusion, parent);
}
public void addDocument(IDocument document) {
if (indexedFile == null) {
indexedFile= tree.addDocument(document);
} else {
throw new IllegalStateException();
}
}
public void addRef(char[] word) {
if (indexedFile == null) {
throw new IllegalStateException();
}
tree.addRef(indexedFile, word);
}
public void addRef(String word) {
addRef(word.toCharArray());
}
}

View file

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

View file

@ -1,150 +0,0 @@
/*******************************************************************************
* Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.internal.core.sourcedependency.impl;
import org.eclipse.cdt.internal.core.index.IDocument;
import org.eclipse.cdt.internal.core.index.impl.IndexedFile;
import org.eclipse.cdt.internal.core.index.impl.IndexedFileHashedArray;
public class InMemoryTree {
/**
* hashtable of IncludeEntrys = includeFiles+numbers of the files they appear in.
*/
protected IncludeEntryHashedArray includes;
/**
* List of IndexedFiles = file name + a unique number.
*/
protected IndexedFileHashedArray files;
/**
* Size of the tree.
*/
protected long footprint;
private int lastId;
public InMemoryTree() {
init();
}
/**
* Initialises the fields of the tree
*/
public void init() {
includes= new IncludeEntryHashedArray(501);
files= new IndexedFileHashedArray(101);
footprint= 0;
lastId=0;
}
public IndexedFile addDocument(IDocument document) {
IndexedFile indexedFile= this.files.add(document);
this.footprint += indexedFile.footprint() + 4;
return indexedFile;
}
/**
* Adds the references of the include to the tree (reference = number of the file the include belongs to).
*/
protected void addRef(char[] include, int[] references) {
int size= references.length;
int i= 0;
while (i < size) {
if (references[i] != 0)
addRef(include, references[i]);
i++;
}
}
/**
* Looks if the include already exists to the tree and adds the fileNum to this include.
* If the include does not exist, it adds it to the tree.
*/
protected void addRef(char[] include, int fileNum) {
IncludeEntry entry= (IncludeEntry) this.includes.get(include);
if (entry == null) {
entry= new IncludeEntry(include, ++lastId);
entry.addRef(fileNum);
this.includes.add(entry);
} else {
this.footprint += entry.addRef(fileNum);
}
}
public void addRef(IndexedFile indexedFile, char[] include) {
addRef(include, indexedFile.getFileNumber());
}
public void addRef(IndexedFile indexedFile, String include) {
addRef(include.toCharArray(), indexedFile.getFileNumber());
}
/**
* Returns the indexed file with the given path, or null if such file does not exist.
*/
public IndexedFile getIndexedFile(String path) {
return files.get(path);
}
/**
* @see IIndex#getNumDocuments()
*/
public int getNumFiles() {
return files.size();
}
/**
* @see IIndex#getNumWords()
*/
public int getNumIncludes() {
return includes.elementSize;
}
/**
* Returns the include entry corresponding to the given include.
*/
protected IncludeEntry getIncludeEntry(char[] include) {
return (IncludeEntry) includes.get(include);
}
public void addRelatives(IndexedFile indexedFile, String inclusion, String parent) {
addRelatives(indexedFile.getFileNumber(),inclusion.toCharArray(),(parent != null ) ? parent.toCharArray() : null);
}
protected void addRelatives(int fileNumber, char[] inclusion, char[] parent) {
IncludeEntry childEntry=null;
IncludeEntry parentEntry=null;
if (inclusion != null)
childEntry= (IncludeEntry) this.includes.get(inclusion);
if (parent != null)
parentEntry= (IncludeEntry) this.includes.get(parent);
childEntry.addParent(fileNumber,(parentEntry!=null) ? parentEntry.getID() : -1);
if (parent!=null)
parentEntry.addChild(fileNumber,(childEntry!=null) ? childEntry.getID() : -1);
}
/**
* Returns the include entries contained in the hashtable of includes.
*/
public IncludeEntry[] getIncludeEntries() {
return this.includes.asArray();
}
public IndexedFile[] getIndexedFiles(){
return this.files.asArray();
}
/**
* Returns the footprint of the index.
*/
public long getFootprint() {
return this.footprint;
}
}

View file

@ -1,3 +1,35 @@
2003-09-25 Bogdan Gheorghe
Integrated the dependency service into the indexer. Changes
as follows:
org.eclipse.cdt.internal.core.index.impl:
* IIndex - added getFileDependencies methods
* IIndexerOutput - modified to allow dep inputs into the index
* BlocksIndexInput - modified to allow the reading of the new index (which includes dep entries)
* BlocksIndexOutput - added facilities to write includes to the index
* GammaCompressedIndexBlock - modified with addIncludeEntry() and nextEntry()
* IncludeEntry - new file
* IncludeEntryHashedArray - new file
* Index - Added getFileDepenendencies to query includeEntries from the index
* IndexBlock - modified to reflect changes in GammaCompressedIndexBlock
* IndexerOutput - added new methods from IIndexerOutput
* IndexInput - modified to allow reading of includes from index files
* IndexSummary - modified to save/read new format which contains include info
* InMemoryIndex - modified InMemoryIndex to keep track of includes
* MergeFactory - modified MergeFactory to accomodate new index file format
* SimpleIndexInput - modified to use the new functions for includes in InMemoryIndex
* Util - Added a quickSort for includeEntry[]
org.eclipse.cdt.internal.core.search.indexing:
* AbstractIndexer - modified to getResourceFile being indexed, added bestIncludePrefix
to find include table entries, addInclude() which accepts IASTInclusion node and adds it
to the index
* IIndexConstants - added includeRef constant
* IndexManager - got rid of all dependency table references
* SourceIndexer - modified to return resource being indexed
* SourceIndexerRequestor - Added inclusion handling code; stack for includes
2003-09-22 Bogdan Gheorghe 2003-09-22 Bogdan Gheorghe
Took out the old CTags Indexer. Modified IndexAllProject to get Took out the old CTags Indexer. Modified IndexAllProject to get

View file

@ -13,6 +13,9 @@ package org.eclipse.cdt.internal.core.index;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.IPath;
/** /**
* An IIndex is the interface used to generate an index file, and to make queries on * An IIndex is the interface used to generate an index file, and to make queries on
* this index. * this index.
@ -71,5 +74,11 @@ public interface IIndex {
* Saves the index on the disk. * Saves the index on the disk.
*/ */
void save() throws IOException; void save() throws IOException;
/**
* @param path
* @return
*/
String[] getFileDependencies(IPath path) throws IOException;
String[] getFileDependencies(IFile file) throws IOException;
} }

View file

@ -19,4 +19,8 @@ public interface IIndexerOutput {
public void addDocument(IDocument document); public void addDocument(IDocument document);
public void addRef(char[] word); public void addRef(char[] word);
public void addRef(String word); public void addRef(String word);
//For Dep Tree
public void addIncludeRef(char[] word);
public void addIncludeRef(String word);
public void addRelatives(String inclusion, String parent);
} }

View file

@ -31,6 +31,7 @@ public class BlocksIndexInput extends IndexInput {
protected int currentFileListBlockNum; protected int currentFileListBlockNum;
protected int currentIndexBlockNum; protected int currentIndexBlockNum;
protected IndexBlock currentIndexBlock; protected IndexBlock currentIndexBlock;
protected IndexBlock currentIncludeIndexBlock;
private RandomAccessFile raf; private RandomAccessFile raf;
protected File indexFile; protected File indexFile;
protected LRUCache blockCache; protected LRUCache blockCache;
@ -156,6 +157,12 @@ public class BlocksIndexInput extends IndexInput {
public int getNumWords() { public int getNumWords() {
return summary.getNumWords(); return summary.getNumWords();
} }
/**
* @see IndexInput#getNumIncludes()
*/
public int getNumIncludes() {
return summary.getNumIncludes();
}
/** /**
* @see IndexInput#getSource() * @see IndexInput#getSource()
*/ */
@ -169,6 +176,7 @@ public class BlocksIndexInput extends IndexInput {
clearCache(); clearCache();
setFirstFile(); setFirstFile();
setFirstWord(); setFirstWord();
setFirstInclude();
} }
/** /**
* @see IndexInput#moveToNextFile() * @see IndexInput#moveToNextFile()
@ -388,4 +396,79 @@ public class BlocksIndexInput extends IndexInput {
currentIndexBlock.nextEntry(currentWordEntry); currentIndexBlock.nextEntry(currentWordEntry);
} }
} }
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.index.impl.IndexInput#moveToNextIncludeEntry()
*/
public void moveToNextIncludeEntry() throws IOException {
includePosition++;
if (!hasMoreIncludes()) {
return;
}
//if end of the current block, we load the next one.
boolean endOfBlock= !currentIncludeIndexBlock.nextEntry(currentIncludeEntry);
if (endOfBlock) {
currentIncludeIndexBlock= getIndexBlock(++currentIndexBlockNum);
currentIncludeIndexBlock.nextEntry(currentWordEntry);
}
}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.index.impl.IndexInput#setFirstInclude()
*/
protected void setFirstInclude() throws IOException {
includePosition= 1;
if (getNumIncludes() > 0) {
currentIndexBlockNum= summary.getFirstIncludeBlockNum();
currentIncludeIndexBlock= getIndexBlock(currentIndexBlockNum);
currentIncludeEntry= new IncludeEntry(0);
currentIncludeIndexBlock.reset();
currentIncludeIndexBlock.nextEntry(currentIncludeEntry);
}
}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.index.impl.IndexInput#queryIncludeEntries()
*/
public IncludeEntry[] queryIncludeEntries() {
// TODO Auto-generated method stub
return null;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.index.impl.IndexInput#queryIncludeEntries(int)
*/
public IncludeEntry[] queryIncludeEntries(int fileNum) throws IOException {
open();
if (fileNum < 0) return null;
int[] blockNums = null;
blockNums = summary.getBlockNumsForIncludes();
if (blockNums == null || blockNums.length == 0) return null;
IncludeEntry[] entries = new IncludeEntry[5];
int count = 0;
for (int i = 0, max = blockNums.length; i < max; i++) {
IndexBlock block = getIndexBlock(blockNums[i]);
block.reset();
boolean found = false;
IncludeEntry entry = new IncludeEntry(0);
while (block.nextEntry(entry)) {
if (count == entries.length){
System.arraycopy(entries, 0, entries = new IncludeEntry[count*2], 0, count);
}
for (int j=0; j<entry.getNumRefs(); j++){
if (entry.getRef(j) == fileNum){
entries[count++] = new IncludeEntry(entry.getFile(),entry.getID());
break;
}
}
}
}
if (count == 0) return null;
if (count != entries.length){
System.arraycopy(entries, 0, entries = new IncludeEntry[count], 0, count);
}
return entries;
}
} }

View file

@ -23,18 +23,25 @@ import java.io.RandomAccessFile;
*/ */
public class BlocksIndexOutput extends IndexOutput { public class BlocksIndexOutput extends IndexOutput {
protected RandomAccessFile indexOut; protected RandomAccessFile indexOut;
protected int blockNum; protected int blockNum;
protected boolean opened= false; protected boolean opened= false;
protected File indexFile; protected File indexFile;
protected FileListBlock fileListBlock; protected FileListBlock fileListBlock;
protected IndexBlock indexBlock; protected IndexBlock indexBlock;
protected IndexBlock includeIndexBlock;
protected int numWords= 0; protected int numWords= 0;
protected IndexSummary summary;
protected int numFiles= 0; protected int numFiles= 0;
protected int numIncludes= 0;
protected IndexSummary summary;
protected boolean firstInBlock; protected boolean firstInBlock;
protected boolean firstIndexBlock; protected boolean firstIndexBlock;
protected boolean firstFileListBlock; protected boolean firstFileListBlock;
protected boolean firstIncludeIndexBlock;
public BlocksIndexOutput(File indexFile) { public BlocksIndexOutput(File indexFile) {
this.indexFile= indexFile; this.indexFile= indexFile;
@ -43,6 +50,7 @@ public class BlocksIndexOutput extends IndexOutput {
firstInBlock= true; firstInBlock= true;
firstIndexBlock= true; firstIndexBlock= true;
firstFileListBlock= true; firstFileListBlock= true;
firstIncludeIndexBlock=true;
} }
/** /**
* @see IndexOutput#addFile * @see IndexOutput#addFile
@ -92,6 +100,31 @@ public class BlocksIndexOutput extends IndexOutput {
addWord(entry); addWord(entry);
} }
} }
/**
* @see IndexOutput#addInclude
*/
public void addInclude(IncludeEntry entry) throws IOException {
if (firstIncludeIndexBlock) {
includeIndexBlock= new GammaCompressedIndexBlock(IIndexConstants.BLOCK_SIZE);
firstInBlock= true;
firstIncludeIndexBlock= false;
}
if (entry.getNumRefs() == 0)
return;
if (includeIndexBlock.addIncludeEntry(entry)) {
if (firstInBlock) {
summary.addFirstIncludeInBlock(entry.getFile(), blockNum);
firstInBlock= false;
}
numIncludes++;
} else {
if (includeIndexBlock.isEmpty()) {
return;
}
flushWords();
addInclude(entry);
}
}
/** /**
* @see IndexOutput#close * @see IndexOutput#close
*/ */
@ -110,6 +143,7 @@ public class BlocksIndexOutput extends IndexOutput {
summary.setNumFiles(numFiles); summary.setNumFiles(numFiles);
summary.setNumWords(numWords); summary.setNumWords(numWords);
summary.setNumIncludes(numIncludes);
indexOut.seek(blockNum * (long) IIndexConstants.BLOCK_SIZE); indexOut.seek(blockNum * (long) IIndexConstants.BLOCK_SIZE);
summary.write(indexOut); summary.write(indexOut);
indexOut.seek(0); indexOut.seek(0);
@ -141,6 +175,19 @@ public class BlocksIndexOutput extends IndexOutput {
indexBlock.clear(); indexBlock.clear();
firstInBlock= true; firstInBlock= true;
} }
}
/**
*
*/
public void flushIncludes() throws IOException {
if (!firstInBlock
&& includeIndexBlock != null) { // could have added a document without any indexed word, no block created yet
includeIndexBlock.flush();
includeIndexBlock.write(indexOut, blockNum++);
includeIndexBlock.clear();
firstInBlock= true;
}
} }
/** /**
* @see IndexOutput#getDestination * @see IndexOutput#getDestination
@ -156,10 +203,12 @@ public class BlocksIndexOutput extends IndexOutput {
summary= new IndexSummary(); summary= new IndexSummary();
numFiles= 0; numFiles= 0;
numWords= 0; numWords= 0;
numIncludes=0;
blockNum= 1; blockNum= 1;
firstInBlock= true; firstInBlock= true;
firstIndexBlock= true; firstIndexBlock= true;
firstFileListBlock= true; firstFileListBlock= true;
firstIncludeIndexBlock=true;
indexOut= new SafeRandomAccessFile(this.indexFile, "rw"); //$NON-NLS-1$ indexOut= new SafeRandomAccessFile(this.indexFile, "rw"); //$NON-NLS-1$
opened= true; opened= true;
} }

View file

@ -56,6 +56,43 @@ public class GammaCompressedIndexBlock extends IndexBlock {
prevRef= ref; prevRef= ref;
} }
} }
/**
* @see IndexBlock#addEntry
*/
public boolean addIncludeEntry(IncludeEntry entry) {
writeCodeStream.reset();
encodeEntry(entry, prevWord, writeCodeStream);
if (offset + writeCodeStream.byteLength() > this.blockSize - 2) {
return false;
}
byte[] bytes= writeCodeStream.toByteArray();
field.put(offset, bytes);
offset += bytes.length;
prevWord= entry.getFile();
return true;
}
/**
* @param entry
* @param prevWord
* @param writeCodeStream
*/
protected void encodeEntry(IncludeEntry entry, char[] prevWord, CodeByteStream codeStream) {
char[] file= entry.getFile();
int prefixLen= prevWord == null ? 0 : Util.prefixLength(prevWord, file);
codeStream.writeByte(prefixLen);
codeStream.writeUTF(file, prefixLen, file.length);
int n= entry.getNumRefs();
codeStream.writeGamma(n);
int prevRef= 0;
for (int i= 0; i < n; ++i) {
int ref= entry.getRef(i);
if (ref <= prevRef)
throw new IllegalArgumentException();
codeStream.writeGamma(ref - prevRef);
prevRef= ref;
}
}
/** /**
* @see IndexBlock#flush * @see IndexBlock#flush
*/ */
@ -106,6 +143,40 @@ public class GammaCompressedIndexBlock extends IndexBlock {
return false; return false;
} }
} }
/**
* @see IndexBlock#nextEntry
*/
public boolean nextEntry(IncludeEntry entry) {
try {
readCodeStream.reset(field.buffer(), offset);
int prefixLength= readCodeStream.readByte();
char[] file= readCodeStream.readUTF();
if (prevWord != null && prefixLength > 0) {
char[] temp= new char[prefixLength + file.length];
System.arraycopy(prevWord, 0, temp, 0, prefixLength);
System.arraycopy(file, 0, temp, prefixLength, file.length);
file= temp;
}
if (file.length == 0) {
return false;
}
entry.reset(file);
int n= readCodeStream.readGamma();
int prevRef= 0;
for (int i= 0; i < n; ++i) {
int ref= prevRef + readCodeStream.readGamma();
if (ref < prevRef)
throw new InternalError();
entry.addRef(ref);
prevRef= ref;
}
offset= readCodeStream.byteLength();
prevWord= file;
return true;
} catch (UTFDataFormatException e) {
return false;
}
}
/** /**
* @see IndexBlock#reset * @see IndexBlock#reset
*/ */
@ -114,5 +185,6 @@ public class GammaCompressedIndexBlock extends IndexBlock {
offset= 0; offset= 0;
prevWord= null; prevWord= null;
} }
} }

View file

@ -17,7 +17,7 @@ public interface IIndexConstants {
/** /**
* The signature of the index file. * The signature of the index file.
*/ */
public static final String SIGNATURE= "INDEX FILE 0.012"; //$NON-NLS-1$ public static final String SIGNATURE= "INDEX FILE 0.014"; //$NON-NLS-1$
/** /**
* The separator for files in the index file. * The separator for files in the index file.
*/ */

View file

@ -22,6 +22,10 @@ import org.eclipse.cdt.internal.core.index.IDocument;
public class InMemoryIndex { public class InMemoryIndex {
/**
* hashtable of IncludeEntrys = includeFiles+numbers of the files they appear in.
*/
protected IncludeEntryHashedArray includes;
/** /**
* hashtable of WordEntrys = words+numbers of the files they appear in. * hashtable of WordEntrys = words+numbers of the files they appear in.
*/ */
@ -35,9 +39,14 @@ public class InMemoryIndex {
*/ */
protected long footprint; protected long footprint;
private IncludeEntry[] sortedIncludeEntries;
private WordEntry[] sortedWordEntries; private WordEntry[] sortedWordEntries;
private IndexedFile[] sortedFiles; private IndexedFile[] sortedFiles;
private int lastId;
public InMemoryIndex() { public InMemoryIndex() {
includes= new IncludeEntryHashedArray(501);
init(); init();
} }
@ -47,6 +56,46 @@ public class InMemoryIndex {
this.sortedFiles = null; this.sortedFiles = null;
return indexedFile; return indexedFile;
} }
public void addIncludeRef(IndexedFile indexedFile, char[] include) {
addIncludeRef(include, indexedFile.getFileNumber());
}
public void addIncludeRef(IndexedFile indexedFile, String include) {
addIncludeRef(include.toCharArray(), indexedFile.getFileNumber());
}
/**
* Adds the references of the include to the tree (reference = number of the file the include belongs to).
*/
protected void addIncludeRef(char[] include, int[] references) {
int size= references.length;
int i= 0;
while (i < size) {
if (references[i] != 0)
addIncludeRef(include, references[i]);
i++;
}
}
/**
* Looks if the include already exists to the tree and adds the fileNum to this include.
* If the include does not exist, it adds it to the tree.
*/
protected void addIncludeRef(char[] include, int fileNum) {
IncludeEntry entry= (IncludeEntry) this.includes.get(include);
if (entry == null) {
entry= new IncludeEntry(include, ++lastId);
entry.addRef(fileNum);
this.includes.add(entry);
this.sortedIncludeEntries= null;
//TODO: BOG FIGURE OUT FOOTPRINT
//this.footprint += entry.getClass(); //footprint();
//
} else {
this.footprint += entry.addRef(fileNum);
}
}
/** /**
* Adds the references of the word to the index (reference = number of the file the word belongs to). * Adds the references of the word to the index (reference = number of the file the word belongs to).
*/ */
@ -83,18 +132,57 @@ public class InMemoryIndex {
public void addRef(IndexedFile indexedFile, String word) { public void addRef(IndexedFile indexedFile, String word) {
addRef(word.toCharArray(), indexedFile.getFileNumber()); addRef(word.toCharArray(), indexedFile.getFileNumber());
} }
public void addRelatives(IndexedFile indexedFile, String inclusion, String parent) {
addRelatives(indexedFile.getFileNumber(),inclusion.toCharArray(),(parent != null ) ? parent.toCharArray() : null);
}
protected void addRelatives(int fileNumber, char[] inclusion, char[] parent) {
IncludeEntry childEntry=null;
IncludeEntry parentEntry=null;
if (inclusion != null)
childEntry= (IncludeEntry) this.includes.get(inclusion);
if (parent != null)
parentEntry= (IncludeEntry) this.includes.get(parent);
childEntry.addParent(fileNumber,(parentEntry!=null) ? parentEntry.getID() : -1);
if (parent!=null)
parentEntry.addChild(fileNumber,(childEntry!=null) ? childEntry.getID() : -1);
}
/** /**
* Returns the footprint of the index. * Returns the footprint of the index.
*/ */
public long getFootprint() { public long getFootprint() {
return this.footprint; return this.footprint;
} }
/**
* Returns the indexed files contained in the hashtable of includes.
*/
public IndexedFile[] getIndexedFiles(){
return this.files.asArray();
}
/** /**
* Returns the indexed file with the given path, or null if such file does not exist. * Returns the indexed file with the given path, or null if such file does not exist.
*/ */
public IndexedFile getIndexedFile(String path) { public IndexedFile getIndexedFile(String path) {
return files.get(path); return files.get(path);
} }
/**
* Returns the include entries contained in the hashtable of includes.
*/
public IncludeEntry[] getIncludeEntries() {
return this.includes.asArray();
}
/**
* Returns the include entry corresponding to the given include.
*/
protected IncludeEntry getIncludeEntry(char[] include) {
return (IncludeEntry) includes.get(include);
}
/** /**
* @see IIndex#getNumDocuments() * @see IIndex#getNumDocuments()
*/ */
@ -107,6 +195,11 @@ public class InMemoryIndex {
public int getNumWords() { public int getNumWords() {
return words.elementSize; return words.elementSize;
} }
public int getNumIncludes() {
return includes.elementSize;
}
/** /**
* Returns the words contained in the hashtable of words, sorted by alphabetical order. * Returns the words contained in the hashtable of words, sorted by alphabetical order.
*/ */
@ -129,6 +222,17 @@ public class InMemoryIndex {
} }
return this.sortedWordEntries; return this.sortedWordEntries;
} }
/**
* Returns the include entries contained in the hashtable of includeas, sorted by alphabetical order.
*/
protected IncludeEntry[] getSortedIncludeEntries() {
if (this.sortedIncludeEntries == null) {
IncludeEntry[] includes= this.includes.asArray();
Util.sort(includes);
this.sortedIncludeEntries= includes;
}
return this.sortedIncludeEntries;
}
/** /**
* Returns the word entry corresponding to the given word. * Returns the word entry corresponding to the given word.
*/ */
@ -139,11 +243,14 @@ public class InMemoryIndex {
* Initialises the fields of the index * Initialises the fields of the index
*/ */
public void init() { public void init() {
includes= new IncludeEntryHashedArray(501);
words= new WordEntryHashedArray(501); words= new WordEntryHashedArray(501);
files= new IndexedFileHashedArray(101); files= new IndexedFileHashedArray(101);
footprint= 0; footprint= 0;
lastId=0;
sortedWordEntries= null; sortedWordEntries= null;
sortedFiles= null; sortedFiles= null;
sortedIncludeEntries=null;
} }
/** /**
* Saves the index in the given file. * Saves the index in the given file.

View file

@ -9,12 +9,13 @@
* IBM Corporation - initial API and implementation * IBM Corporation - initial API and implementation
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.core.sourcedependency.impl; package org.eclipse.cdt.internal.core.index.impl;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Iterator; import java.util.Iterator;
import org.eclipse.cdt.internal.core.CharOperation; import org.eclipse.cdt.internal.core.CharOperation;
import org.eclipse.cdt.internal.core.sourcedependency.Node;
/** /**
* @author bgheorgh * @author bgheorgh
@ -69,6 +70,51 @@ public class IncludeEntry {
fParent.add(newParent); fParent.add(newParent);
fNumParent++; fNumParent++;
} }
/**
* @param is
*/
public void addRefs(int[] refs) {
int[] newRefs= new int[fNumRefs + refs.length];
int pos1= 0;
int pos2= 0;
int posNew= 0;
int compare;
int r1= 0;
int r2= 0;
while (pos1 < fNumRefs || pos2 < refs.length) {
if (pos1 >= fNumRefs) {
r2= refs[pos2];
compare= -1;
} else if (pos2 >= refs.length) {
compare= 1;
r1= fRefs[pos1];
} else {
r1= fRefs[pos1];
r2= refs[pos2];
compare= r2 - r1;
}
if (compare > 0) {
newRefs[posNew]= r1;
posNew++;
pos1++;
} else {
if (r2 != 0) {
newRefs[posNew]= r2;
posNew++;
}
pos2++;
}
}
fRefs= newRefs;
fNumRefs= posNew;
/*for (int i = 0; i < refs.length; i++)
addRef(refs[i]);
int[] newRefs = new int[fNumRefs];
System.arraycopy(fRefs, 0, newRefs, 0, fNumRefs);
fRefs = newRefs;
Util.sort(fRefs);*/
}
public void addChild(int fileRef, int parentId){ public void addChild(int fileRef, int parentId){
Node newChild = new Node(fileRef,parentId); Node newChild = new Node(fileRef,parentId);
@ -102,7 +148,26 @@ public class IncludeEntry {
public char[] getFile() { public char[] getFile() {
return fFile; return fFile;
} }
/**
* Changes the references of the wordEntry to match the mapping. For example,<br>
* if the current references are [1 3 4]<br>
* and mapping is [1 2 3 4 5]<br>
* in references 1 becomes mapping[1] = 2, 3->4, and 4->5<br>
* => references = [2 4 5].<br>
*/
public void mapRefs(int[] mappings) {
int position= 0;
for (int i= 0; i < fNumRefs; i++) {
int map= mappings[fRefs[i]];
if (map != -1 && map != 0)
fRefs[position++]= map;
}
fNumRefs= position;
//to be changed!
System.arraycopy(fRefs, 0, (fRefs= new int[fNumRefs]), 0, fNumRefs);
Util.sort(fRefs);
}
/** /**
* Clears the includeEntry. * Clears the includeEntry.
*/ */
@ -155,5 +220,4 @@ public class IncludeEntry {
tempBuffer.append("} >"); tempBuffer.append("} >");
return tempBuffer.toString(); return tempBuffer.toString();
} }
} }

View file

@ -9,7 +9,7 @@
* IBM Corporation - initial API and implementation * IBM Corporation - initial API and implementation
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.core.sourcedependency.impl; package org.eclipse.cdt.internal.core.index.impl;
import org.eclipse.cdt.internal.core.CharOperation; import org.eclipse.cdt.internal.core.CharOperation;

View file

@ -12,7 +12,9 @@ package org.eclipse.cdt.internal.core.index.impl;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List;
import java.util.Map; import java.util.Map;
import org.eclipse.cdt.internal.core.index.IDocument; import org.eclipse.cdt.internal.core.index.IDocument;
@ -20,6 +22,8 @@ import org.eclipse.cdt.internal.core.index.IEntryResult;
import org.eclipse.cdt.internal.core.index.IIndex; import org.eclipse.cdt.internal.core.index.IIndex;
import org.eclipse.cdt.internal.core.index.IIndexer; import org.eclipse.cdt.internal.core.index.IIndexer;
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;
/** /**
* An Index is used to create an index on the disk, and to make queries. It uses a set of * An Index is used to create an index on the disk, and to make queries. It uses a set of
@ -167,6 +171,19 @@ public class Index implements IIndex {
input.close(); input.close();
} }
} }
/**
* @see IIndex#getNumWords
*/
public int getNumIncludes() throws IOException {
//save();
IndexInput input= new BlocksIndexInput(indexFile);
try {
input.open();
return input.getNumIncludes();
} finally {
input.close();
}
}
/** /**
* Returns the path corresponding to a given document number * Returns the path corresponding to a given document number
*/ */
@ -302,6 +319,63 @@ public class Index implements IIndex {
input.close(); input.close();
} }
} }
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.sourcedependency.IDependencyTree#getFileDepencies(int)
*/
public String[] getFileDependencies(IPath filePath) throws IOException {
// List tempFileReturn = new ArrayList();
//
// IndexedFile indexFile = addsIndex.getIndexedFile(filePath.toString());
//
// if (indexFile == null)
// return new String[0];
//
// int fileNum = indexFile.getFileNumber();
// IncludeEntry[] tempEntries = addsIndex.getIncludeEntries();
// for (int i=0; i<tempEntries.length; i++)
// {
// int[] fileRefs = tempEntries[i].getRefs();
// for (int j=0; j<fileRefs.length; j++)
// {
// if (fileRefs[j] == fileNum)
// {
// char[] tempFile = tempEntries[i].getFile();
// StringBuffer tempString = new StringBuffer();
// tempString.append(tempFile);
// tempFileReturn.add(tempString.toString());
// break;
// }
// }
// }
// return (String []) tempFileReturn.toArray(new String[tempFileReturn.size()]);
return null;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.index.IIndex#getFileDependencies(org.eclipse.core.resources.IFile)
*/
public String[] getFileDependencies(IFile file) throws IOException {
IndexInput input= new BlocksIndexInput(indexFile);
int fileNum=0;
List tempFileReturn = new ArrayList();
try {
IDocument temp = new IFileDocument(file);
input.open();
IndexedFile inFile = input.getIndexedFile(temp);
fileNum =inFile.getFileNumber();
IncludeEntry[] tempEntries = input.queryIncludeEntries(fileNum);
for (int i=0; i<tempEntries.length; i++)
{
char[] tempFile = tempEntries[i].getFile();
StringBuffer tempString = new StringBuffer();
tempString.append(tempFile);
tempFileReturn.add(tempString.toString());
}
}
finally{input.close();}
return (String []) tempFileReturn.toArray(new String[tempFileReturn.size()]);
}
/** /**
* @see IIndex#remove * @see IIndex#remove
*/ */
@ -361,4 +435,6 @@ public class Index implements IIndex {
str += "(length: "+ getIndexFile().length() +")"; //$NON-NLS-1$ //$NON-NLS-2$ str += "(length: "+ getIndexFile().length() +")"; //$NON-NLS-1$ //$NON-NLS-2$
return str; return str;
} }
} }

View file

@ -24,6 +24,10 @@ public abstract class IndexBlock extends Block {
* Adds the given wordEntry to the indexBlock. * Adds the given wordEntry to the indexBlock.
*/ */
public abstract boolean addEntry(WordEntry entry); public abstract boolean addEntry(WordEntry entry);
/**
* Adds the given wordEntry to the indexBlock.
*/
public abstract boolean addIncludeEntry(IncludeEntry entry);
/** /**
* @see Block#clear() * @see Block#clear()
*/ */
@ -69,6 +73,9 @@ public abstract class IndexBlock extends Block {
* Finds the next wordEntry and stores it in the given entry. * Finds the next wordEntry and stores it in the given entry.
*/ */
public abstract boolean nextEntry(WordEntry entry); public abstract boolean nextEntry(WordEntry entry);
public abstract boolean nextEntry(IncludeEntry entry);
public void reset() { public void reset() {
} }
} }

View file

@ -29,12 +29,14 @@ public abstract class IndexInput {
protected int filePosition; protected int filePosition;
protected WordEntry currentWordEntry; protected WordEntry currentWordEntry;
protected int wordPosition; protected int wordPosition;
protected IncludeEntry currentIncludeEntry;
protected int includePosition;
public IndexInput() { public IndexInput() {
super(); super();
wordPosition= 1; wordPosition= 1;
filePosition= 1; filePosition= 1;
includePosition= 1;
} }
/** /**
* clears the cache of this indexInput, if it keeps track of the information already read. * clears the cache of this indexInput, if it keeps track of the information already read.
@ -57,6 +59,14 @@ public abstract class IndexInput {
return null; return null;
return currentWordEntry; return currentWordEntry;
} }
/**
* Returns the current file the indexInput is pointing to in the index.
*/
public IncludeEntry getCurrentIncludeEntry() throws IOException {
if (!hasMoreIncludes())
return null;
return currentIncludeEntry;
}
/** /**
* Returns the position of the current file the input is pointing to in the index. * Returns the position of the current file the input is pointing to in the index.
*/ */
@ -82,6 +92,10 @@ public abstract class IndexInput {
* Returns the number of unique words in the index. * Returns the number of unique words in the index.
*/ */
public abstract int getNumWords(); public abstract int getNumWords();
/**
* Returns the number of unique words in the index.
*/
public abstract int getNumIncludes();
/** /**
* Returns the Object the input is reading from. It can be an IIndex, * Returns the Object the input is reading from. It can be an IIndex,
* a File, ... * a File, ...
@ -99,6 +113,12 @@ public abstract class IndexInput {
public boolean hasMoreWords() { public boolean hasMoreWords() {
return wordPosition <= getNumWords(); return wordPosition <= getNumWords();
} }
/**
* Returns true if the input has not reached the end of the index for the files.
*/
public boolean hasMoreIncludes() {
return includePosition <= getNumIncludes();
}
/** /**
* Moves the pointer on the current file to the next file in the index. * Moves the pointer on the current file to the next file in the index.
*/ */
@ -107,6 +127,10 @@ public abstract class IndexInput {
* Moves the pointer on the current word to the next file in the index. * Moves the pointer on the current word to the next file in the index.
*/ */
public abstract void moveToNextWordEntry() throws IOException; public abstract void moveToNextWordEntry() throws IOException;
/**
* Moves the pointer on the current include entry to the next file in the index.
*/
public abstract void moveToNextIncludeEntry() throws IOException;
/** /**
* Open the Source where the input gets the information from. * Open the Source where the input gets the information from.
*/ */
@ -121,6 +145,15 @@ public abstract class IndexInput {
* Returns the list of the files whose name contain the given word in the index. * Returns the list of the files whose name contain the given word in the index.
*/ */
public abstract IQueryResult[] queryInDocumentNames(String word) throws IOException; public abstract IQueryResult[] queryInDocumentNames(String word) throws IOException;
/**
* Returns the list of the files whose name contain the given word in the index.
*/
public abstract IncludeEntry[] queryIncludeEntries();
/**
* @param fileNum
* @return
*/
public abstract IncludeEntry[] queryIncludeEntries(int fileNum) throws IOException;
/** /**
* Set the pointer on the current file to the first file of the index. * Set the pointer on the current file to the first file of the index.
*/ */
@ -129,4 +162,10 @@ public abstract class IndexInput {
* Set the pointer on the current word to the first word of the index. * Set the pointer on the current word to the first word of the index.
*/ */
protected abstract void setFirstWord() throws IOException; protected abstract void setFirstWord() throws IOException;
/**
* Set the pointer on the current include to the first include of the index.
*/
protected abstract void setFirstInclude() throws IOException;
} }

View file

@ -31,6 +31,10 @@ public class IndexSummary {
* First word for each block. * First word for each block.
*/ */
protected ArrayList firstWordsInBlocks= new ArrayList(); protected ArrayList firstWordsInBlocks= new ArrayList();
/**
* First include for each block.
*/
protected ArrayList firstIncludesInBlocks= new ArrayList();
/** /**
* Number of files in the index. * Number of files in the index.
*/ */
@ -39,6 +43,10 @@ public class IndexSummary {
* Number of words in the index. * Number of words in the index.
*/ */
protected int numWords; protected int numWords;
/**
* Number of includes in the index.
*/
protected int numIncludes;
static class FirstFileInBlock { static class FirstFileInBlock {
IndexedFile indexedFile; IndexedFile indexedFile;
@ -53,8 +61,19 @@ public class IndexSummary {
} }
} }
static class FirstIncludeInBlock {
char[] file;
int blockNum;
public String toString(){
return "FirstIncludeInBlock: " + new String(file) + ", blockNum: " + blockNum; //$NON-NLS-1$ //$NON-NLS-2$
}
}
protected int firstWordBlockNum; protected int firstWordBlockNum;
protected boolean firstWordAdded= true; protected boolean firstWordAdded= true;
protected int firstIncludeBlockNum;
protected boolean firstIncludeBlockAdded= true;
/** /**
* Adds the given file as the first file for the given Block number. * Adds the given file as the first file for the given Block number.
*/ */
@ -77,6 +96,19 @@ public class IndexSummary {
entry.blockNum= blockNum; entry.blockNum= blockNum;
firstWordsInBlocks.add(entry); firstWordsInBlocks.add(entry);
} }
/**
* Adds the given include as the first include for the given Block number.
*/
public void addFirstIncludeInBlock(char[] file, int blockNum) {
if (firstIncludeBlockAdded) {
firstIncludeBlockNum= blockNum;
firstIncludeBlockAdded= false;
}
FirstIncludeInBlock entry= new FirstIncludeInBlock();
entry.file = file;
entry.blockNum= blockNum;
firstIncludesInBlocks.add(entry);
}
/** /**
* Returns the numbers of all the blocks * Returns the numbers of all the blocks
*/ */
@ -187,6 +219,14 @@ public class IndexSummary {
} }
return result; return result;
} }
public int[] getBlockNumsForIncludes() {
int max = firstIncludesInBlocks.size();
int[] blockNums = new int[max];
for (int i = 0; i < max; i++){
blockNums[i] = ((FirstIncludeInBlock)firstIncludesInBlocks.get(i)).blockNum;
}
return blockNums;
}
public int getFirstBlockLocationForPrefix(char[] prefix) { public int getFirstBlockLocationForPrefix(char[] prefix) {
int min = 0; int min = 0;
int size = firstWordsInBlocks.size(); int size = firstWordsInBlocks.size();
@ -229,6 +269,12 @@ public class IndexSummary {
public int getFirstWordBlockNum() { public int getFirstWordBlockNum() {
return firstWordBlockNum; return firstWordBlockNum;
} }
/**
* Returns the number of the first IndexBlock (containing words).
*/
public int getFirstIncludeBlockNum() {
return firstIncludeBlockNum;
}
/** /**
* Blocks are contiguous, so the next one is a potential candidate if its first word starts with * Blocks are contiguous, so the next one is a potential candidate if its first word starts with
* the given prefix * the given prefix
@ -252,13 +298,21 @@ public class IndexSummary {
public int getNumWords() { public int getNumWords() {
return numWords; return numWords;
} }
/**
* Returns the number of words contained in the index.
*/
public int getNumIncludes() {
return numIncludes;
}
/** /**
* Loads the summary in memory. * Loads the summary in memory.
*/ */
public void read(RandomAccessFile raf) throws IOException { public void read(RandomAccessFile raf) throws IOException {
numFiles= raf.readInt(); numFiles= raf.readInt();
numWords= raf.readInt(); numWords= raf.readInt();
numIncludes= raf.readInt();
firstWordBlockNum= raf.readInt(); firstWordBlockNum= raf.readInt();
firstIncludeBlockNum= raf.readInt();
int numFirstFiles= raf.readInt(); int numFirstFiles= raf.readInt();
for (int i= 0; i < numFirstFiles; ++i) { for (int i= 0; i < numFirstFiles; ++i) {
FirstFileInBlock entry= new FirstFileInBlock(); FirstFileInBlock entry= new FirstFileInBlock();
@ -275,6 +329,13 @@ public class IndexSummary {
entry.blockNum= raf.readInt(); entry.blockNum= raf.readInt();
firstWordsInBlocks.add(entry); firstWordsInBlocks.add(entry);
} }
int numIncludes = raf.readInt();
for (int i= 0; i < numIncludes; ++i) {
FirstIncludeInBlock entry= new FirstIncludeInBlock();
entry.file= raf.readUTF().toCharArray();
entry.blockNum= raf.readInt();
firstIncludesInBlocks.add(entry);
}
} }
/** /**
* Sets the number of files of the index. * Sets the number of files of the index.
@ -290,13 +351,21 @@ public class IndexSummary {
public void setNumWords(int numWords) { public void setNumWords(int numWords) {
this.numWords= numWords; this.numWords= numWords;
} }
/**
* Sets the number of includes of the index.
*/
public void setNumIncludes(int numIncs) {
this.numIncludes= numIncs;
}
/** /**
* Saves the summary on the disk. * Saves the summary on the disk.
*/ */
public void write(RandomAccessFile raf) throws IOException { public void write(RandomAccessFile raf) throws IOException {
raf.writeInt(numFiles); raf.writeInt(numFiles);
raf.writeInt(numWords); raf.writeInt(numWords);
raf.writeInt(numIncludes);
raf.writeInt(firstWordBlockNum); raf.writeInt(firstWordBlockNum);
raf.writeInt(firstIncludeBlockNum);
raf.writeInt(firstFilesInBlocks.size()); raf.writeInt(firstFilesInBlocks.size());
for (int i= 0, size= firstFilesInBlocks.size(); i < size; ++i) { for (int i= 0, size= firstFilesInBlocks.size(); i < size; ++i) {
FirstFileInBlock entry= (FirstFileInBlock) firstFilesInBlocks.get(i); FirstFileInBlock entry= (FirstFileInBlock) firstFilesInBlocks.get(i);
@ -310,6 +379,12 @@ public class IndexSummary {
raf.writeUTF(new String(entry.word)); raf.writeUTF(new String(entry.word));
raf.writeInt(entry.blockNum); raf.writeInt(entry.blockNum);
} }
raf.writeInt(firstIncludesInBlocks.size());
for (int i= 0, size= firstIncludesInBlocks.size(); i < size; ++i) {
FirstIncludeInBlock entry= (FirstIncludeInBlock) firstIncludesInBlocks.get(i);
raf.writeUTF(new String(entry.file));
raf.writeInt(entry.blockNum);
}
} }
} }

View file

@ -55,4 +55,23 @@ public class IndexerOutput implements IIndexerOutput {
public void addRef(String word) { public void addRef(String word) {
addRef(word.toCharArray()); addRef(word.toCharArray());
} }
public void addRelatives(String inclusion, String parent) {
if (indexedFile == null) {
throw new IllegalStateException();
}
index.addRelatives(indexedFile, inclusion, parent);
}
public void addIncludeRef(char[] word) {
if (indexedFile == null) {
throw new IllegalStateException();
}
index.addIncludeRef(indexedFile, word);
}
public void addIncludeRef(String word) {
addIncludeRef(word.toCharArray());
}
} }

View file

@ -79,6 +79,7 @@ public class MergeFactory {
//findChanges(); //findChanges();
mergeFiles(); mergeFiles();
mergeReferences(); mergeReferences();
mergeIncludes();
mergeOutput.flush(); mergeOutput.flush();
} finally { } finally {
//closes everything //closes everything
@ -96,6 +97,7 @@ public class MergeFactory {
protected void mergeFiles() throws IOException { protected void mergeFiles() throws IOException {
int positionInMerge= 1; int positionInMerge= 1;
int compare; int compare;
while (oldInput.hasMoreFiles() || addsInput.hasMoreFiles()) { while (oldInput.hasMoreFiles() || addsInput.hasMoreFiles()) {
IndexedFile file1= oldInput.getCurrentFile(); IndexedFile file1= oldInput.getCurrentFile();
IndexedFile file2= addsInput.getCurrentFile(); IndexedFile file2= addsInput.getCurrentFile();
@ -185,6 +187,45 @@ public class MergeFactory {
} }
mergeOutput.flushWords(); mergeOutput.flushWords();
} }
/**
* Merges the files of the 2 indexes in the new index, according to the changes
* recorded during mergeFiles().
*/
protected void mergeIncludes() throws IOException {
int compare;
while (oldInput.hasMoreIncludes() || addsInput.hasMoreIncludes()) {
IncludeEntry inc1= oldInput.getCurrentIncludeEntry();
IncludeEntry inc2= addsInput.getCurrentIncludeEntry();
if (inc1 == null && inc2 == null)
break;
if (inc1 == null)
compare= 1;
else if (inc2 == null)
compare= -1;
else
compare= Util.compare(inc1.getFile(), inc2.getFile());
if (compare < 0) {
inc1.mapRefs(mappingOld);
mergeOutput.addInclude(inc1);
oldInput.moveToNextIncludeEntry();
} else if (compare > 0) {
inc2.mapRefs(mappingAdds);
mergeOutput.addInclude(inc2);
addsInput.moveToNextIncludeEntry();
} else {
inc1.mapRefs(mappingOld);
inc2.mapRefs(mappingAdds);
inc1.addRefs(inc2.getRefs());
mergeOutput.addInclude(inc1);
addsInput.moveToNextIncludeEntry();
oldInput.moveToNextIncludeEntry();
}
}
mergeOutput.flushIncludes();
}
/** /**
* Records the deletion of one file. * Records the deletion of one file.
*/ */

View file

@ -23,6 +23,7 @@ import org.eclipse.cdt.internal.core.index.IQueryResult;
public class SimpleIndexInput extends IndexInput { public class SimpleIndexInput extends IndexInput {
protected WordEntry[] sortedWordEntries; protected WordEntry[] sortedWordEntries;
protected IncludeEntry[] sortedIncludes;
protected IndexedFile currentFile; protected IndexedFile currentFile;
protected IndexedFile[] sortedFiles; protected IndexedFile[] sortedFiles;
protected InMemoryIndex index; protected InMemoryIndex index;
@ -77,6 +78,12 @@ public class SimpleIndexInput extends IndexInput {
public int getNumFiles() { public int getNumFiles() {
return index.getNumFiles(); return index.getNumFiles();
} }
/**
* @see IndexInput#getNumIncludes()
*/
public int getNumIncludes() {
return sortedIncludes.length;
}
/** /**
* @see IndexInput#getNumWords() * @see IndexInput#getNumWords()
*/ */
@ -111,16 +118,27 @@ public class SimpleIndexInput extends IndexInput {
if (hasMoreWords()) if (hasMoreWords())
currentWordEntry= sortedWordEntries[wordPosition - 1]; currentWordEntry= sortedWordEntries[wordPosition - 1];
} }
/**
* @see IndexInput#moveToNextIncludeEntry()
*/
public void moveToNextIncludeEntry() throws IOException {
includePosition++;
if (hasMoreIncludes())
currentIncludeEntry= sortedIncludes[includePosition - 1];
}
/** /**
* @see IndexInput#open() * @see IndexInput#open()
*/ */
public void open() throws IOException { public void open() throws IOException {
sortedWordEntries= index.getSortedWordEntries(); sortedWordEntries= index.getSortedWordEntries();
sortedFiles= index.getSortedFiles(); sortedFiles= index.getSortedFiles();
sortedIncludes = index.getSortedIncludeEntries();
filePosition= 1; filePosition= 1;
wordPosition= 1; wordPosition= 1;
includePosition=1;
setFirstFile(); setFirstFile();
setFirstWord(); setFirstWord();
setFirstInclude();
} }
/** /**
* @see IndexInput#query(String) * @see IndexInput#query(String)
@ -173,5 +191,19 @@ public class SimpleIndexInput extends IndexInput {
if (sortedWordEntries.length > 0) if (sortedWordEntries.length > 0)
currentWordEntry= sortedWordEntries[0]; currentWordEntry= sortedWordEntries[0];
} }
/**
* @see IndexInput#setFirstInclude()
*/
protected void setFirstInclude() throws IOException {
includePosition=1;
if (sortedIncludes.length >0)
currentIncludeEntry=sortedIncludes[0];
}
public IncludeEntry[] queryIncludeEntries() {
return null;
}
public IncludeEntry[] queryIncludeEntries(int fileNum) throws IOException {
return null;
}
} }

View file

@ -195,6 +195,32 @@ public class Util {
quickSort(list, left, original_right); quickSort(list, left, original_right);
} }
} }
private static void quickSort(IncludeEntry[] list, int left, int right) {
int original_left= left;
int original_right= right;
char[] mid= list[(left + right) / 2].fFile;
do {
while (compare(list[left].fFile, mid) < 0) {
left++;
}
while (compare(mid, list[right].fFile) < 0) {
right--;
}
if (left <= right) {
IncludeEntry tmp= list[left];
list[left]= list[right];
list[right]= tmp;
left++;
right--;
}
} while (left <= right);
if (original_left < right) {
quickSort(list, original_left, right);
}
if (left < original_right) {
quickSort(list, left, original_right);
}
}
/** /**
* Reads in a string from the specified data input stream. The * Reads in a string from the specified data input stream. The
* string has been encoded using a modified UTF-8 format. * string has been encoded using a modified UTF-8 format.
@ -291,6 +317,10 @@ public class Util {
if (list.length > 1) if (list.length > 1)
quickSort(list, 0, list.length - 1); quickSort(list, 0, list.length - 1);
} }
public static void sort(IncludeEntry[] list) {
if (list.length > 1)
quickSort(list, 0, list.length - 1);
}
/** /**
* Writes a string to the given output stream using UTF-8 * Writes a string to the given output stream using UTF-8
* encoding in a machine-independent manner. * encoding in a machine-independent manner.

View file

@ -21,6 +21,7 @@ import org.eclipse.cdt.core.parser.ast.IASTEnumerationSpecifier;
import org.eclipse.cdt.core.parser.ast.IASTEnumerator; import org.eclipse.cdt.core.parser.ast.IASTEnumerator;
import org.eclipse.cdt.core.parser.ast.IASTField; import org.eclipse.cdt.core.parser.ast.IASTField;
import org.eclipse.cdt.core.parser.ast.IASTFunction; import org.eclipse.cdt.core.parser.ast.IASTFunction;
import org.eclipse.cdt.core.parser.ast.IASTInclusion;
import org.eclipse.cdt.core.parser.ast.IASTMacro; import org.eclipse.cdt.core.parser.ast.IASTMacro;
import org.eclipse.cdt.core.parser.ast.IASTMethod; import org.eclipse.cdt.core.parser.ast.IASTMethod;
import org.eclipse.cdt.core.parser.ast.IASTNamespaceDefinition; import org.eclipse.cdt.core.parser.ast.IASTNamespaceDefinition;
@ -33,6 +34,7 @@ import org.eclipse.cdt.internal.core.CharOperation;
import org.eclipse.cdt.internal.core.index.IDocument; import org.eclipse.cdt.internal.core.index.IDocument;
import org.eclipse.cdt.internal.core.index.IIndexer; import org.eclipse.cdt.internal.core.index.IIndexer;
import org.eclipse.cdt.internal.core.index.IIndexerOutput; import org.eclipse.cdt.internal.core.index.IIndexerOutput;
import org.eclipse.core.resources.IFile;
public abstract class AbstractIndexer implements IIndexer, IIndexConstants, ICSearchConstants { public abstract class AbstractIndexer implements IIndexer, IIndexConstants, ICSearchConstants {
@ -339,6 +341,10 @@ public abstract class AbstractIndexer implements IIndexer, IIndexConstants, ICSe
* Returns the file types the <code>IIndexer</code> handles. * Returns the file types the <code>IIndexer</code> handles.
*/ */
public abstract String[] getFileTypes(); public abstract String[] getFileTypes();
/**
* Returns the file types being indexed.
*/
public abstract IFile getResourceFile();
/** /**
* @see IIndexer#index(IDocument document, IIndexerOutput output) * @see IIndexer#index(IDocument document, IIndexerOutput output)
*/ */
@ -621,5 +627,33 @@ public abstract class AbstractIndexer implements IIndexer, IIndexConstants, ICSe
return bestPrefix( prefix, (char)0, macroName, null, matchMode, isCaseSenstive ); return bestPrefix( prefix, (char)0, macroName, null, matchMode, isCaseSenstive );
} }
/**
* @param _limitTo
* @param simpleName
* @param _matchMode
* @param _caseSensitive
* @return
*/
public static final char[] bestIncludePrefix( LimitTo limitTo, char[] incName, int matchMode, boolean isCaseSenstive ){
//since we only index macro declarations we already know the prefix
char [] prefix = null;
if( limitTo == REFERENCES ){
prefix = INCLUDE_REF;
} else {
return null;
}
return bestPrefix( prefix, (char)0, incName, null, matchMode, isCaseSenstive );
}
public void addInclude(IASTInclusion inclusion, IASTInclusion parent){
this.output.addIncludeRef(inclusion.getFullFileName());
this.output.addRelatives(inclusion.getFullFileName(),(parent != null ) ? parent.getFullFileName() : null);
//Add Dep Table entry
String[] incName = new String[1];
incName[0] = inclusion.getFullFileName();
this.output.addRef(encodeEntry(incName, INCLUDE_REF, INCLUDE_REF_LENGTH));
}
} }

View file

@ -62,6 +62,9 @@ public interface IIndexConstants {
char[] MACRO_DECL = "macroDecl/".toCharArray(); char[] MACRO_DECL = "macroDecl/".toCharArray();
int MACRO_DECL_LENGTH = 10; int MACRO_DECL_LENGTH = 10;
char[] INCLUDE_REF = "includeRef/".toCharArray();
int INCLUDE_REF_LENGTH = 11;
//a Var REF will be treated as a typeREF //a Var REF will be treated as a typeREF
//char[] VAR_REF= "varRef/".toCharArray(); //$NON-NLS-1$ //char[] VAR_REF= "varRef/".toCharArray(); //$NON-NLS-1$

View file

@ -14,6 +14,12 @@ package org.eclipse.cdt.internal.core.search.indexing;
import java.io.IOException; import java.io.IOException;
import java.util.HashSet; import java.util.HashSet;
import org.eclipse.cdt.internal.core.Util;
import org.eclipse.cdt.internal.core.index.IIndex;
import org.eclipse.cdt.internal.core.index.IQueryResult;
import org.eclipse.cdt.internal.core.index.impl.IFileDocument;
import org.eclipse.cdt.internal.core.search.SimpleLookupTable;
import org.eclipse.cdt.internal.core.search.processing.JobManager;
import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.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;
@ -23,16 +29,6 @@ import org.eclipse.core.resources.IWorkspaceRoot;
import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.cdt.core.model.ICProject;
import org.eclipse.cdt.internal.core.Util;
import org.eclipse.cdt.internal.core.index.IIndex;
import org.eclipse.cdt.internal.core.index.IQueryResult;
import org.eclipse.cdt.internal.core.index.impl.IFileDocument;
import org.eclipse.cdt.internal.core.search.processing.JobManager;
import org.eclipse.cdt.internal.core.search.SimpleLookupTable;
import org.eclipse.cdt.internal.core.model.CModel;
import org.eclipse.cdt.internal.core.model.CModelManager;
import org.eclipse.cdt.core.model.ICElement;
public class IndexAllProject extends IndexRequest { public class IndexAllProject extends IndexRequest {

View file

@ -35,9 +35,7 @@ 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;
import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.QualifiedName;
public class IndexManager extends JobManager implements IIndexConstants { public class IndexManager extends JobManager implements IIndexConstants {
@ -106,13 +104,6 @@ public class IndexManager extends JobManager implements IIndexConstants {
*/ */
public void addSource(IFile resource, IPath indexedContainer){ public void addSource(IFile resource, IPath indexedContainer){
/******
*TODO: BOG Remove these methods once the new indexer is
*fully integrated
*/
// IProject project= resource.getProject();
// if (!isEnabled(project)) return;
if (CCorePlugin.getDefault() == null) return; if (CCorePlugin.getDefault() == null) return;
AddCompilationUnitToIndex job = new AddCompilationUnitToIndex(resource, indexedContainer, this); AddCompilationUnitToIndex job = new AddCompilationUnitToIndex(resource, indexedContainer, this);
if (this.awaitingJobsCount() < MAX_FILES_IN_MEMORY) { if (this.awaitingJobsCount() < MAX_FILES_IN_MEMORY) {
@ -241,12 +232,6 @@ public class IndexManager extends JobManager implements IIndexConstants {
public void indexAll(IProject project) { public void indexAll(IProject project) {
if (CCorePlugin.getDefault() == null) return; if (CCorePlugin.getDefault() == null) return;
/******
*TODO: BOG Remove these methods once the new indexer is
*fully integrated
*/
// if (!isEnabled(project)) return;
// check if the same request is not already in the queue // check if the same request is not already in the queue
IndexRequest request = new IndexAllProject(project, this); IndexRequest request = new IndexAllProject(project, this);
for (int i = this.jobEnd; i > this.jobStart; i--) // NB: don't check job at jobStart, as it may have already started (see http://bugs.eclipse.org/bugs/show_bug.cgi?id=32488) for (int i = this.jobEnd; i > this.jobStart; i--) // NB: don't check job at jobStart, as it may have already started (see http://bugs.eclipse.org/bugs/show_bug.cgi?id=32488)
@ -258,11 +243,6 @@ public class IndexManager extends JobManager implements IIndexConstants {
*/ */
public void indexSourceFolder(CProject javaProject, IPath sourceFolder, final char[][] exclusionPattern) { public void indexSourceFolder(CProject javaProject, IPath sourceFolder, final char[][] exclusionPattern) {
IProject project = javaProject.getProject(); IProject project = javaProject.getProject();
/******
*TODO: BOG Remove these methods once the new indexer is
*fully integrated
*/
// if (!isEnabled(project)) return;
if (this.jobEnd > this.jobStart) { if (this.jobEnd > this.jobStart) {
// check if a job to index the project is not already in the queue // check if a job to index the project is not already in the queue
@ -320,13 +300,6 @@ public class IndexManager extends JobManager implements IIndexConstants {
IndexRequest request = null; IndexRequest request = null;
if (target instanceof IProject) { if (target instanceof IProject) {
IProject p = (IProject) target; IProject p = (IProject) target;
/******
*TODO: BOG Remove these methods once the new indexer is
*fully integrated
*/
// if (!isEnabled(p)) return;
//if (JavaProject.hasJavaNature(p))
request = new IndexAllProject(p, this); request = new IndexAllProject(p, this);
} }
@ -409,11 +382,6 @@ public class IndexManager extends JobManager implements IIndexConstants {
*/ */
public void removeSourceFolderFromIndex(CProject javaProject, IPath sourceFolder, char[][] exclusionPatterns) { public void removeSourceFolderFromIndex(CProject javaProject, IPath sourceFolder, char[][] exclusionPatterns) {
IProject project = javaProject.getProject(); IProject project = javaProject.getProject();
/******
*TODO: BOG Remove these methods once the new indexer is
*fully integrated
*/
// if (!isEnabled(project)) return;
if (this.jobEnd > this.jobStart) { if (this.jobEnd > this.jobStart) {
// check if a job to index the project is not already in the queue // check if a job to index the project is not already in the queue
@ -597,48 +565,4 @@ public class IndexManager extends JobManager implements IIndexConstants {
JobManager.verbose("-> index state updated to: " + state + " for: "+indexName); //$NON-NLS-1$ //$NON-NLS-2$ JobManager.verbose("-> index state updated to: " + state + " for: "+indexName); //$NON-NLS-1$ //$NON-NLS-2$
} }
} }
/*************
*TODO: BOG Remove these methods once the new indexer is
*fully integrated
* START OF TEMP INDEXER ENABLE SECTION
*/
// final static String INDEX_MODEL_ID = CCorePlugin.PLUGIN_ID + ".newindexmodel";
// final static String ACTIVATION = "enable";
//
// static QualifiedName activationKey = new QualifiedName(INDEX_MODEL_ID, ACTIVATION);
//
// public boolean isEnabled(IProject project) {
// String prop = null;
// try {
// if (project != null) {
// prop = project.getPersistentProperty(activationKey);
// }
// } catch (CoreException e) {
// }
// return ((prop != null) && prop.equalsIgnoreCase("true"));
// }
//
// public void setEnabled(IProject project, boolean on) {
// try {
// if (project != null) {
// Boolean newValue = new Boolean(on);
// Boolean oldValue = new Boolean(isEnabled(project));
// if (!oldValue.equals(newValue)) {
// project.setPersistentProperty(activationKey, newValue.toString());
// if (on) {
// indexAll(project);
// } else {
// //remove(project);
// }
// }
// }
// } catch (CoreException e) {
// }
// }
/************
* END OF TEMP INDEXER ENABLE SECTION
*/
} }

View file

@ -108,4 +108,10 @@ public class SourceIndexer extends AbstractIndexer {
*/ */
public void setFileTypes(String[] fileTypes){} public void setFileTypes(String[] fileTypes){}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.search.indexing.AbstractIndexer#getResourceFile()
*/
public IFile getResourceFile() {
return resourceFile;
}
} }

View file

@ -15,6 +15,8 @@ package org.eclipse.cdt.internal.core.search.indexing;
* @author bgheorgh * @author bgheorgh
*/ */
import java.util.LinkedList;
import org.eclipse.cdt.core.parser.IProblem; import org.eclipse.cdt.core.parser.IProblem;
import org.eclipse.cdt.core.parser.ISourceElementRequestor; import org.eclipse.cdt.core.parser.ISourceElementRequestor;
import org.eclipse.cdt.core.parser.ast.IASTASMDefinition; import org.eclipse.cdt.core.parser.ast.IASTASMDefinition;
@ -69,6 +71,9 @@ public class SourceIndexerRequestor implements ISourceElementRequestor, IIndexCo
int depth = 0; int depth = 0;
int methodDepth = 0; int methodDepth = 0;
private IASTInclusion currentInclude = null;
private LinkedList includeStack = new LinkedList();
public SourceIndexerRequestor(SourceIndexer indexer, IDocument document) { public SourceIndexerRequestor(SourceIndexer indexer, IDocument document) {
super(); super();
this.indexer = indexer; this.indexer = indexer;
@ -180,9 +185,10 @@ public class SourceIndexerRequestor implements ISourceElementRequestor, IIndexCo
public void enterInclusion(IASTInclusion inclusion) { public void enterInclusion(IASTInclusion inclusion) {
// TODO Auto-generated method stub // TODO Auto-generated method stub
//System.out.println("NEW INCLUSION \nInclusion short name: " + inclusion.getName()); IASTInclusion parent = peekInclude();
//System.out.println("Inclusion Long Name: " + inclusion.getFullFileName()); indexer.addInclude(inclusion, parent);
//System.out.println("enterInclusion"); //Push on stack
pushInclude(inclusion);
} }
/* (non-Javadoc) /* (non-Javadoc)
@ -342,8 +348,7 @@ public class SourceIndexerRequestor implements ISourceElementRequestor, IIndexCo
*/ */
public void exitInclusion(IASTInclusion inclusion) { public void exitInclusion(IASTInclusion inclusion) {
// TODO Auto-generated method stub // TODO Auto-generated method stub
//System.out.println("exitInclusion"); popInclude();
} }
/* (non-Javadoc) /* (non-Javadoc)
@ -455,4 +460,19 @@ public class SourceIndexerRequestor implements ISourceElementRequestor, IIndexCo
indexer.addParameterReference( (IASTParameterDeclaration) reference.getReferencedElement() ); indexer.addParameterReference( (IASTParameterDeclaration) reference.getReferencedElement() );
} }
private void pushInclude( IASTInclusion inclusion ){
includeStack.addFirst( currentInclude );
currentInclude = inclusion;
}
private IASTInclusion popInclude(){
IASTInclusion oldInclude = currentInclude;
currentInclude = (includeStack.size() > 0 ) ? (IASTInclusion) includeStack.removeFirst() : null;
return oldInclude;
}
private IASTInclusion peekInclude(){
return currentInclude;
}
} }

View file

@ -9,7 +9,6 @@ import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.internal.core.model.BatchOperation; import org.eclipse.cdt.internal.core.model.BatchOperation;
import org.eclipse.cdt.internal.core.model.CModelManager; import org.eclipse.cdt.internal.core.model.CModelManager;
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.core.resources.IFile; import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IFolder; import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IProject;
@ -226,12 +225,4 @@ public class CoreModel {
public IndexManager getIndexManager(){ public IndexManager getIndexManager(){
return manager.getIndexManager(); return manager.getIndexManager();
} }
public void startDependencyService() {
manager.getSourceDependencyManager().reset();
}
public DependencyManager getDependencyManager(){
return manager.getSourceDependencyManager();
}
} }

View file

@ -28,6 +28,7 @@ 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.IElementChangedListener; import org.eclipse.cdt.core.model.IElementChangedListener;
import org.eclipse.cdt.core.model.IParent; import org.eclipse.cdt.core.model.IParent;
import org.eclipse.cdt.internal.core.search.indexing.IndexManager;
import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IFolder; import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IProject;
@ -42,8 +43,6 @@ import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.cdt.internal.core.search.indexing.IndexManager;
import org.eclipse.cdt.internal.core.sourcedependency.DependencyManager;
public class CModelManager implements IResourceChangeListener { public class CModelManager implements IResourceChangeListener {
@ -783,9 +782,4 @@ public class CModelManager implements IResourceChangeListener {
// discard all indexing jobs for this project // discard all indexing jobs for this project
this.getIndexManager().discardJobs(project.getName()); this.getIndexManager().discardJobs(project.getName());
} }
public DependencyManager getSourceDependencyManager() {
return this.fDeltaProcessor.sourceDependencyManager;
}
} }

View file

@ -5,9 +5,6 @@ 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.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;
@ -18,18 +15,20 @@ 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.core.search.ICSearchConstants;
import org.eclipse.cdt.core.search.ICSearchScope;
import org.eclipse.cdt.core.search.SearchEngine;
import org.eclipse.cdt.internal.core.search.PathCollector;
import org.eclipse.cdt.internal.core.search.PatternSearchJob;
import org.eclipse.cdt.internal.core.search.indexing.IndexManager; import org.eclipse.cdt.internal.core.search.indexing.IndexManager;
import org.eclipse.cdt.internal.core.sourcedependency.DependencyManager; import org.eclipse.cdt.internal.core.search.matching.CSearchPattern;
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.resources.IWorkspaceRoot;
import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
/** /**
* This class is used by <code>CModelManager</code> to convert * This class is used by <code>CModelManager</code> to convert
@ -46,8 +45,6 @@ public class DeltaProcessor {
protected IndexManager indexManager = new IndexManager(); protected IndexManager indexManager = new IndexManager();
protected DependencyManager sourceDependencyManager = new DependencyManager();
/* The C element that was last created (see createElement(IResource). /* The C element that was last created (see createElement(IResource).
* This is used as a stack of C elements (using getParent() to pop it, and * This is used as a stack of C elements (using getParent() to pop it, and
* using the various get*(...) to push it. */ * using the various get*(...) to push it. */
@ -465,7 +462,6 @@ public class DeltaProcessor {
} }
protected void updateIndexAddResource(ICElement element, IResourceDelta delta) { protected void updateIndexAddResource(ICElement element, IResourceDelta delta) {
//CModelManager.getDefault().getIndexManager().addResource(delta.getResource());
if (indexManager == null) if (indexManager == null)
return; return;
@ -473,28 +469,18 @@ 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();
IProject filesProject = file.getProject(); IProject filesProject = file.getProject();
indexManager.addSource(file, filesProject.getFullPath()); 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;
} }
} }
protected void updateIndexRemoveResource(ICElement element, IResourceDelta delta) { protected void updateIndexRemoveResource(ICElement element, IResourceDelta delta) {
//CModelManager.getDefault().getIndexManager().removeResource(delta.getResource());
if (indexManager == null) if (indexManager == null)
return; return;
@ -503,7 +489,6 @@ 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
@ -511,7 +496,6 @@ 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;
} }
@ -519,7 +503,7 @@ public class DeltaProcessor {
} }
private void updateDependencies(ICElement element){ private void updateDependencies(ICElement element){
//Update table
IResource resource = element.getResource(); IResource resource = element.getResource();
if (resource == null) if (resource == null)
return; return;
@ -529,23 +513,30 @@ public class DeltaProcessor {
if ((fileExtension != null) && if ((fileExtension != null) &&
(fileExtension.equals("h") || (fileExtension.equals("h") ||
fileExtension.equals("hh") || fileExtension.equals("hh") ||
fileExtension.equals("hpp"))){ fileExtension.equals("hpp")))
{
if (sourceDependencyManager.getProjectDependsForFile(element.getResource().getLocation().toOSString()) == null){ PathCollector pathCollector = new PathCollector();
//retrigger dep trees //SubProgressMonitor subMonitor = (progressMonitor == null ) ? null : new SubProgressMonitor( progressMonitor, 5 );
sourceDependencyManager.performConcurrentJob(new DependencyQueryJob(null,null,sourceDependencyManager,null),ICSearchConstants.WAIT_UNTIL_READY_TO_SEARCH,null); ICSearchScope scope = SearchEngine.createWorkspaceScope();
} CSearchPattern pattern = CSearchPattern.createPattern(resource.getLocation().toOSString(),ICSearchConstants.INCLUDE, ICSearchConstants.REFERENCES,ICSearchConstants.EXACT_MATCH,true);
IndexManager indexManager = CCorePlugin.getDefault().getCoreModel().getIndexManager();
ArrayList projs =sourceDependencyManager.getProjectDependsForFile(element.getResource().getLocation().toOSString()); indexManager.performConcurrentJob(
if (projs != null){ new PatternSearchJob(
Iterator iter = projs.iterator(); (CSearchPattern) pattern,
while (iter.hasNext()){ scope,
IPath pathToReindex = (IPath) iter.next(); pathCollector,
indexManager
),
ICSearchConstants.WAIT_UNTIL_READY_TO_SEARCH,
null );
String[] iPath = pathCollector.getPaths();
for (int i=0;i<iPath.length; i++){
IPath pathToReindex = new Path(iPath[i]);
IWorkspaceRoot workRoot = element.getCProject().getProject().getWorkspace().getRoot(); IWorkspaceRoot workRoot = element.getCProject().getProject().getWorkspace().getRoot();
IFile fileToReindex = workRoot.getFileForLocation(pathToReindex); IFile fileToReindex = workRoot.getFile(pathToReindex);
if (fileToReindex.exists() ) { if (fileToReindex!=null && fileToReindex.exists() ) {
if (VERBOSE) if (VERBOSE)
System.out.println("Going to reindex " + fileToReindex.getName()); System.out.println("Going to reindex " + fileToReindex.getName());
this.indexManager.addSource(fileToReindex,fileToReindex.getProject().getProject().getFullPath()); this.indexManager.addSource(fileToReindex,fileToReindex.getProject().getProject().getFullPath());
@ -554,16 +545,3 @@ public class DeltaProcessor {
} }
} }
} }
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

@ -5,6 +5,13 @@
* search/org/eclipse/cdt/internal/core/search/matching/MatchLocator.java * search/org/eclipse/cdt/internal/core/search/matching/MatchLocator.java
* search/org/eclipse/cdt/internal/core/search/matching/CSearchPattern.java * search/org/eclipse/cdt/internal/core/search/matching/CSearchPattern.java
2003-09-25 Bogdan Gheorghe
- added SearchFor INCLUDE in ICSearchConstants
- added acceptIncludeDeclaration to IIndexSearchRequestor
- modified PathCollector to acceptIncludeDeclarations
- modified CSearchPattern to create an IncludePattern
- added IncludePattern.java
2003-09-25 Andrew Niefer 2003-09-25 Andrew Niefer
- partial fix for 43664 Modify Matchlocator to not try and create a link if we have no - partial fix for 43664 Modify Matchlocator to not try and create a link if we have no
resource, instead just use the path resource, instead just use the path

View file

@ -99,6 +99,9 @@ public interface ICSearchConstants {
public static final SearchFor TYPEDEF = new SearchFor( 12 ); public static final SearchFor TYPEDEF = new SearchFor( 12 );
public static final SearchFor INCLUDE = new SearchFor( 13 );
/* Nature of match */ /* Nature of match */
/** /**

View file

@ -82,4 +82,6 @@ void acceptFieldDeclaration(String resourcePath, char[] simpleTypeName, char[][]
void acceptMacroDeclaration(String resourcePath, char[] decodedSimpleName); void acceptMacroDeclaration(String resourcePath, char[] decodedSimpleName);
void acceptIncludeDeclaration(String resourcePath, char[] decodedSimpleName);
} }

View file

@ -156,6 +156,12 @@ import org.eclipse.core.runtime.Path;
public void acceptMacroDeclaration(String resourcePath, char[] decodedSimpleName) { public void acceptMacroDeclaration(String resourcePath, char[] decodedSimpleName) {
this.paths.add(resourcePath); this.paths.add(resourcePath);
} }
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.search.IIndexSearchRequestor#acceptIncludeDeclaration(java.lang.String, char[])
*/
public void acceptIncludeDeclaration(String resourcePath, char[] decodedSimpleName) {
this.paths.add(resourcePath);
}

View file

@ -23,8 +23,8 @@ import org.eclipse.cdt.core.parser.IParser;
import org.eclipse.cdt.core.parser.IQuickParseCallback; import org.eclipse.cdt.core.parser.IQuickParseCallback;
import org.eclipse.cdt.core.parser.IScanner; import org.eclipse.cdt.core.parser.IScanner;
import org.eclipse.cdt.core.parser.IToken; import org.eclipse.cdt.core.parser.IToken;
import org.eclipse.cdt.core.parser.ParserLanguage;
import org.eclipse.cdt.core.parser.ParserFactory; import org.eclipse.cdt.core.parser.ParserFactory;
import org.eclipse.cdt.core.parser.ParserLanguage;
import org.eclipse.cdt.core.parser.ParserMode; import org.eclipse.cdt.core.parser.ParserMode;
import org.eclipse.cdt.core.parser.ScannerException; import org.eclipse.cdt.core.parser.ScannerException;
import org.eclipse.cdt.core.parser.ast.ASTClassKind; import org.eclipse.cdt.core.parser.ast.ASTClassKind;
@ -103,11 +103,27 @@ public abstract class CSearchPattern implements ICSearchConstants, ICSearchPatte
pattern = createNamespacePattern( patternString, limitTo, matchMode, caseSensitive ); pattern = createNamespacePattern( patternString, limitTo, matchMode, caseSensitive );
} else if ( searchFor == MACRO ){ } else if ( searchFor == MACRO ){
pattern = createMacroPattern( patternString, limitTo, matchMode, caseSensitive ); pattern = createMacroPattern( patternString, limitTo, matchMode, caseSensitive );
} else if ( searchFor == INCLUDE){
pattern = createIncludePattern( patternString, limitTo, matchMode, caseSensitive);
} }
return pattern; return pattern;
} }
/**
* @param patternString
* @param limitTo
* @param matchMode
* @param caseSensitive
* @return
*/
private static CSearchPattern createIncludePattern(String patternString, LimitTo limitTo, int matchMode, boolean caseSensitive) {
if( limitTo != REFERENCES )
return null;
return new IncludePattern ( patternString.toCharArray(), matchMode, limitTo, caseSensitive );
}
/** /**
* @param patternString * @param patternString
* @param limitTo * @param limitTo

View file

@ -0,0 +1,105 @@
/**********************************************************************
* Copyright (c) 2002,2003 Rational Software Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v0.5
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v05.html
*
* Contributors:
* IBM Rational Software - Initial API and implementation
***********************************************************************/
package org.eclipse.cdt.internal.core.search.matching;
import java.io.IOException;
import org.eclipse.cdt.core.parser.ISourceElementCallbackDelegate;
import org.eclipse.cdt.core.search.ICSearchScope;
import org.eclipse.cdt.internal.core.CharOperation;
import org.eclipse.cdt.internal.core.index.IEntryResult;
import org.eclipse.cdt.internal.core.index.impl.IndexInput;
import org.eclipse.cdt.internal.core.index.impl.IndexedFile;
import org.eclipse.cdt.internal.core.search.IIndexSearchRequestor;
import org.eclipse.cdt.internal.core.search.indexing.AbstractIndexer;
/**
* @author bgheorgh
*/
public class IncludePattern extends CSearchPattern {
protected char [] simpleName;
protected char [] decodedSimpleName;
/**
*
*/
public IncludePattern(char[] name, int matchMode, LimitTo limitTo, boolean caseSensitive) {
super( matchMode, caseSensitive, limitTo );
simpleName = name;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.search.matching.CSearchPattern#decodeIndexEntry(org.eclipse.cdt.internal.core.index.IEntryResult)
*/
protected void decodeIndexEntry(IEntryResult entryResult) {
char[] word = entryResult.getWord();
int size = word.length;
int firstSlash = CharOperation.indexOf( SEPARATOR, word, 0 );
this.decodedSimpleName = CharOperation.subarray(word, firstSlash + 1, -1);
}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.search.matching.CSearchPattern#feedIndexRequestor(org.eclipse.cdt.internal.core.search.IIndexSearchRequestor, int, int[], org.eclipse.cdt.internal.core.index.impl.IndexInput, org.eclipse.cdt.core.search.ICSearchScope)
*/
public void feedIndexRequestor(IIndexSearchRequestor requestor, int detailLevel, int[] references, IndexInput input, ICSearchScope scope) throws IOException {
for (int i = 0, max = references.length; i < max; i++) {
IndexedFile file = input.getIndexedFile(references[i]);
String path;
if (file != null && scope.encloses(path =file.getPath())) {
requestor.acceptIncludeDeclaration(path, decodedSimpleName);
}
}
}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.search.matching.CSearchPattern#resetIndexInfo()
*/
protected void resetIndexInfo() {
decodedSimpleName = null;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.search.matching.CSearchPattern#indexEntryPrefix()
*/
public char[] indexEntryPrefix() {
return AbstractIndexer.bestIncludePrefix(
_limitTo,
simpleName,
_matchMode, _caseSensitive
);
}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.search.matching.CSearchPattern#matchIndexEntry()
*/
protected boolean matchIndexEntry() {
/* check simple name matches */
if (simpleName != null){
if( ! matchesName( simpleName, decodedSimpleName ) ){
return false;
}
}
return true;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.search.ICSearchPattern#matchLevel(org.eclipse.cdt.core.parser.ISourceElementCallbackDelegate, org.eclipse.cdt.core.search.ICSearchConstants.LimitTo)
*/
public int matchLevel(ISourceElementCallbackDelegate node, LimitTo limit) {
// TODO Auto-generated method stub
return 0;
}
}

View file

@ -32,7 +32,6 @@ 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.search.processing.JobManager;
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;
import org.eclipse.core.resources.IWorkspace; import org.eclipse.core.resources.IWorkspace;
@ -230,9 +229,6 @@ public class CCorePlugin extends Plugin {
//Fired up the indexer //Fired up the indexer
fCoreModel.startIndexing(); fCoreModel.startIndexing();
//Fire up dependency manager
fCoreModel.startDependencyService();
fDescriptorManager = new CDescriptorManager(); fDescriptorManager = new CDescriptorManager();
fDescriptorManager.startup(); fDescriptorManager.startup();
} }
@ -765,7 +761,6 @@ public class CCorePlugin extends Plugin {
private static final String SEARCH = CCorePlugin.PLUGIN_ID + "/debug/search" ; //$NON-NLS-1$ private static final String SEARCH = CCorePlugin.PLUGIN_ID + "/debug/search" ; //$NON-NLS-1$
private static final String MATCH_LOCATOR = CCorePlugin.PLUGIN_ID + "/debug/matchlocator" ; //$NON-NLS-1$ private static final String MATCH_LOCATOR = CCorePlugin.PLUGIN_ID + "/debug/matchlocator" ; //$NON-NLS-1$
private static final String PARSER = CCorePlugin.PLUGIN_ID + "/debug/parser" ; //$NON-NLS-1$ private static final String PARSER = CCorePlugin.PLUGIN_ID + "/debug/parser" ; //$NON-NLS-1$
private static final String DEPENDENCY = CCorePlugin.PLUGIN_ID + "/debug/dependency" ; //$NON-NLS-1$
private static final String DELTA = CCorePlugin.PLUGIN_ID + "/debug/deltaprocessor" ; private static final String DELTA = CCorePlugin.PLUGIN_ID + "/debug/deltaprocessor" ;
/** /**
* Configure the plugin with respect to option settings defined in ".options" file * Configure the plugin with respect to option settings defined in ".options" file
@ -779,13 +774,6 @@ 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);
if(option != null){
depFlag = option.equalsIgnoreCase("true");
DependencyManager.VERBOSE = depFlag;
}//$NON-NLS-1$
boolean indexFlag = false; boolean indexFlag = false;
option = Platform.getDebugOption(INDEX_MANAGER); option = Platform.getDebugOption(INDEX_MANAGER);
if(option != null) { if(option != null) {
@ -805,8 +793,7 @@ 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 || if (indexFlag == true){
depFlag == true){
JobManager.VERBOSE = true; JobManager.VERBOSE = true;
} }
} }

View file

@ -10,6 +10,13 @@
bug#43154: Code Assist Preferences: Enable Auto activation not working bug#43154: Code Assist Preferences: Enable Auto activation not working
bug#42224: Code Assist preferences Do not work properly bug#42224: Code Assist preferences Do not work properly
2003-09-25 Bogdan Gheorghe
Deleted the remaining CProjectPropertyPage artifacts.
* src/org/eclipse/cdt/internal/ui/preferences/CProjectOptionBlock.java
* src/org/eclipse/cdt/internal/ui/preferences/CProjectPropertyPage.java
* src/org/eclipse/cdt/ui/dialogs/IndexerBlock.java
2003-09-25 Hoda Amer 2003-09-25 Hoda Amer
Solution to bug#43646: Code Assist won't work if missing end bracket Solution to bug#43646: Code Assist won't work if missing end bracket

View file

@ -305,7 +305,7 @@ FileSearchActionInWorkingSet.description=Performs a text based file search for e
# ------- SearchDialogAction --------------- # ------- SearchDialogAction ---------------
SearchDialogAction.label=C/C++ Search Dialog... SearchDialogAction.label=C/C++ Search...
SearchDialogAction.tooltip=Opens C/C++ Search Dialog SearchDialogAction.tooltip=Opens C/C++ Search Dialog
SearchDialogAction.description=Opens C/C++ Search Dialog SearchDialogAction.description=Opens C/C++ Search Dialog

View file

@ -1,25 +0,0 @@
/*
* Created on 7-Aug-2003
*
* Copyright (c) 2002,2003 QNX Software Systems Ltd.
*
* Contributors:
* QNX Software Systems - Initial API and implementation
***********************************************************************/
package org.eclipse.cdt.internal.ui.preferences;
import org.eclipse.cdt.ui.dialogs.ICOptionContainer;
import org.eclipse.cdt.ui.dialogs.IndexerBlock;
import org.eclipse.cdt.ui.dialogs.TabFolderOptionBlock;
//TODO: BOG UI Get rid before final 1.2
public class CProjectOptionBlock extends TabFolderOptionBlock {
public CProjectOptionBlock(ICOptionContainer parent) {
super(parent);
}
protected void addTabs() {
addTab(new IndexerBlock());
}
}

View file

@ -1,120 +0,0 @@
package org.eclipse.cdt.internal.ui.preferences;
/*
* (c) Copyright IBM Corp. 2000, 2001.
* All Rights Reserved.
*/
import java.lang.reflect.InvocationTargetException;
import org.eclipse.cdt.ui.CUIPlugin;
import org.eclipse.cdt.ui.dialogs.ICOptionContainer;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jface.dialogs.ProgressMonitorDialog;
import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.actions.WorkspaceModifyDelegatingOperation;
import org.eclipse.ui.dialogs.PropertyPage;
//TODO: BOG UI Get rid before final 1.2
public class CProjectPropertyPage extends PropertyPage implements ICOptionContainer {
private CProjectOptionBlock fOptionBlock;
private static final String MSG_CLOSEDPROJECT = "CProjectPropertyPage.closedproject";
public CProjectPropertyPage() {
super();
fOptionBlock = new CProjectOptionBlock(this);
}
protected Control createContents(Composite parent) {
Composite composite = new Composite(parent, SWT.NONE);
composite.setLayout(new FillLayout());
IProject project = getProject();
if (!project.isOpen()) {
contentForClosedProject(composite);
} else {
contentForCProject(composite);
}
return composite;
}
private void contentForCProject(Composite parent) {
fOptionBlock.createContents(parent);
// WorkbenchHelp.setHelp(parent, ICMakeHelpContextIds.PROJECT_PROPERTY_PAGE);
}
private void contentForClosedProject(Composite parent) {
Label label = new Label(parent, SWT.LEFT);
label.setText(CUIPlugin.getResourceString(MSG_CLOSEDPROJECT));
label.setFont(parent.getFont());
noDefaultAndApplyButton();
}
/**
* @see PreferencePage#performOk
*/
public boolean performOk() {
Shell shell = getControl().getShell();
IRunnableWithProgress runnable = new IRunnableWithProgress() {
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
fOptionBlock.performApply(monitor);
}
};
IRunnableWithProgress op = new WorkspaceModifyDelegatingOperation(runnable);
try {
new ProgressMonitorDialog(shell).run(false, true, op);
} catch (InvocationTargetException e) {
return false;
} catch (InterruptedException e) {
// cancelled
return false;
}
return true;
}
public IProject getProject() {
Object element = getElement();
if (element instanceof IProject) {
return (IProject) element;
}
return null;
}
/**
* @see DialogPage#setVisible(boolean)
*/
public void setVisible(boolean visible) {
super.setVisible(visible);
fOptionBlock.setVisible(visible);
}
public void updateContainer() {
boolean ok = true;
ok = fOptionBlock.isValid();
if (!ok) {
setErrorMessage(fOptionBlock.getErrorMessage());
}
if (ok) {
setErrorMessage(null);
}
setValid(ok);
}
protected void performDefaults() {
fOptionBlock.performDefaults();
super.performDefaults();
}
public boolean isValid() {
updateContainer();
return super.isValid();
}
}

View file

@ -1,87 +0,0 @@
package org.eclipse.cdt.ui.dialogs;
/***********************************************************************
* Copyright (c) 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v0.5
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v05.html
*
* Contributors:
* QNX Software Systems - Initial API and implementation
***********************************************************************/
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.internal.core.search.indexing.IndexManager;
import org.eclipse.cdt.internal.core.sourcedependency.DependencyManager;
import org.eclipse.cdt.ui.CUIPlugin;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
//TODO: BOG UI Get rid before final 1.2
public class IndexerBlock extends AbstractCOptionPage {
private static final String PREFIX = "IndexerBlock"; // $NON-NLS-1$
private static final String LABEL = PREFIX + ".label"; // $NON-NLS-1$
private static final String DESC = PREFIX + ".desc"; // $NON-NLS-1$
private Button indexerSwitch2;
private Button dTreeSwitch;
public IndexerBlock() {
super(CUIPlugin.getResourceString(LABEL));
setDescription(CUIPlugin.getResourceString(DESC));
}
public void createControl(Composite parent) {
Composite composite = new Composite(parent, SWT.NONE);
GridLayout grid = new GridLayout();
grid.numColumns = 1;
composite.setLayout(grid);
indexerSwitch2 = new Button(composite, SWT.CHECK | SWT.RIGHT);
indexerSwitch2.setAlignment(SWT.LEFT);
indexerSwitch2.setText("Enable NEW indexing service for this project");
dTreeSwitch = new Button(composite, SWT.CHECK | SWT.RIGHT);
dTreeSwitch.setAlignment(SWT.LEFT);
dTreeSwitch.setText("Enable dependency tree service for this project");
IProject project = getContainer().getProject();
if (project != null) {
// IndexManager newIndexer = CCorePlugin.getDefault().getCoreModel().getIndexManager();
//
// if (indexerSwitch2 != null) {
// indexerSwitch2.setSelection(newIndexer.isEnabled(project));
// }
// DependencyManager depManager = CCorePlugin.getDefault().getCoreModel().getDependencyManager();
//
// if (dTreeSwitch != null) {
// dTreeSwitch.setSelection(depManager.isEnabled(project));
// }
}
setControl(composite);
}
public void performApply(IProgressMonitor monitor) throws CoreException {
IProject project = getContainer().getProject();
if (project != null) {
// IndexManager newIndexer = CCorePlugin.getDefault().getCoreModel().getIndexManager();
// newIndexer.setEnabled(project, indexerSwitch2.getSelection());
// DependencyManager depManager = CCorePlugin.getDefault().getCoreModel().getDependencyManager();
// depManager.setEnabled(project, dTreeSwitch.getSelection());
}
}
public void performDefaults() {
if (getContainer().getProject() != null) {
indexerSwitch2.setSelection(false);
dTreeSwitch.setSelection(false);
}
}
}