mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-11 02:05:39 +02:00
apply patch for 162172: make PDOM relocatable
This commit is contained in:
parent
ba0d37b4a8
commit
d6d9ed6df0
51 changed files with 826 additions and 349 deletions
|
@ -19,19 +19,18 @@ import org.eclipse.cdt.core.index.IIndex;
|
||||||
import org.eclipse.cdt.core.index.IIndexFile;
|
import org.eclipse.cdt.core.index.IIndexFile;
|
||||||
import org.eclipse.cdt.core.index.IIndexInclude;
|
import org.eclipse.cdt.core.index.IIndexInclude;
|
||||||
import org.eclipse.cdt.core.index.IIndexManager;
|
import org.eclipse.cdt.core.index.IIndexManager;
|
||||||
|
import org.eclipse.cdt.core.index.IndexLocationFactory;
|
||||||
import org.eclipse.cdt.core.model.CoreModel;
|
import org.eclipse.cdt.core.model.CoreModel;
|
||||||
import org.eclipse.cdt.core.model.ICProject;
|
import org.eclipse.cdt.core.model.ICProject;
|
||||||
import org.eclipse.cdt.internal.core.pdom.PDOM;
|
|
||||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMFile;
|
|
||||||
import org.eclipse.cdt.managedbuilder.core.IBuildObject;
|
import org.eclipse.cdt.managedbuilder.core.IBuildObject;
|
||||||
import org.eclipse.cdt.managedbuilder.core.ITool;
|
import org.eclipse.cdt.managedbuilder.core.ITool;
|
||||||
import org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyCalculator;
|
import org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyCalculator;
|
||||||
|
import org.eclipse.core.resources.IFile;
|
||||||
import org.eclipse.core.resources.IResource;
|
import org.eclipse.core.resources.IResource;
|
||||||
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.Path;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Doug Schaefer
|
* @author Doug Schaefer
|
||||||
*/
|
*/
|
||||||
public class PDOMDependencyCalculator implements IManagedDependencyCalculator {
|
public class PDOMDependencyCalculator implements IManagedDependencyCalculator {
|
||||||
|
@ -44,7 +43,7 @@ public class PDOMDependencyCalculator implements IManagedDependencyCalculator {
|
||||||
private IPath[] dependencies;
|
private IPath[] dependencies;
|
||||||
|
|
||||||
public PDOMDependencyCalculator(IPath source, IResource resource, IBuildObject buildContext, ITool tool, IPath topBuildDirectory) {
|
public PDOMDependencyCalculator(IPath source, IResource resource, IBuildObject buildContext, ITool tool, IPath topBuildDirectory) {
|
||||||
this.source = source;
|
this.source = source;
|
||||||
this.resource = resource;
|
this.resource = resource;
|
||||||
this.buildContext = buildContext;
|
this.buildContext = buildContext;
|
||||||
this.tool = tool;
|
this.tool = tool;
|
||||||
|
@ -60,16 +59,16 @@ public class PDOMDependencyCalculator implements IManagedDependencyCalculator {
|
||||||
if (resource != null) {
|
if (resource != null) {
|
||||||
ICProject project = CoreModel.getDefault().create(resource.getProject());
|
ICProject project = CoreModel.getDefault().create(resource.getProject());
|
||||||
try {
|
try {
|
||||||
IIndex index= CCorePlugin.getIndexManager().getIndex(project, IIndexManager.ADD_DEPENDENCIES);
|
IIndex index = CCorePlugin.getIndexManager().getIndex(project, IIndexManager.ADD_DEPENDENCIES);
|
||||||
index.acquireReadLock();
|
index.acquireReadLock();
|
||||||
try {
|
try {
|
||||||
IIndexFile file = index.getFile(resource.getLocation());
|
IIndexFile file = index.getFile(IndexLocationFactory.getWorkspaceIFL((IFile)resource));
|
||||||
if (file != null) {
|
if (file != null) {
|
||||||
IIndexInclude[] includes = index.findIncludes(file, IIndex.DEPTH_INFINITE);
|
IIndexInclude[] includes = index.findIncludes(file, IIndex.DEPTH_INFINITE);
|
||||||
|
|
||||||
List/*<IPath>*/ list = new ArrayList/*<IPath>*/();
|
List/*<IPath>*/ list = new ArrayList/*<IPath>*/();
|
||||||
for (int i = 0; i < includes.length; ++i)
|
for (int i = 0; i < includes.length; ++i)
|
||||||
list.add(new Path(includes[i].getIncludesLocation()));
|
list.add(IndexLocationFactory.getAbsolutePath(includes[i].getIncludesLocation()));
|
||||||
|
|
||||||
dependencies = (IPath[])list.toArray(new IPath[list.size()]);
|
dependencies = (IPath[])list.toArray(new IPath[list.size()]);
|
||||||
} else
|
} else
|
||||||
|
|
|
@ -29,6 +29,7 @@ import org.eclipse.cdt.core.index.IIndexInclude;
|
||||||
import org.eclipse.cdt.core.index.IIndexMacro;
|
import org.eclipse.cdt.core.index.IIndexMacro;
|
||||||
import org.eclipse.cdt.core.index.IIndexName;
|
import org.eclipse.cdt.core.index.IIndexName;
|
||||||
import org.eclipse.cdt.core.index.IndexFilter;
|
import org.eclipse.cdt.core.index.IndexFilter;
|
||||||
|
import org.eclipse.cdt.core.index.IndexLocationFactory;
|
||||||
import org.eclipse.cdt.core.model.ICProject;
|
import org.eclipse.cdt.core.model.ICProject;
|
||||||
import org.eclipse.cdt.core.model.ITranslationUnit;
|
import org.eclipse.cdt.core.model.ITranslationUnit;
|
||||||
import org.eclipse.cdt.core.testplugin.CProjectHelper;
|
import org.eclipse.cdt.core.testplugin.CProjectHelper;
|
||||||
|
@ -195,13 +196,13 @@ public class IndexBugsTests extends BaseTestCase {
|
||||||
|
|
||||||
fIndex.acquireReadLock();
|
fIndex.acquireReadLock();
|
||||||
try {
|
try {
|
||||||
IIndexFile ifile= fIndex.getFile(file.getLocation());
|
IIndexFile ifile= fIndex.getFile(IndexLocationFactory.getWorkspaceIFL(file));
|
||||||
assertNotNull(ifile);
|
assertNotNull(ifile);
|
||||||
IIndexInclude[] includes= ifile.getIncludes();
|
IIndexInclude[] includes= ifile.getIncludes();
|
||||||
assertEquals(1, includes.length);
|
assertEquals(1, includes.length);
|
||||||
IIndexInclude i= includes[0];
|
IIndexInclude i= includes[0];
|
||||||
assertEquals(file.getLocation().toOSString(), i.getIncludedByLocation());
|
assertEquals(file.getLocationURI(), i.getIncludedByLocation().getURI());
|
||||||
assertEquals(include.getLocation().toOSString(), i.getIncludesLocation());
|
assertEquals(include.getLocationURI(), i.getIncludesLocation().getURI());
|
||||||
assertEquals(true, i.isSystemInclude());
|
assertEquals(true, i.isSystemInclude());
|
||||||
assertEquals(0, i.getNameOffset());
|
assertEquals(0, i.getNameOffset());
|
||||||
assertEquals(0, i.getNameLength());
|
assertEquals(0, i.getNameLength());
|
||||||
|
@ -225,13 +226,13 @@ public class IndexBugsTests extends BaseTestCase {
|
||||||
|
|
||||||
fIndex.acquireReadLock();
|
fIndex.acquireReadLock();
|
||||||
try {
|
try {
|
||||||
IIndexFile ifile= fIndex.getFile(file.getLocation());
|
IIndexFile ifile= fIndex.getFile(IndexLocationFactory.getWorkspaceIFL(file));
|
||||||
assertNotNull(ifile);
|
assertNotNull(ifile);
|
||||||
IIndexInclude[] includes= ifile.getIncludes();
|
IIndexInclude[] includes= ifile.getIncludes();
|
||||||
assertEquals(1, includes.length);
|
assertEquals(1, includes.length);
|
||||||
IIndexInclude i= includes[0];
|
IIndexInclude i= includes[0];
|
||||||
assertEquals(file.getLocation().toOSString(), i.getIncludedByLocation());
|
assertEquals(file.getLocationURI(), i.getIncludedByLocation().getURI());
|
||||||
assertEquals(include.getLocation().toOSString(), i.getIncludesLocation());
|
assertEquals(include.getLocationURI(), i.getIncludesLocation().getURI());
|
||||||
assertEquals(true, i.isSystemInclude());
|
assertEquals(true, i.isSystemInclude());
|
||||||
assertEquals(0, i.getNameOffset());
|
assertEquals(0, i.getNameOffset());
|
||||||
assertEquals(0, i.getNameLength());
|
assertEquals(0, i.getNameLength());
|
||||||
|
@ -257,7 +258,7 @@ public class IndexBugsTests extends BaseTestCase {
|
||||||
|
|
||||||
fIndex.acquireReadLock();
|
fIndex.acquireReadLock();
|
||||||
try {
|
try {
|
||||||
IIndexFile ifile= fIndex.getFile(file.getLocation());
|
IIndexFile ifile= fIndex.getFile(IndexLocationFactory.getWorkspaceIFL(file));
|
||||||
assertNotNull(ifile);
|
assertNotNull(ifile);
|
||||||
IIndexMacro[] macros= ifile.getMacros();
|
IIndexMacro[] macros= ifile.getMacros();
|
||||||
assertEquals(2, macros.length);
|
assertEquals(2, macros.length);
|
||||||
|
|
|
@ -23,6 +23,7 @@ import org.eclipse.cdt.core.index.IIndexBinding;
|
||||||
import org.eclipse.cdt.core.index.IIndexFile;
|
import org.eclipse.cdt.core.index.IIndexFile;
|
||||||
import org.eclipse.cdt.core.index.IIndexInclude;
|
import org.eclipse.cdt.core.index.IIndexInclude;
|
||||||
import org.eclipse.cdt.core.index.IndexFilter;
|
import org.eclipse.cdt.core.index.IndexFilter;
|
||||||
|
import org.eclipse.cdt.core.index.IndexLocationFactory;
|
||||||
import org.eclipse.cdt.core.model.CoreModel;
|
import org.eclipse.cdt.core.model.CoreModel;
|
||||||
import org.eclipse.cdt.core.model.ICProject;
|
import org.eclipse.cdt.core.model.ICProject;
|
||||||
import org.eclipse.cdt.core.model.IPathEntry;
|
import org.eclipse.cdt.core.model.IPathEntry;
|
||||||
|
@ -133,7 +134,7 @@ public class IndexIncludeTest extends IndexTestBase {
|
||||||
TestSourceReader.waitUntilFileIsIndexed(fIndex, file, 4000);
|
TestSourceReader.waitUntilFileIsIndexed(fIndex, file, 4000);
|
||||||
fIndex.acquireReadLock();
|
fIndex.acquireReadLock();
|
||||||
try {
|
try {
|
||||||
IIndexFile ifile= fIndex.getFile(file.getLocation());
|
IIndexFile ifile= fIndex.getFile(IndexLocationFactory.getWorkspaceIFL(file));
|
||||||
assertNotNull("Can't find " + file.getLocation(), ifile);
|
assertNotNull("Can't find " + file.getLocation(), ifile);
|
||||||
assertTrue("timestamp not ok", ifile.getTimestamp() >= timestamp);
|
assertTrue("timestamp not ok", ifile.getTimestamp() >= timestamp);
|
||||||
|
|
||||||
|
@ -160,7 +161,7 @@ public class IndexIncludeTest extends IndexTestBase {
|
||||||
|
|
||||||
fIndex.acquireReadLock();
|
fIndex.acquireReadLock();
|
||||||
try {
|
try {
|
||||||
IIndexFile ifile= fIndex.getFile(file.getLocation());
|
IIndexFile ifile= fIndex.getFile(IndexLocationFactory.getWorkspaceIFL(file));
|
||||||
assertNotNull(ifile);
|
assertNotNull(ifile);
|
||||||
IIndexInclude[] includes= ifile.getIncludes();
|
IIndexInclude[] includes= ifile.getIncludes();
|
||||||
assertEquals(2, includes.length);
|
assertEquals(2, includes.length);
|
||||||
|
@ -190,7 +191,7 @@ public class IndexIncludeTest extends IndexTestBase {
|
||||||
|
|
||||||
fIndex.acquireReadLock();
|
fIndex.acquireReadLock();
|
||||||
try {
|
try {
|
||||||
IIndexFile ifile= fIndex.getFile(file.getLocation());
|
IIndexFile ifile= fIndex.getFile(IndexLocationFactory.getWorkspaceIFL(file));
|
||||||
assertNotNull(ifile);
|
assertNotNull(ifile);
|
||||||
IIndexInclude[] includes= ifile.getIncludes();
|
IIndexInclude[] includes= ifile.getIncludes();
|
||||||
assertEquals(1, includes.length);
|
assertEquals(1, includes.length);
|
||||||
|
@ -205,7 +206,7 @@ public class IndexIncludeTest extends IndexTestBase {
|
||||||
TestScannerProvider.sIncludes= null;
|
TestScannerProvider.sIncludes= null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkInclude(IIndexInclude include, String content, String includeName, boolean isSystem) throws CoreException {
|
private void checkInclude(IIndexInclude include, String content, String includeName, boolean isSystem) throws CoreException {
|
||||||
int offset= content.indexOf(includeName);
|
int offset= content.indexOf(includeName);
|
||||||
assertEquals(offset, include.getNameOffset());
|
assertEquals(offset, include.getNameOffset());
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
package org.eclipse.cdt.internal.index.tests;
|
||||||
|
|
||||||
|
public class IndexLocationTests {
|
||||||
|
|
||||||
|
}
|
|
@ -50,7 +50,7 @@ public class BTreeTests extends BaseTestCase {
|
||||||
// and invoke it multiple times per Junit test
|
// and invoke it multiple times per Junit test
|
||||||
protected void init(int degree) throws Exception {
|
protected void init(int degree) throws Exception {
|
||||||
dbFile = File.createTempFile("pdomtest", "db");
|
dbFile = File.createTempFile("pdomtest", "db");
|
||||||
db = new Database(dbFile.getAbsolutePath());
|
db = new Database(dbFile);
|
||||||
rootRecord = Database.DATA_AREA;
|
rootRecord = Database.DATA_AREA;
|
||||||
comparator = new BTMockRecordComparator();
|
comparator = new BTMockRecordComparator();
|
||||||
btree = new BTree(db, rootRecord, degree, comparator);
|
btree = new BTree(db, rootRecord, degree, comparator);
|
||||||
|
|
|
@ -37,7 +37,7 @@ public class DBTest extends TestCase {
|
||||||
// Tests block size and simple first block
|
// Tests block size and simple first block
|
||||||
File f = getTestDir().append("test1.dat").toFile();
|
File f = getTestDir().append("test1.dat").toFile();
|
||||||
f.delete();
|
f.delete();
|
||||||
Database db = new Database(f.getCanonicalPath());
|
Database db = new Database(f);
|
||||||
assertEquals(0, db.getVersion());
|
assertEquals(0, db.getVersion());
|
||||||
|
|
||||||
final int realsize = 42;
|
final int realsize = 42;
|
||||||
|
@ -55,7 +55,7 @@ public class DBTest extends TestCase {
|
||||||
// Tests free block linking
|
// Tests free block linking
|
||||||
File f = getTestDir().append("test2.dat").toFile();
|
File f = getTestDir().append("test2.dat").toFile();
|
||||||
f.delete();
|
f.delete();
|
||||||
Database db = new Database(f.getCanonicalPath());
|
Database db = new Database(f);
|
||||||
|
|
||||||
final int realsize = 42;
|
final int realsize = 42;
|
||||||
final int blocksize = (realsize / Database.MIN_SIZE + 1) * Database.MIN_SIZE;
|
final int blocksize = (realsize / Database.MIN_SIZE + 1) * Database.MIN_SIZE;
|
||||||
|
@ -75,7 +75,7 @@ public class DBTest extends TestCase {
|
||||||
//
|
//
|
||||||
File f = getTestDir().append("test2.dat").toFile();
|
File f = getTestDir().append("test2.dat").toFile();
|
||||||
f.delete();
|
f.delete();
|
||||||
Database db = new Database(f.getCanonicalPath());
|
Database db = new Database(f);
|
||||||
|
|
||||||
int mem1 = db.malloc(42);
|
int mem1 = db.malloc(42);
|
||||||
db.free(mem1);
|
db.free(mem1);
|
||||||
|
@ -112,7 +112,7 @@ public class DBTest extends TestCase {
|
||||||
// Tests inserting and retrieving strings
|
// Tests inserting and retrieving strings
|
||||||
File f = getTestDir().append("testStrings.dat").toFile();
|
File f = getTestDir().append("testStrings.dat").toFile();
|
||||||
f.delete();
|
f.delete();
|
||||||
final Database db = new Database(f.getCanonicalPath());
|
final Database db = new Database(f);
|
||||||
|
|
||||||
String[] names = {
|
String[] names = {
|
||||||
"ARLENE",
|
"ARLENE",
|
||||||
|
|
|
@ -19,6 +19,7 @@ import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||||
import org.eclipse.cdt.core.index.IIndex;
|
import org.eclipse.cdt.core.index.IIndex;
|
||||||
import org.eclipse.cdt.core.index.IIndexFile;
|
import org.eclipse.cdt.core.index.IIndexFile;
|
||||||
import org.eclipse.cdt.core.index.IndexFilter;
|
import org.eclipse.cdt.core.index.IndexFilter;
|
||||||
|
import org.eclipse.cdt.core.index.IndexLocationFactory;
|
||||||
import org.eclipse.cdt.core.model.ICProject;
|
import org.eclipse.cdt.core.model.ICProject;
|
||||||
import org.eclipse.cdt.internal.core.CCoreInternals;
|
import org.eclipse.cdt.internal.core.CCoreInternals;
|
||||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMBinding;
|
import org.eclipse.cdt.internal.core.pdom.dom.PDOMBinding;
|
||||||
|
@ -68,13 +69,13 @@ public class FilesOnReindexTests extends PDOMTestBase {
|
||||||
|
|
||||||
void performAssertions(IFile file) throws CoreException {
|
void performAssertions(IFile file) throws CoreException {
|
||||||
IIndex index = CCorePlugin.getIndexManager().getIndex(project);
|
IIndex index = CCorePlugin.getIndexManager().getIndex(project);
|
||||||
assertNotNull(index.getFile(file.getLocation()));
|
assertNotNull(index.getFile(IndexLocationFactory.getWorkspaceIFL(file)));
|
||||||
|
|
||||||
IBinding[] bs = index.findBindings(Pattern.compile("C"), true, new IndexFilter(), new NullProgressMonitor());
|
IBinding[] bs = index.findBindings(Pattern.compile("C"), true, new IndexFilter(), new NullProgressMonitor());
|
||||||
assertEquals(1, bs.length);
|
assertEquals(1, bs.length);
|
||||||
|
|
||||||
PDOMBinding binding = (PDOMBinding) bs[0];
|
PDOMBinding binding = (PDOMBinding) bs[0];
|
||||||
IIndexFile file2 = binding.getFirstDefinition().getFile();
|
IIndexFile file2 = binding.getFirstDefinition().getFile();
|
||||||
assertEquals(file.getLocation().toOSString(), file2.getLocation());
|
assertEquals(file.getLocationURI(), file2.getLocation().getURI());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,8 +16,10 @@ import org.eclipse.cdt.core.CCorePlugin;
|
||||||
import org.eclipse.cdt.core.index.IIndex;
|
import org.eclipse.cdt.core.index.IIndex;
|
||||||
import org.eclipse.cdt.core.index.IIndexFile;
|
import org.eclipse.cdt.core.index.IIndexFile;
|
||||||
import org.eclipse.cdt.core.index.IIndexInclude;
|
import org.eclipse.cdt.core.index.IIndexInclude;
|
||||||
|
import org.eclipse.cdt.core.index.IndexLocationFactory;
|
||||||
import org.eclipse.cdt.core.model.ICProject;
|
import org.eclipse.cdt.core.model.ICProject;
|
||||||
import org.eclipse.core.runtime.IPath;
|
import org.eclipse.core.resources.IFile;
|
||||||
|
import org.eclipse.core.resources.IResource;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Doug Schaefer
|
* @author Doug Schaefer
|
||||||
|
@ -26,37 +28,37 @@ import org.eclipse.core.runtime.IPath;
|
||||||
public class IncludesTests extends PDOMTestBase {
|
public class IncludesTests extends PDOMTestBase {
|
||||||
|
|
||||||
protected ICProject project;
|
protected ICProject project;
|
||||||
protected IIndex pdom;
|
protected IIndex index;
|
||||||
|
|
||||||
public static Test suite() {
|
public static Test suite() {
|
||||||
return suite(IncludesTests.class);
|
return suite(IncludesTests.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void setUp() throws Exception {
|
protected void setUp() throws Exception {
|
||||||
if (pdom == null) {
|
if (index == null) {
|
||||||
project = createProject("includesTests");
|
project = createProject("includesTests");
|
||||||
pdom = CCorePlugin.getIndexManager().getIndex(project);
|
index = CCorePlugin.getIndexManager().getIndex(project);
|
||||||
}
|
}
|
||||||
pdom.acquireReadLock();
|
index.acquireReadLock();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void tearDown() throws Exception {
|
protected void tearDown() throws Exception {
|
||||||
pdom.releaseReadLock();
|
index.releaseReadLock();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testIncludedBy() throws Exception {
|
public void testIncludedBy() throws Exception {
|
||||||
IPath loc = project.getProject().getLocation().append("I2.h");
|
IResource loc = project.getProject().findMember("I2.h");
|
||||||
IIndexFile file = pdom.getFile(loc);
|
IIndexFile file = index.getFile(IndexLocationFactory.getWorkspaceIFL((IFile)loc));
|
||||||
assertNotNull(file);
|
assertNotNull(file);
|
||||||
IIndexInclude[] allIncludedBy = pdom.findIncludedBy(file, -1);
|
IIndexInclude[] allIncludedBy = index.findIncludedBy(file, -1);
|
||||||
assertEquals(9, allIncludedBy.length); // i.e. all of them
|
assertEquals(9, allIncludedBy.length); // i.e. all of them
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testIncludes() throws Exception {
|
public void testIncludes() throws Exception {
|
||||||
IPath loc = project.getProject().getLocation().append("I1.cpp");
|
IResource loc = project.getProject().findMember("I1.cpp");
|
||||||
IIndexFile file = pdom.getFile(loc);
|
IIndexFile file = index.getFile(IndexLocationFactory.getWorkspaceIFL((IFile)loc));
|
||||||
assertNotNull(file);
|
assertNotNull(file);
|
||||||
IIndexInclude[] allIncludesTo= pdom.findIncludes(file, -1);
|
IIndexInclude[] allIncludesTo= index.findIncludes(file, -1);
|
||||||
assertEquals(2, allIncludesTo.length); // i.e. I1.h, I2.h
|
assertEquals(2, allIncludesTo.length); // i.e. I1.h, I2.h
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,8 +62,6 @@ public abstract class IndexBindingResolutionTestBase extends PDOMTestBase {
|
||||||
IFile file = TestSourceReader.createFile(cproject.getProject(), header, testData[0].toString());
|
IFile file = TestSourceReader.createFile(cproject.getProject(), header, testData[0].toString());
|
||||||
CCoreInternals.getPDOMManager().setIndexerId(cproject, IPDOMManager.ID_FAST_INDEXER);
|
CCoreInternals.getPDOMManager().setIndexerId(cproject, IPDOMManager.ID_FAST_INDEXER);
|
||||||
assertTrue(CCorePlugin.getIndexManager().joinIndexer(360000, new NullProgressMonitor()));
|
assertTrue(CCorePlugin.getIndexManager().joinIndexer(360000, new NullProgressMonitor()));
|
||||||
|
|
||||||
/* ((PDOM)CCoreInternals.getPDOMManager().getPDOM(cproject)).accept(new PDOMPrettyPrinter()); */
|
|
||||||
|
|
||||||
IFile cppfile= TestSourceReader.createFile(cproject.getProject(), references, testData[1].toString());
|
IFile cppfile= TestSourceReader.createFile(cproject.getProject(), references, testData[1].toString());
|
||||||
assertTrue(CCorePlugin.getIndexManager().joinIndexer(360000, new NullProgressMonitor()));
|
assertTrue(CCorePlugin.getIndexManager().joinIndexer(360000, new NullProgressMonitor()));
|
||||||
|
|
|
@ -77,12 +77,38 @@ public class IndexCPPBindingResolutionTest extends IndexBindingResolutionTestBas
|
||||||
IBinding b7 = getBindingFromASTName("method(cp->cspp);/*2*/", 6);
|
IBinding b7 = getBindingFromASTName("method(cp->cspp);/*2*/", 6);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// // header file
|
||||||
|
// class C {public: class Base {}; static Base b; };
|
||||||
|
// C::Base C::b = *(new C::Base());
|
||||||
|
// namespace N { class Base2 {}; Base2 b2; };
|
||||||
|
|
||||||
|
// // references
|
||||||
|
// void foo(C::Base b) {}
|
||||||
|
// void foo2(N::Base2 b2) {}
|
||||||
|
// class D : public C::Base {};
|
||||||
|
// class E : public N::Base2 {};
|
||||||
|
// void bar() { foo(C::b); foo2(N::b2); }
|
||||||
|
public void _testSomeMore() {
|
||||||
|
IBinding b0 = getBindingFromASTName("Base {}", 4);
|
||||||
|
IBinding b1 = getBindingFromASTName("Base2 {}", 5);
|
||||||
|
IBinding b2 = getBindingFromASTName("foo(C::Base b)", 3);
|
||||||
|
IBinding b3 = getBindingFromASTName("foo2(N::Base2 b2)", 4);
|
||||||
|
IBinding b4 = getBindingFromASTName("C::b", 1);
|
||||||
|
IBinding b5 = getBindingFromASTName("N::b2", 1);
|
||||||
|
IBinding b6 = getBindingFromASTName("b); f", 1);
|
||||||
|
IBinding b7 = getBindingFromASTName("b2); }", 2);
|
||||||
|
IBinding b8 = getBindingFromASTName("foo(C::b)", 3);
|
||||||
|
IBinding b9 = getBindingFromASTName("foo2(N::b2)", 4);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// // header file
|
// // header file
|
||||||
// class C {}; struct S {}; union U {}; enum E {ER1,ER2,ER3};
|
// class C {}; struct S {}; union U {}; enum E {ER1,ER2,ER3};
|
||||||
// int var1; C var2; S *var3; void func(E); void func(C);
|
// int var1; C var2; S *var3; void func(E); void func(C);
|
||||||
// namespace ns {}
|
// namespace ns {}
|
||||||
// typedef int Int; typedef int *IntPtr;
|
// typedef int Int; typedef int *IntPtr;
|
||||||
// void func(int*); void func(int);
|
// void func(int*); void func(int);
|
||||||
|
|
||||||
// // referencing file
|
// // referencing file
|
||||||
// #include "header.h"
|
// #include "header.h"
|
||||||
// void references() {
|
// void references() {
|
||||||
|
|
|
@ -29,6 +29,7 @@ import org.eclipse.cdt.core.CCorePlugin;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
||||||
import org.eclipse.cdt.core.index.IIndex;
|
import org.eclipse.cdt.core.index.IIndex;
|
||||||
import org.eclipse.cdt.core.index.IIndexFile;
|
import org.eclipse.cdt.core.index.IIndexFile;
|
||||||
|
import org.eclipse.cdt.core.index.IndexLocationFactory;
|
||||||
import org.eclipse.cdt.core.model.CModelException;
|
import org.eclipse.cdt.core.model.CModelException;
|
||||||
import org.eclipse.cdt.core.model.ICElement;
|
import org.eclipse.cdt.core.model.ICElement;
|
||||||
import org.eclipse.cdt.core.model.ICProject;
|
import org.eclipse.cdt.core.model.ICProject;
|
||||||
|
@ -209,18 +210,19 @@ public class TestSourceReader {
|
||||||
final IFile result[] = new IFile[1];
|
final IFile result[] = new IFile[1];
|
||||||
ws.run(new IWorkspaceRunnable() {
|
ws.run(new IWorkspaceRunnable() {
|
||||||
public void run(IProgressMonitor monitor) throws CoreException {
|
public void run(IProgressMonitor monitor) throws CoreException {
|
||||||
//Obtain file handle
|
//Obtain file handle
|
||||||
IFile file = container.getFile(filePath);
|
IFile file = container.getFile(filePath);
|
||||||
InputStream stream = new ByteArrayInputStream(contents.getBytes());
|
|
||||||
//Create file input stream
|
InputStream stream = new ByteArrayInputStream(contents.getBytes());
|
||||||
if (file.exists()) {
|
//Create file input stream
|
||||||
file.setContents(stream, false, false, new NullProgressMonitor());
|
if (file.exists()) {
|
||||||
}
|
file.setContents(stream, false, false, new NullProgressMonitor());
|
||||||
else {
|
}
|
||||||
file.create(stream, false, new NullProgressMonitor());
|
else {
|
||||||
}
|
file.create(stream, false, new NullProgressMonitor());
|
||||||
|
}
|
||||||
result[0]= file;
|
result[0]= file;
|
||||||
}
|
}
|
||||||
}, null);
|
}, null);
|
||||||
return result[0];
|
return result[0];
|
||||||
}
|
}
|
||||||
|
@ -256,7 +258,7 @@ public class TestSourceReader {
|
||||||
Assert.assertTrue(CCorePlugin.getIndexManager().joinIndexer(timeLeft, new NullProgressMonitor()));
|
Assert.assertTrue(CCorePlugin.getIndexManager().joinIndexer(timeLeft, new NullProgressMonitor()));
|
||||||
index.acquireReadLock();
|
index.acquireReadLock();
|
||||||
try {
|
try {
|
||||||
IIndexFile pfile= index.getFile(file.getLocation());
|
IIndexFile pfile= index.getFile(IndexLocationFactory.getWorkspaceIFL(file));
|
||||||
if (pfile != null && pfile.getTimestamp() >= file.getLocalTimeStamp()) {
|
if (pfile != null && pfile.getTimestamp() >= file.getLocalTimeStamp()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -80,6 +80,7 @@ Require-Bundle: org.eclipse.core.resources;bundle-version="[3.2.0,4.0.0)",
|
||||||
org.eclipse.core.runtime;bundle-version="[3.2.0,4.0.0)",
|
org.eclipse.core.runtime;bundle-version="[3.2.0,4.0.0)",
|
||||||
org.eclipse.text;bundle-version="[3.2.0,4.0.0)",
|
org.eclipse.text;bundle-version="[3.2.0,4.0.0)",
|
||||||
org.eclipse.core.variables;bundle-version="[3.1.100,4.0.0)",
|
org.eclipse.core.variables;bundle-version="[3.1.100,4.0.0)",
|
||||||
org.eclipse.core.filebuffers;bundle-version="[3.2.0,4.0.0)"
|
org.eclipse.core.filebuffers;bundle-version="[3.2.0,4.0.0)",
|
||||||
|
org.eclipse.core.filesystem;bundle-version="[1.1.0,2.0.0)"
|
||||||
Eclipse-LazyStart: true
|
Eclipse-LazyStart: true
|
||||||
Bundle-RequiredExecutionEnvironment: J2SE-1.4
|
Bundle-RequiredExecutionEnvironment: J2SE-1.4
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Markus Schorn - initial API and implementation
|
* Markus Schorn - initial API and implementation
|
||||||
|
* Andrew Ferguson (Symbian)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
package org.eclipse.cdt.core.index;
|
package org.eclipse.cdt.core.index;
|
||||||
|
@ -16,7 +17,6 @@ import java.util.regex.Pattern;
|
||||||
import org.eclipse.cdt.core.dom.IName;
|
import org.eclipse.cdt.core.dom.IName;
|
||||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.core.runtime.IPath;
|
|
||||||
import org.eclipse.core.runtime.IProgressMonitor;
|
import org.eclipse.core.runtime.IProgressMonitor;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -125,12 +125,13 @@ public interface IIndex {
|
||||||
public long getLastWriteAccess();
|
public long getLastWriteAccess();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Looks for a file with the given location. May return <code>null</code>.
|
* Looks for a file with the given location. Will return <code>null</code> if there
|
||||||
* @param location absolute path of the file location
|
* is no entry in the index for the given location.
|
||||||
|
* @param location an IIndexFileLocation representing the location of the file
|
||||||
* @return the file in the index or <code>null</code>
|
* @return the file in the index or <code>null</code>
|
||||||
* @throws CoreException
|
* @throws CoreException
|
||||||
*/
|
*/
|
||||||
public IIndexFile getFile(IPath location) throws CoreException;
|
public IIndexFile getFile(IIndexFileLocation location) throws CoreException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Looks for include relations originated by the given file.
|
* Looks for include relations originated by the given file.
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Markus Schorn - initial API and implementation
|
* Markus Schorn - initial API and implementation
|
||||||
|
* Andrew Ferguson (Symbian)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
package org.eclipse.cdt.core.index;
|
package org.eclipse.cdt.core.index;
|
||||||
|
@ -29,13 +30,12 @@ import org.eclipse.core.runtime.CoreException;
|
||||||
* @since 4.0
|
* @since 4.0
|
||||||
*/
|
*/
|
||||||
public interface IIndexFile {
|
public interface IIndexFile {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the absolute path of the location of the file.
|
* Returns an IIndexFileLocation representing the location of this file
|
||||||
* @return the absolute path of the location of the file
|
* @return an IIndexFileLocation representing the location of this file
|
||||||
* @throws CoreException
|
* @throws CoreException
|
||||||
*/
|
*/
|
||||||
String getLocation() throws CoreException;
|
IIndexFileLocation getLocation() throws CoreException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns all includes found in this file.
|
* Returns all includes found in this file.
|
||||||
|
|
|
@ -0,0 +1,44 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2006 Symbian Software Ltd. and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* Andrew Ferguson (Symbian) - initial API and implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.cdt.core.index;
|
||||||
|
|
||||||
|
import java.net.URI;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Files in the index are (conceptually) partitioned into workspace and non-workspace (external) files.
|
||||||
|
* Clients can obtain instances of IIndexFileLocation implementations from {@link IndexLocationFactory}
|
||||||
|
* <p>
|
||||||
|
* This interface is not intended to be implemented by clients.
|
||||||
|
* </p>
|
||||||
|
* <p>
|
||||||
|
* <strong>EXPERIMENTAL</strong>. This class or interface has been added as
|
||||||
|
* part of a work in progress. There is no guarantee that this API will work or
|
||||||
|
* that it will remain the same. Please do not use this API without consulting
|
||||||
|
* with the CDT team.
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @since 4.0
|
||||||
|
*/
|
||||||
|
public interface IIndexFileLocation {
|
||||||
|
/**
|
||||||
|
* The URI of the indexed file
|
||||||
|
* @return the URI of the indexed file (non-null)
|
||||||
|
*/
|
||||||
|
public URI getURI();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the workspace relative path of the indexed file or null if the file
|
||||||
|
* is not in the workspace
|
||||||
|
* @return the workspace relative path of the file in the index, or null if the
|
||||||
|
* file is not in the workspace
|
||||||
|
*/
|
||||||
|
public String getFullPath();
|
||||||
|
}
|
|
@ -7,6 +7,7 @@
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Markus Schorn - initial API and implementation
|
* Markus Schorn - initial API and implementation
|
||||||
|
* Andrew Ferguson (Symbian)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
package org.eclipse.cdt.core.index;
|
package org.eclipse.cdt.core.index;
|
||||||
|
@ -38,18 +39,18 @@ public interface IIndexInclude {
|
||||||
IIndexFile getIncludedBy() throws CoreException;
|
IIndexFile getIncludedBy() throws CoreException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the absolute path of the location of the file that contains this directive.
|
* Returns the IIndexFileLocation of the file that contains this directive.
|
||||||
* @return the absolute path of the location of the file performing the include
|
* @return the IIndexFileLocation of the file performing the include
|
||||||
* @throws CoreException
|
* @throws CoreException
|
||||||
*/
|
*/
|
||||||
String getIncludedByLocation() throws CoreException;
|
IIndexFileLocation getIncludedByLocation() throws CoreException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the absolute path of the location of the file that is included by this directive.
|
* Returns the IIndexFileLocation of the file that is included by this directive.
|
||||||
* @return the absolute path of the location of the file that is included by this directive
|
* @return the IIndexFileLocation of the file that is included by this directive
|
||||||
* @throws CoreException
|
* @throws CoreException
|
||||||
*/
|
*/
|
||||||
String getIncludesLocation() throws CoreException;
|
IIndexFileLocation getIncludesLocation() throws CoreException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the character offset of the name of the include in its source file. The name does
|
* Returns the character offset of the name of the include in its source file. The name does
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Markus Schorn - initial API and implementation
|
* Markus Schorn - initial API and implementation
|
||||||
|
* Andrew Ferguson (Symbian)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
package org.eclipse.cdt.core.index;
|
package org.eclipse.cdt.core.index;
|
||||||
|
@ -31,11 +32,6 @@ import org.eclipse.core.runtime.CoreException;
|
||||||
* @since 4.0
|
* @since 4.0
|
||||||
*/
|
*/
|
||||||
public interface IIndexName extends IName {
|
public interface IIndexName extends IName {
|
||||||
/**
|
|
||||||
* Returns the location of the file the name resides in.
|
|
||||||
*/
|
|
||||||
public String getFileName();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the file the name belongs to.
|
* Returns the file the name belongs to.
|
||||||
* @throws CoreException
|
* @throws CoreException
|
||||||
|
|
|
@ -0,0 +1,98 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2006 Symbian Software Ltd. and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* Andrew Ferguson (Symbian) - initial API and implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.cdt.core.index;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.model.ITranslationUnit;
|
||||||
|
import org.eclipse.cdt.internal.core.index.IndexFileLocation;
|
||||||
|
import org.eclipse.core.filesystem.URIUtil;
|
||||||
|
import org.eclipse.core.resources.IFile;
|
||||||
|
import org.eclipse.core.resources.IResource;
|
||||||
|
import org.eclipse.core.resources.ResourcesPlugin;
|
||||||
|
import org.eclipse.core.runtime.IPath;
|
||||||
|
import org.eclipse.core.runtime.Path;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Factory for obtaining instances of IIndexFileLocation for workspace or external files, and
|
||||||
|
* some utility methods for going in the opposite direction.
|
||||||
|
*/
|
||||||
|
public class IndexLocationFactory {
|
||||||
|
/**
|
||||||
|
* Returns
|
||||||
|
* <ul>
|
||||||
|
* <li> the full path if this IIndexFileLocation if within the workspace root
|
||||||
|
* <li> the absolute path if this IIndexFileLocation is URI based and corresponds
|
||||||
|
* to a location on the local file system
|
||||||
|
* <li> otherwise, null
|
||||||
|
* </ul>
|
||||||
|
* @param location
|
||||||
|
* @return the workspace root relative path, a local file system absolute path or null
|
||||||
|
*/
|
||||||
|
public static IPath getPath(IIndexFileLocation location) {
|
||||||
|
String fp = location.getFullPath();
|
||||||
|
if(fp!=null) {
|
||||||
|
return new Path(fp);
|
||||||
|
}
|
||||||
|
return getAbsolutePath(location);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the absolute file path of an URI or null if the
|
||||||
|
* URI is not a filesystem path.
|
||||||
|
* @param uri
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static IPath getAbsolutePath(IIndexFileLocation location) {
|
||||||
|
return URIUtil.toPath(location.getURI());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static IIndexFileLocation getIFLExpensive(String absolutePath) {
|
||||||
|
IFile[] files = ResourcesPlugin.getWorkspace().getRoot().findFilesForLocation(new Path(absolutePath));
|
||||||
|
if(files.length==1) {
|
||||||
|
return getWorkspaceIFL(files[0]);
|
||||||
|
}
|
||||||
|
return new IndexFileLocation(URIUtil.toURI(absolutePath), null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static IIndexFileLocation getExternalIFL(String absolutePath) {
|
||||||
|
return getExternalIFL(new Path(absolutePath));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static IIndexFileLocation getExternalIFL(IPath absolutePath) {
|
||||||
|
return new IndexFileLocation(URIUtil.toURI(absolutePath), null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static IIndexFileLocation getWorkspaceIFL(IFile file) {
|
||||||
|
return new IndexFileLocation(file.getLocationURI(), file.getFullPath().toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns<ul>
|
||||||
|
* <li> a workspace IIndexFileLocation if the translation unit has an associated resource
|
||||||
|
* <li> an external IIndexFileLocation if the translation unit does not have an associated resource
|
||||||
|
* <li> null, in any other case
|
||||||
|
* </ul>
|
||||||
|
* @param tu
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static IIndexFileLocation getIFL(ITranslationUnit tu) {
|
||||||
|
IResource res = tu.getResource();
|
||||||
|
if(res instanceof IFile) {
|
||||||
|
return getWorkspaceIFL((IFile)res);
|
||||||
|
} else {
|
||||||
|
IPath location = tu.getLocation();
|
||||||
|
if(location!=null) {
|
||||||
|
return getExternalIFL(location);
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -2005,7 +2005,7 @@ public class CPPVisitor {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String [] getQualifiedName( IBinding binding ){
|
public static String [] getQualifiedName( IBinding binding ){
|
||||||
IASTName [] ns = null;
|
IName [] ns = null;
|
||||||
try {
|
try {
|
||||||
ICPPScope scope = (ICPPScope) binding.getScope();
|
ICPPScope scope = (ICPPScope) binding.getScope();
|
||||||
while( scope != null ){
|
while( scope != null ){
|
||||||
|
@ -2020,12 +2020,12 @@ public class CPPVisitor {
|
||||||
if( scope instanceof ICPPNamespaceScope && scope.getScopeName().toCharArray().length == 0 )
|
if( scope instanceof ICPPNamespaceScope && scope.getScopeName().toCharArray().length == 0 )
|
||||||
break;
|
break;
|
||||||
|
|
||||||
ns = (IASTName[]) ArrayUtil.append( IASTName.class, ns, n );
|
ns = (IName[]) ArrayUtil.append( IName.class, ns, n );
|
||||||
scope = (ICPPScope) scope.getParent();
|
scope = (ICPPScope) scope.getParent();
|
||||||
}
|
}
|
||||||
} catch ( DOMException e ) {
|
} catch ( DOMException e ) {
|
||||||
}
|
}
|
||||||
ns = (IASTName[]) ArrayUtil.trim( IASTName.class, ns );
|
ns = (IName[]) ArrayUtil.trim( IName.class, ns );
|
||||||
String [] result = new String[ ns.length + 1 ];
|
String [] result = new String[ ns.length + 1 ];
|
||||||
for( int i = ns.length - 1; i >= 0; i-- ){
|
for( int i = ns.length - 1; i >= 0; i-- ){
|
||||||
result[ ns.length - i - 1 ] = ns[i].toString();
|
result[ ns.length - i - 1 ] = ns[i].toString();
|
||||||
|
|
|
@ -26,11 +26,11 @@ import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||||
import org.eclipse.cdt.core.index.IIndex;
|
import org.eclipse.cdt.core.index.IIndex;
|
||||||
import org.eclipse.cdt.core.index.IIndexBinding;
|
import org.eclipse.cdt.core.index.IIndexBinding;
|
||||||
import org.eclipse.cdt.core.index.IIndexFile;
|
import org.eclipse.cdt.core.index.IIndexFile;
|
||||||
|
import org.eclipse.cdt.core.index.IIndexFileLocation;
|
||||||
import org.eclipse.cdt.core.index.IIndexInclude;
|
import org.eclipse.cdt.core.index.IIndexInclude;
|
||||||
import org.eclipse.cdt.core.index.IIndexName;
|
import org.eclipse.cdt.core.index.IIndexName;
|
||||||
import org.eclipse.cdt.core.index.IndexFilter;
|
import org.eclipse.cdt.core.index.IndexFilter;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.core.runtime.IPath;
|
|
||||||
import org.eclipse.core.runtime.IProgressMonitor;
|
import org.eclipse.core.runtime.IProgressMonitor;
|
||||||
import org.eclipse.core.runtime.SubProgressMonitor;
|
import org.eclipse.core.runtime.SubProgressMonitor;
|
||||||
|
|
||||||
|
@ -177,11 +177,10 @@ public class CIndex implements IIndex {
|
||||||
return findNames(binding, FIND_REFERENCES);
|
return findNames(binding, FIND_REFERENCES);
|
||||||
}
|
}
|
||||||
|
|
||||||
public IIndexFile getFile(IPath location) throws CoreException {
|
public IIndexFile getFile(IIndexFileLocation location) throws CoreException {
|
||||||
IIndexFile result= null;
|
IIndexFile result= null;
|
||||||
String path= location.toOSString();
|
|
||||||
for (int i = 0; result==null && i < fPrimaryFragmentCount; i++) {
|
for (int i = 0; result==null && i < fPrimaryFragmentCount; i++) {
|
||||||
result= fFragments[i].getFile(path);
|
result= fFragments[i].getFile(location);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -195,7 +194,8 @@ public class CIndex implements IIndex {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
String location= include.getIncludesLocation();
|
|
||||||
|
IIndexFileLocation location= include.getIncludesLocation();
|
||||||
for (int i = 0; i < fPrimaryFragmentCount; i++) {
|
for (int i = 0; i < fPrimaryFragmentCount; i++) {
|
||||||
IIndexFragment otherFrag = fFragments[i];
|
IIndexFragment otherFrag = fFragments[i];
|
||||||
if (otherFrag != frag) {
|
if (otherFrag != frag) {
|
||||||
|
|
|
@ -18,11 +18,11 @@ import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||||
import org.eclipse.cdt.core.index.IIndex;
|
import org.eclipse.cdt.core.index.IIndex;
|
||||||
import org.eclipse.cdt.core.index.IIndexBinding;
|
import org.eclipse.cdt.core.index.IIndexBinding;
|
||||||
import org.eclipse.cdt.core.index.IIndexFile;
|
import org.eclipse.cdt.core.index.IIndexFile;
|
||||||
|
import org.eclipse.cdt.core.index.IIndexFileLocation;
|
||||||
import org.eclipse.cdt.core.index.IIndexInclude;
|
import org.eclipse.cdt.core.index.IIndexInclude;
|
||||||
import org.eclipse.cdt.core.index.IIndexName;
|
import org.eclipse.cdt.core.index.IIndexName;
|
||||||
import org.eclipse.cdt.core.index.IndexFilter;
|
import org.eclipse.cdt.core.index.IndexFilter;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.core.runtime.IPath;
|
|
||||||
import org.eclipse.core.runtime.IProgressMonitor;
|
import org.eclipse.core.runtime.IProgressMonitor;
|
||||||
|
|
||||||
final public class EmptyCIndex implements IIndex {
|
final public class EmptyCIndex implements IIndex {
|
||||||
|
@ -47,7 +47,7 @@ final public class EmptyCIndex implements IIndex {
|
||||||
return IIndexFragmentName.EMPTY_NAME_ARRAY;
|
return IIndexFragmentName.EMPTY_NAME_ARRAY;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IIndexFile getFile(IPath location) {
|
public IIndexFile getFile(IIndexFileLocation location) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,6 +16,7 @@ import java.util.regex.Pattern;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||||
import org.eclipse.cdt.core.index.IIndex;
|
import org.eclipse.cdt.core.index.IIndex;
|
||||||
|
import org.eclipse.cdt.core.index.IIndexFileLocation;
|
||||||
import org.eclipse.cdt.core.index.IndexFilter;
|
import org.eclipse.cdt.core.index.IndexFilter;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.core.runtime.IProgressMonitor;
|
import org.eclipse.core.runtime.IProgressMonitor;
|
||||||
|
@ -50,11 +51,11 @@ public interface IIndexFragment {
|
||||||
/**
|
/**
|
||||||
* Returns the file for the given location. May return <code>null</code>, if no such file exists.
|
* Returns the file for the given location. May return <code>null</code>, if no such file exists.
|
||||||
* This method may only return files that are actually managed by this fragement.
|
* This method may only return files that are actually managed by this fragement.
|
||||||
* @param location absolute path to the location of the file
|
* @param location the IIndexFileLocation representing the location of the file
|
||||||
* @return the file for the location
|
* @return the file for the location
|
||||||
* @throws CoreException
|
* @throws CoreException
|
||||||
*/
|
*/
|
||||||
IIndexFragmentFile getFile(String location) throws CoreException;
|
IIndexFragmentFile getFile(IIndexFileLocation location) throws CoreException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns all include directives that point to the given file. The input file may belong to
|
* Returns all include directives that point to the given file. The input file may belong to
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Markus Schorn - initial API and implementation
|
* Markus Schorn - initial API and implementation
|
||||||
|
* Andrew Ferguson (Symbian)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
package org.eclipse.cdt.internal.core.index;
|
package org.eclipse.cdt.internal.core.index;
|
||||||
|
@ -15,8 +16,8 @@ import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTPreprocessorIncludeStatement;
|
import org.eclipse.cdt.core.dom.ast.IASTPreprocessorIncludeStatement;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTPreprocessorMacroDefinition;
|
import org.eclipse.cdt.core.dom.ast.IASTPreprocessorMacroDefinition;
|
||||||
import org.eclipse.cdt.core.index.IIndex;
|
import org.eclipse.cdt.core.index.IIndex;
|
||||||
|
import org.eclipse.cdt.core.index.IIndexFileLocation;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.core.runtime.IPath;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Interface used by the indexer to write to the index.
|
* Interface used by the indexer to write to the index.
|
||||||
|
@ -28,13 +29,14 @@ public interface IWritableIndex extends IIndex {
|
||||||
/**
|
/**
|
||||||
* Creates a file object for the given location or returns an existing one.
|
* Creates a file object for the given location or returns an existing one.
|
||||||
*/
|
*/
|
||||||
IIndexFragmentFile addFile(IPath fileLocation) throws CoreException;
|
IIndexFragmentFile addFile(IIndexFileLocation fileLocation) throws CoreException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds content to the given file.
|
* Adds content to the given file.
|
||||||
*/
|
*/
|
||||||
void setFileContent(IIndexFragmentFile sourceFile,
|
void setFileContent(IIndexFragmentFile sourceFile,
|
||||||
IASTPreprocessorIncludeStatement[] includes,
|
IASTPreprocessorIncludeStatement[] includes,
|
||||||
|
IIndexFileLocation[] includeLocations,
|
||||||
IASTPreprocessorMacroDefinition[] macros, IASTName[][] names) throws CoreException;
|
IASTPreprocessorMacroDefinition[] macros, IASTName[][] names) throws CoreException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Markus Schorn - initial API and implementation
|
* Markus Schorn - initial API and implementation
|
||||||
|
* Andrew Ferguson (Symbian)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
package org.eclipse.cdt.internal.core.index;
|
package org.eclipse.cdt.internal.core.index;
|
||||||
|
@ -14,6 +15,7 @@ package org.eclipse.cdt.internal.core.index;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTPreprocessorIncludeStatement;
|
import org.eclipse.cdt.core.dom.ast.IASTPreprocessorIncludeStatement;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTPreprocessorMacroDefinition;
|
import org.eclipse.cdt.core.dom.ast.IASTPreprocessorMacroDefinition;
|
||||||
|
import org.eclipse.cdt.core.index.IIndexFileLocation;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -33,8 +35,11 @@ public interface IWritableIndexFragment extends IIndexFragment {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a file object for the given location or returns an existing one.
|
* Creates a file object for the given location or returns an existing one.
|
||||||
|
* @param fileLocation an IIndexFileLocation representing the location of the file
|
||||||
|
* @return the existing IIndexFragmentFile for this location, or a newly created one
|
||||||
|
* @throws CoreException
|
||||||
*/
|
*/
|
||||||
IIndexFragmentFile addFile(String fileLocation) throws CoreException;
|
IIndexFragmentFile addFile(IIndexFileLocation fileLocation) throws CoreException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds an include to the given file.
|
* Adds an include to the given file.
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* QNX - Initial API and implementation
|
* QNX - Initial API and implementation
|
||||||
* Markus Schorn (Wind River Systems)
|
* Markus Schorn (Wind River Systems)
|
||||||
|
* Andrew Ferguson (Symbian)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.index;
|
package org.eclipse.cdt.internal.core.index;
|
||||||
|
|
||||||
|
@ -24,9 +25,10 @@ import org.eclipse.cdt.core.CCorePlugin;
|
||||||
import org.eclipse.cdt.core.dom.ICodeReaderFactory;
|
import org.eclipse.cdt.core.dom.ICodeReaderFactory;
|
||||||
import org.eclipse.cdt.core.index.IIndex;
|
import org.eclipse.cdt.core.index.IIndex;
|
||||||
import org.eclipse.cdt.core.index.IIndexFile;
|
import org.eclipse.cdt.core.index.IIndexFile;
|
||||||
|
import org.eclipse.cdt.core.index.IIndexFileLocation;
|
||||||
import org.eclipse.cdt.core.index.IIndexInclude;
|
import org.eclipse.cdt.core.index.IIndexInclude;
|
||||||
import org.eclipse.cdt.core.index.IIndexMacro;
|
import org.eclipse.cdt.core.index.IIndexMacro;
|
||||||
import org.eclipse.cdt.core.model.ITranslationUnit;
|
import org.eclipse.cdt.core.index.IndexLocationFactory;
|
||||||
import org.eclipse.cdt.core.parser.CodeReader;
|
import org.eclipse.cdt.core.parser.CodeReader;
|
||||||
import org.eclipse.cdt.core.parser.ICodeReaderCache;
|
import org.eclipse.cdt.core.parser.ICodeReaderCache;
|
||||||
import org.eclipse.cdt.core.parser.IMacro;
|
import org.eclipse.cdt.core.parser.IMacro;
|
||||||
|
@ -35,7 +37,6 @@ import org.eclipse.cdt.core.parser.ParserUtil;
|
||||||
import org.eclipse.cdt.internal.core.parser.scanner2.ObjectStyleMacro;
|
import org.eclipse.cdt.internal.core.parser.scanner2.ObjectStyleMacro;
|
||||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMMacro;
|
import org.eclipse.cdt.internal.core.pdom.dom.PDOMMacro;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.core.runtime.Path;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Doug Schaefer
|
* @author Doug Schaefer
|
||||||
|
@ -45,12 +46,15 @@ public class IndexBasedCodeReaderFactory implements ICodeReaderFactory {
|
||||||
|
|
||||||
private final static boolean CASE_SENSITIVE_FILES= !new File("a").equals(new File("A")); //$NON-NLS-1$//$NON-NLS-2$
|
private final static boolean CASE_SENSITIVE_FILES= !new File("a").equals(new File("A")); //$NON-NLS-1$//$NON-NLS-2$
|
||||||
private final IIndex index;
|
private final IIndex index;
|
||||||
private Map fileInfoCache = new HashMap(); // filename, fileInfo
|
private Map/*<IIndexFileLocation,FileInfo>*/ fileInfoCache;
|
||||||
|
private Map/*<String,IIndexFileLocation>*/ iflCache;
|
||||||
private List usedMacros = new ArrayList();
|
private List usedMacros = new ArrayList();
|
||||||
|
|
||||||
private static final char[] EMPTY_CHARS = new char[0];
|
private static final char[] EMPTY_CHARS = new char[0];
|
||||||
|
|
||||||
private static class NeedToParseException extends Exception {}
|
private static class NeedToParseException extends Exception {
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
}
|
||||||
public static class FileInfo {
|
public static class FileInfo {
|
||||||
private FileInfo() {}
|
private FileInfo() {}
|
||||||
public IIndexFile fFile= null;
|
public IIndexFile fFile= null;
|
||||||
|
@ -66,9 +70,14 @@ public class IndexBasedCodeReaderFactory implements ICodeReaderFactory {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public IndexBasedCodeReaderFactory(IIndex index) {
|
public IndexBasedCodeReaderFactory(IIndex index) {
|
||||||
|
this(index, new HashMap/*<String,IIndexFileLocation>*/());
|
||||||
|
}
|
||||||
|
|
||||||
|
public IndexBasedCodeReaderFactory(IIndex index, Map iflCache) {
|
||||||
this.index = index;
|
this.index = index;
|
||||||
|
this.fileInfoCache = new HashMap/*<IIndexFileLocation,FileInfo>*/();
|
||||||
|
this.iflCache = iflCache;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getUniqueIdentifier() {
|
public int getUniqueIdentifier() {
|
||||||
|
@ -95,7 +104,8 @@ public class IndexBasedCodeReaderFactory implements ICodeReaderFactory {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
FileInfo info= createInfo(canonicalPath, null);
|
IIndexFileLocation incLocation = findLocation(canonicalPath);
|
||||||
|
FileInfo info= createInfo(incLocation, null);
|
||||||
|
|
||||||
// try to build macro dictionary off index
|
// try to build macro dictionary off index
|
||||||
if (info.fFile != null) {
|
if (info.fFile != null) {
|
||||||
|
@ -133,17 +143,17 @@ public class IndexBasedCodeReaderFactory implements ICodeReaderFactory {
|
||||||
return ParserUtil.createReader(canonicalPath, null);
|
return ParserUtil.createReader(canonicalPath, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
private FileInfo createInfo(String location, IIndexFile file) throws CoreException {
|
private FileInfo createInfo(IIndexFileLocation location, IIndexFile file) throws CoreException {
|
||||||
FileInfo info= (FileInfo) fileInfoCache.get(location);
|
FileInfo info= (FileInfo) fileInfoCache.get(location);
|
||||||
if (info == null) {
|
if (info == null) {
|
||||||
info= new FileInfo();
|
info= new FileInfo();
|
||||||
info.fFile= file == null ? index.getFile(new Path(location)) : file;
|
info.fFile= file == null ? index.getFile(location) : file;
|
||||||
fileInfoCache.put(location, info);
|
fileInfoCache.put(location, info);
|
||||||
}
|
}
|
||||||
return info;
|
return info;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void getInfosForMacroDictionary(FileInfo fileInfo, LinkedHashSet target) throws CoreException, NeedToParseException {
|
private void getInfosForMacroDictionary(FileInfo fileInfo, LinkedHashSet/*<FileInfo>*/ target) throws CoreException, NeedToParseException {
|
||||||
if (!target.add(fileInfo)) {
|
if (!target.add(fileInfo)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -181,11 +191,14 @@ public class IndexBasedCodeReaderFactory implements ICodeReaderFactory {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public FileInfo createFileInfo(String location) throws CoreException {
|
public FileInfo createFileInfo(IIndexFileLocation location) throws CoreException {
|
||||||
return createInfo(location, null);
|
return createInfo(location, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public FileInfo createFileInfo(ITranslationUnit tu) throws CoreException {
|
public IIndexFileLocation findLocation(String absolutePath) {
|
||||||
return createInfo(tu.getLocation().toOSString(), null);
|
if(!iflCache.containsKey(absolutePath)) {
|
||||||
|
iflCache.put(absolutePath, IndexLocationFactory.getIFLExpensive(absolutePath));
|
||||||
|
}
|
||||||
|
return (IIndexFileLocation) iflCache.get(absolutePath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,65 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2006 Symbian Software Ltd. and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* Andrew Ferguson (Symbian) - initial API and implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.cdt.internal.core.index;
|
||||||
|
|
||||||
|
import java.net.URI;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.index.IIndexFileLocation;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An implementation of IIndexFileLocation
|
||||||
|
*/
|
||||||
|
public class IndexFileLocation implements IIndexFileLocation {
|
||||||
|
private final URI uri;
|
||||||
|
private final String fullPath;
|
||||||
|
|
||||||
|
public IndexFileLocation(URI uri, String fullPath) {
|
||||||
|
if(uri==null)
|
||||||
|
throw new IllegalArgumentException();
|
||||||
|
this.uri = uri;
|
||||||
|
this.fullPath = fullPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.index.IIndexFileLocation#getFullPath()
|
||||||
|
*/
|
||||||
|
public String getFullPath() {
|
||||||
|
return fullPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.index.IIndexFileLocation#getURI()
|
||||||
|
*/
|
||||||
|
public URI getURI() {
|
||||||
|
return uri;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
* @see java.lang.Object#equals(java.lang.Object)
|
||||||
|
*/
|
||||||
|
public boolean equals(Object obj) {
|
||||||
|
if(obj instanceof IIndexFileLocation) {
|
||||||
|
return uri.equals(((IIndexFileLocation)obj).getURI());
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
* @see java.lang.Object#hashCode()
|
||||||
|
*/
|
||||||
|
public int hashCode() {
|
||||||
|
return uri.hashCode();
|
||||||
|
}
|
||||||
|
}
|
|
@ -7,6 +7,7 @@
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Markus Schorn - initial API and implementation
|
* Markus Schorn - initial API and implementation
|
||||||
|
* Andrew Ferguson (Symbian)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
package org.eclipse.cdt.internal.core.index;
|
package org.eclipse.cdt.internal.core.index;
|
||||||
|
@ -14,9 +15,8 @@ package org.eclipse.cdt.internal.core.index;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTPreprocessorIncludeStatement;
|
import org.eclipse.cdt.core.dom.ast.IASTPreprocessorIncludeStatement;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTPreprocessorMacroDefinition;
|
import org.eclipse.cdt.core.dom.ast.IASTPreprocessorMacroDefinition;
|
||||||
|
import org.eclipse.cdt.core.index.IIndexFileLocation;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.core.runtime.IPath;
|
|
||||||
import org.eclipse.core.runtime.Path;
|
|
||||||
|
|
||||||
public class WritableCIndex extends CIndex implements IWritableIndex {
|
public class WritableCIndex extends CIndex implements IWritableIndex {
|
||||||
|
|
||||||
|
@ -35,12 +35,12 @@ public class WritableCIndex extends CIndex implements IWritableIndex {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IIndexFragmentFile addFile(IPath fileLocation) throws CoreException {
|
public IIndexFragmentFile addFile(IIndexFileLocation fileLocation) throws CoreException {
|
||||||
IWritableIndexFragment frag= selectFragment(fileLocation);
|
IWritableIndexFragment frag= selectFragment(fileLocation);
|
||||||
return frag.addFile(fileLocation.toOSString());
|
return frag.addFile(fileLocation);
|
||||||
}
|
}
|
||||||
|
|
||||||
private IWritableIndexFragment selectFragment(IPath fileLocation) {
|
private IWritableIndexFragment selectFragment(IIndexFileLocation fileLocation) {
|
||||||
// todo handling of multiple writable indices
|
// todo handling of multiple writable indices
|
||||||
assert fWritableFragments.length == 1;
|
assert fWritableFragments.length == 1;
|
||||||
return fWritableFragments[0];
|
return fWritableFragments[0];
|
||||||
|
@ -57,6 +57,7 @@ public class WritableCIndex extends CIndex implements IWritableIndex {
|
||||||
|
|
||||||
public void setFileContent(IIndexFragmentFile file,
|
public void setFileContent(IIndexFragmentFile file,
|
||||||
IASTPreprocessorIncludeStatement[] includes,
|
IASTPreprocessorIncludeStatement[] includes,
|
||||||
|
IIndexFileLocation[] includeLocations,
|
||||||
IASTPreprocessorMacroDefinition[] macros, IASTName[][] names) throws CoreException {
|
IASTPreprocessorMacroDefinition[] macros, IASTName[][] names) throws CoreException {
|
||||||
|
|
||||||
IIndexFragment indexFragment = file.getIndexFragment();
|
IIndexFragment indexFragment = file.getIndexFragment();
|
||||||
|
@ -64,8 +65,7 @@ public class WritableCIndex extends CIndex implements IWritableIndex {
|
||||||
|
|
||||||
IIndexFragmentFile[] destFiles= new IIndexFragmentFile[includes.length];
|
IIndexFragmentFile[] destFiles= new IIndexFragmentFile[includes.length];
|
||||||
for (int i = 0; i < includes.length; i++) {
|
for (int i = 0; i < includes.length; i++) {
|
||||||
IASTPreprocessorIncludeStatement statement = includes[i];
|
destFiles[i]= addFile(includeLocations[i]);
|
||||||
destFiles[i]= addFile(new Path(statement.getPath()));
|
|
||||||
}
|
}
|
||||||
((IWritableIndexFragment) indexFragment).addFileContent(file,
|
((IWritableIndexFragment) indexFragment).addFileContent(file,
|
||||||
includes, destFiles, macros, names);
|
includes, destFiles, macros, names);
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.pdom;
|
package org.eclipse.cdt.internal.core.pdom;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.BitSet;
|
import java.util.BitSet;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
@ -29,8 +30,9 @@ import org.eclipse.cdt.core.dom.IPDOMNode;
|
||||||
import org.eclipse.cdt.core.dom.IPDOMVisitor;
|
import org.eclipse.cdt.core.dom.IPDOMVisitor;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||||
import org.eclipse.cdt.core.index.IIndex;
|
|
||||||
import org.eclipse.cdt.core.index.IIndexBinding;
|
import org.eclipse.cdt.core.index.IIndexBinding;
|
||||||
|
import org.eclipse.cdt.core.index.IIndex;
|
||||||
|
import org.eclipse.cdt.core.index.IIndexFileLocation;
|
||||||
import org.eclipse.cdt.core.index.IIndexName;
|
import org.eclipse.cdt.core.index.IIndexName;
|
||||||
import org.eclipse.cdt.core.index.IndexFilter;
|
import org.eclipse.cdt.core.index.IndexFilter;
|
||||||
import org.eclipse.cdt.core.model.LanguageManager;
|
import org.eclipse.cdt.core.model.LanguageManager;
|
||||||
|
@ -42,6 +44,7 @@ import org.eclipse.cdt.internal.core.index.IIndexFragmentName;
|
||||||
import org.eclipse.cdt.internal.core.index.IIndexProxyBinding;
|
import org.eclipse.cdt.internal.core.index.IIndexProxyBinding;
|
||||||
import org.eclipse.cdt.internal.core.pdom.db.BTree;
|
import org.eclipse.cdt.internal.core.pdom.db.BTree;
|
||||||
import org.eclipse.cdt.internal.core.pdom.db.Database;
|
import org.eclipse.cdt.internal.core.pdom.db.Database;
|
||||||
|
import org.eclipse.cdt.internal.core.pdom.dom.IIndexLocationConverter;
|
||||||
import org.eclipse.cdt.internal.core.pdom.dom.IPDOMLinkageFactory;
|
import org.eclipse.cdt.internal.core.pdom.dom.IPDOMLinkageFactory;
|
||||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMBinding;
|
import org.eclipse.cdt.internal.core.pdom.dom.PDOMBinding;
|
||||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMFile;
|
import org.eclipse.cdt.internal.core.pdom.dom.PDOMFile;
|
||||||
|
@ -49,9 +52,7 @@ import org.eclipse.cdt.internal.core.pdom.dom.PDOMInclude;
|
||||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMLinkage;
|
import org.eclipse.cdt.internal.core.pdom.dom.PDOMLinkage;
|
||||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMName;
|
import org.eclipse.cdt.internal.core.pdom.dom.PDOMName;
|
||||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
|
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
|
||||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMFile.Finder;
|
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.core.runtime.IPath;
|
|
||||||
import org.eclipse.core.runtime.IProgressMonitor;
|
import org.eclipse.core.runtime.IProgressMonitor;
|
||||||
import org.eclipse.core.runtime.PlatformObject;
|
import org.eclipse.core.runtime.PlatformObject;
|
||||||
import org.eclipse.core.runtime.Status;
|
import org.eclipse.core.runtime.Status;
|
||||||
|
@ -85,6 +86,7 @@ public class PDOM extends PlatformObject implements IIndexFragment, IPDOM {
|
||||||
// 16 - have PDOMCPPField store type information, and PDOMCPPNamespaceAlias store what it is aliasing
|
// 16 - have PDOMCPPField store type information, and PDOMCPPNamespaceAlias store what it is aliasing
|
||||||
// 17 - use single linked list for names in file, adds a link to enclosing defintion name.
|
// 17 - use single linked list for names in file, adds a link to enclosing defintion name.
|
||||||
// 18 - distinction between c-unions and c-structs.
|
// 18 - distinction between c-unions and c-structs.
|
||||||
|
// 19 - alter representation of paths in the pdom (162172)
|
||||||
|
|
||||||
public static final int LINKAGES = Database.DATA_AREA;
|
public static final int LINKAGES = Database.DATA_AREA;
|
||||||
public static final int FILE_INDEX = Database.DATA_AREA + 4;
|
public static final int FILE_INDEX = Database.DATA_AREA + 4;
|
||||||
|
@ -92,16 +94,23 @@ public class PDOM extends PlatformObject implements IIndexFragment, IPDOM {
|
||||||
// Local caches
|
// Local caches
|
||||||
private BTree fileIndex;
|
private BTree fileIndex;
|
||||||
private Map fLinkageIDCache = new HashMap();
|
private Map fLinkageIDCache = new HashMap();
|
||||||
private IPath fPath;
|
private File fPath;
|
||||||
|
private IIndexLocationConverter locationConverter;
|
||||||
public PDOM(IPath dbPath) throws CoreException {
|
|
||||||
|
public PDOM(File dbPath, IIndexLocationConverter locationConverter) throws CoreException {
|
||||||
// Load up the database
|
// Load up the database
|
||||||
fPath= dbPath;
|
fPath= dbPath;
|
||||||
db = new Database(dbPath.toOSString());
|
db = new Database(fPath);
|
||||||
|
|
||||||
if (db.getVersion() == VERSION) {
|
if (db.getVersion() == VERSION) {
|
||||||
readLinkages();
|
readLinkages();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.locationConverter = locationConverter;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IIndexLocationConverter getLocationConverter() {
|
||||||
|
return locationConverter;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean versionMismatch() {
|
public boolean versionMismatch() {
|
||||||
|
@ -155,17 +164,14 @@ public class PDOM extends PlatformObject implements IIndexFragment, IPDOM {
|
||||||
return fileIndex;
|
return fileIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IIndexFragmentFile getFile(String path) throws CoreException {
|
public IIndexFragmentFile getFile(IIndexFileLocation location) throws CoreException {
|
||||||
Finder finder = new Finder(db, path);
|
return PDOMFile.findFile(this, getFileIndex(), location, locationConverter);
|
||||||
getFileIndex().accept(finder);
|
|
||||||
int record = finder.getRecord();
|
|
||||||
return record != 0 ? new PDOMFile(this, record) : null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected IIndexFragmentFile addFile(String path) throws CoreException {
|
protected IIndexFragmentFile addFile(IIndexFileLocation location) throws CoreException {
|
||||||
IIndexFragmentFile file = getFile(path);
|
IIndexFragmentFile file = getFile(location);
|
||||||
if (file == null) {
|
if (file == null) {
|
||||||
PDOMFile pdomFile = new PDOMFile(this, path);
|
PDOMFile pdomFile = new PDOMFile(this, location);
|
||||||
getFileIndex().insert(pdomFile.getRecord());
|
getFileIndex().insert(pdomFile.getRecord());
|
||||||
file= pdomFile;
|
file= pdomFile;
|
||||||
}
|
}
|
||||||
|
@ -571,7 +577,7 @@ public class PDOM extends PlatformObject implements IIndexFragment, IPDOM {
|
||||||
return (PDOMFile) getFile(file.getLocation());
|
return (PDOMFile) getFile(file.getLocation());
|
||||||
}
|
}
|
||||||
|
|
||||||
public IPath getPath() {
|
public File getPath() {
|
||||||
return fPath;
|
return fPath;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -11,6 +11,7 @@
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.pdom;
|
package org.eclipse.cdt.internal.core.pdom;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
import java.text.MessageFormat;
|
import java.text.MessageFormat;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
@ -24,8 +25,8 @@ import org.eclipse.cdt.core.dom.IPDOM;
|
||||||
import org.eclipse.cdt.core.dom.IPDOMIndexer;
|
import org.eclipse.cdt.core.dom.IPDOMIndexer;
|
||||||
import org.eclipse.cdt.core.dom.IPDOMIndexerTask;
|
import org.eclipse.cdt.core.dom.IPDOMIndexerTask;
|
||||||
import org.eclipse.cdt.core.dom.IPDOMManager;
|
import org.eclipse.cdt.core.dom.IPDOMManager;
|
||||||
import org.eclipse.cdt.core.index.IIndex;
|
|
||||||
import org.eclipse.cdt.core.index.IIndexChangeListener;
|
import org.eclipse.cdt.core.index.IIndexChangeListener;
|
||||||
|
import org.eclipse.cdt.core.index.IIndex;
|
||||||
import org.eclipse.cdt.core.index.IIndexerStateListener;
|
import org.eclipse.cdt.core.index.IIndexerStateListener;
|
||||||
import org.eclipse.cdt.core.model.CoreModel;
|
import org.eclipse.cdt.core.model.CoreModel;
|
||||||
import org.eclipse.cdt.core.model.ICElementDelta;
|
import org.eclipse.cdt.core.model.ICElementDelta;
|
||||||
|
@ -37,6 +38,7 @@ import org.eclipse.cdt.internal.core.index.IndexChangeEvent;
|
||||||
import org.eclipse.cdt.internal.core.index.IndexFactory;
|
import org.eclipse.cdt.internal.core.index.IndexFactory;
|
||||||
import org.eclipse.cdt.internal.core.index.IndexerStateEvent;
|
import org.eclipse.cdt.internal.core.index.IndexerStateEvent;
|
||||||
import org.eclipse.cdt.internal.core.pdom.PDOM.IListener;
|
import org.eclipse.cdt.internal.core.pdom.PDOM.IListener;
|
||||||
|
import org.eclipse.cdt.internal.core.pdom.dom.PDOMProjectIndexLocationConverter;
|
||||||
import org.eclipse.cdt.internal.core.pdom.indexer.nulli.PDOMNullIndexer;
|
import org.eclipse.cdt.internal.core.pdom.indexer.nulli.PDOMNullIndexer;
|
||||||
import org.eclipse.core.resources.IProject;
|
import org.eclipse.core.resources.IProject;
|
||||||
import org.eclipse.core.resources.IResourceDelta;
|
import org.eclipse.core.resources.IResourceDelta;
|
||||||
|
@ -177,7 +179,7 @@ public class PDOMManager implements IPDOMManager, IWritableIndexManager, IListen
|
||||||
dbPath= CCorePlugin.getDefault().getStateLocation().append(dbName);
|
dbPath= CCorePlugin.getDefault().getStateLocation().append(dbName);
|
||||||
}
|
}
|
||||||
|
|
||||||
pdom = new WritablePDOM(dbPath);
|
pdom = new WritablePDOM(new File(dbPath.toOSString()), new PDOMProjectIndexLocationConverter(rproject));
|
||||||
pdom.addListener(this);
|
pdom.addListener(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -11,27 +11,29 @@
|
||||||
|
|
||||||
package org.eclipse.cdt.internal.core.pdom;
|
package org.eclipse.cdt.internal.core.pdom;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
import java.text.MessageFormat;
|
import java.text.MessageFormat;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.CCorePlugin;
|
import org.eclipse.cdt.core.CCorePlugin;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTPreprocessorIncludeStatement;
|
import org.eclipse.cdt.core.dom.ast.IASTPreprocessorIncludeStatement;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTPreprocessorMacroDefinition;
|
import org.eclipse.cdt.core.dom.ast.IASTPreprocessorMacroDefinition;
|
||||||
|
import org.eclipse.cdt.core.index.IIndexFileLocation;
|
||||||
import org.eclipse.cdt.internal.core.index.IIndexFragmentFile;
|
import org.eclipse.cdt.internal.core.index.IIndexFragmentFile;
|
||||||
import org.eclipse.cdt.internal.core.index.IWritableIndexFragment;
|
import org.eclipse.cdt.internal.core.index.IWritableIndexFragment;
|
||||||
|
import org.eclipse.cdt.internal.core.pdom.dom.IIndexLocationConverter;
|
||||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMBinding;
|
import org.eclipse.cdt.internal.core.pdom.dom.PDOMBinding;
|
||||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMFile;
|
import org.eclipse.cdt.internal.core.pdom.dom.PDOMFile;
|
||||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMLinkage;
|
import org.eclipse.cdt.internal.core.pdom.dom.PDOMLinkage;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.core.runtime.IPath;
|
|
||||||
|
|
||||||
public class WritablePDOM extends PDOM implements IWritableIndexFragment {
|
public class WritablePDOM extends PDOM implements IWritableIndexFragment {
|
||||||
|
|
||||||
public WritablePDOM(IPath dbPath) throws CoreException {
|
public WritablePDOM(File dbPath, IIndexLocationConverter locationConverter) throws CoreException {
|
||||||
super(dbPath);
|
super(dbPath, locationConverter);
|
||||||
}
|
}
|
||||||
public IIndexFragmentFile addFile(String filename) throws CoreException {
|
public IIndexFragmentFile addFile(IIndexFileLocation location) throws CoreException {
|
||||||
return super.addFile(filename);
|
return super.addFile(location);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addFileContent(IIndexFragmentFile sourceFile,
|
public void addFileContent(IIndexFragmentFile sourceFile,
|
||||||
|
|
|
@ -78,10 +78,10 @@ public class Database {
|
||||||
|
|
||||||
public static final int MAX_SIZE = CHUNK_SIZE - 4; // Room for overhead
|
public static final int MAX_SIZE = CHUNK_SIZE - 4; // Room for overhead
|
||||||
|
|
||||||
public Database(String filename) throws CoreException {
|
public Database(File location) throws CoreException {
|
||||||
try {
|
try {
|
||||||
location = new File(filename);
|
this.location = location;
|
||||||
file = new RandomAccessFile(filename, "rw"); //$NON-NLS-1$
|
this.file = new RandomAccessFile(location, "rw"); //$NON-NLS-1$
|
||||||
|
|
||||||
// Allocate chunk table, make sure we have at least one
|
// Allocate chunk table, make sure we have at least one
|
||||||
long nChunks = file.length() / CHUNK_SIZE;
|
long nChunks = file.length() / CHUNK_SIZE;
|
||||||
|
|
|
@ -0,0 +1,38 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2006 Symbian Software Ltd. and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* Andrew Ferguson (Symbian) - initial API and implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.cdt.internal.core.pdom.dom;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.index.IIndexFileLocation;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Each IIndexFragment stores file location representations in an implementation specific manner.
|
||||||
|
* External to IIndexFragment files are identified by an {@link IIndexFileLocation}
|
||||||
|
*
|
||||||
|
* Internal to IIndexFragment a mechanism for converting between the string location format used
|
||||||
|
* and the URI world is needed. This interface represents that mechanism.
|
||||||
|
*/
|
||||||
|
public interface IIndexLocationConverter {
|
||||||
|
/**
|
||||||
|
* Convert a raw string in an internal IIndexFragment implementation specific format to
|
||||||
|
* an IIndexFileLocation or null if the internal format could not be translated.
|
||||||
|
* @param raw
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public abstract IIndexFileLocation fromInternalFormat(String raw);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert a IIndexFileLocation to the internal IIndexFragment implementation specific format
|
||||||
|
* or null if the location could not be translated.
|
||||||
|
* @param location
|
||||||
|
* @return an internal representation for the location specified
|
||||||
|
*/
|
||||||
|
public abstract String toInternalFormat(IIndexFileLocation location);
|
||||||
|
}
|
|
@ -0,0 +1,22 @@
|
||||||
|
package org.eclipse.cdt.internal.core.pdom.dom;
|
||||||
|
|
||||||
|
import java.util.MissingResourceException;
|
||||||
|
import java.util.ResourceBundle;
|
||||||
|
|
||||||
|
public class Messages {
|
||||||
|
private static final String BUNDLE_NAME = "org.eclipse.cdt.internal.core.pdom.dom.messages"; //$NON-NLS-1$
|
||||||
|
|
||||||
|
private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle
|
||||||
|
.getBundle(BUNDLE_NAME);
|
||||||
|
|
||||||
|
private Messages() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getString(String key) {
|
||||||
|
try {
|
||||||
|
return RESOURCE_BUNDLE.getString(key);
|
||||||
|
} catch (MissingResourceException e) {
|
||||||
|
return '!' + key + '!';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -15,9 +15,11 @@ import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.CCorePlugin;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTPreprocessorIncludeStatement;
|
import org.eclipse.cdt.core.dom.ast.IASTPreprocessorIncludeStatement;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTPreprocessorMacroDefinition;
|
import org.eclipse.cdt.core.dom.ast.IASTPreprocessorMacroDefinition;
|
||||||
|
import org.eclipse.cdt.core.index.IIndexFileLocation;
|
||||||
import org.eclipse.cdt.core.index.IIndexInclude;
|
import org.eclipse.cdt.core.index.IIndexInclude;
|
||||||
import org.eclipse.cdt.core.index.IIndexMacro;
|
import org.eclipse.cdt.core.index.IIndexMacro;
|
||||||
import org.eclipse.cdt.core.index.IIndexName;
|
import org.eclipse.cdt.core.index.IIndexName;
|
||||||
|
@ -26,6 +28,7 @@ import org.eclipse.cdt.internal.core.index.IIndexFragmentFile;
|
||||||
import org.eclipse.cdt.internal.core.index.IWritableIndexFragment;
|
import org.eclipse.cdt.internal.core.index.IWritableIndexFragment;
|
||||||
import org.eclipse.cdt.internal.core.pdom.PDOM;
|
import org.eclipse.cdt.internal.core.pdom.PDOM;
|
||||||
import org.eclipse.cdt.internal.core.pdom.WritablePDOM;
|
import org.eclipse.cdt.internal.core.pdom.WritablePDOM;
|
||||||
|
import org.eclipse.cdt.internal.core.pdom.db.BTree;
|
||||||
import org.eclipse.cdt.internal.core.pdom.db.Database;
|
import org.eclipse.cdt.internal.core.pdom.db.Database;
|
||||||
import org.eclipse.cdt.internal.core.pdom.db.IBTreeComparator;
|
import org.eclipse.cdt.internal.core.pdom.db.IBTreeComparator;
|
||||||
import org.eclipse.cdt.internal.core.pdom.db.IBTreeVisitor;
|
import org.eclipse.cdt.internal.core.pdom.db.IBTreeVisitor;
|
||||||
|
@ -42,75 +45,54 @@ public class PDOMFile implements IIndexFragmentFile {
|
||||||
|
|
||||||
private final PDOM pdom;
|
private final PDOM pdom;
|
||||||
private final int record;
|
private final int record;
|
||||||
|
|
||||||
private static final int FIRST_NAME = 0;
|
private static final int FIRST_NAME = 0;
|
||||||
private static final int FIRST_INCLUDE = 4;
|
private static final int FIRST_INCLUDE = 4;
|
||||||
private static final int FIRST_INCLUDED_BY = 8;
|
private static final int FIRST_INCLUDED_BY = 8;
|
||||||
private static final int FIRST_MACRO = 12;
|
private static final int FIRST_MACRO = 12;
|
||||||
private static final int FILE_NAME = 16;
|
private static final int LOCATION_REPRESENTATION = 16;
|
||||||
private static final int TIME_STAMP = 20;
|
private static final int TIME_STAMP = 20;
|
||||||
|
|
||||||
private static final int RECORD_SIZE = 28;
|
private static final int RECORD_SIZE = 28;
|
||||||
|
|
||||||
public static class Comparator implements IBTreeComparator {
|
public static class Comparator implements IBTreeComparator {
|
||||||
private Database db;
|
private Database db;
|
||||||
|
|
||||||
public Comparator(Database db) {
|
public Comparator(Database db) {
|
||||||
this.db = db;
|
this.db = db;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int compare(int record1, int record2) throws CoreException {
|
public int compare(int record1, int record2) throws CoreException {
|
||||||
IString name1 = db.getString(db.getInt(record1 + FILE_NAME));
|
IString name1 = db.getString(db.getInt(record1 + LOCATION_REPRESENTATION));
|
||||||
IString name2 = db.getString(db.getInt(record2 + FILE_NAME));
|
IString name2 = db.getString(db.getInt(record2 + LOCATION_REPRESENTATION));
|
||||||
return name1.compare(name2);
|
return name1.compare(name2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Finder implements IBTreeVisitor {
|
|
||||||
private final Database db;
|
|
||||||
private final String key;
|
|
||||||
private int record;
|
|
||||||
|
|
||||||
public Finder(Database db, String key) {
|
|
||||||
this.db = db;
|
|
||||||
this.key = key;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int compare(int record) throws CoreException {
|
|
||||||
IString name = db.getString(db.getInt(record + FILE_NAME));
|
|
||||||
return name.compare(key);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean visit(int record) throws CoreException {
|
|
||||||
this.record = record;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getRecord() {
|
|
||||||
return record;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public PDOMFile(PDOM pdom, int record) {
|
public PDOMFile(PDOM pdom, int record) {
|
||||||
this.pdom = pdom;
|
this.pdom = pdom;
|
||||||
this.record = record;
|
this.record = record;
|
||||||
}
|
}
|
||||||
|
|
||||||
public PDOMFile(PDOM pdom, String filename) throws CoreException {
|
public PDOMFile(PDOM pdom, IIndexFileLocation location) throws CoreException {
|
||||||
this.pdom = pdom;
|
this.pdom = pdom;
|
||||||
Database db = pdom.getDB();
|
Database db = pdom.getDB();
|
||||||
record = db.malloc(RECORD_SIZE);
|
record = db.malloc(RECORD_SIZE);
|
||||||
db.putInt(record + FILE_NAME, db.newString(filename).getRecord());
|
String locationString = pdom.getLocationConverter().toInternalFormat(location);
|
||||||
|
if(locationString==null)
|
||||||
|
throw new CoreException(CCorePlugin.createStatus(Messages.getString("PDOMFile.toInternalProblem")+location.getURI())); //$NON-NLS-1$
|
||||||
|
IString locationDBString = db.newString(locationString);
|
||||||
|
db.putInt(record + LOCATION_REPRESENTATION, locationDBString.getRecord());
|
||||||
db.putLong(record + TIME_STAMP, 0);
|
db.putLong(record + TIME_STAMP, 0);
|
||||||
setFirstName(null);
|
setFirstName(null);
|
||||||
setFirstInclude(null);
|
setFirstInclude(null);
|
||||||
setFirstIncludedBy(null);
|
setFirstIncludedBy(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getRecord() {
|
public int getRecord() {
|
||||||
return record;
|
return record;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean equals(Object obj) {
|
public boolean equals(Object obj) {
|
||||||
if (obj == this)
|
if (obj == this)
|
||||||
return true;
|
return true;
|
||||||
|
@ -120,29 +102,31 @@ public class PDOMFile implements IIndexFragmentFile {
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IString getFileName() throws CoreException {
|
/**
|
||||||
|
* Directly changes this record's internal location string. The format
|
||||||
|
* of this string is unspecified in general and is determined by the
|
||||||
|
* associated IIndexLocationConverter
|
||||||
|
* @param newName
|
||||||
|
* @throws CoreException
|
||||||
|
*/
|
||||||
|
public void setInternalLocation(String internalLocation) throws CoreException {
|
||||||
Database db = pdom.getDB();
|
Database db = pdom.getDB();
|
||||||
return db.getString(db.getInt(record + FILE_NAME));
|
int oldRecord = db.getInt(record + LOCATION_REPRESENTATION);
|
||||||
}
|
|
||||||
|
|
||||||
public void setFilename(String newName) throws CoreException {
|
|
||||||
Database db = pdom.getDB();
|
|
||||||
int oldRecord = db.getInt(record + FILE_NAME);
|
|
||||||
db.free(oldRecord);
|
db.free(oldRecord);
|
||||||
db.putInt(record + FILE_NAME, db.newString(newName).getRecord());
|
db.putInt(record + LOCATION_REPRESENTATION, db.newString(internalLocation).getRecord());
|
||||||
}
|
}
|
||||||
|
|
||||||
public long getTimestamp() throws CoreException {
|
public long getTimestamp() throws CoreException {
|
||||||
Database db = pdom.getDB();
|
Database db = pdom.getDB();
|
||||||
return db.getLong(record + TIME_STAMP);
|
return db.getLong(record + TIME_STAMP);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTimestamp(long timestamp) throws CoreException {
|
public void setTimestamp(long timestamp) throws CoreException {
|
||||||
Database db= pdom.getDB();
|
Database db= pdom.getDB();
|
||||||
db.putLong(record + TIME_STAMP, timestamp);
|
db.putLong(record + TIME_STAMP, timestamp);
|
||||||
}
|
}
|
||||||
|
|
||||||
public PDOMName getFirstName() throws CoreException {
|
public PDOMName getFirstName() throws CoreException {
|
||||||
int namerec = pdom.getDB().getInt(record + FIRST_NAME);
|
int namerec = pdom.getDB().getInt(record + FIRST_NAME);
|
||||||
return namerec != 0 ? new PDOMName(pdom, namerec) : null;
|
return namerec != 0 ? new PDOMName(pdom, namerec) : null;
|
||||||
|
@ -152,27 +136,27 @@ public class PDOMFile implements IIndexFragmentFile {
|
||||||
int namerec = firstName != null ? firstName.getRecord() : 0;
|
int namerec = firstName != null ? firstName.getRecord() : 0;
|
||||||
pdom.getDB().putInt(record + FIRST_NAME, namerec);
|
pdom.getDB().putInt(record + FIRST_NAME, namerec);
|
||||||
}
|
}
|
||||||
|
|
||||||
public PDOMInclude getFirstInclude() throws CoreException {
|
public PDOMInclude getFirstInclude() throws CoreException {
|
||||||
int increc = pdom.getDB().getInt(record + FIRST_INCLUDE);
|
int increc = pdom.getDB().getInt(record + FIRST_INCLUDE);
|
||||||
return increc != 0 ? new PDOMInclude(pdom, increc) : null;
|
return increc != 0 ? new PDOMInclude(pdom, increc) : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setFirstInclude(PDOMInclude include) throws CoreException {
|
public void setFirstInclude(PDOMInclude include) throws CoreException {
|
||||||
int rec = include != null ? include.getRecord() : 0;
|
int rec = include != null ? include.getRecord() : 0;
|
||||||
pdom.getDB().putInt(record + FIRST_INCLUDE, rec);
|
pdom.getDB().putInt(record + FIRST_INCLUDE, rec);
|
||||||
}
|
}
|
||||||
|
|
||||||
public PDOMInclude getFirstIncludedBy() throws CoreException {
|
public PDOMInclude getFirstIncludedBy() throws CoreException {
|
||||||
int rec = pdom.getDB().getInt(record + FIRST_INCLUDED_BY);
|
int rec = pdom.getDB().getInt(record + FIRST_INCLUDED_BY);
|
||||||
return rec != 0 ? new PDOMInclude(pdom, rec) : null;
|
return rec != 0 ? new PDOMInclude(pdom, rec) : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setFirstIncludedBy(PDOMInclude includedBy) throws CoreException {
|
public void setFirstIncludedBy(PDOMInclude includedBy) throws CoreException {
|
||||||
int rec = includedBy != null ? includedBy.getRecord() : 0;
|
int rec = includedBy != null ? includedBy.getRecord() : 0;
|
||||||
pdom.getDB().putInt(record + FIRST_INCLUDED_BY, rec);
|
pdom.getDB().putInt(record + FIRST_INCLUDED_BY, rec);
|
||||||
}
|
}
|
||||||
|
|
||||||
public PDOMMacro getFirstMacro() throws CoreException {
|
public PDOMMacro getFirstMacro() throws CoreException {
|
||||||
int rec = pdom.getDB().getInt(record + FIRST_MACRO);
|
int rec = pdom.getDB().getInt(record + FIRST_MACRO);
|
||||||
return rec != 0 ? new PDOMMacro(pdom, rec) : null;
|
return rec != 0 ? new PDOMMacro(pdom, rec) : null;
|
||||||
|
@ -182,10 +166,10 @@ public class PDOMFile implements IIndexFragmentFile {
|
||||||
int rec = macro != null ? macro.getRecord() : 0;
|
int rec = macro != null ? macro.getRecord() : 0;
|
||||||
pdom.getDB().putInt(record + FIRST_MACRO, rec);
|
pdom.getDB().putInt(record + FIRST_MACRO, rec);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addMacros(IASTPreprocessorMacroDefinition[] macros) throws CoreException {
|
public void addMacros(IASTPreprocessorMacroDefinition[] macros) throws CoreException {
|
||||||
assert getFirstMacro() == null;
|
assert getFirstMacro() == null;
|
||||||
|
|
||||||
PDOMMacro lastMacro= null;
|
PDOMMacro lastMacro= null;
|
||||||
for (int i = 0; i < macros.length; i++) {
|
for (int i = 0; i < macros.length; i++) {
|
||||||
IASTPreprocessorMacroDefinition macro = macros[i];
|
IASTPreprocessorMacroDefinition macro = macros[i];
|
||||||
|
@ -199,7 +183,7 @@ public class PDOMFile implements IIndexFragmentFile {
|
||||||
lastMacro= pdomMacro;
|
lastMacro= pdomMacro;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addNames(IASTName[][] names) throws CoreException {
|
public void addNames(IASTName[][] names) throws CoreException {
|
||||||
assert getFirstName() == null;
|
assert getFirstName() == null;
|
||||||
HashMap nameCache= new HashMap();
|
HashMap nameCache= new HashMap();
|
||||||
|
@ -220,7 +204,7 @@ public class PDOMFile implements IIndexFragmentFile {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private PDOMName createPDOMName(IASTName name, PDOMName caller) throws CoreException {
|
private PDOMName createPDOMName(IASTName name, PDOMName caller) throws CoreException {
|
||||||
PDOMName result= null;
|
PDOMName result= null;
|
||||||
PDOMBinding binding= ((WritablePDOM) pdom).addBinding(name);
|
PDOMBinding binding= ((WritablePDOM) pdom).addBinding(name);
|
||||||
|
@ -239,7 +223,7 @@ public class PDOMFile implements IIndexFragmentFile {
|
||||||
include = nextInclude;
|
include = nextInclude;
|
||||||
}
|
}
|
||||||
setFirstInclude(include);
|
setFirstInclude(include);
|
||||||
|
|
||||||
// Delete all the macros in this file
|
// Delete all the macros in this file
|
||||||
PDOMMacro macro = getFirstMacro();
|
PDOMMacro macro = getFirstMacro();
|
||||||
while (macro != null) {
|
while (macro != null) {
|
||||||
|
@ -248,7 +232,7 @@ public class PDOMFile implements IIndexFragmentFile {
|
||||||
macro = nextMacro;
|
macro = nextMacro;
|
||||||
}
|
}
|
||||||
setFirstMacro(null);
|
setFirstMacro(null);
|
||||||
|
|
||||||
// Delete all the names in this file
|
// Delete all the names in this file
|
||||||
PDOMName name = getFirstName();
|
PDOMName name = getFirstName();
|
||||||
while (name != null) {
|
while (name != null) {
|
||||||
|
@ -258,21 +242,21 @@ public class PDOMFile implements IIndexFragmentFile {
|
||||||
}
|
}
|
||||||
setFirstName(null);
|
setFirstName(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addIncludesTo(IIndexFragmentFile[] files, IASTPreprocessorIncludeStatement[] includes) throws CoreException {
|
public void addIncludesTo(IIndexFragmentFile[] files, IASTPreprocessorIncludeStatement[] includes) throws CoreException {
|
||||||
assert files.length == includes.length;
|
assert files.length == includes.length;
|
||||||
assert getFirstInclude() == null;
|
assert getFirstInclude() == null;
|
||||||
|
|
||||||
PDOMInclude lastInclude= null;
|
PDOMInclude lastInclude= null;
|
||||||
for (int i = 0; i < includes.length; i++) {
|
for (int i = 0; i < includes.length; i++) {
|
||||||
IASTPreprocessorIncludeStatement statement = includes[i];
|
IASTPreprocessorIncludeStatement statement = includes[i];
|
||||||
PDOMFile file= (PDOMFile) files[i];
|
PDOMFile file= (PDOMFile) files[i];
|
||||||
assert file.getIndexFragment() instanceof IWritableIndexFragment;
|
assert file.getIndexFragment() instanceof IWritableIndexFragment;
|
||||||
|
|
||||||
PDOMInclude pdomInclude = new PDOMInclude(pdom, statement);
|
PDOMInclude pdomInclude = new PDOMInclude(pdom, statement);
|
||||||
pdomInclude.setIncludedBy(this);
|
pdomInclude.setIncludedBy(this);
|
||||||
pdomInclude.setIncludes(file);
|
pdomInclude.setIncludes(file);
|
||||||
|
|
||||||
file.addIncludedBy(pdomInclude);
|
file.addIncludedBy(pdomInclude);
|
||||||
if (lastInclude == null) {
|
if (lastInclude == null) {
|
||||||
setFirstInclude(pdomInclude);
|
setFirstInclude(pdomInclude);
|
||||||
|
@ -283,7 +267,7 @@ public class PDOMFile implements IIndexFragmentFile {
|
||||||
lastInclude= pdomInclude;
|
lastInclude= pdomInclude;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addIncludedBy(PDOMInclude include) throws CoreException {
|
public void addIncludedBy(PDOMInclude include) throws CoreException {
|
||||||
PDOMInclude firstIncludedBy = getFirstIncludedBy();
|
PDOMInclude firstIncludedBy = getFirstIncludedBy();
|
||||||
if (firstIncludedBy != null) {
|
if (firstIncludedBy != null) {
|
||||||
|
@ -292,9 +276,9 @@ public class PDOMFile implements IIndexFragmentFile {
|
||||||
}
|
}
|
||||||
setFirstIncludedBy(include);
|
setFirstIncludedBy(include);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public IIndexInclude[] getIncludes() throws CoreException {
|
public IIndexInclude[] getIncludes() throws CoreException {
|
||||||
List result= new ArrayList();
|
List result= new ArrayList();
|
||||||
PDOMInclude include = getFirstInclude();
|
PDOMInclude include = getFirstInclude();
|
||||||
|
@ -305,10 +289,6 @@ public class PDOMFile implements IIndexFragmentFile {
|
||||||
return (IIndexInclude[]) result.toArray(new IIndexInclude[result.size()]);
|
return (IIndexInclude[]) result.toArray(new IIndexInclude[result.size()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getLocation() throws CoreException {
|
|
||||||
return getFileName().getString();
|
|
||||||
}
|
|
||||||
|
|
||||||
public IIndexMacro[] getMacros() throws CoreException {
|
public IIndexMacro[] getMacros() throws CoreException {
|
||||||
List result= new ArrayList();
|
List result= new ArrayList();
|
||||||
PDOMMacro macro = getFirstMacro();
|
PDOMMacro macro = getFirstMacro();
|
||||||
|
@ -318,7 +298,7 @@ public class PDOMFile implements IIndexFragmentFile {
|
||||||
}
|
}
|
||||||
return (IIndexMacro[]) result.toArray(new IIndexMacro[result.size()]);
|
return (IIndexMacro[]) result.toArray(new IIndexMacro[result.size()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public IIndexFragment getIndexFragment() {
|
public IIndexFragment getIndexFragment() {
|
||||||
return pdom;
|
return pdom;
|
||||||
}
|
}
|
||||||
|
@ -339,8 +319,52 @@ public class PDOMFile implements IIndexFragmentFile {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return (IIndexName[]) result.toArray(new IIndexName[result.size()]);
|
return (IIndexName[]) result.toArray(new IIndexName[result.size()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static IIndexFragmentFile findFile(PDOM pdom, BTree btree, IIndexFileLocation location, IIndexLocationConverter strategy)
|
||||||
|
throws CoreException {
|
||||||
|
Finder finder = new Finder(pdom.getDB(), location, strategy);
|
||||||
|
btree.accept(finder);
|
||||||
|
int record = finder.getRecord();
|
||||||
|
return record != 0 ? new PDOMFile(pdom, record) : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static class Finder implements IBTreeVisitor {
|
||||||
|
private final Database db;
|
||||||
|
private final String rawKey;
|
||||||
|
private int record;
|
||||||
|
|
||||||
|
public Finder(Database db, IIndexFileLocation location, IIndexLocationConverter strategy)
|
||||||
|
throws CoreException
|
||||||
|
{
|
||||||
|
this.db = db;
|
||||||
|
this.rawKey = strategy.toInternalFormat(location);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int compare(int record) throws CoreException {
|
||||||
|
IString name = db.getString(db.getInt(record + PDOMFile.LOCATION_REPRESENTATION));
|
||||||
|
return name.compare(rawKey);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean visit(int record) throws CoreException {
|
||||||
|
this.record = record;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getRecord() {
|
||||||
|
return record;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public IIndexFileLocation getLocation() throws CoreException {
|
||||||
|
Database db = pdom.getDB();
|
||||||
|
String raw = db.getString(db.getInt(record + LOCATION_REPRESENTATION)).getString();
|
||||||
|
IIndexFileLocation result = pdom.getLocationConverter().fromInternalFormat(raw);
|
||||||
|
if(result==null)
|
||||||
|
throw new CoreException(CCorePlugin.createStatus(Messages.getString("PDOMFile.toExternalProblem")+raw)); //$NON-NLS-1$
|
||||||
|
return result;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,6 +16,7 @@ import org.eclipse.cdt.core.dom.ast.IASTFileLocation;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTPreprocessorIncludeStatement;
|
import org.eclipse.cdt.core.dom.ast.IASTPreprocessorIncludeStatement;
|
||||||
import org.eclipse.cdt.core.index.IIndexFile;
|
import org.eclipse.cdt.core.index.IIndexFile;
|
||||||
|
import org.eclipse.cdt.core.index.IIndexFileLocation;
|
||||||
import org.eclipse.cdt.internal.core.index.IIndexFragment;
|
import org.eclipse.cdt.internal.core.index.IIndexFragment;
|
||||||
import org.eclipse.cdt.internal.core.index.IIndexFragmentFile;
|
import org.eclipse.cdt.internal.core.index.IIndexFragmentFile;
|
||||||
import org.eclipse.cdt.internal.core.index.IIndexFragmentInclude;
|
import org.eclipse.cdt.internal.core.index.IIndexFragmentInclude;
|
||||||
|
@ -139,11 +140,11 @@ public class PDOMInclude implements IIndexFragmentInclude {
|
||||||
pdom.getDB().putInt(record + INCLUDED_BY_PREV, rec);
|
pdom.getDB().putInt(record + INCLUDED_BY_PREV, rec);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getIncludedByLocation() throws CoreException {
|
public IIndexFileLocation getIncludedByLocation() throws CoreException {
|
||||||
return getIncludedBy().getLocation();
|
return getIncludedBy().getLocation();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getIncludesLocation() throws CoreException {
|
public IIndexFileLocation getIncludesLocation() throws CoreException {
|
||||||
return getIncludes().getLocation();
|
return getIncludes().getLocation();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.pdom.dom;
|
package org.eclipse.cdt.internal.core.pdom.dom;
|
||||||
|
|
||||||
|
import java.net.URI;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.CCorePlugin;
|
import org.eclipse.cdt.core.CCorePlugin;
|
||||||
|
@ -106,16 +107,16 @@ public class PDOMName implements IIndexFragmentName, IASTFileLocation {
|
||||||
private int getRecField(int offset) throws CoreException {
|
private int getRecField(int offset) throws CoreException {
|
||||||
return pdom.getDB().getInt(record + offset);
|
return pdom.getDB().getInt(record + offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setRecField(int offset, int fieldrec) throws CoreException {
|
private void setRecField(int offset, int fieldrec) throws CoreException {
|
||||||
pdom.getDB().putInt(record + offset, fieldrec);
|
pdom.getDB().putInt(record + offset, fieldrec);
|
||||||
}
|
}
|
||||||
|
|
||||||
public PDOMBinding getPDOMBinding() throws CoreException {
|
public PDOMBinding getPDOMBinding() throws CoreException {
|
||||||
int bindingrec = getRecField(BINDING_REC_OFFSET);
|
int bindingrec = getRecField(BINDING_REC_OFFSET);
|
||||||
return pdom.getBinding(bindingrec);
|
return pdom.getBinding(bindingrec);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setBinding(PDOMBinding binding) throws CoreException {
|
public void setBinding(PDOMBinding binding) throws CoreException {
|
||||||
int bindingrec = binding != null ? binding.getRecord() : 0;
|
int bindingrec = binding != null ? binding.getRecord() : 0;
|
||||||
setRecField(BINDING_REC_OFFSET, bindingrec);
|
setRecField(BINDING_REC_OFFSET, bindingrec);
|
||||||
|
@ -125,16 +126,16 @@ public class PDOMName implements IIndexFragmentName, IASTFileLocation {
|
||||||
int namerec = getRecField(offset);
|
int namerec = getRecField(offset);
|
||||||
return namerec != 0 ? new PDOMName(pdom, namerec) : null;
|
return namerec != 0 ? new PDOMName(pdom, namerec) : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setNameField(int offset, PDOMName name) throws CoreException {
|
private void setNameField(int offset, PDOMName name) throws CoreException {
|
||||||
int namerec = name != null ? name.getRecord() : 0;
|
int namerec = name != null ? name.getRecord() : 0;
|
||||||
setRecField(offset, namerec);
|
setRecField(offset, namerec);
|
||||||
}
|
}
|
||||||
|
|
||||||
public PDOMName getPrevInBinding() throws CoreException {
|
public PDOMName getPrevInBinding() throws CoreException {
|
||||||
return getNameField(BINDING_PREV_OFFSET);
|
return getNameField(BINDING_PREV_OFFSET);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPrevInBinding(PDOMName name) throws CoreException {
|
public void setPrevInBinding(PDOMName name) throws CoreException {
|
||||||
setNameField(BINDING_PREV_OFFSET, name);
|
setNameField(BINDING_PREV_OFFSET, name);
|
||||||
}
|
}
|
||||||
|
@ -194,7 +195,7 @@ public class PDOMName implements IIndexFragmentName, IASTFileLocation {
|
||||||
private byte getFlags() throws CoreException {
|
private byte getFlags() throws CoreException {
|
||||||
return pdom.getDB().getByte(record + FLAGS);
|
return pdom.getDB().getByte(record + FLAGS);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isDeclaration() {
|
public boolean isDeclaration() {
|
||||||
try {
|
try {
|
||||||
byte flags = getFlags();
|
byte flags = getFlags();
|
||||||
|
@ -232,11 +233,20 @@ public class PDOMName implements IIndexFragmentName, IASTFileLocation {
|
||||||
public String getFileName() {
|
public String getFileName() {
|
||||||
try {
|
try {
|
||||||
PDOMFile file = (PDOMFile) getFile();
|
PDOMFile file = (PDOMFile) getFile();
|
||||||
return file != null ? file.getFileName().getString() : null;
|
if(file!=null) {
|
||||||
|
/*
|
||||||
|
* We need to spec. what this method can return to know
|
||||||
|
* how to implement this. Existing implmentations return
|
||||||
|
* the absolute path, so here we attempt to do the same.
|
||||||
|
*/
|
||||||
|
URI uri = file.getLocation().getURI();
|
||||||
|
if ("file".equals(uri.getScheme())) //$NON-NLS-1$
|
||||||
|
return uri.getSchemeSpecificPart();
|
||||||
|
}
|
||||||
} catch (CoreException e) {
|
} catch (CoreException e) {
|
||||||
CCorePlugin.log(e);
|
CCorePlugin.log(e);
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getStartingLineNumber() {
|
public int getStartingLineNumber() {
|
||||||
|
@ -288,10 +298,10 @@ public class PDOMName implements IIndexFragmentName, IASTFileLocation {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nextName != null)
|
if (nextName != null)
|
||||||
nextName.setPrevInBinding(prevName);
|
nextName.setPrevInBinding(prevName);
|
||||||
|
|
||||||
// Delete our record
|
// Delete our record
|
||||||
pdom.getDB().free(record);
|
pdom.getDB().free(record);
|
||||||
}
|
}
|
||||||
|
@ -299,7 +309,7 @@ public class PDOMName implements IIndexFragmentName, IASTFileLocation {
|
||||||
public IIndexFragment getIndexFragment() {
|
public IIndexFragment getIndexFragment() {
|
||||||
return pdom;
|
return pdom;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IIndexProxyBinding getBinding() throws CoreException {
|
public IIndexProxyBinding getBinding() throws CoreException {
|
||||||
return getPDOMBinding();
|
return getPDOMBinding();
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,66 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2006 Symbian Software Ltd. and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* Andrew Ferguson (Symbian) - initial API and implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.cdt.internal.core.pdom.dom;
|
||||||
|
|
||||||
|
import java.net.URI;
|
||||||
|
import java.net.URISyntaxException;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.index.IIndexFileLocation;
|
||||||
|
import org.eclipse.cdt.internal.core.index.IndexFileLocation;
|
||||||
|
import org.eclipse.core.resources.IProject;
|
||||||
|
import org.eclipse.core.resources.IWorkspaceRoot;
|
||||||
|
import org.eclipse.core.resources.ResourcesPlugin;
|
||||||
|
import org.eclipse.core.runtime.Path;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The standard location converter used by the per-project PDOM
|
||||||
|
*/
|
||||||
|
public class PDOMProjectIndexLocationConverter implements IIndexLocationConverter {
|
||||||
|
IProject project;
|
||||||
|
IWorkspaceRoot root;
|
||||||
|
private static final String EXTERNAL = "<EXT>"; //$NON-NLS-1$
|
||||||
|
|
||||||
|
public PDOMProjectIndexLocationConverter(IProject project) {
|
||||||
|
this.project = project;
|
||||||
|
this.root = ResourcesPlugin.getWorkspace().getRoot();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.internal.core.pdom.dom.IIndexLocationConverter#fromInternalFormat(java.lang.String)
|
||||||
|
*/
|
||||||
|
public IIndexFileLocation fromInternalFormat(String raw) {
|
||||||
|
String fullPath = null;
|
||||||
|
URI uri;
|
||||||
|
if(raw.startsWith(EXTERNAL)) {
|
||||||
|
try {
|
||||||
|
uri = new URI(raw.substring(EXTERNAL.length()));
|
||||||
|
} catch(URISyntaxException use) {
|
||||||
|
uri = null;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
uri = project.findMember(raw).getLocationURI();
|
||||||
|
}
|
||||||
|
return new IndexFileLocation(uri, fullPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.internal.core.pdom.dom.IIndexLocationConverter#toRaw(java.net.URI)
|
||||||
|
*/
|
||||||
|
public String toInternalFormat(IIndexFileLocation location) {
|
||||||
|
String result;
|
||||||
|
if(location.getFullPath()!=null) {
|
||||||
|
result = new Path(location.getFullPath()).removeFirstSegments(1).toString();
|
||||||
|
} else {
|
||||||
|
result = EXTERNAL+location.getURI().toString();
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,2 @@
|
||||||
|
PDOMFile.toInternalProblem=Unable to translate location to internal format:
|
||||||
|
PDOMFile.toExternalProblem=Unable to translate from internal format for
|
|
@ -31,7 +31,9 @@ import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||||
import org.eclipse.cdt.core.dom.ast.IProblemBinding;
|
import org.eclipse.cdt.core.dom.ast.IProblemBinding;
|
||||||
import org.eclipse.cdt.core.index.IIndex;
|
import org.eclipse.cdt.core.index.IIndex;
|
||||||
import org.eclipse.cdt.core.index.IIndexFile;
|
import org.eclipse.cdt.core.index.IIndexFile;
|
||||||
|
import org.eclipse.cdt.core.index.IIndexFileLocation;
|
||||||
import org.eclipse.cdt.core.index.IIndexInclude;
|
import org.eclipse.cdt.core.index.IIndexInclude;
|
||||||
|
import org.eclipse.cdt.core.index.IndexLocationFactory;
|
||||||
import org.eclipse.cdt.core.model.CoreModel;
|
import org.eclipse.cdt.core.model.CoreModel;
|
||||||
import org.eclipse.cdt.core.model.CoreModelUtil;
|
import org.eclipse.cdt.core.model.CoreModelUtil;
|
||||||
import org.eclipse.cdt.core.model.ICContainer;
|
import org.eclipse.cdt.core.model.ICContainer;
|
||||||
|
@ -42,12 +44,12 @@ import org.eclipse.cdt.core.model.ICProject;
|
||||||
import org.eclipse.cdt.core.model.ITranslationUnit;
|
import org.eclipse.cdt.core.model.ITranslationUnit;
|
||||||
import org.eclipse.cdt.internal.core.index.IIndexFragmentFile;
|
import org.eclipse.cdt.internal.core.index.IIndexFragmentFile;
|
||||||
import org.eclipse.cdt.internal.core.index.IWritableIndex;
|
import org.eclipse.cdt.internal.core.index.IWritableIndex;
|
||||||
|
import org.eclipse.core.filesystem.EFS;
|
||||||
import org.eclipse.core.resources.IFile;
|
import org.eclipse.core.resources.IFile;
|
||||||
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.core.runtime.IStatus;
|
import org.eclipse.core.runtime.IStatus;
|
||||||
import org.eclipse.core.runtime.Path;
|
|
||||||
import org.eclipse.core.runtime.Platform;
|
import org.eclipse.core.runtime.Platform;
|
||||||
|
|
||||||
public abstract class PDOMIndexerTask implements IPDOMIndexerTask {
|
public abstract class PDOMIndexerTask implements IPDOMIndexerTask {
|
||||||
|
@ -89,7 +91,7 @@ public abstract class PDOMIndexerTask implements IPDOMIndexerTask {
|
||||||
protected volatile int fTotalSourcesEstimate= 0;
|
protected volatile int fTotalSourcesEstimate= 0;
|
||||||
protected volatile int fCompletedSources= 0;
|
protected volatile int fCompletedSources= 0;
|
||||||
protected volatile int fCompletedHeaders= 0;
|
protected volatile int fCompletedHeaders= 0;
|
||||||
protected Map fContextMap= new HashMap();
|
protected Map/*<IIndexFileLocation, Object>*/ fContextMap = new HashMap/*<IIndexFileLocation, Object>*/();
|
||||||
protected volatile String fMessage;
|
protected volatile String fMessage;
|
||||||
|
|
||||||
private boolean fTrace;
|
private boolean fTrace;
|
||||||
|
@ -105,7 +107,7 @@ public abstract class PDOMIndexerTask implements IPDOMIndexerTask {
|
||||||
protected PDOMIndexerTask() {
|
protected PDOMIndexerTask() {
|
||||||
fTrace= checkDebugOption("indexer", "true"); //$NON-NLS-1$//$NON-NLS-2$
|
fTrace= checkDebugOption("indexer", "true"); //$NON-NLS-1$//$NON-NLS-2$
|
||||||
fShowStatistics= checkDebugOption("pdomtimings", "true"); //$NON-NLS-1$//$NON-NLS-2$
|
fShowStatistics= checkDebugOption("pdomtimings", "true"); //$NON-NLS-1$//$NON-NLS-2$
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean checkDebugOption(String option, String value) {
|
private boolean checkDebugOption(String option, String value) {
|
||||||
String trace = Platform.getDebugOption(CCorePlugin.PLUGIN_ID + "/debug/" + option); //$NON-NLS-1$
|
String trace = Platform.getDebugOption(CCorePlugin.PLUGIN_ID + "/debug/" + option); //$NON-NLS-1$
|
||||||
|
@ -168,8 +170,7 @@ public abstract class PDOMIndexerTask implements IPDOMIndexerTask {
|
||||||
protected void removeTU(IWritableIndex index, ITranslationUnit tu) throws CoreException, InterruptedException {
|
protected void removeTU(IWritableIndex index, ITranslationUnit tu) throws CoreException, InterruptedException {
|
||||||
index.acquireWriteLock(0);
|
index.acquireWriteLock(0);
|
||||||
try {
|
try {
|
||||||
IPath path = ((IFile)tu.getResource()).getLocation();
|
IIndexFragmentFile file = (IIndexFragmentFile) index.getFile(getIndexFileLocation(tu));
|
||||||
IIndexFragmentFile file = (IIndexFragmentFile) index.getFile(path);
|
|
||||||
if (file != null)
|
if (file != null)
|
||||||
index.clearFile(file);
|
index.clearFile(file);
|
||||||
} finally {
|
} finally {
|
||||||
|
@ -179,29 +180,26 @@ public abstract class PDOMIndexerTask implements IPDOMIndexerTask {
|
||||||
|
|
||||||
protected void parseTUs(Collection sources, Collection headers, IProgressMonitor monitor) throws CoreException, InterruptedException {
|
protected void parseTUs(Collection sources, Collection headers, IProgressMonitor monitor) throws CoreException, InterruptedException {
|
||||||
// sources first
|
// sources first
|
||||||
Iterator iter;
|
for (Iterator iter = sources.iterator(); iter.hasNext();) {
|
||||||
for (iter = sources.iterator(); iter.hasNext();) {
|
|
||||||
if (monitor.isCanceled())
|
if (monitor.isCanceled())
|
||||||
return;
|
return;
|
||||||
ITranslationUnit tu = (ITranslationUnit) iter.next();
|
ITranslationUnit tu = (ITranslationUnit) iter.next();
|
||||||
String path = tu.getLocation().toOSString();
|
if (needToUpdate(getIndexFileLocation(tu))) {
|
||||||
if (needToUpdate(path)) {
|
|
||||||
parseTU(tu, monitor);
|
parseTU(tu, monitor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// headers with context
|
// headers with context
|
||||||
for (iter = headers.iterator(); iter.hasNext();) {
|
for (Iterator iter = headers.iterator(); iter.hasNext();) {
|
||||||
if (monitor.isCanceled())
|
if (monitor.isCanceled())
|
||||||
return;
|
return;
|
||||||
ITranslationUnit tu = (ITranslationUnit) iter.next();
|
ITranslationUnit tu = (ITranslationUnit) iter.next();
|
||||||
String path = tu.getLocation().toOSString();
|
IIndexFileLocation location = getIndexFileLocation(tu);
|
||||||
if (!needToUpdate(path)) {
|
if (!needToUpdate(location)) {
|
||||||
iter.remove();
|
iter.remove();
|
||||||
}
|
} else {
|
||||||
else {
|
ITranslationUnit context= findContext(getIndex(), location);
|
||||||
ITranslationUnit context= findContext(getIndex(), path);
|
if (context != null) {
|
||||||
if (context != null) {
|
|
||||||
parseTU(context, monitor);
|
parseTU(context, monitor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -209,12 +207,11 @@ public abstract class PDOMIndexerTask implements IPDOMIndexerTask {
|
||||||
|
|
||||||
// headers without context
|
// headers without context
|
||||||
if (getIndexAllFiles()) {
|
if (getIndexAllFiles()) {
|
||||||
for (iter = headers.iterator(); iter.hasNext();) {
|
for (Iterator iter = headers.iterator(); iter.hasNext();) {
|
||||||
if (monitor.isCanceled())
|
if (monitor.isCanceled())
|
||||||
return;
|
return;
|
||||||
ITranslationUnit tu = (ITranslationUnit) iter.next();
|
ITranslationUnit tu = (ITranslationUnit) iter.next();
|
||||||
String path = tu.getLocation().toOSString();
|
if (!needToUpdate(getIndexFileLocation(tu))) {
|
||||||
if (!needToUpdate(path)) {
|
|
||||||
iter.remove();
|
iter.remove();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -276,38 +273,37 @@ public abstract class PDOMIndexerTask implements IPDOMIndexerTask {
|
||||||
return getIndexer().getIndexAllFiles();
|
return getIndexer().getIndexAllFiles();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected ITranslationUnit findContext(IIndex index, String path) {
|
protected ITranslationUnit findContext(IIndex index, IIndexFileLocation location) {
|
||||||
Object cachedContext= fContextMap.get(path);
|
Object cachedContext= fContextMap.get(location);
|
||||||
if (cachedContext != null) {
|
if (cachedContext != null) {
|
||||||
return cachedContext == NO_CONTEXT ? null : (ITranslationUnit) cachedContext;
|
return cachedContext == NO_CONTEXT ? null : (ITranslationUnit) cachedContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
ITranslationUnit context= null;
|
fContextMap.put(location, NO_CONTEXT); // prevent recursion
|
||||||
fContextMap.put(path, NO_CONTEXT); // prevent recursion
|
|
||||||
IIndexFile pdomFile;
|
IIndexFile pdomFile;
|
||||||
try {
|
try {
|
||||||
pdomFile = index.getFile(new Path(path));
|
pdomFile = index.getFile(location);
|
||||||
if (pdomFile != null) {
|
if (pdomFile != null) {
|
||||||
ICProject project= getIndexer().getProject();
|
ICProject project= getIndexer().getProject();
|
||||||
IIndexInclude[] includedBy = index.findIncludedBy(pdomFile, IIndex.DEPTH_ZERO);
|
IIndexInclude[] includedBy = index.findIncludedBy(pdomFile, IIndex.DEPTH_ZERO);
|
||||||
ArrayList paths= new ArrayList(includedBy.length);
|
ArrayList/*<IIndexFileLocation>*/ paths= new ArrayList/*<IIndexFileLocation>*/(includedBy.length);
|
||||||
for (int i = 0; i < includedBy.length; i++) {
|
for (int i = 0; i < includedBy.length; i++) {
|
||||||
IIndexInclude include = includedBy[i];
|
IIndexInclude include = includedBy[i];
|
||||||
String incfilename = include.getIncludedByLocation();
|
IIndexFileLocation incLocation = include.getIncludedByLocation();
|
||||||
if (CoreModel.isValidSourceUnitName(project.getProject(), incfilename)) {
|
if (CoreModel.isValidSourceUnitName(project.getProject(), incLocation.getURI().toString())) { // FIXME - is this ok?
|
||||||
context= CoreModelUtil.findTranslationUnitForLocation(new Path(incfilename), project);
|
ITranslationUnit context = CoreModelUtil.findTranslationUnitForLocation(IndexLocationFactory.getAbsolutePath(incLocation), project);
|
||||||
if (context != null) {
|
if (context != null) {
|
||||||
fContextMap.put(path, context);
|
fContextMap.put(location, context);
|
||||||
return context;
|
return context;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
paths.add(incfilename);
|
paths.add(incLocation);
|
||||||
}
|
}
|
||||||
for (Iterator iter = paths.iterator(); iter.hasNext();) {
|
for (Iterator/*<IIndexFileLocation>*/ iter = paths.iterator(); iter.hasNext();) {
|
||||||
String nextLevel = (String) iter.next();
|
IIndexFileLocation nextLevel = (IIndexFileLocation) iter.next();
|
||||||
context= findContext(index, nextLevel);
|
ITranslationUnit context = findContext(index, nextLevel);
|
||||||
if (context != null) {
|
if (context != null) {
|
||||||
fContextMap.put(path, context);
|
fContextMap.put(location, context);
|
||||||
return context;
|
return context;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -339,12 +335,12 @@ public abstract class PDOMIndexerTask implements IPDOMIndexerTask {
|
||||||
protected void addSymbols(IASTTranslationUnit ast, IProgressMonitor pm) throws InterruptedException, CoreException {
|
protected void addSymbols(IASTTranslationUnit ast, IProgressMonitor pm) throws InterruptedException, CoreException {
|
||||||
final Map symbolMap= new HashMap();
|
final Map symbolMap= new HashMap();
|
||||||
try {
|
try {
|
||||||
String[] orderedPaths= extractSymbols(ast, symbolMap);
|
IIndexFileLocation[] orderedPaths= extractSymbols(ast, symbolMap);
|
||||||
for (int i=0; i<orderedPaths.length; i++) {
|
for (int i=0; i<orderedPaths.length; i++) {
|
||||||
if (pm.isCanceled()) {
|
if (pm.isCanceled()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
String path= orderedPaths[i];
|
IIndexFileLocation path= orderedPaths[i];
|
||||||
ArrayList[] arrayLists = ((ArrayList[]) symbolMap.get(path));
|
ArrayList[] arrayLists = ((ArrayList[]) symbolMap.get(path));
|
||||||
|
|
||||||
// resolve the names
|
// resolve the names
|
||||||
|
@ -360,8 +356,8 @@ public abstract class PDOMIndexerTask implements IPDOMIndexerTask {
|
||||||
fReferenceCount++;
|
fReferenceCount++;
|
||||||
else
|
else
|
||||||
fDeclarationCount++;
|
fDeclarationCount++;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
fResolutionTime += System.currentTimeMillis()-start;
|
fResolutionTime += System.currentTimeMillis()-start;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -375,7 +371,7 @@ public abstract class PDOMIndexerTask implements IPDOMIndexerTask {
|
||||||
if (pm.isCanceled())
|
if (pm.isCanceled())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
String path = orderedPaths[i];
|
IIndexFileLocation path = orderedPaths[i];
|
||||||
if (path != null) {
|
if (path != null) {
|
||||||
if (fTrace) {
|
if (fTrace) {
|
||||||
System.out.println("Indexer: adding " + path); //$NON-NLS-1$
|
System.out.println("Indexer: adding " + path); //$NON-NLS-1$
|
||||||
|
@ -403,35 +399,36 @@ public abstract class PDOMIndexerTask implements IPDOMIndexerTask {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private String[] extractSymbols(IASTTranslationUnit ast, final Map symbolMap) throws CoreException {
|
private IIndexFileLocation[] extractSymbols(IASTTranslationUnit ast, final Map symbolMap) throws CoreException {
|
||||||
LinkedHashSet orderedIncludes= new LinkedHashSet();
|
LinkedHashSet/*<IIndexFileLocation>*/ orderedIncludes= new LinkedHashSet/*<IIndexFileLocation>*/();
|
||||||
ArrayList stack= new ArrayList();
|
ArrayList/*<IIndexFileLocation>*/ stack= new ArrayList/*<IIndexFileLocation>*/();
|
||||||
|
|
||||||
final String astFilePath = ast.getFilePath();
|
|
||||||
String currentPath= astFilePath;
|
final IIndexFileLocation astLocation = findLocation(ast.getFilePath());
|
||||||
|
IIndexFileLocation currentPath = astLocation;
|
||||||
|
|
||||||
IASTPreprocessorIncludeStatement[] includes = ast.getIncludeDirectives();
|
IASTPreprocessorIncludeStatement[] includes = ast.getIncludeDirectives();
|
||||||
for (int i= 0; i < includes.length; i++) {
|
for (int i= 0; i < includes.length; i++) {
|
||||||
IASTPreprocessorIncludeStatement include = includes[i];
|
IASTPreprocessorIncludeStatement include = includes[i];
|
||||||
IASTFileLocation sourceLoc = include.getFileLocation();
|
IASTFileLocation sourceLoc = include.getFileLocation();
|
||||||
String newPath= sourceLoc != null ? sourceLoc.getFileName() : astFilePath; // command-line includes
|
IIndexFileLocation newPath= sourceLoc != null ? findLocation(sourceLoc.getFileName()) : astLocation; // command-line includes
|
||||||
while (!stack.isEmpty() && !currentPath.equals(newPath)) {
|
while (!stack.isEmpty() && !currentPath.equals(newPath)) {
|
||||||
if (needToUpdate(currentPath)) {
|
if (needToUpdate(currentPath)) {
|
||||||
prepareInMap(symbolMap, currentPath);
|
prepareInMap(symbolMap, currentPath);
|
||||||
orderedIncludes.add(currentPath);
|
orderedIncludes.add(currentPath);
|
||||||
}
|
}
|
||||||
currentPath= (String) stack.remove(stack.size()-1);
|
currentPath= (IIndexFileLocation) stack.remove(stack.size()-1);
|
||||||
}
|
}
|
||||||
if (needToUpdate(newPath)) {
|
if (needToUpdate(newPath)) {
|
||||||
prepareInMap(symbolMap, newPath);
|
prepareInMap(symbolMap, newPath);
|
||||||
addToMap(symbolMap, 0, newPath, include);
|
addToMap(symbolMap, 0, newPath, include);
|
||||||
}
|
}
|
||||||
stack.add(currentPath);
|
stack.add(currentPath);
|
||||||
currentPath= include.getPath();
|
currentPath= findLocation(include.getPath());
|
||||||
}
|
}
|
||||||
stack.add(currentPath);
|
stack.add(currentPath);
|
||||||
while (!stack.isEmpty()) {
|
while (!stack.isEmpty()) {
|
||||||
currentPath= (String) stack.remove(stack.size()-1);
|
currentPath= (IIndexFileLocation) stack.remove(stack.size()-1);
|
||||||
if (needToUpdate(currentPath)) {
|
if (needToUpdate(currentPath)) {
|
||||||
prepareInMap(symbolMap, currentPath);
|
prepareInMap(symbolMap, currentPath);
|
||||||
orderedIncludes.add(currentPath);
|
orderedIncludes.add(currentPath);
|
||||||
|
@ -444,7 +441,7 @@ public abstract class PDOMIndexerTask implements IPDOMIndexerTask {
|
||||||
IASTPreprocessorMacroDefinition macro = macros[i2];
|
IASTPreprocessorMacroDefinition macro = macros[i2];
|
||||||
IASTFileLocation sourceLoc = macro.getFileLocation();
|
IASTFileLocation sourceLoc = macro.getFileLocation();
|
||||||
if (sourceLoc != null) { // skip built-ins and command line macros
|
if (sourceLoc != null) { // skip built-ins and command line macros
|
||||||
String path2 = sourceLoc.getFileName();
|
IIndexFileLocation path2 = findLocation(sourceLoc.getFileName());
|
||||||
addToMap(symbolMap, 1, path2, macro);
|
addToMap(symbolMap, 1, path2, macro);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -454,44 +451,41 @@ public abstract class PDOMIndexerTask implements IPDOMIndexerTask {
|
||||||
public void visit(IASTName name, IASTName caller) {
|
public void visit(IASTName name, IASTName caller) {
|
||||||
IASTFileLocation nameLoc = name.getFileLocation();
|
IASTFileLocation nameLoc = name.getFileLocation();
|
||||||
if (nameLoc != null) {
|
if (nameLoc != null) {
|
||||||
addToMap(symbolMap, 2, nameLoc.getFileName(), new IASTName[]{name, caller});
|
IIndexFileLocation location = findLocation(nameLoc.getFileName());
|
||||||
|
addToMap(symbolMap, 2, location, new IASTName[]{name, caller});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return (String[]) orderedIncludes.toArray(new String[orderedIncludes.size()]);
|
return (IIndexFileLocation[]) orderedIncludes.toArray(new IIndexFileLocation[orderedIncludes.size()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected abstract IWritableIndex getIndex();
|
protected abstract IWritableIndex getIndex();
|
||||||
protected abstract int getReadlockCount();
|
protected abstract int getReadlockCount();
|
||||||
protected abstract boolean needToUpdate(String path) throws CoreException;
|
protected abstract boolean needToUpdate(IIndexFileLocation location) throws CoreException;
|
||||||
protected abstract boolean postAddToIndex(String path, IIndexFile file) throws CoreException;
|
protected abstract boolean postAddToIndex(IIndexFileLocation location, IIndexFile file) throws CoreException;
|
||||||
|
|
||||||
|
private void addToMap(Map map, int idx, IIndexFileLocation location, Object thing) {
|
||||||
private void addToMap(Map map, int idx, String path, Object thing) {
|
List[] lists= (List[]) map.get(location);
|
||||||
List[] lists= (List[]) map.get(path);
|
|
||||||
if (lists != null)
|
if (lists != null)
|
||||||
lists[idx].add(thing);
|
lists[idx].add(thing);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean prepareInMap(Map map, String path) {
|
private boolean prepareInMap(Map map, IIndexFileLocation location) {
|
||||||
if (map.get(path) == null) {
|
if (map.get(location) == null) {
|
||||||
Object lists= new ArrayList[]{new ArrayList(), new ArrayList(), new ArrayList()};
|
Object lists= new ArrayList[]{new ArrayList(), new ArrayList(), new ArrayList()};
|
||||||
map.put(path, lists);
|
map.put(location, lists);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private IIndexFragmentFile addToIndex(IWritableIndex index, String location, Map symbolMap) throws CoreException {
|
private IIndexFragmentFile addToIndex(IWritableIndex index, IIndexFileLocation location, Map symbolMap) throws CoreException {
|
||||||
// Remove the old symbols in the tu
|
IIndexFragmentFile file= (IIndexFragmentFile) index.getFile(location);
|
||||||
Path path= new Path(location);
|
|
||||||
IIndexFragmentFile file= (IIndexFragmentFile) index.getFile(path);
|
|
||||||
if (file != null) {
|
if (file != null) {
|
||||||
index.clearFile(file);
|
index.clearFile(file);
|
||||||
|
} else {
|
||||||
|
file= index.addFile(location);
|
||||||
}
|
}
|
||||||
else {
|
file.setTimestamp(EFS.getStore(location.getURI()).fetchInfo().getLastModified());
|
||||||
file= index.addFile(path);
|
|
||||||
}
|
|
||||||
file.setTimestamp(path.toFile().lastModified());
|
|
||||||
ArrayList[] lists= (ArrayList[]) symbolMap.get(location);
|
ArrayList[] lists= (ArrayList[]) symbolMap.get(location);
|
||||||
if (lists != null) {
|
if (lists != null) {
|
||||||
ArrayList list= lists[0];
|
ArrayList list= lists[0];
|
||||||
|
@ -501,7 +495,11 @@ public abstract class PDOMIndexerTask implements IPDOMIndexerTask {
|
||||||
list= lists[2];
|
list= lists[2];
|
||||||
IASTName[][] names= (IASTName[][]) list.toArray(new IASTName[list.size()][]);
|
IASTName[][] names= (IASTName[][]) list.toArray(new IASTName[list.size()][]);
|
||||||
|
|
||||||
index.setFileContent(file, includes, macros, names);
|
IIndexFileLocation[] includeLocations = new IIndexFileLocation[includes.length];
|
||||||
|
for(int i=0; i<includes.length; i++) {
|
||||||
|
includeLocations[i] = findLocation(includes[i].getPath());
|
||||||
|
}
|
||||||
|
index.setFileContent(file, includes, includeLocations, macros, names);
|
||||||
}
|
}
|
||||||
return file;
|
return file;
|
||||||
}
|
}
|
||||||
|
@ -527,4 +525,13 @@ public abstract class PDOMIndexerTask implements IPDOMIndexerTask {
|
||||||
+ fProblemBindingCount + " problems."); //$NON-NLS-1$
|
+ fProblemBindingCount + " problems."); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected IIndexFileLocation getIndexFileLocation(ITranslationUnit tu) {
|
||||||
|
if(tu.getResource()!=null)
|
||||||
|
return IndexLocationFactory.getWorkspaceIFL((IFile)tu.getResource());
|
||||||
|
else
|
||||||
|
return IndexLocationFactory.getExternalIFL(tu.getLocation());
|
||||||
|
}
|
||||||
|
|
||||||
|
protected abstract IIndexFileLocation findLocation(String absolutePath);
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,13 +14,17 @@
|
||||||
package org.eclipse.cdt.internal.core.pdom.indexer.fast;
|
package org.eclipse.cdt.internal.core.pdom.indexer.fast;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.CCorePlugin;
|
import org.eclipse.cdt.core.CCorePlugin;
|
||||||
import org.eclipse.cdt.core.dom.IPDOMIndexer;
|
import org.eclipse.cdt.core.dom.IPDOMIndexer;
|
||||||
import org.eclipse.cdt.core.dom.IPDOMIndexerTask;
|
import org.eclipse.cdt.core.dom.IPDOMIndexerTask;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
||||||
import org.eclipse.cdt.core.index.IIndexFile;
|
import org.eclipse.cdt.core.index.IIndexFile;
|
||||||
|
import org.eclipse.cdt.core.index.IIndexFileLocation;
|
||||||
|
import org.eclipse.cdt.core.index.IndexLocationFactory;
|
||||||
import org.eclipse.cdt.core.model.ILanguage;
|
import org.eclipse.cdt.core.model.ILanguage;
|
||||||
import org.eclipse.cdt.core.model.ITranslationUnit;
|
import org.eclipse.cdt.core.model.ITranslationUnit;
|
||||||
import org.eclipse.cdt.core.parser.CodeReader;
|
import org.eclipse.cdt.core.parser.CodeReader;
|
||||||
|
@ -44,6 +48,7 @@ abstract class PDOMFastIndexerJob extends PDOMIndexerTask implements IPDOMIndexe
|
||||||
protected final PDOMFastIndexer indexer;
|
protected final PDOMFastIndexer indexer;
|
||||||
protected IWritableIndex index;
|
protected IWritableIndex index;
|
||||||
protected IndexBasedCodeReaderFactory codeReaderFactory;
|
protected IndexBasedCodeReaderFactory codeReaderFactory;
|
||||||
|
private Map/*<String,IIndexFileLocation>*/ iflCache;
|
||||||
|
|
||||||
public PDOMFastIndexerJob(PDOMFastIndexer indexer) throws CoreException {
|
public PDOMFastIndexerJob(PDOMFastIndexer indexer) throws CoreException {
|
||||||
this.indexer = indexer;
|
this.indexer = indexer;
|
||||||
|
@ -51,13 +56,24 @@ abstract class PDOMFastIndexerJob extends PDOMIndexerTask implements IPDOMIndexe
|
||||||
|
|
||||||
protected void setupIndexAndReaderFactory() throws CoreException {
|
protected void setupIndexAndReaderFactory() throws CoreException {
|
||||||
this.index= ((IWritableIndexManager) CCorePlugin.getIndexManager()).getWritableIndex(indexer.getProject());
|
this.index= ((IWritableIndexManager) CCorePlugin.getIndexManager()).getWritableIndex(indexer.getProject());
|
||||||
this.codeReaderFactory = new IndexBasedCodeReaderFactory(index);
|
this.iflCache = new HashMap/*<String,IIndexFileLocation>*/();
|
||||||
}
|
this.codeReaderFactory = new IndexBasedCodeReaderFactory(index, iflCache);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected IIndexFileLocation findLocation(String absolutePath) {
|
||||||
|
IIndexFileLocation result = (IIndexFileLocation) iflCache.get(absolutePath);
|
||||||
|
if(result==null) {
|
||||||
|
result = IndexLocationFactory.getIFLExpensive(absolutePath);
|
||||||
|
iflCache.put(absolutePath, result);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
protected void registerTUsInReaderFactory(Collection files) throws CoreException {
|
protected void registerTUsInReaderFactory(Collection files) throws CoreException {
|
||||||
for (Iterator iter = files.iterator(); iter.hasNext();) {
|
for (Iterator iter = files.iterator(); iter.hasNext();) {
|
||||||
ITranslationUnit tu = (ITranslationUnit) iter.next();
|
ITranslationUnit tu = (ITranslationUnit) iter.next();
|
||||||
FileInfo info= codeReaderFactory.createFileInfo(tu);
|
IIndexFileLocation location = getIndexFileLocation(tu);
|
||||||
|
FileInfo info= codeReaderFactory.createFileInfo(location);
|
||||||
info.setRequested(true);
|
info.setRequested(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -111,13 +127,13 @@ abstract class PDOMFastIndexerJob extends PDOMIndexerTask implements IPDOMIndexe
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean needToUpdate(String path) throws CoreException {
|
protected boolean needToUpdate(IIndexFileLocation location) throws CoreException {
|
||||||
// file is requested or is not yet indexed.
|
// file is requested or is not yet indexed.
|
||||||
FileInfo info= codeReaderFactory.createFileInfo(path);
|
FileInfo info= codeReaderFactory.createFileInfo(location);
|
||||||
return info.isRequested() || info.fFile == null;
|
return info.isRequested() || info.fFile == null;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean postAddToIndex(String path, IIndexFile file) throws CoreException {
|
protected boolean postAddToIndex(IIndexFileLocation path, IIndexFile file) throws CoreException {
|
||||||
FileInfo info= codeReaderFactory.createFileInfo(path);
|
FileInfo info= codeReaderFactory.createFileInfo(path);
|
||||||
info.fFile= file;
|
info.fFile= file;
|
||||||
if (info.isRequested()) {
|
if (info.isRequested()) {
|
||||||
|
|
|
@ -22,6 +22,8 @@ import org.eclipse.cdt.core.dom.IPDOMIndexer;
|
||||||
import org.eclipse.cdt.core.dom.IPDOMIndexerTask;
|
import org.eclipse.cdt.core.dom.IPDOMIndexerTask;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
||||||
import org.eclipse.cdt.core.index.IIndexFile;
|
import org.eclipse.cdt.core.index.IIndexFile;
|
||||||
|
import org.eclipse.cdt.core.index.IIndexFileLocation;
|
||||||
|
import org.eclipse.cdt.core.index.IndexLocationFactory;
|
||||||
import org.eclipse.cdt.core.model.ITranslationUnit;
|
import org.eclipse.cdt.core.model.ITranslationUnit;
|
||||||
import org.eclipse.cdt.internal.core.index.IWritableIndex;
|
import org.eclipse.cdt.internal.core.index.IWritableIndex;
|
||||||
import org.eclipse.cdt.internal.core.index.IWritableIndexManager;
|
import org.eclipse.cdt.internal.core.index.IWritableIndexManager;
|
||||||
|
@ -41,8 +43,9 @@ abstract class PDOMFullIndexerJob extends PDOMIndexerTask implements IPDOMIndexe
|
||||||
|
|
||||||
protected final PDOMFullIndexer indexer;
|
protected final PDOMFullIndexer indexer;
|
||||||
protected IWritableIndex index= null;
|
protected IWritableIndex index= null;
|
||||||
private Map filePathsToParse= new HashMap();
|
private Map/*<IIndexFileLocation, Object>*/ filePathsToParse= new HashMap/*<IIndexFileLocation, Object>*/();
|
||||||
|
private Map/*<String, IIndexFileLocation>*/ iflCache = new HashMap/*<String, IIndexFileLocation>*/();
|
||||||
|
|
||||||
public PDOMFullIndexerJob(PDOMFullIndexer indexer) throws CoreException {
|
public PDOMFullIndexerJob(PDOMFullIndexer indexer) throws CoreException {
|
||||||
this.indexer = indexer;
|
this.indexer = indexer;
|
||||||
}
|
}
|
||||||
|
@ -55,15 +58,23 @@ abstract class PDOMFullIndexerJob extends PDOMIndexerTask implements IPDOMIndexe
|
||||||
this.index = ((IWritableIndexManager) CCorePlugin.getIndexManager()).getWritableIndex(indexer.getProject());
|
this.index = ((IWritableIndexManager) CCorePlugin.getIndexManager()).getWritableIndex(indexer.getProject());
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void registerTUsInReaderFactory(Collection sources) throws CoreException {
|
protected void registerTUsInReaderFactory(Collection/*<ITranslationUnit>*/ sources) throws CoreException {
|
||||||
filePathsToParse= new HashMap();
|
filePathsToParse= new HashMap/*<IIndexFileLocation, Object>*/();
|
||||||
|
|
||||||
for (Iterator iter = sources.iterator(); iter.hasNext();) {
|
for (Iterator iter = sources.iterator(); iter.hasNext();) {
|
||||||
ITranslationUnit tu = (ITranslationUnit) iter.next();
|
ITranslationUnit tu = (ITranslationUnit) iter.next();
|
||||||
filePathsToParse.put(tu.getLocation().toOSString(), REQUIRED);
|
filePathsToParse.put(getIndexFileLocation(tu), REQUIRED);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected IIndexFileLocation findLocation(String absolutePath) {
|
||||||
|
IIndexFileLocation result = (IIndexFileLocation) iflCache.get(absolutePath);
|
||||||
|
if(result==null) {
|
||||||
|
result = IndexLocationFactory.getIFLExpensive(absolutePath);
|
||||||
|
iflCache.put(absolutePath, result);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
protected void doParseTU(ITranslationUnit tu, IProgressMonitor pm) throws CoreException, InterruptedException {
|
protected void doParseTU(ITranslationUnit tu, IProgressMonitor pm) throws CoreException, InterruptedException {
|
||||||
IPath path = tu.getLocation();
|
IPath path = tu.getLocation();
|
||||||
if (path == null) {
|
if (path == null) {
|
||||||
|
@ -87,18 +98,18 @@ abstract class PDOMFullIndexerJob extends PDOMIndexerTask implements IPDOMIndexe
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean needToUpdate(String path) throws CoreException {
|
protected boolean needToUpdate(IIndexFileLocation location) throws CoreException {
|
||||||
Object required= filePathsToParse.get(path);
|
Object required= filePathsToParse.get(location);
|
||||||
if (required == null) {
|
if (required == null) {
|
||||||
required= MISSING;
|
required= MISSING;
|
||||||
filePathsToParse.put(path, required);
|
filePathsToParse.put(location, required);
|
||||||
}
|
}
|
||||||
return required != SKIP;
|
return required != SKIP;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean postAddToIndex(String path, IIndexFile file) throws CoreException {
|
protected boolean postAddToIndex(IIndexFileLocation location, IIndexFile file) throws CoreException {
|
||||||
Object required= filePathsToParse.get(path);
|
Object required= filePathsToParse.get(location);
|
||||||
filePathsToParse.put(path, SKIP);
|
filePathsToParse.put(location, SKIP);
|
||||||
return required == REQUIRED;
|
return required == REQUIRED;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,8 +34,8 @@ class PDOMFullReindex extends PDOMFullIndexerJob {
|
||||||
long start = System.currentTimeMillis();
|
long start = System.currentTimeMillis();
|
||||||
try {
|
try {
|
||||||
boolean allFiles= getIndexAllFiles();
|
boolean allFiles= getIndexAllFiles();
|
||||||
List sources= new ArrayList();
|
List/*<ITranslationUnit>*/ sources= new ArrayList/*<ITranslationUnit>*/();
|
||||||
List headers= new ArrayList();
|
List/*<ITranslationUnit>*/ headers= new ArrayList/*<ITranslationUnit>*/();
|
||||||
|
|
||||||
collectSources(indexer.getProject(), sources, allFiles ? headers : null, allFiles);
|
collectSources(indexer.getProject(), sources, allFiles ? headers : null, allFiles);
|
||||||
fTotalSourcesEstimate= sources.size() + headers.size();
|
fTotalSourcesEstimate= sources.size() + headers.size();
|
||||||
|
|
|
@ -124,7 +124,7 @@ public class CCodeFormatter extends CodeFormatter {
|
||||||
if (lineSeparator != null) {
|
if (lineSeparator != null) {
|
||||||
this.preferences.line_separator = lineSeparator;
|
this.preferences.line_separator = lineSeparator;
|
||||||
} else {
|
} else {
|
||||||
this.preferences.line_separator = System.getProperty("line.separator");
|
this.preferences.line_separator = System.getProperty("line.separator"); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
this.preferences.initial_indentation_level = indentationLevel;
|
this.preferences.initial_indentation_level = indentationLevel;
|
||||||
|
|
||||||
|
|
|
@ -22,6 +22,7 @@ import org.eclipse.swt.widgets.Display;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
||||||
import org.eclipse.cdt.core.index.IIndex;
|
import org.eclipse.cdt.core.index.IIndex;
|
||||||
import org.eclipse.cdt.core.index.IIndexFile;
|
import org.eclipse.cdt.core.index.IIndexFile;
|
||||||
|
import org.eclipse.cdt.core.index.IndexLocationFactory;
|
||||||
import org.eclipse.cdt.core.model.CModelException;
|
import org.eclipse.cdt.core.model.CModelException;
|
||||||
import org.eclipse.cdt.core.model.ICProject;
|
import org.eclipse.cdt.core.model.ICProject;
|
||||||
import org.eclipse.cdt.core.testplugin.util.BaseTestCase;
|
import org.eclipse.cdt.core.testplugin.util.BaseTestCase;
|
||||||
|
@ -62,7 +63,7 @@ public class BaseUITestCase extends BaseTestCase {
|
||||||
do {
|
do {
|
||||||
index.acquireReadLock();
|
index.acquireReadLock();
|
||||||
try {
|
try {
|
||||||
IIndexFile pfile= index.getFile(file.getLocation());
|
IIndexFile pfile= index.getFile(IndexLocationFactory.getWorkspaceIFL(file));
|
||||||
if (pfile != null && pfile.getTimestamp() >= file.getLocalTimeStamp()) {
|
if (pfile != null && pfile.getTimestamp() >= file.getLocalTimeStamp()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -70,6 +70,7 @@ Require-Bundle: org.eclipse.ui.ide;bundle-version="[3.2.0,4.0.0)",
|
||||||
org.eclipse.help;bundle-version="[3.2.0,4.0.0)",
|
org.eclipse.help;bundle-version="[3.2.0,4.0.0)",
|
||||||
org.eclipse.ui.navigator;bundle-version="[3.2.0,4.0.0)",
|
org.eclipse.ui.navigator;bundle-version="[3.2.0,4.0.0)",
|
||||||
com.ibm.icu;bundle-version="[3.4.0,4.0.0)",
|
com.ibm.icu;bundle-version="[3.4.0,4.0.0)",
|
||||||
org.eclipse.cdt.refactoring;bundle-version="[4.0.0,5.0.0)"
|
org.eclipse.cdt.refactoring;bundle-version="[4.0.0,5.0.0)",
|
||||||
|
org.eclipse.core.filesystem;bundle-version="[1.1.0,2.0.0)"
|
||||||
Eclipse-LazyStart: true
|
Eclipse-LazyStart: true
|
||||||
Bundle-RequiredExecutionEnvironment: J2SE-1.4
|
Bundle-RequiredExecutionEnvironment: J2SE-1.4
|
||||||
|
|
|
@ -31,7 +31,9 @@ import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||||
import org.eclipse.cdt.core.index.IIndex;
|
import org.eclipse.cdt.core.index.IIndex;
|
||||||
import org.eclipse.cdt.core.index.IIndexBinding;
|
import org.eclipse.cdt.core.index.IIndexBinding;
|
||||||
import org.eclipse.cdt.core.index.IIndexFile;
|
import org.eclipse.cdt.core.index.IIndexFile;
|
||||||
|
import org.eclipse.cdt.core.index.IIndexFileLocation;
|
||||||
import org.eclipse.cdt.core.index.IIndexName;
|
import org.eclipse.cdt.core.index.IIndexName;
|
||||||
|
import org.eclipse.cdt.core.index.IndexLocationFactory;
|
||||||
import org.eclipse.cdt.core.model.CModelException;
|
import org.eclipse.cdt.core.model.CModelException;
|
||||||
import org.eclipse.cdt.core.model.ICElement;
|
import org.eclipse.cdt.core.model.ICElement;
|
||||||
import org.eclipse.cdt.core.model.ICProject;
|
import org.eclipse.cdt.core.model.ICProject;
|
||||||
|
@ -84,7 +86,7 @@ public class CHQueries {
|
||||||
ISourceReference sf = ((ISourceReference)element);
|
ISourceReference sf = ((ISourceReference)element);
|
||||||
ITranslationUnit tu= sf.getTranslationUnit();
|
ITranslationUnit tu= sf.getTranslationUnit();
|
||||||
if (tu != null) {
|
if (tu != null) {
|
||||||
IPath location= tu.getLocation();
|
IIndexFileLocation location= IndexLocationFactory.getIFL(tu);
|
||||||
if (location != null) {
|
if (location != null) {
|
||||||
IIndexFile file= index.getFile(location);
|
IIndexFile file= index.getFile(location);
|
||||||
if (file != null) {
|
if (file != null) {
|
||||||
|
|
|
@ -187,7 +187,7 @@ public class AddIncludeOnSelectionAction extends Action implements IUpdate {
|
||||||
try {
|
try {
|
||||||
if (binding != null)
|
if (binding != null)
|
||||||
{
|
{
|
||||||
return getBindingQualifiedName(binding) + " - " + name.getFileName(); //$NON-NLS-1$
|
return getBindingQualifiedName(binding) + " - " + name.getFileLocation().getFileName(); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
return null;
|
return null;
|
||||||
|
@ -284,7 +284,7 @@ public class AddIncludeOnSelectionAction extends Action implements IUpdate {
|
||||||
fRequiredIncludes = new IRequiredInclude[selects.length];
|
fRequiredIncludes = new IRequiredInclude[selects.length];
|
||||||
List usings = new ArrayList(selects.length);
|
List usings = new ArrayList(selects.length);
|
||||||
for (int i = 0; i < fRequiredIncludes.length; i++) {
|
for (int i = 0; i < fRequiredIncludes.length; i++) {
|
||||||
IRequiredInclude include = getRequiredInclude(((DisplayName)selects[i]).getName().getFileName(), getTranslationUnit());
|
IRequiredInclude include = getRequiredInclude(((DisplayName)selects[i]).getName().getFileLocation().getFileName(), getTranslationUnit());
|
||||||
if (include != null) {
|
if (include != null) {
|
||||||
fRequiredIncludes[i] = include;
|
fRequiredIncludes[i] = include;
|
||||||
IIndexBinding binding = ((DisplayName)selects[i]).getBinding();
|
IIndexBinding binding = ((DisplayName)selects[i]).getBinding();
|
||||||
|
@ -309,8 +309,9 @@ public class AddIncludeOnSelectionAction extends Action implements IUpdate {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (pdomNames.size() == 1)
|
else if (pdomNames.size() == 1)
|
||||||
{
|
{
|
||||||
String fileName = ((DisplayName)pdomNames.get(0)).getName().getFileName();
|
// we should use the IIndexName.getLocation here rather than getFileLocation
|
||||||
|
String fileName = ((DisplayName)pdomNames.get(0)).getName().getFileLocation().getFileName();
|
||||||
fRequiredIncludes = new IRequiredInclude[] {getRequiredInclude(fileName, getTranslationUnit())};
|
fRequiredIncludes = new IRequiredInclude[] {getRequiredInclude(fileName, getTranslationUnit())};
|
||||||
IIndexBinding binding = ((DisplayName)pdomNames.get(0)).getBinding();
|
IIndexBinding binding = ((DisplayName)pdomNames.get(0)).getBinding();
|
||||||
|
|
||||||
|
|
|
@ -17,14 +17,15 @@ 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.core.runtime.NullProgressMonitor;
|
import org.eclipse.core.runtime.NullProgressMonitor;
|
||||||
import org.eclipse.core.runtime.Path;
|
|
||||||
import org.eclipse.swt.widgets.Display;
|
import org.eclipse.swt.widgets.Display;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.CCorePlugin;
|
import org.eclipse.cdt.core.CCorePlugin;
|
||||||
import org.eclipse.cdt.core.index.IIndex;
|
import org.eclipse.cdt.core.index.IIndex;
|
||||||
import org.eclipse.cdt.core.index.IIndexFile;
|
import org.eclipse.cdt.core.index.IIndexFile;
|
||||||
|
import org.eclipse.cdt.core.index.IIndexFileLocation;
|
||||||
import org.eclipse.cdt.core.index.IIndexInclude;
|
import org.eclipse.cdt.core.index.IIndexInclude;
|
||||||
import org.eclipse.cdt.core.index.IIndexManager;
|
import org.eclipse.cdt.core.index.IIndexManager;
|
||||||
|
import org.eclipse.cdt.core.index.IndexLocationFactory;
|
||||||
import org.eclipse.cdt.core.model.ITranslationUnit;
|
import org.eclipse.cdt.core.model.ITranslationUnit;
|
||||||
import org.eclipse.cdt.ui.CUIPlugin;
|
import org.eclipse.cdt.ui.CUIPlugin;
|
||||||
|
|
||||||
|
@ -104,9 +105,9 @@ public class IBContentProvider extends AsyncTreeContentProvider {
|
||||||
for (int i = 0; i < includes.length; i++) {
|
for (int i = 0; i < includes.length; i++) {
|
||||||
IIndexInclude include = includes[i];
|
IIndexInclude include = includes[i];
|
||||||
try {
|
try {
|
||||||
Path includesPath = new Path(include.getIncludesLocation());
|
IPath includesPath = IndexLocationFactory.getAbsolutePath(include.getIncludesLocation());
|
||||||
if (fComputeIncludedBy) {
|
if (fComputeIncludedBy) {
|
||||||
directiveFile= targetFile= new IBFile(tu.getCProject(), new Path(include.getIncludedByLocation()));
|
directiveFile= targetFile= new IBFile(tu.getCProject(), IndexLocationFactory.getAbsolutePath(include.getIncludesLocation()));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
targetFile= new IBFile(tu.getCProject(), includesPath);
|
targetFile= new IBFile(tu.getCProject(), includesPath);
|
||||||
|
@ -147,7 +148,7 @@ public class IBContentProvider extends AsyncTreeContentProvider {
|
||||||
|
|
||||||
private IIndexInclude[] findIncludedBy(IIndex index, ITranslationUnit tu, IProgressMonitor pm) {
|
private IIndexInclude[] findIncludedBy(IIndex index, ITranslationUnit tu, IProgressMonitor pm) {
|
||||||
try {
|
try {
|
||||||
IPath location= tu.getLocation();
|
IIndexFileLocation location= IndexLocationFactory.getIFL(tu);
|
||||||
if (location != null) {
|
if (location != null) {
|
||||||
IIndexFile file= index.getFile(location);
|
IIndexFile file= index.getFile(location);
|
||||||
if (file != null) {
|
if (file != null) {
|
||||||
|
@ -163,7 +164,7 @@ public class IBContentProvider extends AsyncTreeContentProvider {
|
||||||
|
|
||||||
public IIndexInclude[] findIncludesTo(IIndex index, ITranslationUnit tu, IProgressMonitor pm) {
|
public IIndexInclude[] findIncludesTo(IIndex index, ITranslationUnit tu, IProgressMonitor pm) {
|
||||||
try {
|
try {
|
||||||
IPath location= tu.getLocation();
|
IIndexFileLocation location= IndexLocationFactory.getIFL(tu);
|
||||||
if (location != null) {
|
if (location != null) {
|
||||||
IIndexFile file= index.getFile(location);
|
IIndexFile file= index.getFile(location);
|
||||||
if (file != null) {
|
if (file != null) {
|
||||||
|
|
|
@ -13,7 +13,6 @@ package org.eclipse.cdt.internal.ui.indexview;
|
||||||
|
|
||||||
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.Path;
|
|
||||||
import org.eclipse.jface.text.BadLocationException;
|
import org.eclipse.jface.text.BadLocationException;
|
||||||
import org.eclipse.jface.text.IDocument;
|
import org.eclipse.jface.text.IDocument;
|
||||||
import org.eclipse.jface.viewers.ISelection;
|
import org.eclipse.jface.viewers.ISelection;
|
||||||
|
@ -27,6 +26,7 @@ import org.eclipse.cdt.core.CCorePlugin;
|
||||||
import org.eclipse.cdt.core.index.IIndex;
|
import org.eclipse.cdt.core.index.IIndex;
|
||||||
import org.eclipse.cdt.core.index.IIndexBinding;
|
import org.eclipse.cdt.core.index.IIndexBinding;
|
||||||
import org.eclipse.cdt.core.index.IIndexName;
|
import org.eclipse.cdt.core.index.IIndexName;
|
||||||
|
import org.eclipse.cdt.core.index.IndexLocationFactory;
|
||||||
import org.eclipse.cdt.core.model.CModelException;
|
import org.eclipse.cdt.core.model.CModelException;
|
||||||
import org.eclipse.cdt.core.model.CoreModel;
|
import org.eclipse.cdt.core.model.CoreModel;
|
||||||
import org.eclipse.cdt.ui.CUIPlugin;
|
import org.eclipse.cdt.ui.CUIPlugin;
|
||||||
|
@ -75,23 +75,25 @@ public class OpenDefinitionAction extends IndexAction {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void showInEditor(IIndexName name) throws CModelException, PartInitException {
|
private void showInEditor(IIndexName name) throws CModelException, PartInitException, CoreException {
|
||||||
IPath path = new Path(name.getFileName());
|
IPath path = IndexLocationFactory.getPath(name.getFile().getLocation());
|
||||||
IEditorPart editor = EditorUtility.openInEditor(path, null);
|
if(path!=null) {
|
||||||
if (editor != null && editor instanceof ITextEditor) {
|
IEditorPart editor = EditorUtility.openInEditor(path, null);
|
||||||
ITextEditor textEditor = (ITextEditor)editor;
|
if (editor != null && editor instanceof ITextEditor) {
|
||||||
int nodeOffset = name.getNodeOffset();
|
ITextEditor textEditor = (ITextEditor)editor;
|
||||||
int nodeLength = name.getNodeLength();
|
int nodeOffset = name.getNodeOffset();
|
||||||
try {
|
int nodeLength = name.getNodeLength();
|
||||||
if (nodeLength == -1) {
|
try {
|
||||||
// This means the offset is actually a line number
|
if (nodeLength == -1) {
|
||||||
IDocument document = textEditor.getDocumentProvider().getDocument(editor.getEditorInput());
|
// This means the offset is actually a line number
|
||||||
nodeOffset = document.getLineOffset(nodeOffset);
|
IDocument document = textEditor.getDocumentProvider().getDocument(editor.getEditorInput());
|
||||||
nodeLength = document.getLineLength(nodeOffset);
|
nodeOffset = document.getLineOffset(nodeOffset);
|
||||||
}
|
nodeLength = document.getLineLength(nodeOffset);
|
||||||
textEditor.selectAndReveal(nodeOffset, nodeLength);
|
}
|
||||||
} catch (BadLocationException e) {
|
textEditor.selectAndReveal(nodeOffset, nodeLength);
|
||||||
CUIPlugin.getDefault().log(e);
|
} catch (BadLocationException e) {
|
||||||
|
CUIPlugin.getDefault().log(e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,7 +31,7 @@ public class PDOMSearchElement {
|
||||||
public PDOMSearchElement(IIndexName name, IIndexBinding binding) throws CoreException {
|
public PDOMSearchElement(IIndexName name, IIndexBinding binding) throws CoreException {
|
||||||
this.binding= binding;
|
this.binding= binding;
|
||||||
this.name = binding.getName();
|
this.name = binding.getName();
|
||||||
filename = name.getFileName();
|
filename = name.getFileLocation().getFileName();
|
||||||
}
|
}
|
||||||
|
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
|
|
|
@ -18,7 +18,6 @@ import java.util.List;
|
||||||
import org.eclipse.core.resources.IFile;
|
import org.eclipse.core.resources.IFile;
|
||||||
import org.eclipse.core.resources.ResourcesPlugin;
|
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.Path;
|
import org.eclipse.core.runtime.Path;
|
||||||
import org.eclipse.jface.resource.ImageDescriptor;
|
import org.eclipse.jface.resource.ImageDescriptor;
|
||||||
import org.eclipse.search.ui.ISearchQuery;
|
import org.eclipse.search.ui.ISearchQuery;
|
||||||
|
@ -30,6 +29,7 @@ import org.eclipse.ui.IEditorInput;
|
||||||
import org.eclipse.ui.IEditorPart;
|
import org.eclipse.ui.IEditorPart;
|
||||||
import org.eclipse.ui.part.FileEditorInput;
|
import org.eclipse.ui.part.FileEditorInput;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.index.IIndexFileLocation;
|
||||||
import org.eclipse.cdt.core.index.IIndexName;
|
import org.eclipse.cdt.core.index.IIndexName;
|
||||||
import org.eclipse.cdt.ui.CUIPlugin;
|
import org.eclipse.cdt.ui.CUIPlugin;
|
||||||
|
|
||||||
|
@ -121,14 +121,14 @@ public class PDOMSearchResult extends AbstractTextSearchResult implements IEdito
|
||||||
public IFile getFile(Object element) {
|
public IFile getFile(Object element) {
|
||||||
if (element instanceof IIndexName) {
|
if (element instanceof IIndexName) {
|
||||||
IIndexName name = (IIndexName)element;
|
IIndexName name = (IIndexName)element;
|
||||||
IPath path = new Path(name.getFileName());
|
try {
|
||||||
IFile[] files = ResourcesPlugin.getWorkspace().getRoot().findFilesForLocation(path);
|
IIndexFileLocation location = name.getFile().getLocation();
|
||||||
if (files.length > 0)
|
if(location.getFullPath()!=null) {
|
||||||
return files[0];
|
return ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(location.getFullPath()));
|
||||||
else
|
}
|
||||||
return null;
|
} catch(CoreException ce) { /* fall-through to return null */ }
|
||||||
} else
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getLabel() {
|
public String getLabel() {
|
||||||
|
|
Loading…
Add table
Reference in a new issue