mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Headers included from c- and c++-files (bug 191989).
This commit is contained in:
parent
643f6c20d3
commit
21b09a659c
75 changed files with 2155 additions and 2457 deletions
|
@ -8,6 +8,7 @@
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* QNX Software Systems - Initial API and implementation
|
* QNX Software Systems - Initial API and implementation
|
||||||
* Anton Leherbauer (Wind River Systems)
|
* Anton Leherbauer (Wind River Systems)
|
||||||
|
* Markus Schorn (Wind River Systems)
|
||||||
**********************************************************************/
|
**********************************************************************/
|
||||||
|
|
||||||
package org.eclipse.cdt.managedbuilder.pdomdepgen;
|
package org.eclipse.cdt.managedbuilder.pdomdepgen;
|
||||||
|
@ -63,9 +64,9 @@ public class PDOMDependencyCalculator implements IManagedDependencyCalculator {
|
||||||
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(IndexLocationFactory.getWorkspaceIFL((IFile)resource));
|
IIndexFile[] files = index.getFiles(IndexLocationFactory.getWorkspaceIFL((IFile)resource));
|
||||||
if (file != null) {
|
if (files.length > 0) {
|
||||||
IIndexInclude[] includes = index.findIncludes(file, IIndex.DEPTH_INFINITE);
|
IIndexInclude[] includes = index.findIncludes(files[0], 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) {
|
||||||
|
|
|
@ -25,7 +25,7 @@ import org.eclipse.cdt.core.parser.ParserMode;
|
||||||
import org.eclipse.cdt.core.parser.ScannerInfo;
|
import org.eclipse.cdt.core.parser.ScannerInfo;
|
||||||
import org.eclipse.cdt.core.testplugin.CProjectHelper;
|
import org.eclipse.cdt.core.testplugin.CProjectHelper;
|
||||||
import org.eclipse.cdt.core.testplugin.util.TestSourceReader;
|
import org.eclipse.cdt.core.testplugin.util.TestSourceReader;
|
||||||
import org.eclipse.cdt.internal.core.pdom.indexer.nulli.PDOMNullIndexer;
|
import org.eclipse.cdt.internal.core.pdom.indexer.PDOMNullIndexer;
|
||||||
import org.eclipse.core.resources.IFile;
|
import org.eclipse.core.resources.IFile;
|
||||||
import org.eclipse.core.resources.IFolder;
|
import org.eclipse.core.resources.IFolder;
|
||||||
import org.eclipse.core.runtime.NullProgressMonitor;
|
import org.eclipse.core.runtime.NullProgressMonitor;
|
||||||
|
|
|
@ -80,11 +80,16 @@ public class EmptyIndexFragment implements IIndexFragment {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IIndexFragmentFile getFile(IIndexFileLocation location)
|
public IIndexFragmentFile getFile(int linkageID, IIndexFileLocation location)
|
||||||
throws CoreException {
|
throws CoreException {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public IIndexFragmentFile[] getFiles(IIndexFileLocation location) throws CoreException {
|
||||||
|
return new IIndexFragmentFile[0];
|
||||||
|
}
|
||||||
|
|
||||||
public long getLastWriteAccess() {
|
public long getLastWriteAccess() {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -304,7 +304,7 @@ public class IndexBugsTests extends BaseTestCase {
|
||||||
|
|
||||||
fIndex.acquireReadLock();
|
fIndex.acquireReadLock();
|
||||||
try {
|
try {
|
||||||
IIndexFile ifile= fIndex.getFile(IndexLocationFactory.getWorkspaceIFL(file));
|
IIndexFile ifile= fIndex.getFile(ILinkage.CPP_LINKAGE_ID, IndexLocationFactory.getWorkspaceIFL(file));
|
||||||
assertNotNull(ifile);
|
assertNotNull(ifile);
|
||||||
IIndexInclude[] includes= ifile.getIncludes();
|
IIndexInclude[] includes= ifile.getIncludes();
|
||||||
assertEquals(1, includes.length);
|
assertEquals(1, includes.length);
|
||||||
|
@ -329,7 +329,7 @@ public class IndexBugsTests extends BaseTestCase {
|
||||||
|
|
||||||
fIndex.acquireReadLock();
|
fIndex.acquireReadLock();
|
||||||
try {
|
try {
|
||||||
IIndexFile ifile= fIndex.getFile(IndexLocationFactory.getWorkspaceIFL(file));
|
IIndexFile ifile= fIndex.getFile(ILinkage.CPP_LINKAGE_ID, IndexLocationFactory.getWorkspaceIFL(file));
|
||||||
assertNotNull(ifile);
|
assertNotNull(ifile);
|
||||||
IIndexInclude[] includes= ifile.getIncludes();
|
IIndexInclude[] includes= ifile.getIncludes();
|
||||||
assertEquals(1, includes.length);
|
assertEquals(1, includes.length);
|
||||||
|
@ -355,7 +355,7 @@ public class IndexBugsTests extends BaseTestCase {
|
||||||
|
|
||||||
fIndex.acquireReadLock();
|
fIndex.acquireReadLock();
|
||||||
try {
|
try {
|
||||||
IIndexFile ifile= fIndex.getFile(IndexLocationFactory.getWorkspaceIFL(file));
|
IIndexFile ifile= fIndex.getFile(ILinkage.CPP_LINKAGE_ID, IndexLocationFactory.getWorkspaceIFL(file));
|
||||||
assertNotNull(ifile);
|
assertNotNull(ifile);
|
||||||
IIndexInclude[] includes= ifile.getIncludes();
|
IIndexInclude[] includes= ifile.getIncludes();
|
||||||
assertEquals(1, includes.length);
|
assertEquals(1, includes.length);
|
||||||
|
@ -381,7 +381,7 @@ public class IndexBugsTests extends BaseTestCase {
|
||||||
|
|
||||||
fIndex.acquireReadLock();
|
fIndex.acquireReadLock();
|
||||||
try {
|
try {
|
||||||
IIndexFile ifile= fIndex.getFile(IndexLocationFactory.getWorkspaceIFL(file));
|
IIndexFile ifile= fIndex.getFile(ILinkage.CPP_LINKAGE_ID, IndexLocationFactory.getWorkspaceIFL(file));
|
||||||
assertNotNull(ifile);
|
assertNotNull(ifile);
|
||||||
IIndexInclude[] includes= ifile.getIncludes();
|
IIndexInclude[] includes= ifile.getIncludes();
|
||||||
assertEquals(1, includes.length);
|
assertEquals(1, includes.length);
|
||||||
|
@ -412,7 +412,7 @@ public class IndexBugsTests extends BaseTestCase {
|
||||||
|
|
||||||
fIndex.acquireReadLock();
|
fIndex.acquireReadLock();
|
||||||
try {
|
try {
|
||||||
IIndexFile ifile= fIndex.getFile(IndexLocationFactory.getWorkspaceIFL(file));
|
IIndexFile ifile= fIndex.getFile(ILinkage.CPP_LINKAGE_ID, IndexLocationFactory.getWorkspaceIFL(file));
|
||||||
assertNotNull(ifile);
|
assertNotNull(ifile);
|
||||||
IIndexMacro[] macros= ifile.getMacros();
|
IIndexMacro[] macros= ifile.getMacros();
|
||||||
assertEquals(2, macros.length);
|
assertEquals(2, macros.length);
|
||||||
|
@ -826,7 +826,7 @@ public class IndexBugsTests extends BaseTestCase {
|
||||||
assertEquals(1, names.length);
|
assertEquals(1, names.length);
|
||||||
assertEquals(f4.getFullPath().toString(), names[0].getFile().getLocation().getFullPath());
|
assertEquals(f4.getFullPath().toString(), names[0].getFile().getLocation().getFullPath());
|
||||||
|
|
||||||
IIndexFile idxFile= index.getFile(IndexLocationFactory.getWorkspaceIFL(f5));
|
IIndexFile idxFile= index.getFile(ILinkage.CPP_LINKAGE_ID, IndexLocationFactory.getWorkspaceIFL(f5));
|
||||||
IIndexInclude[] includes= idxFile.getIncludes();
|
IIndexInclude[] includes= idxFile.getIncludes();
|
||||||
assertEquals(2, includes.length);
|
assertEquals(2, includes.length);
|
||||||
assertTrue(includes[0].isActive());
|
assertTrue(includes[0].isActive());
|
||||||
|
|
|
@ -17,6 +17,7 @@ import java.util.regex.Pattern;
|
||||||
import junit.framework.TestSuite;
|
import junit.framework.TestSuite;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.CCorePlugin;
|
import org.eclipse.cdt.core.CCorePlugin;
|
||||||
|
import org.eclipse.cdt.core.dom.ILinkage;
|
||||||
import org.eclipse.cdt.core.dom.IPDOMManager;
|
import org.eclipse.cdt.core.dom.IPDOMManager;
|
||||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||||
import org.eclipse.cdt.core.dom.ast.IVariable;
|
import org.eclipse.cdt.core.dom.ast.IVariable;
|
||||||
|
@ -134,7 +135,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(IndexLocationFactory.getWorkspaceIFL(file));
|
IIndexFile ifile= fIndex.getFile(ILinkage.CPP_LINKAGE_ID, 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);
|
||||||
|
|
||||||
|
@ -163,7 +164,7 @@ public class IndexIncludeTest extends IndexTestBase {
|
||||||
|
|
||||||
fIndex.acquireReadLock();
|
fIndex.acquireReadLock();
|
||||||
try {
|
try {
|
||||||
IIndexFile ifile= fIndex.getFile(IndexLocationFactory.getWorkspaceIFL(file));
|
IIndexFile ifile= fIndex.getFile(ILinkage.CPP_LINKAGE_ID, IndexLocationFactory.getWorkspaceIFL(file));
|
||||||
assertNotNull(ifile);
|
assertNotNull(ifile);
|
||||||
IIndexInclude[] includes= ifile.getIncludes();
|
IIndexInclude[] includes= ifile.getIncludes();
|
||||||
assertEquals(2, includes.length);
|
assertEquals(2, includes.length);
|
||||||
|
@ -188,7 +189,7 @@ public class IndexIncludeTest extends IndexTestBase {
|
||||||
|
|
||||||
fIndex.acquireReadLock();
|
fIndex.acquireReadLock();
|
||||||
try {
|
try {
|
||||||
IIndexFile ifile= fIndex.getFile(IndexLocationFactory.getWorkspaceIFL(file));
|
IIndexFile ifile= fIndex.getFile(ILinkage.CPP_LINKAGE_ID, IndexLocationFactory.getWorkspaceIFL(file));
|
||||||
assertNotNull(ifile);
|
assertNotNull(ifile);
|
||||||
IIndexInclude[] includes= ifile.getIncludes();
|
IIndexInclude[] includes= ifile.getIncludes();
|
||||||
assertEquals(1, includes.length);
|
assertEquals(1, includes.length);
|
||||||
|
@ -209,7 +210,7 @@ public class IndexIncludeTest extends IndexTestBase {
|
||||||
|
|
||||||
fIndex.acquireReadLock();
|
fIndex.acquireReadLock();
|
||||||
try {
|
try {
|
||||||
IIndexFile ifile= fIndex.getFile(IndexLocationFactory.getWorkspaceIFL(file));
|
IIndexFile ifile= fIndex.getFile(ILinkage.CPP_LINKAGE_ID, IndexLocationFactory.getWorkspaceIFL(file));
|
||||||
assertNotNull(ifile);
|
assertNotNull(ifile);
|
||||||
IIndexInclude[] includes= ifile.getIncludes();
|
IIndexInclude[] includes= ifile.getIncludes();
|
||||||
assertEquals(1, includes.length);
|
assertEquals(1, includes.length);
|
||||||
|
@ -231,7 +232,7 @@ public class IndexIncludeTest extends IndexTestBase {
|
||||||
|
|
||||||
fIndex.acquireReadLock();
|
fIndex.acquireReadLock();
|
||||||
try {
|
try {
|
||||||
IIndexFile ifile= fIndex.getFile(IndexLocationFactory.getWorkspaceIFL(file));
|
IIndexFile ifile= fIndex.getFile(ILinkage.CPP_LINKAGE_ID, IndexLocationFactory.getWorkspaceIFL(file));
|
||||||
assertNotNull(ifile);
|
assertNotNull(ifile);
|
||||||
IIndexInclude[] includes= ifile.getIncludes();
|
IIndexInclude[] includes= ifile.getIncludes();
|
||||||
assertEquals(1, includes.length);
|
assertEquals(1, includes.length);
|
||||||
|
@ -311,16 +312,17 @@ public class IndexIncludeTest extends IndexTestBase {
|
||||||
|
|
||||||
fIndex.acquireReadLock();
|
fIndex.acquireReadLock();
|
||||||
try {
|
try {
|
||||||
IIndexFile ifile= fIndex.getFile(IndexLocationFactory.getWorkspaceIFL(header));
|
IIndexFile ifile= fIndex.getFile(ILinkage.CPP_LINKAGE_ID, IndexLocationFactory.getWorkspaceIFL(header));
|
||||||
assertNotNull(ifile);
|
assertNotNull(ifile);
|
||||||
IIndexInclude[] includes= fIndex.findIncludedBy(ifile);
|
IIndexInclude[] includes= fIndex.findIncludedBy(ifile);
|
||||||
assertEquals(2, includes.length);
|
assertEquals(2, includes.length);
|
||||||
assertEquals(s1.getFullPath().toString(), includes[0].getIncludedByLocation().getFullPath());
|
|
||||||
assertEquals(s2.getFullPath().toString(), includes[1].getIncludedByLocation().getFullPath());
|
|
||||||
|
|
||||||
IIndexInclude context= ifile.getParsedInContext();
|
IIndexInclude context= ifile.getParsedInContext();
|
||||||
assertNotNull(context);
|
assertNotNull(context);
|
||||||
assertEquals(s1.getFullPath().toString(), context.getIncludedByLocation().getFullPath());
|
assertEquals(s1.getFullPath().toString(), context.getIncludedByLocation().getFullPath());
|
||||||
|
|
||||||
|
assertEquals(s1.getFullPath().toString(), includes[0].getIncludedByLocation().getFullPath());
|
||||||
|
assertEquals(s2.getFullPath().toString(), includes[1].getIncludedByLocation().getFullPath());
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
fIndex.releaseReadLock();
|
fIndex.releaseReadLock();
|
||||||
|
@ -331,7 +333,7 @@ public class IndexIncludeTest extends IndexTestBase {
|
||||||
fIndex.acquireReadLock();
|
fIndex.acquireReadLock();
|
||||||
try {
|
try {
|
||||||
assertEquals(1, fIndex.findBindings("a20070426".toCharArray(), IndexFilter.ALL_DECLARED, NPM).length);
|
assertEquals(1, fIndex.findBindings("a20070426".toCharArray(), IndexFilter.ALL_DECLARED, NPM).length);
|
||||||
IIndexFile ifile= fIndex.getFile(IndexLocationFactory.getWorkspaceIFL(header));
|
IIndexFile ifile= fIndex.getFile(ILinkage.CPP_LINKAGE_ID, IndexLocationFactory.getWorkspaceIFL(header));
|
||||||
assertNotNull(ifile);
|
assertNotNull(ifile);
|
||||||
IIndexInclude[] includes= fIndex.findIncludedBy(ifile);
|
IIndexInclude[] includes= fIndex.findIncludedBy(ifile);
|
||||||
assertEquals(2, includes.length);
|
assertEquals(2, includes.length);
|
||||||
|
@ -350,7 +352,7 @@ public class IndexIncludeTest extends IndexTestBase {
|
||||||
fIndex.acquireReadLock();
|
fIndex.acquireReadLock();
|
||||||
try {
|
try {
|
||||||
assertEquals(1, fIndex.findBindings("b20070426".toCharArray(), IndexFilter.ALL_DECLARED, NPM).length);
|
assertEquals(1, fIndex.findBindings("b20070426".toCharArray(), IndexFilter.ALL_DECLARED, NPM).length);
|
||||||
IIndexFile ifile= fIndex.getFile(IndexLocationFactory.getWorkspaceIFL(header));
|
IIndexFile ifile= fIndex.getFile(ILinkage.CPP_LINKAGE_ID, IndexLocationFactory.getWorkspaceIFL(header));
|
||||||
assertNotNull(ifile);
|
assertNotNull(ifile);
|
||||||
IIndexInclude[] includes= fIndex.findIncludedBy(ifile);
|
IIndexInclude[] includes= fIndex.findIncludedBy(ifile);
|
||||||
assertEquals(2, includes.length);
|
assertEquals(2, includes.length);
|
||||||
|
@ -435,8 +437,8 @@ public class IndexIncludeTest extends IndexTestBase {
|
||||||
try {
|
try {
|
||||||
assertEquals(1, fIndex.findBindings(tag.toCharArray(), IndexFilter.ALL_DECLARED, NPM).length);
|
assertEquals(1, fIndex.findBindings(tag.toCharArray(), IndexFilter.ALL_DECLARED, NPM).length);
|
||||||
|
|
||||||
IIndexFile ifile= fIndex.getFile(IndexLocationFactory.getWorkspaceIFL(header));
|
IIndexFile ifile= fIndex.getFile(ILinkage.CPP_LINKAGE_ID, IndexLocationFactory.getWorkspaceIFL(header));
|
||||||
IIndexFile sfile= fIndex.getFile(IndexLocationFactory.getWorkspaceIFL(s1));
|
IIndexFile sfile= fIndex.getFile(ILinkage.CPP_LINKAGE_ID, IndexLocationFactory.getWorkspaceIFL(s1));
|
||||||
assertNotNull(ifile);
|
assertNotNull(ifile);
|
||||||
IIndexInclude[] includes= fIndex.findIncludedBy(ifile);
|
IIndexInclude[] includes= fIndex.findIncludedBy(ifile);
|
||||||
assertEquals(1, includes.length);
|
assertEquals(1, includes.length);
|
||||||
|
@ -477,8 +479,8 @@ public class IndexIncludeTest extends IndexTestBase {
|
||||||
try {
|
try {
|
||||||
assertEquals(1, fIndex.findBindings(tag.toCharArray(), IndexFilter.ALL_DECLARED, NPM).length);
|
assertEquals(1, fIndex.findBindings(tag.toCharArray(), IndexFilter.ALL_DECLARED, NPM).length);
|
||||||
|
|
||||||
IIndexFile ifile= fIndex.getFile(IndexLocationFactory.getWorkspaceIFL(header));
|
IIndexFile ifile= fIndex.getFile(ILinkage.CPP_LINKAGE_ID, IndexLocationFactory.getWorkspaceIFL(header));
|
||||||
IIndexFile sfile= fIndex.getFile(IndexLocationFactory.getWorkspaceIFL(s1));
|
IIndexFile sfile= fIndex.getFile(ILinkage.CPP_LINKAGE_ID, IndexLocationFactory.getWorkspaceIFL(s1));
|
||||||
assertNotNull(ifile);
|
assertNotNull(ifile);
|
||||||
IIndexInclude[] includes= fIndex.findIncludedBy(ifile);
|
IIndexInclude[] includes= fIndex.findIncludedBy(ifile);
|
||||||
assertEquals(0, includes.length);
|
assertEquals(0, includes.length);
|
||||||
|
@ -509,8 +511,8 @@ public class IndexIncludeTest extends IndexTestBase {
|
||||||
try {
|
try {
|
||||||
assertEquals(1, fIndex.findBindings(tag.toCharArray(), IndexFilter.ALL_DECLARED, NPM).length);
|
assertEquals(1, fIndex.findBindings(tag.toCharArray(), IndexFilter.ALL_DECLARED, NPM).length);
|
||||||
|
|
||||||
IIndexFile ifile= fIndex.getFile(IndexLocationFactory.getWorkspaceIFL(header));
|
IIndexFile ifile= fIndex.getFile(ILinkage.CPP_LINKAGE_ID, IndexLocationFactory.getWorkspaceIFL(header));
|
||||||
IIndexFile sfile= fIndex.getFile(IndexLocationFactory.getWorkspaceIFL(s1));
|
IIndexFile sfile= fIndex.getFile(ILinkage.CPP_LINKAGE_ID, IndexLocationFactory.getWorkspaceIFL(s1));
|
||||||
assertNotNull(ifile);
|
assertNotNull(ifile);
|
||||||
IIndexInclude[] includes= fIndex.findIncludedBy(ifile);
|
IIndexInclude[] includes= fIndex.findIncludedBy(ifile);
|
||||||
assertEquals(1, includes.length);
|
assertEquals(1, includes.length);
|
||||||
|
@ -545,8 +547,8 @@ public class IndexIncludeTest extends IndexTestBase {
|
||||||
try {
|
try {
|
||||||
assertEquals(1, fIndex.findBindings(tag.toCharArray(), IndexFilter.ALL_DECLARED, NPM).length);
|
assertEquals(1, fIndex.findBindings(tag.toCharArray(), IndexFilter.ALL_DECLARED, NPM).length);
|
||||||
|
|
||||||
IIndexFile ifile= fIndex.getFile(IndexLocationFactory.getWorkspaceIFL(header));
|
IIndexFile ifile= fIndex.getFile(ILinkage.CPP_LINKAGE_ID, IndexLocationFactory.getWorkspaceIFL(header));
|
||||||
IIndexFile sfile= fIndex.getFile(IndexLocationFactory.getWorkspaceIFL(s1));
|
IIndexFile sfile= fIndex.getFile(ILinkage.CPP_LINKAGE_ID, IndexLocationFactory.getWorkspaceIFL(s1));
|
||||||
assertNotNull(ifile);
|
assertNotNull(ifile);
|
||||||
IIndexInclude[] includes= fIndex.findIncludedBy(ifile);
|
IIndexInclude[] includes= fIndex.findIncludedBy(ifile);
|
||||||
assertEquals(1, includes.length);
|
assertEquals(1, includes.length);
|
||||||
|
|
|
@ -17,6 +17,7 @@ import java.util.regex.Pattern;
|
||||||
import junit.framework.AssertionFailedError;
|
import junit.framework.AssertionFailedError;
|
||||||
import junit.framework.Test;
|
import junit.framework.Test;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.dom.ILinkage;
|
||||||
import org.eclipse.cdt.core.dom.IName;
|
import org.eclipse.cdt.core.dom.IName;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTFileLocation;
|
import org.eclipse.cdt.core.dom.ast.IASTFileLocation;
|
||||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||||
|
@ -218,7 +219,7 @@ public class DefDeclTests extends PDOMTestBase {
|
||||||
String elName = "foo" + "08";
|
String elName = "foo" + "08";
|
||||||
|
|
||||||
IIndexFileLocation ifl= IndexLocationFactory.getIFL((ITranslationUnit) cproject.findElement(new Path("func.c")));
|
IIndexFileLocation ifl= IndexLocationFactory.getIFL((ITranslationUnit) cproject.findElement(new Path("func.c")));
|
||||||
IIndexFile file= pdom.getFile(ifl);
|
IIndexFile file= pdom.getFile(ILinkage.C_LINKAGE_ID, ifl);
|
||||||
int offset= TestSourceReader.indexOfInFile("foo08();", new Path(ifl.getFullPath()));
|
int offset= TestSourceReader.indexOfInFile("foo08();", new Path(ifl.getFullPath()));
|
||||||
IIndexName[] names= file.findNames(offset, 5);
|
IIndexName[] names= file.findNames(offset, 5);
|
||||||
assertEquals(1, names.length);
|
assertEquals(1, names.length);
|
||||||
|
@ -230,7 +231,7 @@ public class DefDeclTests extends PDOMTestBase {
|
||||||
|
|
||||||
// check the other file
|
// check the other file
|
||||||
ifl= IndexLocationFactory.getIFL((ITranslationUnit) cproject.findElement(new Path("second.c")));
|
ifl= IndexLocationFactory.getIFL((ITranslationUnit) cproject.findElement(new Path("second.c")));
|
||||||
file= pdom.getFile(ifl);
|
file= pdom.getFile(ILinkage.C_LINKAGE_ID, ifl);
|
||||||
offset= TestSourceReader.indexOfInFile("foo08();", new Path(ifl.getFullPath()));
|
offset= TestSourceReader.indexOfInFile("foo08();", new Path(ifl.getFullPath()));
|
||||||
names= file.findNames(offset, 5);
|
names= file.findNames(offset, 5);
|
||||||
assertEquals(1, names.length);
|
assertEquals(1, names.length);
|
||||||
|
|
|
@ -15,6 +15,7 @@ import java.util.regex.Pattern;
|
||||||
import junit.framework.Test;
|
import junit.framework.Test;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.CCorePlugin;
|
import org.eclipse.cdt.core.CCorePlugin;
|
||||||
|
import org.eclipse.cdt.core.dom.ILinkage;
|
||||||
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.IIndexBinding;
|
import org.eclipse.cdt.core.index.IIndexBinding;
|
||||||
|
@ -69,7 +70,7 @@ 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(IndexLocationFactory.getWorkspaceIFL(file)));
|
assertNotNull(index.getFile(ILinkage.CPP_LINKAGE_ID, IndexLocationFactory.getWorkspaceIFL(file)));
|
||||||
|
|
||||||
IBinding[] bs = index.findBindings(Pattern.compile("C"), true, IndexFilter.ALL, new NullProgressMonitor());
|
IBinding[] bs = index.findBindings(Pattern.compile("C"), true, IndexFilter.ALL, new NullProgressMonitor());
|
||||||
assertEquals(1, bs.length);
|
assertEquals(1, bs.length);
|
||||||
|
|
|
@ -13,6 +13,7 @@ package org.eclipse.cdt.internal.pdom.tests;
|
||||||
import junit.framework.Test;
|
import junit.framework.Test;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.CCorePlugin;
|
import org.eclipse.cdt.core.CCorePlugin;
|
||||||
|
import org.eclipse.cdt.core.dom.ILinkage;
|
||||||
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;
|
||||||
|
@ -48,7 +49,7 @@ public class IncludesTests extends PDOMTestBase {
|
||||||
|
|
||||||
public void testIncludedBy() throws Exception {
|
public void testIncludedBy() throws Exception {
|
||||||
IResource loc = project.getProject().findMember("I2.h");
|
IResource loc = project.getProject().findMember("I2.h");
|
||||||
IIndexFile file = index.getFile(IndexLocationFactory.getWorkspaceIFL((IFile)loc));
|
IIndexFile file = index.getFile(ILinkage.CPP_LINKAGE_ID, IndexLocationFactory.getWorkspaceIFL((IFile)loc));
|
||||||
assertNotNull(file);
|
assertNotNull(file);
|
||||||
IIndexInclude[] allIncludedBy = index.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
|
||||||
|
@ -56,7 +57,7 @@ public class IncludesTests extends PDOMTestBase {
|
||||||
|
|
||||||
public void testIncludes() throws Exception {
|
public void testIncludes() throws Exception {
|
||||||
IResource loc = project.getProject().findMember("I1.cpp");
|
IResource loc = project.getProject().findMember("I1.cpp");
|
||||||
IIndexFile file = index.getFile(IndexLocationFactory.getWorkspaceIFL((IFile)loc));
|
IIndexFile file = index.getFile(ILinkage.CPP_LINKAGE_ID, IndexLocationFactory.getWorkspaceIFL((IFile)loc));
|
||||||
assertNotNull(file);
|
assertNotNull(file);
|
||||||
IIndexInclude[] allIncludesTo= index.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
|
||||||
|
|
|
@ -27,6 +27,7 @@ import junit.framework.Assert;
|
||||||
import junit.framework.TestCase;
|
import junit.framework.TestCase;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.CCorePlugin;
|
import org.eclipse.cdt.core.CCorePlugin;
|
||||||
|
import org.eclipse.cdt.core.dom.ILinkage;
|
||||||
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;
|
||||||
|
@ -285,7 +286,11 @@ 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(IndexLocationFactory.getWorkspaceIFL(file));
|
IIndexFile pfile= index.getFile(ILinkage.CPP_LINKAGE_ID, IndexLocationFactory.getWorkspaceIFL(file));
|
||||||
|
if (pfile != null && pfile.getTimestamp() >= file.getLocalTimeStamp()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
pfile= index.getFile(ILinkage.C_LINKAGE_ID, IndexLocationFactory.getWorkspaceIFL(file));
|
||||||
if (pfile != null && pfile.getTimestamp() >= file.getLocalTimeStamp()) {
|
if (pfile != null && pfile.getTimestamp() >= file.getLocalTimeStamp()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,9 +64,6 @@ Export-Package: org.eclipse.cdt.core,
|
||||||
org.eclipse.cdt.internal.core.pdom.dom.cpp;x-internal:=true,
|
org.eclipse.cdt.internal.core.pdom.dom.cpp;x-internal:=true,
|
||||||
org.eclipse.cdt.internal.core.pdom.export,
|
org.eclipse.cdt.internal.core.pdom.export,
|
||||||
org.eclipse.cdt.internal.core.pdom.indexer;x-friends:="org.eclipse.cdt.ui",
|
org.eclipse.cdt.internal.core.pdom.indexer;x-friends:="org.eclipse.cdt.ui",
|
||||||
org.eclipse.cdt.internal.core.pdom.indexer.fast;x-internal:=true,
|
|
||||||
org.eclipse.cdt.internal.core.pdom.indexer.full;x-internal:=true,
|
|
||||||
org.eclipse.cdt.internal.core.pdom.indexer.nulli;x-internal:=true,
|
|
||||||
org.eclipse.cdt.internal.core.util;x-internal:=true,
|
org.eclipse.cdt.internal.core.util;x-internal:=true,
|
||||||
org.eclipse.cdt.internal.errorparsers;x-internal:=true,
|
org.eclipse.cdt.internal.errorparsers;x-internal:=true,
|
||||||
org.eclipse.cdt.internal.formatter;x-internal:=true,
|
org.eclipse.cdt.internal.formatter;x-internal:=true,
|
||||||
|
|
|
@ -14,6 +14,7 @@ import java.util.Set;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.CCorePlugin;
|
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.dom.ILinkage;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTCompletionNode;
|
import org.eclipse.cdt.core.dom.ast.IASTCompletionNode;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
||||||
|
@ -151,4 +152,7 @@ public class AssemblyLanguage extends AbstractLanguage implements IAsmLanguage,
|
||||||
fId= CCorePlugin.PLUGIN_ID + '.' + config.getAttribute("id"); //$NON-NLS-1$
|
fId= CCorePlugin.PLUGIN_ID + '.' + config.getAttribute("id"); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getLinkageID() {
|
||||||
|
return ILinkage.NO_LINKAGE_ID;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,14 +6,15 @@
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* QNX - Initial API and implementation
|
* QNX - Initial API and implementation
|
||||||
* Markus Schorn (Wind River Systems)
|
* Markus Schorn (Wind River Systems)
|
||||||
* IBM Corporation
|
* IBM Corporation
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
package org.eclipse.cdt.core.model;
|
package org.eclipse.cdt.core.model;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.dom.ICodeReaderFactory;
|
import org.eclipse.cdt.core.dom.ICodeReaderFactory;
|
||||||
|
import org.eclipse.cdt.core.dom.ILinkage;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTCompletionNode;
|
import org.eclipse.cdt.core.dom.ast.IASTCompletionNode;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
||||||
|
@ -25,7 +26,7 @@ import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.core.runtime.IAdaptable;
|
import org.eclipse.core.runtime.IAdaptable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Models differences between languages. The interace is not supposed to be implemented directly.
|
* Models differences between languages. The interface is not supposed to be implemented directly.
|
||||||
* Rather than that clients may subclass {@link AbstractLanguage}.
|
* Rather than that clients may subclass {@link AbstractLanguage}.
|
||||||
* @author Doug Schaefer
|
* @author Doug Schaefer
|
||||||
*/
|
*/
|
||||||
|
@ -34,34 +35,20 @@ public interface ILanguage extends IAdaptable {
|
||||||
//public static final QualifiedName KEY = new QualifiedName(CCorePlugin.PLUGIN_ID, "language"); //$NON-NLS-1$
|
//public static final QualifiedName KEY = new QualifiedName(CCorePlugin.PLUGIN_ID, "language"); //$NON-NLS-1$
|
||||||
public static final String KEY = "language"; //$NON-NLS-1$
|
public static final String KEY = "language"; //$NON-NLS-1$
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated has no effect.
|
|
||||||
*/
|
|
||||||
public static final int AST_USE_INDEX = 1;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated use {@link ITranslationUnit#AST_SKIP_ALL_HEADERS}
|
|
||||||
*/
|
|
||||||
public static final int AST_SKIP_ALL_HEADERS = ITranslationUnit.AST_SKIP_ALL_HEADERS;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated use {@link ITranslationUnit#AST_SKIP_INDEXED_HEADERS}
|
|
||||||
*/
|
|
||||||
public static final int AST_SKIP_INDEXED_HEADERS = ITranslationUnit.AST_SKIP_INDEXED_HEADERS;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated use {@link ITranslationUnit#AST_SKIP_IF_NO_BUILD_INFO}
|
|
||||||
*/
|
|
||||||
public static final int AST_SKIP_IF_NO_BUILD_INFO = ITranslationUnit.AST_SKIP_IF_NO_BUILD_INFO;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the language id for this language.
|
* Return the language id for this language.
|
||||||
* This is to differentiate languages from eachother.
|
* This is to differentiate languages from each other.
|
||||||
*
|
|
||||||
* @return language id
|
|
||||||
*/
|
*/
|
||||||
public String getId();
|
public String getId();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the id of the linkage this language contributes to. This is especially important
|
||||||
|
* for languages that write to the index.
|
||||||
|
* @see ILinkage
|
||||||
|
* @since 5.0
|
||||||
|
*/
|
||||||
|
public int getLinkageID();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the human readable name corresponding to this language, suitable for display.
|
* @return the human readable name corresponding to this language, suitable for display.
|
||||||
* @since 4.0
|
* @since 4.0
|
||||||
|
|
|
@ -24,6 +24,7 @@ import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.CCorePlugin;
|
import org.eclipse.cdt.core.CCorePlugin;
|
||||||
|
import org.eclipse.cdt.core.dom.ILinkage;
|
||||||
import org.eclipse.cdt.core.language.ProjectLanguageConfiguration;
|
import org.eclipse.cdt.core.language.ProjectLanguageConfiguration;
|
||||||
import org.eclipse.cdt.core.language.WorkspaceLanguageConfiguration;
|
import org.eclipse.cdt.core.language.WorkspaceLanguageConfiguration;
|
||||||
import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
|
import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
|
||||||
|
@ -195,7 +196,7 @@ public class LanguageManager {
|
||||||
return getLanguageForContentTypeID(contentTypeID);
|
return getLanguageForContentTypeID(contentTypeID);
|
||||||
}
|
}
|
||||||
|
|
||||||
private ILanguage getLanguageForContentTypeID(String contentTypeID) {
|
public ILanguage getLanguageForContentTypeID(String contentTypeID) {
|
||||||
cacheAllLanguages();
|
cacheAllLanguages();
|
||||||
|
|
||||||
ILanguage language = (ILanguage)fContentTypeToLanguageCache.get(contentTypeID);
|
ILanguage language = (ILanguage)fContentTypeToLanguageCache.get(contentTypeID);
|
||||||
|
|
|
@ -25,10 +25,12 @@ import java.util.Map;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.CCorePlugin;
|
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.dom.ILinkage;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTCompletionNode;
|
import org.eclipse.cdt.core.dom.ast.IASTCompletionNode;
|
||||||
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.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.index.IndexLocationFactory;
|
||||||
import org.eclipse.cdt.core.model.AbstractLanguage;
|
import org.eclipse.cdt.core.model.AbstractLanguage;
|
||||||
|
@ -60,6 +62,7 @@ import org.eclipse.cdt.core.settings.model.ICProjectDescription;
|
||||||
import org.eclipse.cdt.internal.core.dom.NullCodeReaderFactory;
|
import org.eclipse.cdt.internal.core.dom.NullCodeReaderFactory;
|
||||||
import org.eclipse.cdt.internal.core.dom.SavedCodeReaderFactory;
|
import org.eclipse.cdt.internal.core.dom.SavedCodeReaderFactory;
|
||||||
import org.eclipse.cdt.internal.core.index.IndexBasedCodeReaderFactory;
|
import org.eclipse.cdt.internal.core.index.IndexBasedCodeReaderFactory;
|
||||||
|
import org.eclipse.cdt.internal.core.pdom.indexer.ProjectIndexerInputAdapter;
|
||||||
import org.eclipse.core.resources.IFile;
|
import org.eclipse.core.resources.IFile;
|
||||||
import org.eclipse.core.resources.IProject;
|
import org.eclipse.core.resources.IProject;
|
||||||
import org.eclipse.core.resources.IResource;
|
import org.eclipse.core.resources.IResource;
|
||||||
|
@ -742,16 +745,6 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
|
||||||
}
|
}
|
||||||
|
|
||||||
public IASTTranslationUnit getAST(IIndex index, int style) throws CoreException {
|
public IASTTranslationUnit getAST(IIndex index, int style) throws CoreException {
|
||||||
ICodeReaderFactory codeReaderFactory;
|
|
||||||
if ((style & AST_SKIP_NONINDEXED_HEADERS) != 0) {
|
|
||||||
codeReaderFactory= NullCodeReaderFactory.getInstance();
|
|
||||||
} else {
|
|
||||||
codeReaderFactory= SavedCodeReaderFactory.getInstance();
|
|
||||||
}
|
|
||||||
if (index != null && (style & AST_SKIP_INDEXED_HEADERS) != 0) {
|
|
||||||
codeReaderFactory= new IndexBasedCodeReaderFactory(getCProject(), index, codeReaderFactory);
|
|
||||||
}
|
|
||||||
|
|
||||||
ITranslationUnit configureWith = getSourceContextTU(index, style);
|
ITranslationUnit configureWith = getSourceContextTU(index, style);
|
||||||
|
|
||||||
IScannerInfo scanInfo= configureWith.getScannerInfo( (style & AST_SKIP_IF_NO_BUILD_INFO) == 0);
|
IScannerInfo scanInfo= configureWith.getScannerInfo( (style & AST_SKIP_IF_NO_BUILD_INFO) == 0);
|
||||||
|
@ -766,6 +759,7 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
|
||||||
ILanguage language= configureWith.getLanguage();
|
ILanguage language= configureWith.getLanguage();
|
||||||
fLanguageOfContext= language;
|
fLanguageOfContext= language;
|
||||||
if (language != null) {
|
if (language != null) {
|
||||||
|
ICodeReaderFactory crf= getCodeReaderFactory(style, index, language.getLinkageID());
|
||||||
IASTTranslationUnit ast= null;
|
IASTTranslationUnit ast= null;
|
||||||
if (language instanceof AbstractLanguage) {
|
if (language instanceof AbstractLanguage) {
|
||||||
int options= 0;
|
int options= 0;
|
||||||
|
@ -775,10 +769,10 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
|
||||||
if ((style & AST_CREATE_COMMENT_NODES) != 0) {
|
if ((style & AST_CREATE_COMMENT_NODES) != 0) {
|
||||||
options |= AbstractLanguage.OPTION_ADD_COMMENTS;
|
options |= AbstractLanguage.OPTION_ADD_COMMENTS;
|
||||||
}
|
}
|
||||||
ast= ((AbstractLanguage)language).getASTTranslationUnit(reader, scanInfo, codeReaderFactory, index, options, ParserUtil.getParserLogService());
|
ast= ((AbstractLanguage)language).getASTTranslationUnit(reader, scanInfo, crf, index, options, ParserUtil.getParserLogService());
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
ast= language.getASTTranslationUnit(reader, scanInfo, codeReaderFactory, index, ParserUtil.getParserLogService());
|
ast= language.getASTTranslationUnit(reader, scanInfo, crf, index, ParserUtil.getParserLogService());
|
||||||
}
|
}
|
||||||
if (ast != null) {
|
if (ast != null) {
|
||||||
ast.setIsHeaderUnit(isHeaderUnit());
|
ast.setIsHeaderUnit(isHeaderUnit());
|
||||||
|
@ -789,27 +783,46 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private ICodeReaderFactory getCodeReaderFactory(int style, IIndex index, int linkageID) {
|
||||||
|
ICodeReaderFactory codeReaderFactory;
|
||||||
|
if ((style & AST_SKIP_NONINDEXED_HEADERS) != 0) {
|
||||||
|
codeReaderFactory= NullCodeReaderFactory.getInstance();
|
||||||
|
} else {
|
||||||
|
codeReaderFactory= SavedCodeReaderFactory.getInstance();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (index != null && (style & AST_SKIP_INDEXED_HEADERS) != 0) {
|
||||||
|
IndexBasedCodeReaderFactory ibcf= new IndexBasedCodeReaderFactory(index, new ProjectIndexerInputAdapter(getCProject()), linkageID, codeReaderFactory);
|
||||||
|
codeReaderFactory= ibcf;
|
||||||
|
}
|
||||||
|
|
||||||
|
return codeReaderFactory;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static int[] CTX_LINKAGES= {ILinkage.CPP_LINKAGE_ID, ILinkage.C_LINKAGE_ID};
|
||||||
private ITranslationUnit getSourceContextTU(IIndex index, int style) {
|
private ITranslationUnit getSourceContextTU(IIndex index, int style) {
|
||||||
ITranslationUnit configureWith= this;
|
|
||||||
if (index != null && (style & AST_CONFIGURE_USING_SOURCE_CONTEXT) != 0) {
|
if (index != null && (style & AST_CONFIGURE_USING_SOURCE_CONTEXT) != 0) {
|
||||||
try {
|
try {
|
||||||
fLanguageOfContext= null;
|
fLanguageOfContext= null;
|
||||||
IIndexFile context= null;
|
for (int i = 0; i < CTX_LINKAGES.length; i++) {
|
||||||
IIndexFile indexFile= index.getFile(IndexLocationFactory.getIFL(this));
|
IIndexFile context= null;
|
||||||
if (indexFile != null) {
|
final IIndexFileLocation ifl = IndexLocationFactory.getIFL(this);
|
||||||
// bug 199412, when a source-file includes itself the context may recurse.
|
IIndexFile indexFile= index.getFile(CTX_LINKAGES[i], ifl);
|
||||||
HashSet visited= new HashSet();
|
if (indexFile != null) {
|
||||||
visited.add(indexFile);
|
// bug 199412, when a source-file includes itself the context may recurse.
|
||||||
indexFile = getParsedInContext(indexFile);
|
HashSet visited= new HashSet();
|
||||||
while (indexFile != null && visited.add(indexFile)) {
|
visited.add(indexFile);
|
||||||
context= indexFile;
|
indexFile = getParsedInContext(indexFile);
|
||||||
indexFile= getParsedInContext(indexFile);
|
while (indexFile != null && visited.add(indexFile)) {
|
||||||
|
context= indexFile;
|
||||||
|
indexFile= getParsedInContext(indexFile);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
if (context != null) {
|
||||||
if (context != null) {
|
ITranslationUnit tu= CoreModelUtil.findTranslationUnitForLocation(context.getLocation(), getCProject());
|
||||||
ITranslationUnit tu= CoreModelUtil.findTranslationUnitForLocation(context.getLocation(), getCProject());
|
if (tu != null && tu.isSourceUnit()) {
|
||||||
if (tu != null && tu.isSourceUnit()) {
|
return tu;
|
||||||
configureWith= tu;
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -817,7 +830,7 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
|
||||||
CCorePlugin.log(e);
|
CCorePlugin.log(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return configureWith;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
private IIndexFile getParsedInContext(IIndexFile indexFile)
|
private IIndexFile getParsedInContext(IIndexFile indexFile)
|
||||||
|
@ -830,20 +843,6 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
|
||||||
}
|
}
|
||||||
|
|
||||||
public IASTCompletionNode getCompletionNode(IIndex index, int style, int offset) throws CoreException {
|
public IASTCompletionNode getCompletionNode(IIndex index, int style, int offset) throws CoreException {
|
||||||
ICodeReaderFactory codeReaderFactory;
|
|
||||||
if (index != null && (style & (ITranslationUnit.AST_SKIP_INDEXED_HEADERS | ITranslationUnit.AST_SKIP_ALL_HEADERS)) != 0) {
|
|
||||||
ICodeReaderFactory fallbackFactory;
|
|
||||||
if ((style & ITranslationUnit.AST_SKIP_ALL_HEADERS) != 0) {
|
|
||||||
fallbackFactory= NullCodeReaderFactory.getInstance();
|
|
||||||
} else {
|
|
||||||
fallbackFactory= SavedCodeReaderFactory.getInstance();
|
|
||||||
}
|
|
||||||
codeReaderFactory= new IndexBasedCodeReaderFactory(getCProject(), index, fallbackFactory);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
codeReaderFactory = SavedCodeReaderFactory.getInstance();
|
|
||||||
}
|
|
||||||
|
|
||||||
ITranslationUnit configureWith= getSourceContextTU(index, style);
|
ITranslationUnit configureWith= getSourceContextTU(index, style);
|
||||||
|
|
||||||
IScannerInfo scanInfo = configureWith.getScannerInfo( (style & ITranslationUnit.AST_SKIP_IF_NO_BUILD_INFO) == 0);
|
IScannerInfo scanInfo = configureWith.getScannerInfo( (style & ITranslationUnit.AST_SKIP_IF_NO_BUILD_INFO) == 0);
|
||||||
|
@ -857,7 +856,8 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
|
||||||
ILanguage language= configureWith.getLanguage();
|
ILanguage language= configureWith.getLanguage();
|
||||||
fLanguageOfContext= language;
|
fLanguageOfContext= language;
|
||||||
if (language != null) {
|
if (language != null) {
|
||||||
return language.getCompletionNode(reader, scanInfo, codeReaderFactory, index, ParserUtil.getParserLogService(), offset);
|
ICodeReaderFactory crf= getCodeReaderFactory(style, index, language.getLinkageID());
|
||||||
|
return language.getCompletionNode(reader, scanInfo, crf, index, ParserUtil.getParserLogService(), offset);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,9 +28,11 @@ public interface ILinkage {
|
||||||
final static String FORTRAN_LINKAGE_NAME= "Fortran"; //$NON-NLS-1$
|
final static String FORTRAN_LINKAGE_NAME= "Fortran"; //$NON-NLS-1$
|
||||||
|
|
||||||
final static int NO_LINKAGE_ID= 0;
|
final static int NO_LINKAGE_ID= 0;
|
||||||
final static int C_LINKAGE_ID= 1;
|
final static int CPP_LINKAGE_ID= 1;
|
||||||
final static int CPP_LINKAGE_ID= 2;
|
final static int C_LINKAGE_ID= 2;
|
||||||
final static int FORTRAN_LINKAGE_ID= 3;
|
final static int FORTRAN_LINKAGE_ID= 3;
|
||||||
|
|
||||||
|
final static int MAX_LINKAGE_ID= FORTRAN_LINKAGE_ID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the name of the linkage.
|
* Returns the name of the linkage.
|
||||||
|
|
|
@ -9,9 +9,6 @@
|
||||||
* QNX Software Systems - initial API and implementation
|
* QNX Software Systems - initial API and implementation
|
||||||
* Markus Schorn (Wind River Systems)
|
* Markus Schorn (Wind River Systems)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
package org.eclipse.cdt.core.dom;
|
package org.eclipse.cdt.core.dom;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.CCorePlugin;
|
import org.eclipse.cdt.core.CCorePlugin;
|
||||||
|
@ -31,7 +28,7 @@ public interface IPDOMIndexerTask {
|
||||||
/**
|
/**
|
||||||
* Called by the framework to perform the task.
|
* Called by the framework to perform the task.
|
||||||
*/
|
*/
|
||||||
public void run(IProgressMonitor monitor);
|
public void run(IProgressMonitor monitor) throws InterruptedException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the indexer the task belongs to.
|
* Returns the indexer the task belongs to.
|
||||||
|
|
|
@ -6,15 +6,16 @@
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* QNX - Initial API and implementation
|
* QNX - Initial API and implementation
|
||||||
* Markus Schorn (Wind River Systems)
|
* Markus Schorn (Wind River Systems)
|
||||||
* IBM Corporation
|
* IBM Corporation
|
||||||
* Anton Leherbauer (Wind River Systems)
|
* Anton Leherbauer (Wind River Systems)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
package org.eclipse.cdt.core.dom.ast.gnu.c;
|
package org.eclipse.cdt.core.dom.ast.gnu.c;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.CCorePlugin;
|
import org.eclipse.cdt.core.CCorePlugin;
|
||||||
|
import org.eclipse.cdt.core.dom.ILinkage;
|
||||||
import org.eclipse.cdt.core.dom.parser.IScannerExtensionConfiguration;
|
import org.eclipse.cdt.core.dom.parser.IScannerExtensionConfiguration;
|
||||||
import org.eclipse.cdt.core.dom.parser.c.AbstractCLanguage;
|
import org.eclipse.cdt.core.dom.parser.c.AbstractCLanguage;
|
||||||
import org.eclipse.cdt.core.dom.parser.c.GCCParserExtensionConfiguration;
|
import org.eclipse.cdt.core.dom.parser.c.GCCParserExtensionConfiguration;
|
||||||
|
@ -42,6 +43,10 @@ public class GCCLanguage extends AbstractCLanguage {
|
||||||
return ID;
|
return ID;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getLinkageID() {
|
||||||
|
return ILinkage.C_LINKAGE_ID;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @see org.eclipse.cdt.core.dom.parser.c.AbstractCLanguage#getScannerExtensionConfiguration()
|
* @see org.eclipse.cdt.core.dom.parser.c.AbstractCLanguage#getScannerExtensionConfiguration()
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -6,14 +6,15 @@
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* QNX - Initial API and implementation
|
* QNX - Initial API and implementation
|
||||||
* Markus Schorn (Wind River Systems)
|
* Markus Schorn (Wind River Systems)
|
||||||
* IBM Corporation
|
* IBM Corporation
|
||||||
* Anton Leherbauer (Wind River Systems)
|
* Anton Leherbauer (Wind River Systems)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.core.dom.ast.gnu.cpp;
|
package org.eclipse.cdt.core.dom.ast.gnu.cpp;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.CCorePlugin;
|
import org.eclipse.cdt.core.CCorePlugin;
|
||||||
|
import org.eclipse.cdt.core.dom.ILinkage;
|
||||||
import org.eclipse.cdt.core.dom.parser.IScannerExtensionConfiguration;
|
import org.eclipse.cdt.core.dom.parser.IScannerExtensionConfiguration;
|
||||||
import org.eclipse.cdt.core.dom.parser.cpp.AbstractCPPLanguage;
|
import org.eclipse.cdt.core.dom.parser.cpp.AbstractCPPLanguage;
|
||||||
import org.eclipse.cdt.core.dom.parser.cpp.AbstractCPPParserExtensionConfiguration;
|
import org.eclipse.cdt.core.dom.parser.cpp.AbstractCPPParserExtensionConfiguration;
|
||||||
|
@ -40,6 +41,11 @@ public class GPPLanguage extends AbstractCPPLanguage {
|
||||||
return ID;
|
return ID;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public int getLinkageID() {
|
||||||
|
return ILinkage.CPP_LINKAGE_ID;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @see org.eclipse.cdt.core.dom.parser.cpp.AbstractCPPLanguage#getScannerExtensionConfiguration()
|
* @see org.eclipse.cdt.core.dom.parser.cpp.AbstractCPPLanguage#getScannerExtensionConfiguration()
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -132,13 +132,21 @@ public interface IIndex {
|
||||||
public long getLastWriteAccess();
|
public long getLastWriteAccess();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Looks for a file with the given location. Will return <code>null</code> if there
|
* Returns the file-object for the given location and linkage or returns
|
||||||
* is no entry in the index for the given location.
|
* <code>null</code> if the file was not indexed in this linkage.
|
||||||
* @param location an IIndexFileLocation representing the location of the file
|
* @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(IIndexFileLocation location) throws CoreException;
|
public IIndexFile getFile(int linkageID, IIndexFileLocation location) throws CoreException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the file-objects for the given location in any linkage.
|
||||||
|
* @param location an IIndexFileLocation representing the location of the file
|
||||||
|
* @return an array of file-objects.
|
||||||
|
* @throws CoreException
|
||||||
|
*/
|
||||||
|
public IIndexFile[] getFiles(IIndexFileLocation location) throws CoreException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Looks for include relations originated by the given file.
|
* Looks for include relations originated by the given file.
|
||||||
|
|
|
@ -30,6 +30,8 @@ import org.eclipse.core.runtime.CoreException;
|
||||||
* @since 4.0
|
* @since 4.0
|
||||||
*/
|
*/
|
||||||
public interface IIndexFile {
|
public interface IIndexFile {
|
||||||
|
IIndexFile[] EMPTY_FILE_ARRAY = {};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an IIndexFileLocation representing the location of this file
|
* Returns an IIndexFileLocation representing the location of this file
|
||||||
* @return an IIndexFileLocation representing the location of this file
|
* @return an IIndexFileLocation representing the location of this file
|
||||||
|
@ -59,9 +61,9 @@ public interface IIndexFile {
|
||||||
long getTimestamp() throws CoreException;
|
long getTimestamp() throws CoreException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the hashcode of the scanner configuration that was used to parse the file.
|
* Returns the hash-code of the scanner configuration that was used to parse the file.
|
||||||
* <code>0</code> will be returned in case the hashcode is unknown.
|
* <code>0</code> will be returned in case the hash-code is unknown.
|
||||||
* @return the hashcode of the scanner configuration or <code>0</code>.
|
* @return the hash-code of the scanner configuration or <code>0</code>.
|
||||||
* @throws CoreException
|
* @throws CoreException
|
||||||
*/
|
*/
|
||||||
int getScannerConfigurationHashcode() throws CoreException;
|
int getScannerConfigurationHashcode() throws CoreException;
|
||||||
|
@ -75,5 +77,10 @@ public interface IIndexFile {
|
||||||
* Returns the include that was used to parse this file, may be null.
|
* Returns the include that was used to parse this file, may be null.
|
||||||
*/
|
*/
|
||||||
IIndexInclude getParsedInContext() throws CoreException;
|
IIndexInclude getParsedInContext() throws CoreException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the id of the linkage this file was parsed in.
|
||||||
|
* @since 5.0
|
||||||
|
*/
|
||||||
|
int getLinkageID() throws CoreException;
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,6 +16,7 @@ package org.eclipse.cdt.internal.core.index;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.BitSet;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
|
@ -158,19 +159,34 @@ public class CIndex implements IIndex {
|
||||||
return findNames(binding, FIND_REFERENCES);
|
return findNames(binding, FIND_REFERENCES);
|
||||||
}
|
}
|
||||||
|
|
||||||
public IIndexFile getFile(IIndexFileLocation location) throws CoreException {
|
public IIndexFile getFile(int linkageID, IIndexFileLocation location) throws CoreException {
|
||||||
IIndexFile result= null, backup= null;
|
for (int i = 0; i < fPrimaryFragmentCount; i++) {
|
||||||
for (int i = 0; result==null && i < fPrimaryFragmentCount; i++) {
|
IIndexFragmentFile candidate= fFragments[i].getFile(linkageID, location);
|
||||||
IIndexFragmentFile candidate= fFragments[i].getFile(location);
|
if (candidate!=null && candidate.hasContent()) {
|
||||||
if(candidate!=null) {
|
return candidate;
|
||||||
if(candidate.hasNames()) {
|
|
||||||
result = candidate;
|
|
||||||
}
|
|
||||||
if(backup==null)
|
|
||||||
backup = candidate;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result == null ? backup : result;
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IIndexFile[] getFiles(IIndexFileLocation location) throws CoreException {
|
||||||
|
ArrayList result= new ArrayList();
|
||||||
|
BitSet linkages= new BitSet();
|
||||||
|
for (int i = 0; i < fPrimaryFragmentCount; i++) {
|
||||||
|
IIndexFragmentFile[] candidates= fFragments[i].getFiles(location);
|
||||||
|
for (int j = 0; j < candidates.length; j++) {
|
||||||
|
IIndexFragmentFile candidate= candidates[j];
|
||||||
|
int linkage= candidate.getLinkageID();
|
||||||
|
if (!linkages.get(linkage) && candidate.hasContent()) {
|
||||||
|
result.add(candidate);
|
||||||
|
linkages.set(linkage);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (result.isEmpty()) {
|
||||||
|
return IIndexFile.EMPTY_FILE_ARRAY;
|
||||||
|
}
|
||||||
|
return (IIndexFile[]) result.toArray(new IIndexFile[result.size()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public IIndexFile resolveInclude(IIndexInclude include) throws CoreException {
|
public IIndexFile resolveInclude(IIndexInclude include) throws CoreException {
|
||||||
|
@ -179,11 +195,11 @@ public class CIndex implements IIndex {
|
||||||
}
|
}
|
||||||
IIndexFragmentInclude fragmentInclude = (IIndexFragmentInclude) include;
|
IIndexFragmentInclude fragmentInclude = (IIndexFragmentInclude) include;
|
||||||
IIndexFragmentFile result= fragmentInclude.getIncludes();
|
IIndexFragmentFile result= fragmentInclude.getIncludes();
|
||||||
if (result != null && result.hasNames()) {
|
if (result != null && result.hasContent()) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
return getFile(include.getIncludesLocation());
|
return getFile(include.getIncludedBy().getLinkageID(), include.getIncludesLocation());
|
||||||
}
|
}
|
||||||
|
|
||||||
public IIndexInclude[] findIncludedBy(IIndexFile file) throws CoreException {
|
public IIndexInclude[] findIncludedBy(IIndexFile file) throws CoreException {
|
||||||
|
|
|
@ -50,9 +50,13 @@ final public class EmptyCIndex implements IIndex {
|
||||||
return IIndexFragmentName.EMPTY_NAME_ARRAY;
|
return IIndexFragmentName.EMPTY_NAME_ARRAY;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IIndexFile getFile(IIndexFileLocation location) {
|
public IIndexFile getFile(int linkageID, IIndexFileLocation location) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public IIndexFile[] getFiles(IIndexFileLocation location) {
|
||||||
|
return IIndexFile.EMPTY_FILE_ARRAY;
|
||||||
|
}
|
||||||
|
|
||||||
public IIndexFile resolveInclude(IIndexInclude include) {
|
public IIndexFile resolveInclude(IIndexInclude include) {
|
||||||
return null;
|
return null;
|
||||||
|
|
|
@ -80,13 +80,25 @@ public interface IIndexFragment {
|
||||||
public static final String PROPERTY_FRAGMENT_FORMAT_VERSION= "org.eclipse.cdt.internal.core.index.fragment.format.version"; //$NON-NLS-1$
|
public static final String PROPERTY_FRAGMENT_FORMAT_VERSION= "org.eclipse.cdt.internal.core.index.fragment.format.version"; //$NON-NLS-1$
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the file for the given location. May return <code>null</code>, if no such file exists.
|
* Returns the file for the given location and linkage.
|
||||||
|
* May return <code>null</code>, if no such file exists.
|
||||||
|
* This method may only return files that are actually managed by this fragment.
|
||||||
|
* This method returns files without content, also.
|
||||||
|
* @param linkageID the id of the linkage in which the file has been parsed.
|
||||||
|
* @param location the IIndexFileLocation representing the location of the file
|
||||||
|
* @return the file for the location, or <code>null</code> if the file is not present in the index
|
||||||
|
* @throws CoreException
|
||||||
|
*/
|
||||||
|
IIndexFragmentFile getFile(int linkageID, IIndexFileLocation location) throws CoreException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the files in all linkages for the given location.
|
||||||
* This method may only return files that are actually managed by this fragment.
|
* This method may only return files that are actually managed by this fragment.
|
||||||
* @param location the IIndexFileLocation representing the location of the file
|
* @param location the IIndexFileLocation representing the location of the file
|
||||||
* @return the file for the location, or <code>null</code> if the file is not present in the index
|
* @return the file for the location, or <code>null</code> if the file is not present in the index
|
||||||
* @throws CoreException
|
* @throws CoreException
|
||||||
*/
|
*/
|
||||||
IIndexFragmentFile getFile(IIndexFileLocation location) throws CoreException;
|
IIndexFragmentFile[] getFiles(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
|
||||||
|
|
|
@ -16,6 +16,7 @@ import org.eclipse.cdt.core.index.IIndexFile;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
|
|
||||||
public interface IIndexFragmentFile extends IIndexFile {
|
public interface IIndexFragmentFile extends IIndexFile {
|
||||||
|
IIndexFragmentFile[] EMPTY_ARRAY = {};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the fragment that owns this file.
|
* Returns the fragment that owns this file.
|
||||||
|
@ -24,23 +25,24 @@ public interface IIndexFragmentFile extends IIndexFile {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the timestamp of the file
|
* Sets the timestamp of the file
|
||||||
* @throws CoreException
|
|
||||||
*/
|
*/
|
||||||
void setTimestamp(long timestamp) throws CoreException;
|
void setTimestamp(long timestamp) throws CoreException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the hashcode of the scanner configuration.
|
* Sets the hash-code of the scanner configuration.
|
||||||
* @param hashcode a hashcode or <code>0</code> if it is unknown.
|
* @param hashcode a hash-code or <code>0</code> if it is unknown.
|
||||||
* @throws CoreException
|
* @throws CoreException
|
||||||
*/
|
*/
|
||||||
void setScannerConfigurationHashcode(int hashcode) throws CoreException;
|
void setScannerConfigurationHashcode(int hashcode) throws CoreException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns whether any names are associated with this file object
|
* Returns whether this file contains content in its
|
||||||
* in this fragment - i.e. whether this file contains content in its
|
* associated fragment. Files without content are inserted to track includes.
|
||||||
* associated fragment
|
|
||||||
* @return whether any names are associated with this file object
|
|
||||||
* in this fragment
|
|
||||||
*/
|
*/
|
||||||
boolean hasNames() throws CoreException;
|
boolean hasContent() throws CoreException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the id of the linkage this file belongs to.
|
||||||
|
*/
|
||||||
|
int getLinkageID() throws CoreException;
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,6 +18,7 @@ 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.IIndexFile;
|
||||||
import org.eclipse.cdt.core.index.IIndexFileLocation;
|
import org.eclipse.cdt.core.index.IIndexFileLocation;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
|
|
||||||
|
@ -38,12 +39,19 @@ public interface IWritableIndex extends IIndex {
|
||||||
/**
|
/**
|
||||||
* Checks whether the given file can be written to in this index.
|
* Checks whether the given file can be written to in this index.
|
||||||
*/
|
*/
|
||||||
boolean isWritableFile(IIndexFragmentFile file);
|
boolean isWritableFile(IIndexFile file);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a writable file for the given location, or null.
|
* Returns a writable file for the given location and linkage, or null. This method
|
||||||
|
* returns file-objects without content, also.
|
||||||
*/
|
*/
|
||||||
IIndexFragmentFile getWritableFile(IIndexFileLocation location) throws CoreException;
|
IIndexFragmentFile getWritableFile(int linkageID, IIndexFileLocation location) throws CoreException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the writable files for the given location in any linkage. This method
|
||||||
|
* returns file-objects without content, also.
|
||||||
|
*/
|
||||||
|
IIndexFragmentFile[] getWritableFiles(IIndexFileLocation location) throws CoreException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clears the given file in the index.
|
* Clears the given file in the index.
|
||||||
|
@ -56,13 +64,13 @@ 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(IIndexFileLocation fileLocation) throws CoreException;
|
IIndexFragmentFile addFile(int linkageID, IIndexFileLocation fileLocation) throws CoreException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds content to the given file.
|
* Adds content to the given file.
|
||||||
*/
|
*/
|
||||||
void setFileContent(IIndexFragmentFile sourceFile,
|
void setFileContent(IIndexFragmentFile sourceFile,
|
||||||
IncludeInformation[] includes,
|
int linkageID, IncludeInformation[] includes,
|
||||||
IASTPreprocessorMacroDefinition[] macros, IASTName[][] names) throws CoreException;
|
IASTPreprocessorMacroDefinition[] macros, IASTName[][] names) throws CoreException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -39,12 +39,12 @@ public interface IWritableIndexFragment extends IIndexFragment {
|
||||||
void clearFile(IIndexFragmentFile file, Collection contextsRemoved) throws CoreException;
|
void clearFile(IIndexFragmentFile file, Collection contextsRemoved) throws CoreException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a file object for the given location or returns an existing one.
|
* Creates a file object for the given location and linkage or returns an existing one.
|
||||||
* @param fileLocation an IIndexFileLocation representing the location of the file
|
* @param fileLocation an IIndexFileLocation representing the location of the file
|
||||||
* @return the existing IIndexFragmentFile for this location, or a newly created one
|
* @return the existing IIndexFragmentFile for this location, or a newly created one
|
||||||
* @throws CoreException
|
* @throws CoreException
|
||||||
*/
|
*/
|
||||||
IIndexFragmentFile addFile(IIndexFileLocation fileLocation) throws CoreException;
|
IIndexFragmentFile addFile(int linkageID, IIndexFileLocation fileLocation) throws CoreException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds an include to the given file.
|
* Adds an include to the given file.
|
||||||
|
|
|
@ -6,22 +6,17 @@
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* 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)
|
* Andrew Ferguson (Symbian)
|
||||||
* Anton Leherbauer (Wind River Systems)
|
* Anton Leherbauer (Wind River Systems)
|
||||||
* IBM Corporation
|
* IBM Corporation
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.index;
|
package org.eclipse.cdt.internal.core.index;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.LinkedHashSet;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
@ -33,93 +28,49 @@ import org.eclipse.cdt.core.index.IIndexFile;
|
||||||
import org.eclipse.cdt.core.index.IIndexFileLocation;
|
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.IndexLocationFactory;
|
|
||||||
import org.eclipse.cdt.core.model.ICProject;
|
|
||||||
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;
|
||||||
import org.eclipse.cdt.core.parser.ParserUtil;
|
import org.eclipse.cdt.core.parser.ParserUtil;
|
||||||
import org.eclipse.cdt.internal.core.parser.scanner2.IIndexBasedCodeReaderFactory;
|
import org.eclipse.cdt.internal.core.parser.scanner2.IIndexBasedCodeReaderFactory;
|
||||||
import org.eclipse.cdt.internal.core.parser.scanner2.ObjectStyleMacro;
|
import org.eclipse.cdt.internal.core.pdom.ASTFilePathResolver;
|
||||||
|
import org.eclipse.cdt.internal.core.pdom.AbstractIndexerTask;
|
||||||
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;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Code reader factory, that fakes code readers for header files already stored in the
|
* Code reader factory, that fakes code readers for header files already stored in the
|
||||||
* index.
|
* index.
|
||||||
*
|
|
||||||
* <p>
|
|
||||||
* This interface is not intended to be implemented by clients.
|
|
||||||
* </p>
|
|
||||||
*/
|
*/
|
||||||
public class IndexBasedCodeReaderFactory implements IIndexBasedCodeReaderFactory {
|
public final class IndexBasedCodeReaderFactory implements IIndexBasedCodeReaderFactory {
|
||||||
public static interface CallbackHandler {
|
private static final class NeedToParseException extends Exception {}
|
||||||
boolean needToUpdate(IndexFileInfo fileInfo) throws CoreException;
|
|
||||||
}
|
|
||||||
public static class IndexFileInfo {
|
|
||||||
public final static int NOT_REQUESTED= 0;
|
|
||||||
public final static int REQUESTED_IF_CONFIG_CHANGED= 1;
|
|
||||||
public final static int REQUESTED= 2;
|
|
||||||
|
|
||||||
private IndexFileInfo() {}
|
|
||||||
private IMacro[] fMacros= null;
|
|
||||||
|
|
||||||
public IIndexFile fFile= null;
|
|
||||||
public int fRequested= 0;
|
|
||||||
|
|
||||||
public boolean hasCachedMacros() {
|
|
||||||
return fMacros != null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
private static class NeedToParseException extends Exception {
|
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
}
|
|
||||||
|
|
||||||
private final static boolean CASE_SENSITIVE_FILES= !new File("a").equals(new File("A")); //$NON-NLS-1$//$NON-NLS-2$
|
|
||||||
private final static char[] EMPTY_CHARS = new char[0];
|
private final static char[] EMPTY_CHARS = new char[0];
|
||||||
|
|
||||||
private final IIndex index;
|
private final IIndex fIndex;
|
||||||
private Map/*<IIndexFileLocation,FileInfo>*/ fileInfoCache;
|
private int fLinkage;
|
||||||
private Map/*<String,IIndexFileLocation>*/ iflCache;
|
private Set fIncludedFiles= new HashSet();
|
||||||
private List usedMacros = new ArrayList();
|
|
||||||
private Set/*<FileInfo>*/ fIncluded= new HashSet();
|
|
||||||
/** The fall-back code reader factory used in case a header file is not indexed */
|
/** The fall-back code reader factory used in case a header file is not indexed */
|
||||||
private ICodeReaderFactory fFallBackFactory;
|
private final ICodeReaderFactory fFallBackFactory;
|
||||||
private CallbackHandler fCallbackHandler;
|
private final ASTFilePathResolver fPathResolver;
|
||||||
private final ICProject cproject;
|
private final AbstractIndexerTask fRelatedIndexerTask;
|
||||||
private final String fProjectPathPrefix;
|
|
||||||
|
|
||||||
public IndexBasedCodeReaderFactory(ICProject cproject, IIndex index) {
|
public IndexBasedCodeReaderFactory(IIndex index, ASTFilePathResolver pathResolver, int linkage) {
|
||||||
this(cproject, index, new HashMap/*<String,IIndexFileLocation>*/());
|
this(index, pathResolver, linkage, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public IndexBasedCodeReaderFactory(ICProject cproject, IIndex index, ICodeReaderFactory fallbackFactory) {
|
public IndexBasedCodeReaderFactory(IIndex index, ASTFilePathResolver pathResolver, int linkage, ICodeReaderFactory fallbackFactory) {
|
||||||
this(cproject, index, new HashMap/*<String,IIndexFileLocation>*/(), fallbackFactory);
|
this(index, pathResolver, linkage, fallbackFactory, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public IndexBasedCodeReaderFactory(ICProject cproject, IIndex index, Map iflCache) {
|
public IndexBasedCodeReaderFactory(IIndex index, ASTFilePathResolver pathResolver, int linkage,
|
||||||
this(cproject, index, iflCache, null);
|
ICodeReaderFactory fallbackFactory, AbstractIndexerTask relatedIndexerTask) {
|
||||||
|
fIndex= index;
|
||||||
|
fFallBackFactory= fallbackFactory;
|
||||||
|
fPathResolver= pathResolver;
|
||||||
|
fRelatedIndexerTask= relatedIndexerTask;
|
||||||
|
fLinkage= linkage;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param cproject the ICProject to prefer when resolving external includes to workspace resources (may be null)
|
|
||||||
* @param index the IIndex that backs this code reader
|
|
||||||
* @param iflCache
|
|
||||||
* @param fallbackFactory
|
|
||||||
*/
|
|
||||||
public IndexBasedCodeReaderFactory(ICProject cproject, IIndex index, Map iflCache, ICodeReaderFactory fallbackFactory) {
|
|
||||||
this.cproject= cproject;
|
|
||||||
this.index = index;
|
|
||||||
this.fileInfoCache = new HashMap/*<IIndexFileLocation,FileInfo>*/();
|
|
||||||
this.iflCache = iflCache;
|
|
||||||
this.fFallBackFactory= fallbackFactory;
|
|
||||||
this.fProjectPathPrefix= cproject == null ? null : '/' + cproject.getElementName() + '/';
|
|
||||||
}
|
|
||||||
|
|
||||||
final protected Map getIFLCache() {
|
|
||||||
return iflCache;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getUniqueIdentifier() {
|
public int getUniqueIdentifier() {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -129,185 +80,95 @@ public class IndexBasedCodeReaderFactory implements IIndexBasedCodeReaderFactory
|
||||||
}
|
}
|
||||||
|
|
||||||
public CodeReader createCodeReaderForInclusion(IMacroCollector scanner, String path) {
|
public CodeReader createCodeReaderForInclusion(IMacroCollector scanner, String path) {
|
||||||
// if the file is in the index, we skip it
|
IIndexFileLocation ifl= fPathResolver.resolveIncludeFile(path);
|
||||||
File location= new File(path);
|
if (ifl == null) {
|
||||||
String canonicalPath= path;
|
|
||||||
if (!location.exists()) {
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
if (!CASE_SENSITIVE_FILES) {
|
path= fPathResolver.getASTPath(ifl);
|
||||||
try {
|
|
||||||
canonicalPath= location.getCanonicalPath();
|
// include files once, only.
|
||||||
}
|
if (!fIncludedFiles.add(ifl)) {
|
||||||
catch (IOException e) {
|
return new CodeReader(path, EMPTY_CHARS);
|
||||||
// just use the original
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
IIndexFileLocation incLocation = findLocation(canonicalPath);
|
IIndexFile file= fIndex.getFile(fLinkage, ifl);
|
||||||
IndexFileInfo info= createInfo(incLocation, null);
|
if (file != null) {
|
||||||
|
|
||||||
if (isIncluded(info)) {
|
|
||||||
return new CodeReader(canonicalPath, EMPTY_CHARS);
|
|
||||||
}
|
|
||||||
|
|
||||||
// try to build macro dictionary off index
|
|
||||||
if (info.fFile != null) {
|
|
||||||
try {
|
try {
|
||||||
LinkedHashSet infos= new LinkedHashSet();
|
LinkedHashMap macroMap= new LinkedHashMap();
|
||||||
getInfosForMacroDictionary(info, infos);
|
collectMacros(file, macroMap, false);
|
||||||
for (Iterator iter = infos.iterator(); iter.hasNext();) {
|
for (Iterator iterator = macroMap.entrySet().iterator(); iterator.hasNext();) {
|
||||||
IndexFileInfo fi = (IndexFileInfo) iter.next();
|
Map.Entry entry = (Map.Entry) iterator.next();
|
||||||
if (fi.fMacros == null) {
|
IIndexFileLocation includedIFL = (IIndexFileLocation) entry.getKey();
|
||||||
assert fi.fFile != null;
|
IMacro[] macros = (IMacro[]) entry.getValue();
|
||||||
IIndexMacro[] macros= fi.fFile.getMacros();
|
for (int i = 0; i < macros.length; ++i) {
|
||||||
IMacro[] converted= new IMacro[macros.length];
|
scanner.addDefinition(macros[i]);
|
||||||
for (int i = 0; i < macros.length; i++) {
|
|
||||||
IIndexMacro macro = macros[i];
|
|
||||||
converted[i]= ((PDOMMacro)macro).getMacro();
|
|
||||||
}
|
|
||||||
fi.fMacros= converted;
|
|
||||||
}
|
}
|
||||||
for (int i = 0; i < fi.fMacros.length; ++i) {
|
fIncludedFiles.add(includedIFL);
|
||||||
scanner.addDefinition(fi.fMacros[i]);
|
|
||||||
}
|
|
||||||
// record the macros we used.
|
|
||||||
usedMacros.add(fi.fMacros);
|
|
||||||
setIncluded(fi);
|
|
||||||
}
|
}
|
||||||
return new CodeReader(canonicalPath, EMPTY_CHARS);
|
return new CodeReader(path, EMPTY_CHARS);
|
||||||
} catch (NeedToParseException e) {
|
}
|
||||||
|
catch (NeedToParseException e) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
setIncluded(info);
|
|
||||||
}
|
}
|
||||||
catch (CoreException e) {
|
catch (CoreException e) {
|
||||||
CCorePlugin.log(e);
|
CCorePlugin.log(e);
|
||||||
// still try to parse the file.
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fFallBackFactory != null) {
|
if (fFallBackFactory != null) {
|
||||||
return fFallBackFactory.createCodeReaderForInclusion(scanner, canonicalPath);
|
return fFallBackFactory.createCodeReaderForInclusion(scanner, path);
|
||||||
}
|
}
|
||||||
return ParserUtil.createReader(canonicalPath, null);
|
return ParserUtil.createReader(path, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasFileBeenIncludedInCurrentTranslationUnit(String path) {
|
public boolean hasFileBeenIncludedInCurrentTranslationUnit(String path) {
|
||||||
String canonicalPath= path;
|
IIndexFileLocation ifl= fPathResolver.resolveASTPath(path);
|
||||||
if (!CASE_SENSITIVE_FILES) {
|
return fIncludedFiles.contains(ifl);
|
||||||
try {
|
|
||||||
File location= new File(path);
|
|
||||||
canonicalPath= location.getCanonicalPath();
|
|
||||||
}
|
|
||||||
catch (IOException e) {
|
|
||||||
// just use the original
|
|
||||||
}
|
|
||||||
}
|
|
||||||
IIndexFileLocation loc= findLocation(canonicalPath);
|
|
||||||
IndexFileInfo info= (IndexFileInfo) fileInfoCache.get(loc);
|
|
||||||
if (info != null && isIncluded(info)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Mark the given inclusion as included.
|
|
||||||
* @param info
|
|
||||||
*/
|
|
||||||
private void setIncluded(IndexFileInfo info) {
|
|
||||||
fIncluded.add(info);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test whether the given inclusion is already included.
|
|
||||||
* @param info
|
|
||||||
* @return <code>true</code> if the inclusion is already included.
|
|
||||||
*/
|
|
||||||
private boolean isIncluded(IndexFileInfo info) {
|
|
||||||
return fIncluded.contains(info);
|
|
||||||
}
|
|
||||||
|
|
||||||
private IndexFileInfo createInfo(IIndexFileLocation location, IIndexFile file) throws CoreException {
|
|
||||||
IndexFileInfo info= (IndexFileInfo) fileInfoCache.get(location);
|
|
||||||
if (info == null) {
|
|
||||||
info= new IndexFileInfo();
|
|
||||||
if (file != null) {
|
|
||||||
info.fFile= file;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
// bug 205555, in case a file of the project is also part of a read-only pdom,
|
|
||||||
// we prefer the writable pdom.
|
|
||||||
final String path= location.getFullPath();
|
|
||||||
if (path != null && fProjectPathPrefix != null &&
|
|
||||||
path.startsWith(fProjectPathPrefix) && index instanceof IWritableIndex) {
|
|
||||||
info.fFile= ((IWritableIndex) index).getWritableFile(location);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
info.fFile= index.getFile(location);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fileInfoCache.put(location, info);
|
|
||||||
}
|
|
||||||
return info;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void getInfosForMacroDictionary(IndexFileInfo fileInfo, LinkedHashSet/*<FileInfo>*/ target) throws CoreException, NeedToParseException {
|
private void collectMacros(IIndexFile file, LinkedHashMap macroMap, boolean checkIncluded) throws CoreException, NeedToParseException {
|
||||||
// in case the file is already included, don't load the macros again.
|
IIndexFileLocation ifl= file.getLocation();
|
||||||
if (isIncluded(fileInfo)) {
|
if (macroMap.containsKey(ifl) || (checkIncluded && fIncludedFiles.contains(ifl))) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!target.add(fileInfo)) {
|
IMacro[] converted;
|
||||||
return;
|
if (fRelatedIndexerTask != null) {
|
||||||
|
converted= fRelatedIndexerTask.getConvertedMacros(fLinkage, ifl);
|
||||||
|
if (converted == null) {
|
||||||
|
throw new NeedToParseException();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
final IIndexFile file= fileInfo.fFile;
|
else {
|
||||||
if (file == null ||
|
IIndexMacro[] macros= file.getMacros();
|
||||||
(fCallbackHandler != null && fCallbackHandler.needToUpdate(fileInfo))) {
|
converted= new IMacro[macros.length];
|
||||||
throw new NeedToParseException();
|
for (int i = 0; i < macros.length; i++) {
|
||||||
|
IIndexMacro macro = macros[i];
|
||||||
|
converted[i]= ((PDOMMacro)macro).getMacro();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
macroMap.put(ifl, converted); // prevent recursion
|
||||||
// Follow the includes
|
|
||||||
|
// follow the includes
|
||||||
IIndexInclude[] includeDirectives= file.getIncludes();
|
IIndexInclude[] includeDirectives= file.getIncludes();
|
||||||
for (int i = 0; i < includeDirectives.length; i++) {
|
for (int i = 0; i < includeDirectives.length; i++) {
|
||||||
IIndexFile includedFile= index.resolveInclude(includeDirectives[i]);
|
final IIndexInclude indexInclude = includeDirectives[i];
|
||||||
|
IIndexFile includedFile= fIndex.resolveInclude(indexInclude);
|
||||||
if (includedFile != null) {
|
if (includedFile != null) {
|
||||||
IndexFileInfo nextInfo= createInfo(includedFile.getLocation(), includedFile);
|
collectMacros(includedFile, macroMap, true);
|
||||||
getInfosForMacroDictionary(nextInfo, target);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void clearMacroAttachements() {
|
public void cleanupAfterTranslationUnit() {
|
||||||
Iterator i = usedMacros.iterator();
|
fIncludedFiles.clear();
|
||||||
while (i.hasNext()) {
|
|
||||||
IMacro[] macros = (IMacro[])i.next();
|
|
||||||
for (int j = 0; j < macros.length; ++j) {
|
|
||||||
if (macros[j] instanceof ObjectStyleMacro) {
|
|
||||||
((ObjectStyleMacro)macros[j]).attachment = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
usedMacros.clear();
|
|
||||||
fIncluded.clear();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ICodeReaderCache getCodeReaderCache() {
|
public ICodeReaderCache getCodeReaderCache() {
|
||||||
// No need for cache here
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IndexFileInfo createFileInfo(IIndexFileLocation location) throws CoreException {
|
public void setLinkage(int linkageID) {
|
||||||
return createInfo(location, null);
|
fLinkage= linkageID;
|
||||||
}
|
|
||||||
|
|
||||||
public IIndexFileLocation findLocation(String absolutePath) {
|
|
||||||
if(!iflCache.containsKey(absolutePath)) {
|
|
||||||
iflCache.put(absolutePath, IndexLocationFactory.getIFLExpensive(cproject, absolutePath));
|
|
||||||
}
|
|
||||||
return (IIndexFileLocation) iflCache.get(absolutePath);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setCallbackHandler(CallbackHandler callbackHandler) {
|
|
||||||
fCallbackHandler= callbackHandler;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2006 Symbian Software Ltd. and others.
|
* Copyright (c) 2006, 2007 Symbian Software Ltd. and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -62,4 +62,11 @@ public class IndexFileLocation implements IIndexFileLocation {
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return uri.hashCode();
|
return uri.hashCode();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String toString() {
|
||||||
|
if (fullPath == null) {
|
||||||
|
return uri.toString();
|
||||||
|
}
|
||||||
|
return fullPath.toString() + " (" + uri.toString() + ')'; //$NON-NLS-1$
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,6 +16,7 @@ import java.util.Collection;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTPreprocessorMacroDefinition;
|
import org.eclipse.cdt.core.dom.ast.IASTPreprocessorMacroDefinition;
|
||||||
|
import org.eclipse.cdt.core.index.IIndexFile;
|
||||||
import org.eclipse.cdt.core.index.IIndexFileLocation;
|
import org.eclipse.cdt.core.index.IIndexFileLocation;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
|
|
||||||
|
@ -40,19 +41,23 @@ public class WritableCIndex extends CIndex implements IWritableIndex {
|
||||||
return fWritableFragment;
|
return fWritableFragment;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IIndexFragmentFile getWritableFile(IIndexFileLocation location) throws CoreException {
|
public IIndexFragmentFile getWritableFile(int linkageID, IIndexFileLocation location) throws CoreException {
|
||||||
return fWritableFragment.getFile(location);
|
return fWritableFragment.getFile(linkageID, location);
|
||||||
}
|
}
|
||||||
|
|
||||||
public IIndexFragmentFile addFile(IIndexFileLocation fileLocation) throws CoreException {
|
public IIndexFragmentFile[] getWritableFiles(IIndexFileLocation location) throws CoreException {
|
||||||
return fWritableFragment.addFile(fileLocation);
|
return fWritableFragment.getFiles(location);
|
||||||
|
}
|
||||||
|
|
||||||
|
public IIndexFragmentFile addFile(int linkageID, IIndexFileLocation fileLocation) throws CoreException {
|
||||||
|
return fWritableFragment.addFile(linkageID, fileLocation);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isWritableFragment(IIndexFragment frag) {
|
private boolean isWritableFragment(IIndexFragment frag) {
|
||||||
return frag == fWritableFragment;
|
return frag == fWritableFragment;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setFileContent(IIndexFragmentFile file,
|
public void setFileContent(IIndexFragmentFile file, int linkageID,
|
||||||
IncludeInformation[] includes,
|
IncludeInformation[] includes,
|
||||||
IASTPreprocessorMacroDefinition[] macros, IASTName[][] names) throws CoreException {
|
IASTPreprocessorMacroDefinition[] macros, IASTName[][] names) throws CoreException {
|
||||||
|
|
||||||
|
@ -64,7 +69,7 @@ public class WritableCIndex extends CIndex implements IWritableIndex {
|
||||||
for (int i = 0; i < includes.length; i++) {
|
for (int i = 0; i < includes.length; i++) {
|
||||||
IncludeInformation ii= includes[i];
|
IncludeInformation ii= includes[i];
|
||||||
if (ii.fLocation != null) {
|
if (ii.fLocation != null) {
|
||||||
ii.fTargetFile= addFile(ii.fLocation);
|
ii.fTargetFile= addFile(linkageID, ii.fLocation);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
((IWritableIndexFragment) indexFragment).addFileContent(file, includes, macros, names);
|
((IWritableIndexFragment) indexFragment).addFileContent(file, includes, macros, names);
|
||||||
|
@ -75,8 +80,9 @@ public class WritableCIndex extends CIndex implements IWritableIndex {
|
||||||
fWritableFragment.clear();
|
fWritableFragment.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isWritableFile(IIndexFragmentFile file) {
|
public boolean isWritableFile(IIndexFile file) {
|
||||||
return isWritableFragment(file.getIndexFragment());
|
return file instanceof IIndexFragmentFile &&
|
||||||
|
isWritableFragment(((IIndexFragmentFile)file).getIndexFragment());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void clearFile(IIndexFragmentFile file, Collection clearedContexts) throws CoreException {
|
public void clearFile(IIndexFragmentFile file, Collection clearedContexts) throws CoreException {
|
||||||
|
|
|
@ -6,35 +6,16 @@
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* QNX - Initial API and implementation
|
* QNX - Initial API and implementation
|
||||||
* Markus Schorn (Wind River Systems)
|
* Markus Schorn (Wind River Systems)
|
||||||
* IBM Corporation
|
* IBM Corporation
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
package org.eclipse.cdt.internal.core.indexer;
|
package org.eclipse.cdt.internal.core.indexer;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
import org.eclipse.cdt.core.dom.ICodeReaderFactory;
|
||||||
import org.eclipse.cdt.core.index.IIndexFile;
|
|
||||||
import org.eclipse.cdt.core.index.IIndexFileLocation;
|
|
||||||
import org.eclipse.cdt.core.model.AbstractLanguage;
|
|
||||||
import org.eclipse.cdt.core.parser.CodeReader;
|
|
||||||
import org.eclipse.cdt.core.parser.IScannerInfo;
|
|
||||||
import org.eclipse.cdt.internal.core.index.IWritableIndex;
|
|
||||||
import org.eclipse.cdt.internal.core.index.IndexFileLocation;
|
|
||||||
import org.eclipse.cdt.internal.core.index.IndexBasedCodeReaderFactory.CallbackHandler;
|
|
||||||
import org.eclipse.cdt.internal.core.index.IndexBasedCodeReaderFactory.IndexFileInfo;
|
|
||||||
import org.eclipse.core.filesystem.URIUtil;
|
|
||||||
import org.eclipse.core.runtime.CoreException;
|
|
||||||
import org.eclipse.core.runtime.IProgressMonitor;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A task for index updates.
|
* A task for index updates.
|
||||||
|
@ -48,162 +29,12 @@ import org.eclipse.core.runtime.IProgressMonitor;
|
||||||
*
|
*
|
||||||
* @since 4.0
|
* @since 4.0
|
||||||
*/
|
*/
|
||||||
public class StandaloneFastIndexerTask extends StandaloneIndexerTask implements CallbackHandler {
|
public class StandaloneFastIndexerTask extends StandaloneIndexerTask {
|
||||||
private List fChanged = new ArrayList();
|
public StandaloneFastIndexerTask(StandaloneFastIndexer indexer, List added, List changed, List removed) {
|
||||||
private List fRemoved = new ArrayList();
|
super(indexer, added, changed, removed, true);
|
||||||
private IWritableIndex fIndex;
|
|
||||||
private StandaloneIndexBasedCodeReaderFactory fCodeReaderFactory;
|
|
||||||
private Map fIflCache;
|
|
||||||
private int fCurrentConfigHash= 0;
|
|
||||||
|
|
||||||
public StandaloneFastIndexerTask(StandaloneFastIndexer indexer, List added,
|
|
||||||
List changed, List removed) {
|
|
||||||
super(indexer);
|
|
||||||
fChanged.addAll(added);
|
|
||||||
fChanged.addAll(changed);
|
|
||||||
fRemoved.addAll(removed);
|
|
||||||
updateInfo(0, 0, fChanged.size() + fRemoved.size());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void run(IProgressMonitor monitor) throws IOException{
|
protected ICodeReaderFactory createReaderFactory() {
|
||||||
long start = System.currentTimeMillis();
|
return new StandaloneIndexerFallbackReaderFactory();
|
||||||
try {
|
|
||||||
setupIndexAndReaderFactory();
|
|
||||||
fIndex.acquireReadLock();
|
|
||||||
try {
|
|
||||||
registerTUsInReaderFactory(fChanged);
|
|
||||||
|
|
||||||
Iterator i= fRemoved.iterator();
|
|
||||||
while (i.hasNext()) {
|
|
||||||
if (monitor.isCanceled())
|
|
||||||
return;
|
|
||||||
String tu = (String) i.next();
|
|
||||||
removeTU(fIndex, getIndexFileLocation(tu), 1);
|
|
||||||
if (isValidSourceUnitName(tu)) {
|
|
||||||
updateInfo(1, 0, 0);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
updateInfo(0, 1, -1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// separate headers
|
|
||||||
List headers= new ArrayList();
|
|
||||||
List sources= fChanged;
|
|
||||||
for (Iterator iter = fChanged.iterator(); iter.hasNext();) {
|
|
||||||
String tu = (String) iter.next();
|
|
||||||
if (!isValidSourceUnitName(tu)) {
|
|
||||||
headers.add(tu);
|
|
||||||
iter.remove();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
parseTUs(fIndex, 1, sources, headers, monitor);
|
|
||||||
if (monitor.isCanceled()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
finally {
|
|
||||||
fIndex.releaseReadLock();
|
|
||||||
}
|
|
||||||
} catch (CoreException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
} catch (InterruptedException e) {
|
|
||||||
}
|
|
||||||
traceEnd(start);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setupIndexAndReaderFactory() throws CoreException {
|
|
||||||
fIndex= fIndexer.getIndex();
|
|
||||||
fIndex.resetCacheCounters();
|
|
||||||
fIflCache = new HashMap/*<String,IIndexFileLocation>*/();
|
|
||||||
fCodeReaderFactory = new StandaloneIndexBasedCodeReaderFactory(fIndex, fIflCache);
|
|
||||||
fCodeReaderFactory.setCallbackHandler(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void registerTUsInReaderFactory(Collection files) throws IOException, CoreException {
|
|
||||||
int removed= 0;
|
|
||||||
for (Iterator iter = files.iterator(); iter.hasNext();) {
|
|
||||||
String sourcePath = (String) iter.next();
|
|
||||||
String path = new File(sourcePath).getCanonicalPath();
|
|
||||||
IIndexFileLocation location = getIndexFileLocation(path);
|
|
||||||
IndexFileInfo info= fCodeReaderFactory.createFileInfo(location);
|
|
||||||
if (updateAll()) {
|
|
||||||
info.fRequested= IndexFileInfo.REQUESTED;
|
|
||||||
}
|
|
||||||
else if (updateChangedTimestamps() && isOutdated(location, info.fFile)) {
|
|
||||||
info.fRequested= IndexFileInfo.REQUESTED;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
iter.remove();
|
|
||||||
removed++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
updateInfo(0, 0, -removed);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
protected IIndexFileLocation findLocation(String absolutePath) {
|
|
||||||
IIndexFileLocation result = (IIndexFileLocation) fIflCache.get(absolutePath);
|
|
||||||
if(result==null) {
|
|
||||||
//Standalone indexing stores the absolute paths of files being indexed
|
|
||||||
result = new IndexFileLocation(URIUtil.toURI(absolutePath),absolutePath);
|
|
||||||
fIflCache.put(absolutePath, result);
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected IASTTranslationUnit createAST(AbstractLanguage lang, CodeReader codeReader, IScannerInfo scanInfo, int options, IProgressMonitor pm) throws CoreException {
|
|
||||||
|
|
||||||
// get the AST in a "Fast" way
|
|
||||||
IASTTranslationUnit ast= lang.getASTTranslationUnit(codeReader, scanInfo, fCodeReaderFactory, fIndex, options, fIndexer.getParserLog());
|
|
||||||
if (pm.isCanceled()) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
// Clear the macros
|
|
||||||
fCodeReaderFactory.clearMacroAttachements();
|
|
||||||
return ast;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected boolean needToUpdate(IIndexFileLocation location, int confighash) throws CoreException {
|
|
||||||
if (super.needToUpdate(location, confighash)) {
|
|
||||||
// file is requested or is not yet indexed.
|
|
||||||
IndexFileInfo info= fCodeReaderFactory.createFileInfo(location);
|
|
||||||
return needToUpdate(info, confighash);
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean needToUpdate(IndexFileInfo info) throws CoreException {
|
|
||||||
return needToUpdate(info, fCurrentConfigHash);
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean needToUpdate(IndexFileInfo info, int confighash) throws CoreException {
|
|
||||||
if (info.fFile == null) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (confighash != 0 && info.fRequested == IndexFileInfo.REQUESTED_IF_CONFIG_CHANGED) {
|
|
||||||
int oldhash= info.fFile.getScannerConfigurationHashcode();
|
|
||||||
if (oldhash == 0 || oldhash==confighash) {
|
|
||||||
info.fRequested= IndexFileInfo.NOT_REQUESTED;
|
|
||||||
updateInfo(0, 0, -1);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
info.fRequested= IndexFileInfo.REQUESTED;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return info.fRequested != IndexFileInfo.NOT_REQUESTED;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
protected boolean postAddToIndex(IIndexFileLocation path, IIndexFile file)
|
|
||||||
throws CoreException {
|
|
||||||
IndexFileInfo info= fCodeReaderFactory.createFileInfo(path);
|
|
||||||
info.fFile= file;
|
|
||||||
if (info.fRequested != IndexFileInfo.NOT_REQUESTED) {
|
|
||||||
info.fRequested= IndexFileInfo.NOT_REQUESTED;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,26 +13,9 @@
|
||||||
|
|
||||||
package org.eclipse.cdt.internal.core.indexer;
|
package org.eclipse.cdt.internal.core.indexer;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
import org.eclipse.cdt.core.dom.ICodeReaderFactory;
|
||||||
import org.eclipse.cdt.core.index.IIndexFile;
|
|
||||||
import org.eclipse.cdt.core.index.IIndexFileLocation;
|
|
||||||
import org.eclipse.cdt.core.model.AbstractLanguage;
|
|
||||||
import org.eclipse.cdt.core.parser.CodeReader;
|
|
||||||
import org.eclipse.cdt.core.parser.IScannerInfo;
|
|
||||||
import org.eclipse.cdt.internal.core.index.IWritableIndex;
|
|
||||||
import org.eclipse.cdt.internal.core.index.IndexFileLocation;
|
|
||||||
import org.eclipse.core.filesystem.URIUtil;
|
|
||||||
import org.eclipse.core.runtime.CoreException;
|
|
||||||
import org.eclipse.core.runtime.IProgressMonitor;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A task for index updates.
|
* A task for index updates.
|
||||||
|
@ -47,133 +30,12 @@ import org.eclipse.core.runtime.IProgressMonitor;
|
||||||
* @since 4.0
|
* @since 4.0
|
||||||
*/
|
*/
|
||||||
public class StandaloneFullIndexerTask extends StandaloneIndexerTask {
|
public class StandaloneFullIndexerTask extends StandaloneIndexerTask {
|
||||||
private final static Object REQUIRED= new Object();
|
|
||||||
private final static Object MISSING = new Object();
|
|
||||||
private final static Object SKIP= new Object();
|
|
||||||
|
|
||||||
private List fChanged = new ArrayList();
|
|
||||||
private List fRemoved = new ArrayList();
|
|
||||||
private IWritableIndex fIndex = null;
|
|
||||||
private Map filePathsToParse = new HashMap/*<IIndexFileLocation, Object>*/();
|
|
||||||
private Map fIflCache = new HashMap/*<String, IIndexFileLocation>*/();
|
|
||||||
|
|
||||||
public StandaloneFullIndexerTask(StandaloneFullIndexer indexer, List added,
|
public StandaloneFullIndexerTask(StandaloneFullIndexer indexer, List added,
|
||||||
List changed, List removed) {
|
List changed, List removed) {
|
||||||
super(indexer);
|
super(indexer, added, changed, removed, false);
|
||||||
fChanged.addAll(added);
|
|
||||||
fChanged.addAll(changed);
|
|
||||||
fRemoved.addAll(removed);
|
|
||||||
updateInfo(0, 0, fChanged.size() + fRemoved.size());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void run(IProgressMonitor monitor) throws IOException {
|
protected ICodeReaderFactory createReaderFactory() {
|
||||||
long start = System.currentTimeMillis();
|
return ((StandaloneFullIndexer)fIndexer).getCodeReaderFactory();
|
||||||
try {
|
|
||||||
setupIndex();
|
|
||||||
registerTUsInReaderFactory(fChanged);
|
|
||||||
|
|
||||||
// separate headers
|
|
||||||
List headers= new ArrayList();
|
|
||||||
List sources= fChanged;
|
|
||||||
for (Iterator iter = fChanged.iterator(); iter.hasNext();) {
|
|
||||||
String tu = (String) iter.next();
|
|
||||||
if (!isValidSourceUnitName(tu)) {
|
|
||||||
headers.add(tu);
|
|
||||||
iter.remove();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Iterator i= fRemoved.iterator();
|
|
||||||
while (i.hasNext()) {
|
|
||||||
if (monitor.isCanceled())
|
|
||||||
return;
|
|
||||||
String tu = (String) i.next();
|
|
||||||
removeTU(fIndex, getIndexFileLocation(tu), 0);
|
|
||||||
if (isValidSourceUnitName(tu)) {
|
|
||||||
updateInfo(1, 0, 0);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
updateInfo(0, 1, -1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fIndex.acquireReadLock();
|
|
||||||
try {
|
|
||||||
parseTUs(fIndex, 1, sources, headers, monitor);
|
|
||||||
}
|
|
||||||
finally {
|
|
||||||
fIndex.releaseReadLock();
|
|
||||||
}
|
|
||||||
} catch (CoreException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
} catch (InterruptedException e) {
|
|
||||||
}
|
|
||||||
traceEnd(start);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setupIndex() throws CoreException {
|
|
||||||
fIndex = fIndexer.getIndex();
|
|
||||||
fIndex.resetCacheCounters();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void registerTUsInReaderFactory(Collection/*<ITranslationUnit>*/ sources)
|
|
||||||
throws IOException, CoreException {
|
|
||||||
int removed= 0;
|
|
||||||
filePathsToParse= new HashMap/*<IIndexFileLocation, Object>*/();
|
|
||||||
for (Iterator iter = sources.iterator(); iter.hasNext();) {
|
|
||||||
String sourcePath = (String) iter.next();
|
|
||||||
String path = new File(sourcePath).getCanonicalPath();
|
|
||||||
IIndexFileLocation location = getIndexFileLocation(path);
|
|
||||||
if (updateAll()) {
|
|
||||||
filePathsToParse.put(location, REQUIRED);
|
|
||||||
}
|
|
||||||
else if (updateChangedTimestamps() && isOutdated(location, fIndex.getFile(location))) {
|
|
||||||
filePathsToParse.put(location, REQUIRED);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
iter.remove();
|
|
||||||
removed++;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
updateInfo(0, 0, -removed);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected IIndexFileLocation findLocation(String absolutePath) {
|
|
||||||
IIndexFileLocation result = (IIndexFileLocation) fIflCache.get(absolutePath);
|
|
||||||
if(result==null) {
|
|
||||||
//Standalone indexing stores the absolute paths of files being indexed
|
|
||||||
result = new IndexFileLocation(URIUtil.toURI(absolutePath),absolutePath);
|
|
||||||
fIflCache.put(absolutePath, result);
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected IASTTranslationUnit createAST(AbstractLanguage lang, CodeReader codeReader, IScannerInfo scanInfo, int options, IProgressMonitor pm) throws CoreException {
|
|
||||||
// get the AST in a "Fast" way
|
|
||||||
IASTTranslationUnit ast= lang.getASTTranslationUnit(codeReader, scanInfo, ((StandaloneFullIndexer)fIndexer).getCodeReaderFactory(), null, options, fIndexer.getParserLog());
|
|
||||||
if (pm.isCanceled()) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return ast;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected boolean needToUpdate(IIndexFileLocation location, int confighash) throws CoreException {
|
|
||||||
if (super.needToUpdate(location, confighash)) {
|
|
||||||
Object required= filePathsToParse.get(location);
|
|
||||||
if (required == null) {
|
|
||||||
required= MISSING;
|
|
||||||
filePathsToParse.put(location, required);
|
|
||||||
}
|
|
||||||
return required != SKIP;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected boolean postAddToIndex(IIndexFileLocation location, IIndexFile file)
|
|
||||||
throws CoreException {
|
|
||||||
Object required= filePathsToParse.get(location);
|
|
||||||
filePathsToParse.put(location, SKIP);
|
|
||||||
return required == REQUIRED;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,96 +0,0 @@
|
||||||
/*******************************************************************************
|
|
||||||
* Copyright (c) 2007 IBM Corporation 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:
|
|
||||||
* IBM - Initial API and implementation
|
|
||||||
*******************************************************************************/
|
|
||||||
|
|
||||||
package org.eclipse.cdt.internal.core.indexer;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import org.eclipse.cdt.core.dom.ICodeReaderFactory;
|
|
||||||
import org.eclipse.cdt.core.dom.IMacroCollector;
|
|
||||||
import org.eclipse.cdt.core.index.IIndex;
|
|
||||||
import org.eclipse.cdt.core.index.IIndexFileLocation;
|
|
||||||
import org.eclipse.cdt.core.parser.CodeReader;
|
|
||||||
import org.eclipse.cdt.core.parser.ICodeReaderCache;
|
|
||||||
import org.eclipse.cdt.internal.core.index.IndexBasedCodeReaderFactory;
|
|
||||||
import org.eclipse.cdt.internal.core.index.IndexFileLocation;
|
|
||||||
import org.eclipse.core.filesystem.URIUtil;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A factory for CodeReaders construction.
|
|
||||||
*
|
|
||||||
* <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 class StandaloneIndexBasedCodeReaderFactory extends IndexBasedCodeReaderFactory {
|
|
||||||
|
|
||||||
public static class DefaultFallBackFactory implements ICodeReaderFactory {
|
|
||||||
|
|
||||||
public CodeReader createCodeReaderForInclusion(IMacroCollector callback, String path) {
|
|
||||||
try {
|
|
||||||
if (!new File(path).exists())
|
|
||||||
return null;
|
|
||||||
return new CodeReader(path);
|
|
||||||
} catch (IOException e) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public CodeReader createCodeReaderForTranslationUnit(String path) {
|
|
||||||
try {
|
|
||||||
if (!new File(path).exists())
|
|
||||||
return null;
|
|
||||||
return new CodeReader(path);
|
|
||||||
} catch (IOException e) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public ICodeReaderCache getCodeReaderCache() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getUniqueIdentifier() {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public StandaloneIndexBasedCodeReaderFactory(IIndex index) {
|
|
||||||
super(null, index);
|
|
||||||
}
|
|
||||||
|
|
||||||
public StandaloneIndexBasedCodeReaderFactory(IIndex index, ICodeReaderFactory fallbackFactory) {
|
|
||||||
super(null, index, new HashMap/*<String,IIndexFileLocation>*/(), fallbackFactory);
|
|
||||||
}
|
|
||||||
|
|
||||||
public StandaloneIndexBasedCodeReaderFactory(IIndex index, Map iflCache) {
|
|
||||||
super(null, index, iflCache, new DefaultFallBackFactory());
|
|
||||||
}
|
|
||||||
|
|
||||||
public IIndexFileLocation findLocation(String absolutePath) {
|
|
||||||
IIndexFileLocation result = (IIndexFileLocation) getIFLCache().get(absolutePath);
|
|
||||||
if(result==null) {
|
|
||||||
//Standalone indexing stores the absolute paths of files being indexed
|
|
||||||
result = new IndexFileLocation(URIUtil.toURI(absolutePath),absolutePath);
|
|
||||||
getIFLCache().put(absolutePath, result);
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -306,15 +306,13 @@ public abstract class StandaloneIndexer {
|
||||||
fDelegate= createTask(getFilesAdded(tus), NO_TUS, NO_TUS);
|
fDelegate= createTask(getFilesAdded(tus), NO_TUS, NO_TUS);
|
||||||
fDelegate.setUpdateFlags(fUpdateOptions);
|
fDelegate.setUpdateFlags(fUpdateOptions);
|
||||||
|
|
||||||
|
if (fDelegate != null) {
|
||||||
|
fDelegate.run(monitor);
|
||||||
|
}
|
||||||
} catch (CoreException e) {
|
} catch (CoreException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fDelegate != null) {
|
|
||||||
fDelegate.run(monitor);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -329,12 +327,12 @@ public abstract class StandaloneIndexer {
|
||||||
fProgress= new IndexerProgress();
|
fProgress= new IndexerProgress();
|
||||||
|
|
||||||
fDelegate= createTask(getFilesAdded(added), changed, removed);
|
fDelegate= createTask(getFilesAdded(added), changed, removed);
|
||||||
if (fDelegate instanceof StandaloneIndexerTask) {
|
|
||||||
fDelegate.setUpdateFlags(fUpdateOptions);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (fDelegate != null) {
|
if (fDelegate != null) {
|
||||||
fDelegate.run(monitor);
|
try {
|
||||||
|
fDelegate.setUpdateFlags(fUpdateOptions);
|
||||||
|
fDelegate.run(monitor);
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -360,7 +358,7 @@ public abstract class StandaloneIndexer {
|
||||||
if (file.isDirectory()) {
|
if (file.isDirectory()) {
|
||||||
String[] files = file.list(filter);
|
String[] files = file.list(filter);
|
||||||
for (int i = 0; i < files.length; i++) {
|
for (int i = 0; i < files.length; i++) {
|
||||||
added.add((String)files[i]);
|
added.add(files[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
|
@ -0,0 +1,63 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2007 IBM Corporation 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:
|
||||||
|
* IBM - Initial API and implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
|
||||||
|
package org.eclipse.cdt.internal.core.indexer;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.dom.ICodeReaderFactory;
|
||||||
|
import org.eclipse.cdt.core.dom.IMacroCollector;
|
||||||
|
import org.eclipse.cdt.core.parser.CodeReader;
|
||||||
|
import org.eclipse.cdt.core.parser.ICodeReaderCache;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A factory for CodeReaders construction.
|
||||||
|
*
|
||||||
|
* <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 class StandaloneIndexerFallbackReaderFactory implements ICodeReaderFactory {
|
||||||
|
|
||||||
|
public CodeReader createCodeReaderForInclusion(IMacroCollector callback, String path) {
|
||||||
|
try {
|
||||||
|
if (!new File(path).exists())
|
||||||
|
return null;
|
||||||
|
return new CodeReader(path);
|
||||||
|
} catch (IOException e) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public CodeReader createCodeReaderForTranslationUnit(String path) {
|
||||||
|
try {
|
||||||
|
if (!new File(path).exists())
|
||||||
|
return null;
|
||||||
|
return new CodeReader(path);
|
||||||
|
} catch (IOException e) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public ICodeReaderCache getCodeReaderCache() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getUniqueIdentifier() {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,129 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2007 Wind River Systems, Inc. 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:
|
||||||
|
* Markus Schorn - initial API and implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.cdt.internal.core.indexer;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.HashMap;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.index.IIndexFileLocation;
|
||||||
|
import org.eclipse.cdt.core.model.AbstractLanguage;
|
||||||
|
import org.eclipse.cdt.core.model.ILanguage;
|
||||||
|
import org.eclipse.cdt.core.parser.CodeReader;
|
||||||
|
import org.eclipse.cdt.core.parser.IScannerInfo;
|
||||||
|
import org.eclipse.cdt.internal.core.index.IndexFileLocation;
|
||||||
|
import org.eclipse.cdt.internal.core.pdom.IndexerInputAdapter;
|
||||||
|
import org.eclipse.core.filesystem.URIUtil;
|
||||||
|
import org.eclipse.core.runtime.IPath;
|
||||||
|
import org.eclipse.core.runtime.Path;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provides information about the file paths represented as strings.
|
||||||
|
* @since 5.0
|
||||||
|
*/
|
||||||
|
public class StandaloneIndexerInputAdapter extends IndexerInputAdapter {
|
||||||
|
private HashMap fIflCache= new HashMap();
|
||||||
|
|
||||||
|
private final StandaloneIndexer fIndexer;
|
||||||
|
|
||||||
|
public StandaloneIndexerInputAdapter(StandaloneIndexer indexer) {
|
||||||
|
fIndexer= indexer;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IScannerInfo getBuildConfiguration(int linkageID, Object tu) {
|
||||||
|
return fIndexer.getScannerInfo();
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getLastModified(IIndexFileLocation location) {
|
||||||
|
return new File(location.getFullPath()).lastModified();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isSourceUnit(Object tu) {
|
||||||
|
return isValidSourceUnitName((String) tu);
|
||||||
|
}
|
||||||
|
|
||||||
|
public IIndexFileLocation resolveFile(Object tu) {
|
||||||
|
return resolveASTPath((String) tu);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getASTPath(IIndexFileLocation ifl) {
|
||||||
|
return ifl.getFullPath();
|
||||||
|
}
|
||||||
|
|
||||||
|
public IIndexFileLocation resolveASTPath(String astPath) {
|
||||||
|
IIndexFileLocation result= (IIndexFileLocation) fIflCache.get(astPath);
|
||||||
|
if (result == null) {
|
||||||
|
try {
|
||||||
|
astPath = new File(astPath).getCanonicalPath();
|
||||||
|
} catch (IOException e) {
|
||||||
|
// use the original
|
||||||
|
}
|
||||||
|
//Standalone indexing stores the absolute paths of files being indexed
|
||||||
|
result = new IndexFileLocation(URIUtil.toURI(astPath),astPath);
|
||||||
|
fIflCache.put(astPath, result);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IIndexFileLocation resolveIncludeFile(String includePath) {
|
||||||
|
IIndexFileLocation result= (IIndexFileLocation) fIflCache.get(includePath);
|
||||||
|
if (result == null) {
|
||||||
|
File file= new File(includePath);
|
||||||
|
if (!file.exists()) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
includePath = file.getCanonicalPath();
|
||||||
|
} catch (IOException e) {
|
||||||
|
// use the original
|
||||||
|
}
|
||||||
|
//Standalone indexing stores the absolute paths of files being indexed
|
||||||
|
result = new IndexFileLocation(URIUtil.toURI(includePath),includePath);
|
||||||
|
fIflCache.put(includePath, result);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isFileBuildConfigured(Object tu) {
|
||||||
|
return isValidSourceUnitName((String) tu);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean canBePartOfSDK(IIndexFileLocation ifl) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CodeReader getCodeReader(Object tu) {
|
||||||
|
try {
|
||||||
|
return new CodeReader((String) tu);
|
||||||
|
} catch (IOException e) {
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Object getInputFile(IIndexFileLocation location) {
|
||||||
|
return location.getFullPath();
|
||||||
|
}
|
||||||
|
|
||||||
|
public AbstractLanguage[] getLanguages(Object tu) {
|
||||||
|
ILanguage language = fIndexer.getLanguageMapper().getLanguage((String) tu);
|
||||||
|
if (language instanceof AbstractLanguage) {
|
||||||
|
return new AbstractLanguage[] {(AbstractLanguage) language};
|
||||||
|
}
|
||||||
|
return new AbstractLanguage[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean isValidSourceUnitName(String file) {
|
||||||
|
IPath path = new Path(file);
|
||||||
|
if (fIndexer.getValidSourceUnitNames() == null || fIndexer.getValidSourceUnitNames().size() == 0)
|
||||||
|
return true;
|
||||||
|
return fIndexer.getValidSourceUnitNames().contains(path.getFileExtension());
|
||||||
|
}
|
||||||
|
}
|
|
@ -12,38 +12,16 @@
|
||||||
|
|
||||||
package org.eclipse.cdt.internal.core.indexer;
|
package org.eclipse.cdt.internal.core.indexer;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.net.URI;
|
|
||||||
import java.text.NumberFormat;
|
import java.text.NumberFormat;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import org.eclipse.cdt.core.CCorePlugin;
|
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
|
||||||
import org.eclipse.cdt.core.index.IIndex;
|
|
||||||
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.model.AbstractLanguage;
|
import org.eclipse.cdt.core.model.AbstractLanguage;
|
||||||
import org.eclipse.cdt.core.model.ILanguage;
|
import org.eclipse.cdt.core.model.ILanguage;
|
||||||
import org.eclipse.cdt.core.parser.CodeReader;
|
|
||||||
import org.eclipse.cdt.core.parser.IExtendedScannerInfo;
|
|
||||||
import org.eclipse.cdt.core.parser.IScannerInfo;
|
|
||||||
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.cdt.internal.core.index.IndexFileLocation;
|
import org.eclipse.cdt.internal.core.pdom.AbstractIndexerTask;
|
||||||
import org.eclipse.cdt.internal.core.pdom.IndexerProgress;
|
import org.eclipse.cdt.internal.core.pdom.IndexerProgress;
|
||||||
import org.eclipse.cdt.internal.core.pdom.PDOMWriter;
|
|
||||||
import org.eclipse.core.filesystem.URIUtil;
|
|
||||||
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.Path;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A task for index updates.
|
* A task for index updates.
|
||||||
|
@ -57,23 +35,39 @@ import org.eclipse.core.runtime.Path;
|
||||||
*
|
*
|
||||||
* @since 4.0
|
* @since 4.0
|
||||||
*/
|
*/
|
||||||
public abstract class StandaloneIndexerTask extends PDOMWriter{
|
public abstract class StandaloneIndexerTask extends AbstractIndexerTask {
|
||||||
private static final Object NO_CONTEXT = new Object();
|
|
||||||
|
|
||||||
protected StandaloneIndexer fIndexer;
|
protected StandaloneIndexer fIndexer;
|
||||||
protected Map/*<IIndexFileLocation, Object>*/ fContextMap = new HashMap/*<IIndexFileLocation, Object>*/();
|
|
||||||
private List fFilesUpFront= new ArrayList();
|
|
||||||
private String fDummyFileName;
|
|
||||||
private URI fDummyFileURI;
|
|
||||||
private int fUpdateFlags= StandaloneIndexer.UPDATE_ALL;
|
|
||||||
|
|
||||||
protected StandaloneIndexerTask(StandaloneIndexer indexer) {
|
protected StandaloneIndexerTask(StandaloneIndexer indexer, Collection added, Collection changed, Collection removed, boolean isFast) {
|
||||||
|
super(concat(added, changed), removed.toArray(), new StandaloneIndexerInputAdapter(indexer), isFast);
|
||||||
fIndexer= indexer;
|
fIndexer= indexer;
|
||||||
setShowActivity(fIndexer.getShowActivity());
|
setShowActivity(fIndexer.getShowActivity());
|
||||||
setShowProblems(fIndexer.getShowProblems());
|
setShowProblems(fIndexer.getShowProblems());
|
||||||
setSkipReferences(fIndexer.getSkipReferences());
|
setSkipReferences(fIndexer.getSkipReferences());
|
||||||
|
|
||||||
|
if (getIndexAllFiles()) {
|
||||||
|
setIndexFilesWithoutBuildConfiguration(true);
|
||||||
|
setIndexHeadersWithoutContext(true);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
setIndexFilesWithoutBuildConfiguration(false);
|
||||||
|
setIndexHeadersWithoutContext(false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static Object[] concat(Collection added, Collection changed) {
|
||||||
|
Object[] result= new Object[added.size() + changed.size()];
|
||||||
|
int i=0;
|
||||||
|
for (Iterator iterator = added.iterator(); iterator.hasNext();) {
|
||||||
|
result[i++]= iterator.next();
|
||||||
|
}
|
||||||
|
for (Iterator iterator = changed.iterator(); iterator.hasNext();) {
|
||||||
|
result[i++]= iterator.next();
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the indexer.
|
* Return the indexer.
|
||||||
* @return
|
* @return
|
||||||
|
@ -88,294 +82,41 @@ public abstract class StandaloneIndexerTask extends PDOMWriter{
|
||||||
final public IndexerProgress getProgressInformation() {
|
final public IndexerProgress getProgressInformation() {
|
||||||
return super.getProgressInformation();
|
return super.getProgressInformation();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setUpdateFlags(int flags) {
|
|
||||||
fUpdateFlags= flags;
|
|
||||||
}
|
|
||||||
|
|
||||||
final public boolean updateAll() {
|
|
||||||
return (fUpdateFlags & StandaloneIndexer.UPDATE_ALL) != 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
final public boolean updateChangedTimestamps() {
|
|
||||||
return (fUpdateFlags & StandaloneIndexer.UPDATE_CHECK_TIMESTAMPS) != 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tells the parser which files to parse first
|
* Tells the parser which files to parse first
|
||||||
*/
|
*/
|
||||||
final public void setParseUpFront() {
|
final public void setParseUpFront() {
|
||||||
String[] files = fIndexer.getFilesToParseUpFront();
|
setParseUpFront(fIndexer.getFilesToParseUpFront());
|
||||||
for (int i = 0; i < files.length; i++) {
|
|
||||||
fFilesUpFront.add((String) files[i]);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Figurues out whether all files (sources without config, headers not included)
|
* Figures out whether all files (sources without config, headers not included)
|
||||||
* should be parsed.
|
* should be parsed.
|
||||||
* @since 4.0
|
* @since 4.0
|
||||||
*/
|
*/
|
||||||
final protected boolean getIndexAllFiles() {
|
final protected boolean getIndexAllFiles() {
|
||||||
return getIndexer().getIndexAllFiles();
|
return getIndexer().getIndexAllFiles();
|
||||||
}
|
}
|
||||||
|
|
||||||
private IASTTranslationUnit createAST(IIndexFileLocation location, IScannerInfo scannerInfo, int options, IProgressMonitor pm) throws IOException, CoreException {
|
final protected AbstractLanguage[] getLanguages(String filename) {
|
||||||
String path = location.getFullPath();
|
ILanguage l = fIndexer.getLanguageMapper().getLanguage(filename);
|
||||||
if (path == null) {
|
if (l instanceof AbstractLanguage) {
|
||||||
return null;
|
return new AbstractLanguage[] {(AbstractLanguage) l};
|
||||||
}
|
|
||||||
ILanguage language = fIndexer.getLanguageMapper().getLanguage(path);
|
|
||||||
if (language == null)
|
|
||||||
return null;
|
|
||||||
|
|
||||||
CodeReader codeReader = new CodeReader(path);
|
|
||||||
if (codeReader == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return createAST((AbstractLanguage)language, codeReader, scannerInfo, options, pm);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Called to create the ast for a translation unit or a pre-parsed file.
|
|
||||||
* May return <code>null</code>.
|
|
||||||
* @see #parseTUs(IWritableIndex, int, Collection, Collection, IProgressMonitor)
|
|
||||||
* @since 4.0
|
|
||||||
*/
|
|
||||||
abstract protected IASTTranslationUnit createAST(AbstractLanguage lang, CodeReader codeReader, IScannerInfo scanInfo, int options, IProgressMonitor pm) throws CoreException;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Convenience method for subclasses, parses the files calling out to the methods
|
|
||||||
* {@link #createAST(IIndexFileLocation, IProgressMonitor)},
|
|
||||||
* {@link #needToUpdate(IIndexFileLocation)},
|
|
||||||
* {@link #addSymbols(IASTTranslationUnit, IWritableIndex, int, IProgressMonitor)}
|
|
||||||
* {@link #postAddToIndex(IIndexFileLocation, IIndexFile)} and
|
|
||||||
* {@link #findLocation(String)}
|
|
||||||
* @since 4.0
|
|
||||||
*/
|
|
||||||
protected void parseTUs(IWritableIndex index, int readlockCount, Collection sources, Collection headers, IProgressMonitor monitor) throws IOException, CoreException, InterruptedException {
|
|
||||||
int options= 0;
|
|
||||||
if (fIndexer.getSkipReferences() == StandaloneIndexer.SKIP_ALL_REFERENCES) {
|
|
||||||
options |= AbstractLanguage.OPTION_SKIP_FUNCTION_BODIES;
|
|
||||||
}
|
|
||||||
for (Iterator iter = fFilesUpFront.iterator(); iter.hasNext();) {
|
|
||||||
String upfront= (String) iter.next();
|
|
||||||
parseUpFront(upfront, options, index, readlockCount, monitor);
|
|
||||||
}
|
|
||||||
|
|
||||||
// sources first
|
|
||||||
for (Iterator iter = sources.iterator(); iter.hasNext();) {
|
|
||||||
if (monitor.isCanceled())
|
|
||||||
return;
|
|
||||||
String sourcePath = (String) iter.next();
|
|
||||||
String path = new File(sourcePath).getCanonicalPath();
|
|
||||||
final IIndexFileLocation ifl = getIndexFileLocation(path);
|
|
||||||
|
|
||||||
if (needToUpdate(ifl, 0)) {
|
|
||||||
parseTU(ifl, options, index, readlockCount, monitor);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// headers with context
|
|
||||||
for (Iterator iter = headers.iterator(); iter.hasNext();) {
|
|
||||||
if (monitor.isCanceled())
|
|
||||||
return;
|
|
||||||
String sourcePath = (String) iter.next();
|
|
||||||
String path = new File(sourcePath).getCanonicalPath();
|
|
||||||
final IIndexFileLocation location = getIndexFileLocation(path);
|
|
||||||
|
|
||||||
if (!needToUpdate(location, 0)) {
|
|
||||||
iter.remove();
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
IIndexFileLocation context= findContext(index, location);
|
|
||||||
if (context != null) {
|
|
||||||
parseTU(context, options, index, readlockCount, monitor);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// headers without context
|
|
||||||
if (getIndexAllFiles()) {
|
|
||||||
for (Iterator iter = headers.iterator(); iter.hasNext();) {
|
|
||||||
if (monitor.isCanceled())
|
|
||||||
return;
|
|
||||||
|
|
||||||
String sourcePath = (String) iter.next();
|
|
||||||
String path = new File(sourcePath).getCanonicalPath();
|
|
||||||
final IIndexFileLocation ifl = getIndexFileLocation(path);
|
|
||||||
|
|
||||||
if (!needToUpdate(ifl, 0)) {
|
|
||||||
iter.remove();
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
parseTU(ifl, options, index, readlockCount, monitor);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
return new AbstractLanguage[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
final protected boolean isOutdated(IIndexFileLocation ifl, IIndexFile indexFile) throws CoreException {
|
protected final IWritableIndex createIndex() {
|
||||||
if (indexFile == null) {
|
return fIndexer.getIndex();
|
||||||
return true;
|
|
||||||
}
|
|
||||||
File res = new File(ifl.getFullPath());
|
|
||||||
if (res != null) {
|
|
||||||
if (indexFile != null) {
|
|
||||||
if (res.lastModified() == indexFile.getTimestamp()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void parseTU(IIndexFileLocation location, int options, IWritableIndex index, int readlockCount, IProgressMonitor pm) throws IOException, CoreException, InterruptedException {
|
|
||||||
String path = location.getFullPath();
|
|
||||||
|
|
||||||
try {
|
|
||||||
// skip if no scanner info
|
|
||||||
IScannerInfo scanner= fIndexer.getScannerInfo();
|
|
||||||
if (scanner == null) {
|
|
||||||
updateInfo(0, 0, -1);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
final int configHash = computeHashCode(scanner);
|
|
||||||
if (needToUpdate(location, configHash)) {
|
|
||||||
if (fShowActivity) {
|
|
||||||
System.out.println("Indexer: parsing " + path); //$NON-NLS-1$
|
|
||||||
}
|
|
||||||
long start= System.currentTimeMillis();
|
|
||||||
IASTTranslationUnit ast= createAST(location, scanner, options, pm);
|
|
||||||
fStatistics.fParsingTime += System.currentTimeMillis()-start;
|
|
||||||
if (ast != null) {
|
|
||||||
addSymbols(ast, index, readlockCount, configHash, pm);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (CoreException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
catch (RuntimeException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
catch (Error e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void parseUpFront(String file, int options, IWritableIndex index, int readlockCount, IProgressMonitor pm) throws CoreException, InterruptedException {
|
public final void run(IProgressMonitor monitor) throws InterruptedException {
|
||||||
file= file.trim();
|
long start = System.currentTimeMillis();
|
||||||
if (file.length() == 0) {
|
runTask(monitor);
|
||||||
return;
|
traceEnd(start);
|
||||||
}
|
|
||||||
try {
|
|
||||||
if (fShowActivity) {
|
|
||||||
System.out.println("Indexer: parsing " + file + " up front"); //$NON-NLS-1$ //$NON-NLS-2$
|
|
||||||
}
|
|
||||||
|
|
||||||
long start= System.currentTimeMillis();
|
|
||||||
|
|
||||||
IASTTranslationUnit ast= null;
|
|
||||||
ILanguage l = fIndexer.getLanguageMapper().getLanguage(file);
|
|
||||||
if (l instanceof AbstractLanguage) {
|
|
||||||
AbstractLanguage lang= (AbstractLanguage) l;
|
|
||||||
IScannerInfo scanInfo = fIndexer.getScannerInfo();
|
|
||||||
String code= "#include \"" + file + "\"\n"; //$NON-NLS-1$ //$NON-NLS-2$
|
|
||||||
if (fDummyFileName == null) {
|
|
||||||
fDummyFileName= file + "___"; //$NON-NLS-1$
|
|
||||||
fDummyFileURI= findLocation(fDummyFileName).getURI();
|
|
||||||
}
|
|
||||||
CodeReader codeReader= new CodeReader(fDummyFileName, code.toCharArray());
|
|
||||||
ast= createAST(lang, codeReader, scanInfo, options, pm);
|
|
||||||
}
|
|
||||||
fStatistics.fParsingTime += System.currentTimeMillis()-start;
|
|
||||||
if (ast != null) {
|
|
||||||
addSymbols(ast, index, readlockCount, 0, pm);
|
|
||||||
updateInfo(-1, +1, 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (CoreException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
catch (RuntimeException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
catch (Error e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Overriders must call super.needToUpdate(). If <code>false</code> is returned
|
|
||||||
* this must be passed on to their caller:
|
|
||||||
* <pre>
|
|
||||||
* if (super.needToUpdate()) {
|
|
||||||
* // your code
|
|
||||||
* }
|
|
||||||
* return false;
|
|
||||||
*/
|
|
||||||
protected boolean needToUpdate(IIndexFileLocation fileLoc, int configHash) throws CoreException {
|
|
||||||
return fDummyFileURI==null || !fDummyFileURI.equals(fileLoc.getURI());
|
|
||||||
}
|
|
||||||
|
|
||||||
private IIndexFileLocation findContext(IIndex index, IIndexFileLocation location) {
|
|
||||||
Object cachedContext= fContextMap.get(location);
|
|
||||||
if (cachedContext != null) {
|
|
||||||
return cachedContext == NO_CONTEXT ? null : (IIndexFileLocation) cachedContext;
|
|
||||||
}
|
|
||||||
IIndexFileLocation context= null;
|
|
||||||
fContextMap.put(location, NO_CONTEXT); // prevent recursion
|
|
||||||
IIndexFile pdomFile;
|
|
||||||
try {
|
|
||||||
pdomFile = index.getFile(location);
|
|
||||||
if (pdomFile != null) {
|
|
||||||
IIndexInclude[] includedBy = index.findIncludedBy(pdomFile, IIndex.DEPTH_ZERO);
|
|
||||||
ArrayList/*<IIndexFileLocation>*/ paths= new ArrayList/*<IIndexFileLocation>*/(includedBy.length);
|
|
||||||
for (int i = 0; i < includedBy.length; i++) {
|
|
||||||
IIndexInclude include = includedBy[i];
|
|
||||||
IIndexFileLocation incLocation = include.getIncludedByLocation();
|
|
||||||
if (isValidSourceUnitName(incLocation.getFullPath())) {
|
|
||||||
context = incLocation;
|
|
||||||
if (context != null) {
|
|
||||||
fContextMap.put(location, context);
|
|
||||||
return context;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
paths.add(incLocation);
|
|
||||||
}
|
|
||||||
for (Iterator/*<IIndexFileLocation>*/ iter = paths.iterator(); iter.hasNext();) {
|
|
||||||
IIndexFileLocation nextLevel = (IIndexFileLocation) iter.next();
|
|
||||||
context = findContext(index, nextLevel);
|
|
||||||
if (context != null) {
|
|
||||||
fContextMap.put(location, context);
|
|
||||||
return context;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (CoreException e) {
|
|
||||||
CCorePlugin.log(e);
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Conveninence method for subclasses, removes a translation unit from the index.
|
|
||||||
* @since 4.0
|
|
||||||
*/
|
|
||||||
protected void removeTU(IWritableIndex index, IIndexFileLocation ifl, int readlocks) throws CoreException, InterruptedException {
|
|
||||||
index.acquireWriteLock(readlocks);
|
|
||||||
try {
|
|
||||||
IIndexFragmentFile file = (IIndexFragmentFile) index.getFile(ifl);
|
|
||||||
if (file != null)
|
|
||||||
index.clearFile(file, null);
|
|
||||||
} finally {
|
|
||||||
index.releaseWriteLock(readlocks);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void traceEnd(long start) {
|
protected void traceEnd(long start) {
|
||||||
|
@ -425,75 +166,4 @@ public abstract class StandaloneIndexerTask extends PDOMWriter{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract void run(IProgressMonitor monitor) throws IOException;
|
|
||||||
|
|
||||||
protected IIndexFileLocation getIndexFileLocation(String path) {
|
|
||||||
String absolutePath = new File(path).getAbsolutePath();
|
|
||||||
//Standalone indexing stores the absolute paths of files being indexed
|
|
||||||
return new IndexFileLocation(URIUtil.toURI(absolutePath),absolutePath);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected boolean isValidSourceUnitName(String filename) {
|
|
||||||
IPath path = new Path(filename);
|
|
||||||
if (fIndexer.getValidSourceUnitNames() == null || fIndexer.getValidSourceUnitNames().size() == 0)
|
|
||||||
return true;
|
|
||||||
return fIndexer.getValidSourceUnitNames().contains(path.getFileExtension());
|
|
||||||
}
|
|
||||||
|
|
||||||
protected long getLastModified(IIndexFileLocation location) {
|
|
||||||
return new File(location.getFullPath()).lastModified();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected static int computeHashCode(IScannerInfo scannerInfo) {
|
|
||||||
int result= 0;
|
|
||||||
Map macros= scannerInfo.getDefinedSymbols();
|
|
||||||
if (macros != null) {
|
|
||||||
for (Iterator i = macros.entrySet().iterator(); i.hasNext();) {
|
|
||||||
Map.Entry entry = (Map.Entry) i.next();
|
|
||||||
String key = (String) entry.getKey();
|
|
||||||
String value = (String) entry.getValue();
|
|
||||||
result= addToHashcode(result, key);
|
|
||||||
if (value != null && value.length() > 0) {
|
|
||||||
result= addToHashcode(result, value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
String[] a= scannerInfo.getIncludePaths();
|
|
||||||
if (a != null) {
|
|
||||||
for (int i = 0; i < a.length; i++) {
|
|
||||||
result= addToHashcode(result, a[i]);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (scannerInfo instanceof IExtendedScannerInfo) {
|
|
||||||
IExtendedScannerInfo esi= (IExtendedScannerInfo) scannerInfo;
|
|
||||||
a= esi.getIncludeFiles();
|
|
||||||
if (a != null) {
|
|
||||||
for (int i = 0; i < a.length; i++) {
|
|
||||||
result= addToHashcode(result, a[i]);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
a= esi.getLocalIncludePath();
|
|
||||||
if (a != null) {
|
|
||||||
for (int i = 0; i < a.length; i++) {
|
|
||||||
result= addToHashcode(result, a[i]);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
a= esi.getMacroFiles();
|
|
||||||
if (a != null) {
|
|
||||||
for (int i = 0; i < a.length; i++) {
|
|
||||||
result= addToHashcode(result, a[i]);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static int addToHashcode(int result, String key) {
|
|
||||||
return result*31 + key.hashCode();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,9 +28,6 @@ class LocationCtxFile extends LocationCtxContainer {
|
||||||
|
|
||||||
public final void addChildSequenceLength(int childLength) {
|
public final void addChildSequenceLength(int childLength) {
|
||||||
super.addChildSequenceLength(childLength);
|
super.addChildSequenceLength(childLength);
|
||||||
if (fASTInclude != null) {
|
|
||||||
fASTInclude.setLength(fASTInclude.getLength()+childLength);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public final String getFilePath() {
|
public final String getFilePath() {
|
||||||
|
|
|
@ -0,0 +1,38 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2007 Wind River Systems, Inc. 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:
|
||||||
|
* Markus Schorn - initial API and implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.cdt.internal.core.pdom;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.index.IIndexFileLocation;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Abstract class for resolving paths as computed by the parser.
|
||||||
|
* @since 5.0
|
||||||
|
*/
|
||||||
|
public abstract class ASTFilePathResolver {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Resolve a path as stored in the AST.
|
||||||
|
* @return an index file location.
|
||||||
|
*/
|
||||||
|
public abstract IIndexFileLocation resolveASTPath(String astFilePath);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Resolve a path for an inclusion as computed by the preprocessor. Check for existance
|
||||||
|
* and return <code>null</code> if the file does not exist.
|
||||||
|
* @return an index file location or <code>null</code> if the file does not exist.
|
||||||
|
*/
|
||||||
|
public abstract IIndexFileLocation resolveIncludeFile(String includePath);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert an index file location to the path as it will be stored in the AST.
|
||||||
|
*/
|
||||||
|
public abstract String getASTPath(IIndexFileLocation ifl);
|
||||||
|
}
|
|
@ -0,0 +1,782 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2007 Wind River Systems, Inc. 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:
|
||||||
|
* Markus Schorn - initial API and implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
|
||||||
|
package org.eclipse.cdt.internal.core.pdom;
|
||||||
|
|
||||||
|
import java.net.URI;
|
||||||
|
import java.text.MessageFormat;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.LinkedList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.CCorePlugin;
|
||||||
|
import org.eclipse.cdt.core.dom.ICodeReaderFactory;
|
||||||
|
import org.eclipse.cdt.core.dom.ILinkage;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTPreprocessorIncludeStatement;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit.IDependencyTree;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit.IDependencyTree.IASTInclusionNode;
|
||||||
|
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.IIndexMacro;
|
||||||
|
import org.eclipse.cdt.core.index.IIndexManager;
|
||||||
|
import org.eclipse.cdt.core.index.IndexLocationFactory;
|
||||||
|
import org.eclipse.cdt.core.model.AbstractLanguage;
|
||||||
|
import org.eclipse.cdt.core.parser.CodeReader;
|
||||||
|
import org.eclipse.cdt.core.parser.IExtendedScannerInfo;
|
||||||
|
import org.eclipse.cdt.core.parser.IMacro;
|
||||||
|
import org.eclipse.cdt.core.parser.IScannerInfo;
|
||||||
|
import org.eclipse.cdt.core.parser.ParserUtil;
|
||||||
|
import org.eclipse.cdt.core.parser.ScannerInfo;
|
||||||
|
import org.eclipse.cdt.internal.core.index.IIndexFragmentFile;
|
||||||
|
import org.eclipse.cdt.internal.core.index.IWritableIndex;
|
||||||
|
import org.eclipse.cdt.internal.core.index.IndexBasedCodeReaderFactory;
|
||||||
|
import org.eclipse.cdt.internal.core.pdom.dom.PDOMMacro;
|
||||||
|
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNotImplementedError;
|
||||||
|
import org.eclipse.core.runtime.CoreException;
|
||||||
|
import org.eclipse.core.runtime.IPath;
|
||||||
|
import org.eclipse.core.runtime.IProgressMonitor;
|
||||||
|
import org.eclipse.core.runtime.IStatus;
|
||||||
|
import org.eclipse.core.runtime.Path;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Task for the actual indexing. Various indexers need to implement the abstract methods.
|
||||||
|
* @since 5.0
|
||||||
|
*/
|
||||||
|
public abstract class AbstractIndexerTask extends PDOMWriter {
|
||||||
|
private static final int MAX_ERRORS = 500;
|
||||||
|
|
||||||
|
private static class FileKey {
|
||||||
|
final URI fUri;
|
||||||
|
final int fLinkageID;
|
||||||
|
|
||||||
|
public FileKey(int linkageID, URI uri) {
|
||||||
|
fUri= uri;
|
||||||
|
fLinkageID= linkageID;
|
||||||
|
}
|
||||||
|
public int hashCode() {
|
||||||
|
return fUri.hashCode() * 31 + fLinkageID;
|
||||||
|
}
|
||||||
|
public boolean equals(Object obj) {
|
||||||
|
FileKey other = (FileKey) obj;
|
||||||
|
return fLinkageID == other.fLinkageID && fUri.equals(other.fUri);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static class FileInfo {
|
||||||
|
IIndexFile fIndexFile= null;
|
||||||
|
boolean fRequestUpdate= false;
|
||||||
|
boolean fIsUpdated= false;
|
||||||
|
public IMacro[] fMacros;
|
||||||
|
}
|
||||||
|
|
||||||
|
private int fUpdateFlags= IIndexManager.UPDATE_ALL;
|
||||||
|
private boolean fIndexHeadersWithoutContext= true;
|
||||||
|
private boolean fIndexFilesWithoutConfiguration= true;
|
||||||
|
private HashMap fFileInfos= new HashMap();
|
||||||
|
|
||||||
|
private Object[] fFilesToUpdate;
|
||||||
|
private List fFilesToRemove = new ArrayList();
|
||||||
|
private List fFilesUpFront= new ArrayList();
|
||||||
|
private int fASTOptions;
|
||||||
|
|
||||||
|
protected IWritableIndex fIndex;
|
||||||
|
private ITodoTaskUpdater fTodoTaskUpdater;
|
||||||
|
private final boolean fIsFastIndexer;
|
||||||
|
private ICodeReaderFactory fCodeReaderFactory;
|
||||||
|
|
||||||
|
public AbstractIndexerTask(Object[] filesToUpdate, Object[] filesToRemove, IndexerInputAdapter resolver, boolean fastIndexer) {
|
||||||
|
super(resolver);
|
||||||
|
fIsFastIndexer= fastIndexer;
|
||||||
|
fFilesToUpdate= filesToUpdate;
|
||||||
|
fFilesToRemove.addAll(Arrays.asList(filesToRemove));
|
||||||
|
updateInfo(0, 0, fFilesToUpdate.length + fFilesToRemove.size());
|
||||||
|
}
|
||||||
|
|
||||||
|
public final void setIndexHeadersWithoutContext(boolean val) {
|
||||||
|
fIndexHeadersWithoutContext= val;
|
||||||
|
}
|
||||||
|
public final void setIndexFilesWithoutBuildConfiguration(boolean val) {
|
||||||
|
fIndexFilesWithoutConfiguration= val;
|
||||||
|
}
|
||||||
|
public final void setUpdateFlags(int flags) {
|
||||||
|
fUpdateFlags= flags;
|
||||||
|
}
|
||||||
|
public final void setParseUpFront(String[] astFilePaths) {
|
||||||
|
fFilesUpFront.addAll(Arrays.asList(astFilePaths));
|
||||||
|
}
|
||||||
|
|
||||||
|
protected abstract IWritableIndex createIndex();
|
||||||
|
protected abstract ICodeReaderFactory createReaderFactory();
|
||||||
|
protected abstract AbstractLanguage[] getLanguages(String fileName);
|
||||||
|
|
||||||
|
protected ITodoTaskUpdater createTodoTaskUpdater() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected IScannerInfo createDefaultScannerConfig(int linkageID) {
|
||||||
|
return new ScannerInfo();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected String getASTPathForParsingUpFront() {
|
||||||
|
return "______"; //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private final IASTTranslationUnit createAST(String code, AbstractLanguage lang, IScannerInfo scanInfo,
|
||||||
|
int options, IProgressMonitor monitor) throws CoreException {
|
||||||
|
String dummyName= getASTPathForParsingUpFront();
|
||||||
|
if (dummyName != null) {
|
||||||
|
IIndexFileLocation dummyLoc= fResolver.resolveASTPath(dummyName);
|
||||||
|
setIndexed(lang.getLinkageID(), dummyLoc);
|
||||||
|
CodeReader codeReader= new CodeReader(dummyName, code.toCharArray());
|
||||||
|
return createAST(lang, codeReader, scanInfo, options, monitor);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private final IASTTranslationUnit createAST(Object tu, AbstractLanguage language, IScannerInfo scanInfo, int options, IProgressMonitor pm)
|
||||||
|
throws CoreException {
|
||||||
|
final CodeReader codeReader= fResolver.getCodeReader(tu);
|
||||||
|
if (codeReader == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
IASTTranslationUnit ast= createAST(language, codeReader, scanInfo, options, pm);
|
||||||
|
if (ast != null && !fResolver.isSourceUnit(tu)) {
|
||||||
|
ast.setIsHeaderUnit(true);
|
||||||
|
}
|
||||||
|
return ast;
|
||||||
|
}
|
||||||
|
|
||||||
|
private final IASTTranslationUnit createAST(AbstractLanguage language, CodeReader codeReader,
|
||||||
|
IScannerInfo scanInfo, int options, IProgressMonitor pm) throws CoreException {
|
||||||
|
if (fCodeReaderFactory == null) {
|
||||||
|
if (fIsFastIndexer) {
|
||||||
|
fCodeReaderFactory= new IndexBasedCodeReaderFactory(fIndex, fResolver, language.getLinkageID(), createReaderFactory(), this);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
fCodeReaderFactory= createReaderFactory();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (fIsFastIndexer) {
|
||||||
|
((IndexBasedCodeReaderFactory) fCodeReaderFactory).setLinkage(language.getLinkageID());
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
IASTTranslationUnit ast= language.getASTTranslationUnit(codeReader, scanInfo, fCodeReaderFactory, fIndex, options, ParserUtil.getParserLogService());
|
||||||
|
if (pm.isCanceled()) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return ast;
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
if (fIsFastIndexer) {
|
||||||
|
((IndexBasedCodeReaderFactory) fCodeReaderFactory).cleanupAfterTranslationUnit();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public final void runTask(IProgressMonitor monitor) throws InterruptedException {
|
||||||
|
if (!fIndexFilesWithoutConfiguration) {
|
||||||
|
fIndexHeadersWithoutContext= false;
|
||||||
|
}
|
||||||
|
|
||||||
|
fIndex= createIndex();
|
||||||
|
if (fIndex == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
fTodoTaskUpdater= createTodoTaskUpdater();
|
||||||
|
|
||||||
|
fASTOptions= AbstractLanguage.OPTION_ADD_COMMENTS | AbstractLanguage.OPTION_NO_IMAGE_LOCATIONS;
|
||||||
|
if (getSkipReferences() == SKIP_ALL_REFERENCES) {
|
||||||
|
fASTOptions |= AbstractLanguage.OPTION_SKIP_FUNCTION_BODIES;
|
||||||
|
}
|
||||||
|
|
||||||
|
fIndex.resetCacheCounters();
|
||||||
|
fIndex.acquireReadLock();
|
||||||
|
|
||||||
|
try {
|
||||||
|
try {
|
||||||
|
// split into sources and headers, remove excluded sources.
|
||||||
|
final HashMap files= new HashMap();
|
||||||
|
final ArrayList ifilesToRemove= new ArrayList();
|
||||||
|
extractFiles(files, ifilesToRemove, monitor);
|
||||||
|
|
||||||
|
// remove files from index
|
||||||
|
removeFilesInIndex(fFilesToRemove, ifilesToRemove, monitor);
|
||||||
|
|
||||||
|
parseFilesUpFront(monitor);
|
||||||
|
parseLinkage(ILinkage.CPP_LINKAGE_ID, files, monitor);
|
||||||
|
parseLinkage(ILinkage.C_LINKAGE_ID, files, monitor);
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
fIndex.flush();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (CoreException e) {
|
||||||
|
CCorePlugin.log(e);
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
fIndex.releaseReadLock();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void extractFiles(Map files, List iFilesToRemove, IProgressMonitor monitor) throws CoreException {
|
||||||
|
final boolean force= (fUpdateFlags & IIndexManager.UPDATE_ALL) != 0;
|
||||||
|
final boolean checkTimestamps= (fUpdateFlags & IIndexManager.UPDATE_CHECK_TIMESTAMPS) != 0;
|
||||||
|
final boolean checkConfig= (fUpdateFlags & IIndexManager.UPDATE_CHECK_CONFIGURATION) != 0;
|
||||||
|
|
||||||
|
int count= 0;
|
||||||
|
for (int i = 0; i < fFilesToUpdate.length; i++) {
|
||||||
|
if (monitor.isCanceled())
|
||||||
|
return;
|
||||||
|
|
||||||
|
final Object tu= fFilesToUpdate[i];
|
||||||
|
final IIndexFileLocation ifl= fResolver.resolveFile(tu);
|
||||||
|
final boolean isSourceUnit= fResolver.isSourceUnit(tu);
|
||||||
|
final boolean isExcludedSource= isSourceUnit && !fIndexFilesWithoutConfiguration && !fResolver.isFileBuildConfigured(tu);
|
||||||
|
final IIndexFragmentFile[] indexFiles= fIndex.getWritableFiles(ifl);
|
||||||
|
|
||||||
|
if ((isSourceUnit && !isExcludedSource) || fIndexHeadersWithoutContext) {
|
||||||
|
// headers or sources required with a specific linkage
|
||||||
|
AbstractLanguage[] langs= fResolver.getLanguages(tu);
|
||||||
|
for (int j = 0; j < langs.length; j++) {
|
||||||
|
int linkageID = langs[j].getLinkageID();
|
||||||
|
IIndexFragmentFile ifile= getFile(linkageID, indexFiles);
|
||||||
|
if (ifile == null || !ifile.hasContent()) {
|
||||||
|
store(tu, linkageID, isSourceUnit, files);
|
||||||
|
requestUpdate(linkageID, ifl, null);
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
takeFile(ifile, indexFiles);
|
||||||
|
boolean update= false;
|
||||||
|
if (checkConfig) {
|
||||||
|
update= isSourceUnit ? isSourceUnitConfigChange(tu, ifile) : isHeaderConfigChange(tu, ifile);
|
||||||
|
}
|
||||||
|
update= update || force || (checkTimestamps && fResolver.getLastModified(ifl) != ifile.getTimestamp());
|
||||||
|
if (update) {
|
||||||
|
requestUpdate(linkageID, ifl, ifile);
|
||||||
|
store(tu, linkageID, isSourceUnit, files);
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// handle other files present in index
|
||||||
|
for (int j = 0; j < indexFiles.length; j++) {
|
||||||
|
IIndexFragmentFile ifile = indexFiles[j];
|
||||||
|
if (ifile != null && ifile.hasContent()) {
|
||||||
|
IIndexInclude ctx= ifile.getParsedInContext();
|
||||||
|
if (ctx == null) {
|
||||||
|
iFilesToRemove.add(ifile);
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
boolean update= false;
|
||||||
|
if (checkConfig && ifile.getParsedInContext() != null) {
|
||||||
|
update= isHeaderConfigChange(tu, ifile);
|
||||||
|
}
|
||||||
|
update= update || force || (checkTimestamps && fResolver.getLastModified(ifl) != ifile.getTimestamp());
|
||||||
|
if (update) {
|
||||||
|
final int linkageID = ifile.getLinkageID();
|
||||||
|
requestUpdate(linkageID, ifl, ifile);
|
||||||
|
store(tu, linkageID, false, files);
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
updateInfo(0, 0, count-fFilesToUpdate.length);
|
||||||
|
fFilesToUpdate= null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void requestUpdate(int linkageID, IIndexFileLocation ifl, IIndexFragmentFile ifile) {
|
||||||
|
FileKey key= new FileKey(linkageID, ifl.getURI());
|
||||||
|
FileInfo info= (FileInfo) fFileInfos.get(key);
|
||||||
|
if (info == null) {
|
||||||
|
info= createFileInfo(key, null);
|
||||||
|
}
|
||||||
|
info.fIndexFile= ifile;
|
||||||
|
info.fRequestUpdate= true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setIndexed(int linkageID, IIndexFileLocation ifl) {
|
||||||
|
FileKey key= new FileKey(linkageID, ifl.getURI());
|
||||||
|
FileInfo info= (FileInfo) fFileInfos.get(key);
|
||||||
|
if (info == null) {
|
||||||
|
info= createFileInfo(key, null);
|
||||||
|
}
|
||||||
|
info.fIsUpdated= true;
|
||||||
|
info.fMacros= null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private FileInfo createFileInfo(FileKey key, IIndexFile ifile) {
|
||||||
|
FileInfo info = new FileInfo();
|
||||||
|
fFileInfos.put(key, info);
|
||||||
|
info.fIndexFile= ifile;
|
||||||
|
return info;
|
||||||
|
}
|
||||||
|
|
||||||
|
private FileInfo getFileInfo(int linkageID, IIndexFileLocation ifl) {
|
||||||
|
FileKey key= new FileKey(linkageID, ifl.getURI());
|
||||||
|
return (FileInfo) fFileInfos.get(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean isSourceUnitConfigChange(Object tu, IIndexFragmentFile ifile) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean isHeaderConfigChange(Object tu, IIndexFragmentFile ifile) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private IIndexFragmentFile getFile(int linkageID, IIndexFragmentFile[] indexFiles) throws CoreException {
|
||||||
|
for (int i = 0; i < indexFiles.length; i++) {
|
||||||
|
IIndexFragmentFile ifile = indexFiles[i];
|
||||||
|
if (ifile != null && ifile.getLinkageID() == linkageID) {
|
||||||
|
return ifile;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void takeFile(IIndexFragmentFile ifile, IIndexFragmentFile[] indexFiles) {
|
||||||
|
for (int i = 0; i < indexFiles.length; i++) {
|
||||||
|
if (indexFiles[i] == ifile) {
|
||||||
|
indexFiles[i]= null;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void store(Object tu, int linkageID, boolean isSourceUnit, Map files) {
|
||||||
|
Integer key = getFileListKey(linkageID, isSourceUnit);
|
||||||
|
List list= (List) files.get(key);
|
||||||
|
if (list == null) {
|
||||||
|
list= new LinkedList();
|
||||||
|
files.put(key, list);
|
||||||
|
}
|
||||||
|
list.add(tu);
|
||||||
|
}
|
||||||
|
|
||||||
|
private Integer getFileListKey(int linkageID, boolean isSourceUnit) {
|
||||||
|
Integer key= new Integer(linkageID*2 + (isSourceUnit ? 0 : 1));
|
||||||
|
return key;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void removeFilesInIndex(List filesToRemove, List ifilesToRemove, IProgressMonitor monitor) throws InterruptedException, CoreException {
|
||||||
|
if (!filesToRemove.isEmpty() || !ifilesToRemove.isEmpty()) {
|
||||||
|
fIndex.acquireWriteLock(1);
|
||||||
|
try {
|
||||||
|
for (Iterator iterator = fFilesToRemove.iterator(); iterator.hasNext();) {
|
||||||
|
if (monitor.isCanceled()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
final Object tu = iterator.next();
|
||||||
|
IIndexFileLocation ifl= fResolver.resolveFile(tu);
|
||||||
|
IIndexFragmentFile[] ifiles= fIndex.getWritableFiles(ifl);
|
||||||
|
for (int i = 0; i < ifiles.length; i++) {
|
||||||
|
IIndexFragmentFile ifile = ifiles[i];
|
||||||
|
fIndex.clearFile(ifile, null);
|
||||||
|
}
|
||||||
|
updateInfo(0, 0, -1);
|
||||||
|
}
|
||||||
|
for (Iterator iterator = ifilesToRemove.iterator(); iterator.hasNext();) {
|
||||||
|
if (monitor.isCanceled()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
IIndexFragmentFile ifile= (IIndexFragmentFile) iterator.next();
|
||||||
|
fIndex.clearFile(ifile, null);
|
||||||
|
updateInfo(0, 0, -1);
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
fIndex.releaseWriteLock(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fFilesToRemove.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void parseFilesUpFront(IProgressMonitor monitor) throws CoreException {
|
||||||
|
for (Iterator iter = fFilesUpFront.iterator(); iter.hasNext();) {
|
||||||
|
if (monitor.isCanceled()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
String upfront= (String) iter.next();
|
||||||
|
String filePath = upfront;
|
||||||
|
filePath= filePath.trim();
|
||||||
|
if (filePath.length() == 0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
final IPath path= new Path(filePath);
|
||||||
|
final String fileName = path.lastSegment();
|
||||||
|
try {
|
||||||
|
if (fShowActivity) {
|
||||||
|
System.out.println("Indexer: parsing " + filePath + " up front"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
|
}
|
||||||
|
monitor.subTask(MessageFormat.format(Messages.AbstractIndexerTask_parsingFileTask,
|
||||||
|
new Object[]{fileName, path.removeLastSegments(1).toString()}));
|
||||||
|
|
||||||
|
AbstractLanguage[] langs= getLanguages(fileName);
|
||||||
|
for (int i = 0; i < langs.length; i++) {
|
||||||
|
AbstractLanguage lang= langs[i];
|
||||||
|
int linkageID= lang.getLinkageID();
|
||||||
|
String code= "#include \"" + filePath + "\"\n"; //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
|
|
||||||
|
IScannerInfo scanInfo= createDefaultScannerConfig(linkageID);
|
||||||
|
if (scanInfo != null) {
|
||||||
|
long start= System.currentTimeMillis();
|
||||||
|
IASTTranslationUnit ast= createAST(code, lang, scanInfo, fASTOptions, monitor);
|
||||||
|
fStatistics.fParsingTime += System.currentTimeMillis()-start;
|
||||||
|
|
||||||
|
if (ast != null) {
|
||||||
|
writeToIndex(linkageID, ast, computeHashCode(scanInfo), monitor);
|
||||||
|
updateInfo(0, 1, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (OutOfMemoryError e) {
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
catch (Throwable e) {
|
||||||
|
swallowError(path, e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fFilesUpFront.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void parseLinkage(int linkageID, Map fileListMap, IProgressMonitor monitor) throws CoreException, InterruptedException {
|
||||||
|
// sources
|
||||||
|
List files= (List) fileListMap.get(getFileListKey(linkageID, true));
|
||||||
|
if (files != null) {
|
||||||
|
for (Iterator iter = files.iterator(); iter.hasNext();) {
|
||||||
|
if (monitor.isCanceled())
|
||||||
|
return;
|
||||||
|
final Object tu= iter.next();
|
||||||
|
final IIndexFileLocation ifl = fResolver.resolveFile(tu);
|
||||||
|
final FileInfo info= getFileInfo(linkageID, ifl);
|
||||||
|
if (info != null && info.fRequestUpdate && !info.fIsUpdated) {
|
||||||
|
final IScannerInfo scannerInfo= fResolver.getBuildConfiguration(linkageID, tu);
|
||||||
|
parseFile(tu, linkageID, ifl, scannerInfo, monitor);
|
||||||
|
if (info.fIsUpdated) {
|
||||||
|
updateInfo(1, 0, 0); // a source file was parsed
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
files.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
// headers with context
|
||||||
|
HashMap contextMap= new HashMap();
|
||||||
|
files= (List) fileListMap.get(getFileListKey(linkageID, false));
|
||||||
|
if (files != null) {
|
||||||
|
for (Iterator iter = files.iterator(); iter.hasNext();) {
|
||||||
|
if (monitor.isCanceled())
|
||||||
|
return;
|
||||||
|
final Object header= iter.next();
|
||||||
|
final IIndexFileLocation ifl = fResolver.resolveFile(header);
|
||||||
|
final FileInfo info= getFileInfo(linkageID, ifl);
|
||||||
|
if (info != null && info.fRequestUpdate && !info.fIsUpdated) {
|
||||||
|
if (info.fIndexFile != null && fIndex.isWritableFile(info.fIndexFile)) {
|
||||||
|
Object tu= findContext((IIndexFragmentFile) info.fIndexFile, contextMap);
|
||||||
|
if (tu != null) {
|
||||||
|
final IScannerInfo scannerInfo= fResolver.getBuildConfiguration(linkageID, tu);
|
||||||
|
parseFile(tu, linkageID, fResolver.resolveFile(tu), scannerInfo, monitor);
|
||||||
|
if (info.fIsUpdated) {
|
||||||
|
updateInfo(0, 1, 0); // a header was parsed in context
|
||||||
|
iter.remove();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// file was already parsed.
|
||||||
|
iter.remove();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// headers without context
|
||||||
|
contextMap= null;
|
||||||
|
for (Iterator iter = files.iterator(); iter.hasNext();) {
|
||||||
|
if (monitor.isCanceled())
|
||||||
|
return;
|
||||||
|
final Object header= iter.next();
|
||||||
|
final IIndexFileLocation ifl = fResolver.resolveFile(header);
|
||||||
|
final FileInfo info= getFileInfo(linkageID, ifl);
|
||||||
|
if (info != null && info.fRequestUpdate && !info.fIsUpdated) {
|
||||||
|
final IScannerInfo scannerInfo= fResolver.getBuildConfiguration(linkageID, header);
|
||||||
|
parseFile(header, linkageID, ifl, scannerInfo, monitor);
|
||||||
|
if (info.fIsUpdated) {
|
||||||
|
updateInfo(-1, 1, 0); // a header was parsed without context
|
||||||
|
iter.remove();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Object NO_CONTEXT= new Object();
|
||||||
|
private Object findContext(IIndexFragmentFile ifile, HashMap contextMap) {
|
||||||
|
Object cachedContext= contextMap.get(ifile);
|
||||||
|
if (cachedContext != null) {
|
||||||
|
return cachedContext == NO_CONTEXT ? null : cachedContext;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
Object context= fResolver.getInputFile(ifile.getLocation());
|
||||||
|
if (context != null) {
|
||||||
|
contextMap.put(ifile, context);
|
||||||
|
return context;
|
||||||
|
}
|
||||||
|
|
||||||
|
contextMap.put(ifile, NO_CONTEXT); // prevent recursion
|
||||||
|
final IIndexInclude contextInclude= ifile.getParsedInContext();
|
||||||
|
if (contextInclude != null) {
|
||||||
|
final IIndexFragmentFile contextIFile= (IIndexFragmentFile) contextInclude.getIncludedBy();
|
||||||
|
context= findContext(contextIFile, contextMap);
|
||||||
|
if (context != null) {
|
||||||
|
contextMap.put(ifile, context);
|
||||||
|
return context;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (CoreException e) {
|
||||||
|
CCorePlugin.log(e);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void parseFile(Object tu, int linkageID, IIndexFileLocation ifl, IScannerInfo scanInfo, IProgressMonitor pm) throws CoreException, InterruptedException {
|
||||||
|
IPath path= getPathForLabel(ifl);
|
||||||
|
AbstractLanguage[] langs= fResolver.getLanguages(tu);
|
||||||
|
AbstractLanguage lang= null;
|
||||||
|
for (int i = 0; i < langs.length; i++) {
|
||||||
|
if (langs[i].getLinkageID() == linkageID) {
|
||||||
|
lang= langs[i];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (lang==null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
if (fShowActivity) {
|
||||||
|
System.out.println("Indexer: parsing " + path.toOSString()); //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
pm.subTask(MessageFormat.format(Messages.AbstractIndexerTask_parsingFileTask,
|
||||||
|
new Object[]{path.lastSegment(), path.removeLastSegments(1).toString()}));
|
||||||
|
long start= System.currentTimeMillis();
|
||||||
|
IASTTranslationUnit ast= createAST(tu, lang, scanInfo, fASTOptions, pm);
|
||||||
|
fStatistics.fParsingTime += System.currentTimeMillis()-start;
|
||||||
|
if (ast != null) {
|
||||||
|
writeToIndex(linkageID, ast, computeHashCode(scanInfo), pm);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (CoreException e) {
|
||||||
|
swallowError(path, e);
|
||||||
|
}
|
||||||
|
catch (RuntimeException e) {
|
||||||
|
swallowError(path, e);
|
||||||
|
}
|
||||||
|
catch (PDOMNotImplementedError e) {
|
||||||
|
swallowError(path, e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void writeToIndex(final int linkageID, IASTTranslationUnit ast, int configHash, IProgressMonitor pm) throws CoreException, InterruptedException {
|
||||||
|
HashSet enteredASTFilePaths= new HashSet();
|
||||||
|
ArrayList orderedIFLs= new ArrayList();
|
||||||
|
final String astPath = ast.getFilePath();
|
||||||
|
enteredASTFilePaths.add(astPath);
|
||||||
|
|
||||||
|
IDependencyTree tree= ast.getDependencyTree();
|
||||||
|
IASTInclusionNode[] inclusions= tree.getInclusions();
|
||||||
|
for (int i=0; i < inclusions.length; i++) {
|
||||||
|
collectOrderedIFLs(linkageID, inclusions[i], enteredASTFilePaths, orderedIFLs);
|
||||||
|
}
|
||||||
|
|
||||||
|
IIndexFileLocation ifl= fResolver.resolveASTPath(astPath);
|
||||||
|
FileInfo info= getFileInfo(linkageID, ifl);
|
||||||
|
if (info != null && info.fRequestUpdate && !info.fIsUpdated) {
|
||||||
|
orderedIFLs.add(fResolver.resolveASTPath(astPath));
|
||||||
|
}
|
||||||
|
|
||||||
|
IIndexFileLocation[] ifls= (IIndexFileLocation[]) orderedIFLs.toArray(new IIndexFileLocation[orderedIFLs.size()]);
|
||||||
|
addSymbols(ast, ifls, fIndex, 1, false, configHash, fTodoTaskUpdater, pm);
|
||||||
|
for (int i = 0; i < ifls.length; i++) {
|
||||||
|
ifl= ifls[i];
|
||||||
|
info= getFileInfo(linkageID, ifl);
|
||||||
|
assert info != null;
|
||||||
|
if (info != null) {
|
||||||
|
info.fIsUpdated= true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void collectOrderedIFLs(final int linkageID, IASTInclusionNode inclusion, HashSet enteredASTFilePaths, ArrayList orderedIFLs) throws CoreException {
|
||||||
|
final IASTPreprocessorIncludeStatement id= inclusion.getIncludeDirective();
|
||||||
|
if (id.isActive() && id.isResolved()) {
|
||||||
|
final String path= id.getPath();
|
||||||
|
final boolean isFirst= enteredASTFilePaths.add(path);
|
||||||
|
IASTInclusionNode[] nested= inclusion.getNestedInclusions();
|
||||||
|
for (int i = 0; i < nested.length; i++) {
|
||||||
|
collectOrderedIFLs(linkageID, nested[i], enteredASTFilePaths, orderedIFLs);
|
||||||
|
}
|
||||||
|
if (isFirst) {
|
||||||
|
final IIndexFileLocation ifl= fResolver.resolveASTPath(path);
|
||||||
|
if (needToUpdateHeader(linkageID, ifl)) {
|
||||||
|
orderedIFLs.add(ifl);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public final boolean needToUpdateHeader(int linkageID, IIndexFileLocation ifl) throws CoreException {
|
||||||
|
FileInfo info= getFileInfo(linkageID, ifl);
|
||||||
|
if (info == null) {
|
||||||
|
IIndexFile ifile= null;
|
||||||
|
if (fResolver.canBePartOfSDK(ifl)) {
|
||||||
|
ifile= fIndex.getFile(linkageID, ifl);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
IIndexFragmentFile fragFile= fIndex.getWritableFile(linkageID, ifl);
|
||||||
|
if (fragFile != null && fragFile.hasContent()) {
|
||||||
|
ifile= fragFile;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
info= createFileInfo(new FileKey(linkageID, ifl.getURI()), ifile);
|
||||||
|
if (ifile == null) {
|
||||||
|
if (info.fRequestUpdate && !info.fIsUpdated) {
|
||||||
|
updateInfo(0,0,-1); // header found implicitly
|
||||||
|
}
|
||||||
|
info.fRequestUpdate= true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return !info.fIsUpdated && info.fRequestUpdate;
|
||||||
|
}
|
||||||
|
|
||||||
|
private IPath getPathForLabel(IIndexFileLocation ifl) {
|
||||||
|
String fullPath= ifl.getFullPath();
|
||||||
|
if (fullPath != null) {
|
||||||
|
return new Path(fullPath);
|
||||||
|
}
|
||||||
|
IPath path= IndexLocationFactory.getAbsolutePath(ifl);
|
||||||
|
if (path != null) {
|
||||||
|
return path;
|
||||||
|
}
|
||||||
|
URI uri= ifl.getURI();
|
||||||
|
return new Path(uri.getPath());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void swallowError(IPath file, Throwable e) throws CoreException {
|
||||||
|
if (e instanceof CoreException) {
|
||||||
|
CCorePlugin.log(((CoreException) e).getStatus());
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
IStatus status= CCorePlugin.createStatus(
|
||||||
|
MessageFormat.format(Messages.AbstractIndexerTask_errorWhileParsing, new Object[]{file}), e);
|
||||||
|
CCorePlugin.log(status);
|
||||||
|
}
|
||||||
|
if (++fStatistics.fErrorCount > MAX_ERRORS) {
|
||||||
|
throw new CoreException(CCorePlugin.createStatus(Messages.AbstractIndexerTask_tooManyIndexProblems));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static int computeHashCode(IScannerInfo scannerInfo) {
|
||||||
|
int result= 0;
|
||||||
|
Map macros= scannerInfo.getDefinedSymbols();
|
||||||
|
if (macros != null) {
|
||||||
|
for (Iterator i = macros.entrySet().iterator(); i.hasNext();) {
|
||||||
|
Map.Entry entry = (Map.Entry) i.next();
|
||||||
|
String key = (String) entry.getKey();
|
||||||
|
String value = (String) entry.getValue();
|
||||||
|
result= addToHashcode(result, key);
|
||||||
|
if (value != null && value.length() > 0) {
|
||||||
|
result= addToHashcode(result, value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
String[] a= scannerInfo.getIncludePaths();
|
||||||
|
if (a != null) {
|
||||||
|
for (int i = 0; i < a.length; i++) {
|
||||||
|
result= addToHashcode(result, a[i]);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (scannerInfo instanceof IExtendedScannerInfo) {
|
||||||
|
IExtendedScannerInfo esi= (IExtendedScannerInfo) scannerInfo;
|
||||||
|
a= esi.getIncludeFiles();
|
||||||
|
if (a != null) {
|
||||||
|
for (int i = 0; i < a.length; i++) {
|
||||||
|
result= addToHashcode(result, a[i]);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
a= esi.getLocalIncludePath();
|
||||||
|
if (a != null) {
|
||||||
|
for (int i = 0; i < a.length; i++) {
|
||||||
|
result= addToHashcode(result, a[i]);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
a= esi.getMacroFiles();
|
||||||
|
if (a != null) {
|
||||||
|
for (int i = 0; i < a.length; i++) {
|
||||||
|
result= addToHashcode(result, a[i]);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static int addToHashcode(int result, String key) {
|
||||||
|
return result*31 + key.hashCode();
|
||||||
|
}
|
||||||
|
|
||||||
|
public final IMacro[] getConvertedMacros(int linkageID, IIndexFileLocation ifl) throws CoreException {
|
||||||
|
if (!needToUpdateHeader(linkageID, ifl)) {
|
||||||
|
FileInfo info= getFileInfo(linkageID, ifl);
|
||||||
|
assert info != null;
|
||||||
|
if (info != null) {
|
||||||
|
if (info.fIndexFile == null) {
|
||||||
|
info.fIndexFile= fIndex.getFile(linkageID, ifl);
|
||||||
|
if (info.fIndexFile == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
IMacro[] result= info.fMacros;
|
||||||
|
if (result == null) {
|
||||||
|
IIndexMacro[] macros= info.fIndexFile.getMacros();
|
||||||
|
result= new IMacro[macros.length];
|
||||||
|
for (int i = 0; i < macros.length; i++) {
|
||||||
|
IIndexMacro macro = macros[i];
|
||||||
|
result[i]= ((PDOMMacro)macro).getMacro();
|
||||||
|
}
|
||||||
|
info.fMacros= result;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,73 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2007 Wind River Systems, Inc. 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:
|
||||||
|
* Markus Schorn - initial API and implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.cdt.internal.core.pdom;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.index.IIndexFileLocation;
|
||||||
|
import org.eclipse.cdt.core.model.AbstractLanguage;
|
||||||
|
import org.eclipse.cdt.core.parser.CodeReader;
|
||||||
|
import org.eclipse.cdt.core.parser.IScannerInfo;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Abstract class to obtain information about the input to the indexer. For the
|
||||||
|
* project based indexers the input are translation units, for the stand-alone
|
||||||
|
* indexer they are file-paths represented as strings.
|
||||||
|
* @since 5.0
|
||||||
|
*/
|
||||||
|
public abstract class IndexerInputAdapter extends ASTFilePathResolver {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns an object representing an input file for the given index location,
|
||||||
|
* or <code>null</code>, if it does not exist.
|
||||||
|
*/
|
||||||
|
public abstract Object getInputFile(IIndexFileLocation location);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the last modification date for the file denoted by the index location.
|
||||||
|
*/
|
||||||
|
public abstract long getLastModified(IIndexFileLocation location);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create an index location for the given input file.
|
||||||
|
*/
|
||||||
|
public abstract IIndexFileLocation resolveFile(Object tu);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests whether the input file is a source unit.
|
||||||
|
*/
|
||||||
|
public abstract boolean isSourceUnit(Object tu);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests whether the input file is part of the build.
|
||||||
|
*/
|
||||||
|
public abstract boolean isFileBuildConfigured(Object tu);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests whether the file in the index is allowed to be part of an SDK. If not
|
||||||
|
* it will be indexed.
|
||||||
|
*/
|
||||||
|
public abstract boolean canBePartOfSDK(IIndexFileLocation ifl);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Obtains the languages the input file should be parsed with.
|
||||||
|
*/
|
||||||
|
public abstract AbstractLanguage[] getLanguages(Object tu);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Obtains the scanner configuration for the input file.
|
||||||
|
*/
|
||||||
|
public abstract IScannerInfo getBuildConfiguration(int linkageID, Object tu);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a code reader for the given input file.
|
||||||
|
*/
|
||||||
|
public abstract CodeReader getCodeReader(Object tu);
|
||||||
|
|
||||||
|
}
|
|
@ -9,7 +9,7 @@
|
||||||
* Markus Schorn - initial API and implementation
|
* Markus Schorn - initial API and implementation
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
package org.eclipse.cdt.internal.core.pdom.indexer;
|
package org.eclipse.cdt.internal.core.pdom;
|
||||||
|
|
||||||
public class IndexerStatistics {
|
public class IndexerStatistics {
|
||||||
public int fResolutionTime;
|
public int fResolutionTime;
|
|
@ -32,6 +32,9 @@ public class Messages extends NLS {
|
||||||
public static String TeamPDOMExportOperation_subtaskCreateDatabase;
|
public static String TeamPDOMExportOperation_subtaskCreateDatabase;
|
||||||
public static String TeamPDOMExportOperation_taskExportIndex;
|
public static String TeamPDOMExportOperation_taskExportIndex;
|
||||||
public static String WritablePDOM_error_unknownLinkage;
|
public static String WritablePDOM_error_unknownLinkage;
|
||||||
|
public static String AbstractIndexerTask_parsingFileTask;
|
||||||
|
public static String AbstractIndexerTask_errorWhileParsing;
|
||||||
|
public static String AbstractIndexerTask_tooManyIndexProblems;
|
||||||
static {
|
static {
|
||||||
// initialize resource bundle
|
// initialize resource bundle
|
||||||
NLS.initializeMessages(BUNDLE_NAME, Messages.class);
|
NLS.initializeMessages(BUNDLE_NAME, Messages.class);
|
||||||
|
|
|
@ -90,7 +90,7 @@ public class PDOM extends PlatformObject implements IPDOM {
|
||||||
*/
|
*/
|
||||||
public static final String FRAGMENT_PROPERTY_VALUE_FORMAT_ID= "org.eclipse.cdt.internal.core.pdom.PDOM"; //$NON-NLS-1$
|
public static final String FRAGMENT_PROPERTY_VALUE_FORMAT_ID= "org.eclipse.cdt.internal.core.pdom.PDOM"; //$NON-NLS-1$
|
||||||
|
|
||||||
public static final int CURRENT_VERSION = 51;
|
public static final int CURRENT_VERSION = 52;
|
||||||
public static final int MIN_SUPPORTED_VERSION= CURRENT_VERSION;
|
public static final int MIN_SUPPORTED_VERSION= CURRENT_VERSION;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -151,6 +151,7 @@ public class PDOM extends PlatformObject implements IPDOM {
|
||||||
*
|
*
|
||||||
* 50 - support for complex, imaginary and long long (bug 209049).
|
* 50 - support for complex, imaginary and long long (bug 209049).
|
||||||
* 51 - modeling extern "C" (bug 191989)
|
* 51 - modeling extern "C" (bug 191989)
|
||||||
|
* 52 - files per linkage (bug 191989)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public static final int LINKAGES = Database.DATA_AREA;
|
public static final int LINKAGES = Database.DATA_AREA;
|
||||||
|
@ -261,11 +262,15 @@ public class PDOM extends PlatformObject implements IPDOM {
|
||||||
return fileIndex;
|
return fileIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IIndexFragmentFile getFile(IIndexFileLocation location) throws CoreException {
|
public IIndexFragmentFile getFile(int linkageID, IIndexFileLocation location) throws CoreException {
|
||||||
return PDOMFile.findFile(this, getFileIndex(), location, locationConverter);
|
return PDOMFile.findFile(this, getFileIndex(), location, linkageID, locationConverter);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List/*<IIndexFileLocation>*/ getAllFileLocations() throws CoreException {
|
public IIndexFragmentFile[] getFiles(IIndexFileLocation location) throws CoreException {
|
||||||
|
return PDOMFile.findFiles(this, getFileIndex(), location, locationConverter);
|
||||||
|
}
|
||||||
|
|
||||||
|
public IIndexFragmentFile[] getAllFiles() throws CoreException {
|
||||||
final List locations = new ArrayList();
|
final List locations = new ArrayList();
|
||||||
getFileIndex().accept(new IBTreeVisitor(){
|
getFileIndex().accept(new IBTreeVisitor(){
|
||||||
public int compare(int record) throws CoreException {
|
public int compare(int record) throws CoreException {
|
||||||
|
@ -273,17 +278,17 @@ public class PDOM extends PlatformObject implements IPDOM {
|
||||||
}
|
}
|
||||||
public boolean visit(int record) throws CoreException {
|
public boolean visit(int record) throws CoreException {
|
||||||
PDOMFile file = new PDOMFile(PDOM.this, record);
|
PDOMFile file = new PDOMFile(PDOM.this, record);
|
||||||
locations.add(file.getLocation());
|
locations.add(file);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return locations;
|
return (IIndexFragmentFile[]) locations.toArray(new IIndexFragmentFile[locations.size()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected IIndexFragmentFile addFile(IIndexFileLocation location) throws CoreException {
|
protected IIndexFragmentFile addFile(int linkageID, IIndexFileLocation location) throws CoreException {
|
||||||
IIndexFragmentFile file = getFile(location);
|
IIndexFragmentFile file = getFile(linkageID, location);
|
||||||
if (file == null) {
|
if (file == null) {
|
||||||
PDOMFile pdomFile = new PDOMFile(this, location);
|
PDOMFile pdomFile = new PDOMFile(this, location, linkageID);
|
||||||
getFileIndex().insert(pdomFile.getRecord());
|
getFileIndex().insert(pdomFile.getRecord());
|
||||||
file= pdomFile;
|
file= pdomFile;
|
||||||
}
|
}
|
||||||
|
@ -758,7 +763,7 @@ public class PDOM extends PlatformObject implements IPDOM {
|
||||||
return (PDOMFile) file;
|
return (PDOMFile) file;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (PDOMFile) getFile(file.getLocation());
|
return (PDOMFile) getFile(file.getLinkageID(), file.getLocation());
|
||||||
}
|
}
|
||||||
|
|
||||||
public File getPath() {
|
public File getPath() {
|
||||||
|
|
|
@ -93,6 +93,9 @@ public class PDOMIndexerJob extends Job {
|
||||||
System.out.println("Indexer: completed " + name + "[" + time + "ms]"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
System.out.println("Indexer: completed " + name + "[" + time + "ms]"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
catch (InterruptedException e) {
|
||||||
|
Thread.currentThread().interrupt();
|
||||||
|
}
|
||||||
catch (OperationCanceledException e) {
|
catch (OperationCanceledException e) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,10 +64,10 @@ import org.eclipse.cdt.internal.core.pdom.PDOM.IListener;
|
||||||
import org.eclipse.cdt.internal.core.pdom.db.ChunkCache;
|
import org.eclipse.cdt.internal.core.pdom.db.ChunkCache;
|
||||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMProjectIndexLocationConverter;
|
import org.eclipse.cdt.internal.core.pdom.dom.PDOMProjectIndexLocationConverter;
|
||||||
import org.eclipse.cdt.internal.core.pdom.indexer.IndexerPreferences;
|
import org.eclipse.cdt.internal.core.pdom.indexer.IndexerPreferences;
|
||||||
|
import org.eclipse.cdt.internal.core.pdom.indexer.PDOMNullIndexer;
|
||||||
import org.eclipse.cdt.internal.core.pdom.indexer.PDOMRebuildTask;
|
import org.eclipse.cdt.internal.core.pdom.indexer.PDOMRebuildTask;
|
||||||
import org.eclipse.cdt.internal.core.pdom.indexer.PDOMUpdateTask;
|
import org.eclipse.cdt.internal.core.pdom.indexer.PDOMUpdateTask;
|
||||||
import org.eclipse.cdt.internal.core.pdom.indexer.TriggerNotificationTask;
|
import org.eclipse.cdt.internal.core.pdom.indexer.TriggerNotificationTask;
|
||||||
import org.eclipse.cdt.internal.core.pdom.indexer.nulli.PDOMNullIndexer;
|
|
||||||
import org.eclipse.cdt.internal.core.settings.model.CProjectDescriptionManager;
|
import org.eclipse.cdt.internal.core.settings.model.CProjectDescriptionManager;
|
||||||
import org.eclipse.core.resources.IFolder;
|
import org.eclipse.core.resources.IFolder;
|
||||||
import org.eclipse.core.resources.IProject;
|
import org.eclipse.core.resources.IProject;
|
||||||
|
|
|
@ -120,13 +120,20 @@ public class PDOMProxy implements IPDOM {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized IIndexFragmentFile getFile(IIndexFileLocation location) throws CoreException {
|
public synchronized IIndexFragmentFile getFile(int linkageID, IIndexFileLocation location) throws CoreException {
|
||||||
if (fDelegate != null)
|
if (fDelegate != null)
|
||||||
return fDelegate.getFile(location);
|
return fDelegate.getFile(linkageID, location);
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public synchronized IIndexFragmentFile[] getFiles(IIndexFileLocation location) throws CoreException {
|
||||||
|
if (fDelegate != null)
|
||||||
|
return fDelegate.getFiles(location);
|
||||||
|
|
||||||
|
return IIndexFragmentFile.EMPTY_ARRAY;
|
||||||
|
}
|
||||||
|
|
||||||
public synchronized long getLastWriteAccess() {
|
public synchronized long getLastWriteAccess() {
|
||||||
if (fDelegate != null)
|
if (fDelegate != null)
|
||||||
return fDelegate.getLastWriteAccess();
|
return fDelegate.getLastWriteAccess();
|
||||||
|
|
|
@ -17,7 +17,6 @@ import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.LinkedHashSet;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
@ -44,13 +43,10 @@ import org.eclipse.cdt.core.index.IIndexFileLocation;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.ASTInternal;
|
import org.eclipse.cdt.internal.core.dom.parser.ASTInternal;
|
||||||
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.cdt.internal.core.index.IndexFileLocation;
|
|
||||||
import org.eclipse.cdt.internal.core.index.IWritableIndex.IncludeInformation;
|
import org.eclipse.cdt.internal.core.index.IWritableIndex.IncludeInformation;
|
||||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMASTAdapter;
|
import org.eclipse.cdt.internal.core.pdom.dom.PDOMASTAdapter;
|
||||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNotImplementedError;
|
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNotImplementedError;
|
||||||
import org.eclipse.cdt.internal.core.pdom.indexer.IndexerASTVisitor;
|
import org.eclipse.cdt.internal.core.pdom.indexer.IndexerASTVisitor;
|
||||||
import org.eclipse.cdt.internal.core.pdom.indexer.IndexerStatistics;
|
|
||||||
import org.eclipse.core.filesystem.EFS;
|
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.core.runtime.IProgressMonitor;
|
import org.eclipse.core.runtime.IProgressMonitor;
|
||||||
import org.eclipse.core.runtime.IStatus;
|
import org.eclipse.core.runtime.IStatus;
|
||||||
|
@ -68,13 +64,15 @@ abstract public class PDOMWriter {
|
||||||
|
|
||||||
protected boolean fShowActivity;
|
protected boolean fShowActivity;
|
||||||
protected boolean fShowProblems;
|
protected boolean fShowProblems;
|
||||||
protected IndexerStatistics fStatistics;
|
protected final IndexerStatistics fStatistics;
|
||||||
|
protected final IndexerInputAdapter fResolver;
|
||||||
|
|
||||||
private IndexerProgress fInfo= new IndexerProgress();
|
private IndexerProgress fInfo= new IndexerProgress();
|
||||||
private int fSkipReferences= SKIP_NO_REFERENCES;
|
private int fSkipReferences= SKIP_NO_REFERENCES;
|
||||||
|
|
||||||
public PDOMWriter() {
|
public PDOMWriter(IndexerInputAdapter resolver) {
|
||||||
fStatistics= new IndexerStatistics();
|
fStatistics= new IndexerStatistics();
|
||||||
|
fResolver= resolver;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setShowActivity(boolean val) {
|
public void setShowActivity(boolean val) {
|
||||||
|
@ -93,38 +91,10 @@ abstract public class PDOMWriter {
|
||||||
fSkipReferences= options;
|
fSkipReferences= options;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public int getSkipReferences() {
|
||||||
* Called to check whether a translation unit still needs to be updated.
|
return fSkipReferences;
|
||||||
* @see #addSymbols(IASTTranslationUnit, IWritableIndex, int, IProgressMonitor)
|
|
||||||
* @since 4.0
|
|
||||||
*/
|
|
||||||
protected abstract boolean needToUpdate(IIndexFileLocation location, int confighash) throws CoreException;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Called after a file was added to the index.
|
|
||||||
* @return whether the file was actually requested by the indexer.
|
|
||||||
* @see #addSymbols(IASTTranslationUnit, IWritableIndex, int, IProgressMonitor)
|
|
||||||
* @since 4.0
|
|
||||||
*/
|
|
||||||
protected abstract boolean postAddToIndex(IIndexFileLocation location, IIndexFile file) throws CoreException;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Called to resolve an absolute path to an index file location.
|
|
||||||
* @since 4.0
|
|
||||||
*/
|
|
||||||
protected abstract IIndexFileLocation findLocation(String absolutePath);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Fully equivalent to
|
|
||||||
* <code>addSymbols(IASTTranslationUnit, IWritableIndex, int, true, int, null, IProgressMonitor)</code>.
|
|
||||||
* @since 4.0
|
|
||||||
*/
|
|
||||||
public void addSymbols(IASTTranslationUnit ast,
|
|
||||||
IWritableIndex index, int readlockCount,
|
|
||||||
int configHash, IProgressMonitor pm) throws InterruptedException, CoreException {
|
|
||||||
addSymbols(ast, index, readlockCount, true, configHash, null, pm);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Extracts symbols from the given ast and adds them to the index. It will
|
* Extracts symbols from the given ast and adds them to the index. It will
|
||||||
* make calls to
|
* make calls to
|
||||||
|
@ -137,124 +107,31 @@ abstract public class PDOMWriter {
|
||||||
* index after your last write operation.
|
* index after your last write operation.
|
||||||
* @since 4.0
|
* @since 4.0
|
||||||
*/
|
*/
|
||||||
public void addSymbols(IASTTranslationUnit ast,
|
public void addSymbols(IASTTranslationUnit ast, IIndexFileLocation[] ifls, IWritableIndex index,
|
||||||
IWritableIndex index, int readlockCount, boolean flushIndex,
|
int readlockCount, boolean flushIndex, int configHash, ITodoTaskUpdater taskUpdater, IProgressMonitor pm)
|
||||||
int configHash, ITodoTaskUpdater taskUpdater, IProgressMonitor pm) throws InterruptedException, CoreException {
|
throws InterruptedException, CoreException {
|
||||||
final Map symbolMap= new HashMap();
|
final Map symbolMap= new HashMap();
|
||||||
ArrayList stati= new ArrayList();
|
for (int i = 0; i < ifls.length; i++) {
|
||||||
IIndexFileLocation[] orderedPaths= null;
|
prepareInMap(symbolMap, ifls[i]);
|
||||||
try {
|
|
||||||
HashSet contextIncludes= new HashSet();
|
|
||||||
orderedPaths= extractSymbols(ast, symbolMap, configHash, contextIncludes);
|
|
||||||
for (int i=0; i<orderedPaths.length; i++) {
|
|
||||||
if (pm.isCanceled()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
IIndexFileLocation path= orderedPaths[i];
|
|
||||||
ArrayList[] arrayLists = ((ArrayList[]) symbolMap.get(path));
|
|
||||||
|
|
||||||
// resolve the names
|
|
||||||
long start= System.currentTimeMillis();
|
|
||||||
ArrayList names= arrayLists[2];
|
|
||||||
boolean reported= false;
|
|
||||||
for (Iterator j = names.iterator(); j.hasNext();) {
|
|
||||||
final IASTName[] na= (IASTName[]) j.next();
|
|
||||||
final IASTName name = na[0];
|
|
||||||
try {
|
|
||||||
final IBinding binding = name.resolveBinding();
|
|
||||||
if (binding instanceof IProblemBinding)
|
|
||||||
reportProblem((IProblemBinding) binding);
|
|
||||||
else if (name.isReference()) {
|
|
||||||
if (fSkipReferences == SKIP_TYPE_REFERENCES) {
|
|
||||||
if (isTypeReferenceBinding(binding) && !isInheritanceSpec(name)) {
|
|
||||||
na[0]= null;
|
|
||||||
fStatistics.fReferenceCount--;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fStatistics.fReferenceCount++;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
fStatistics.fDeclarationCount++;
|
|
||||||
}
|
|
||||||
} catch (RuntimeException e) {
|
|
||||||
if (!reported) {
|
|
||||||
stati.add(CCorePlugin.createStatus(
|
|
||||||
NLS.bind(Messages.PDOMWriter_errorResolvingName, name.toString(), path.getURI().getPath()), e));
|
|
||||||
}
|
|
||||||
reported= true;
|
|
||||||
j.remove();
|
|
||||||
} catch (PDOMNotImplementedError e) {
|
|
||||||
if (!reported) {
|
|
||||||
stati.add(CCorePlugin.createStatus(
|
|
||||||
NLS.bind(Messages.PDOMWriter_errorResolvingName, name.toString(), path.getURI().getPath()), e));
|
|
||||||
}
|
|
||||||
reported= true;
|
|
||||||
j.remove();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fStatistics.fResolutionTime += System.currentTimeMillis()-start;
|
|
||||||
}
|
|
||||||
|
|
||||||
boolean isFirstRequest= true;
|
|
||||||
boolean isFirstAddition= true;
|
|
||||||
index.acquireWriteLock(readlockCount);
|
|
||||||
long start= System.currentTimeMillis();
|
|
||||||
try {
|
|
||||||
for (int i=0; i<orderedPaths.length; i++) {
|
|
||||||
if (pm.isCanceled())
|
|
||||||
return;
|
|
||||||
|
|
||||||
IIndexFileLocation path = orderedPaths[i];
|
|
||||||
if (path != null) {
|
|
||||||
if (fShowActivity) {
|
|
||||||
System.out.println("Indexer: adding " + path.getURI()); //$NON-NLS-1$
|
|
||||||
}
|
|
||||||
IIndexFile file;
|
|
||||||
try {
|
|
||||||
file = addToIndex(index, path, symbolMap, configHash, contextIncludes);
|
|
||||||
} catch (RuntimeException e) {
|
|
||||||
stati.add(CCorePlugin.createStatus(
|
|
||||||
NLS.bind(Messages.PDOMWriter_errorWhileParsing, path.getURI().getPath()), e));
|
|
||||||
break;
|
|
||||||
} catch (PDOMNotImplementedError e) {
|
|
||||||
stati.add(CCorePlugin.createStatus(
|
|
||||||
NLS.bind(Messages.PDOMWriter_errorWhileParsing, path.getURI().getPath()), e));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
boolean wasRequested= postAddToIndex(path, file);
|
|
||||||
|
|
||||||
synchronized(fInfo) {
|
|
||||||
if (wasRequested) {
|
|
||||||
if (isFirstRequest)
|
|
||||||
isFirstRequest= false;
|
|
||||||
else
|
|
||||||
fInfo.fTotalSourcesEstimate--;
|
|
||||||
}
|
|
||||||
if (isFirstAddition)
|
|
||||||
isFirstAddition= false;
|
|
||||||
else
|
|
||||||
fInfo.fCompletedHeaders++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} finally {
|
|
||||||
index.releaseWriteLock(readlockCount, flushIndex);
|
|
||||||
}
|
|
||||||
fStatistics.fAddToIndexTime+= System.currentTimeMillis()-start;
|
|
||||||
|
|
||||||
if (taskUpdater != null) {
|
|
||||||
taskUpdater.updateTasks(ast.getComments(), orderedPaths);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
finally {
|
ArrayList stati= new ArrayList();
|
||||||
synchronized(fInfo) {
|
|
||||||
fInfo.fCompletedSources++;
|
HashSet contextIncludes= new HashSet();
|
||||||
}
|
extractSymbols(ast, symbolMap, contextIncludes);
|
||||||
|
|
||||||
|
// name resolution
|
||||||
|
resolveNames(symbolMap, ifls, stati, pm);
|
||||||
|
|
||||||
|
// index update
|
||||||
|
storeSymbolsInIndex(symbolMap, ifls, ast.getLinkage().getLinkageID(), configHash, contextIncludes, index, readlockCount, flushIndex, stati, pm);
|
||||||
|
|
||||||
|
if (taskUpdater != null) {
|
||||||
|
taskUpdater.updateTasks(ast.getComments(), ifls);
|
||||||
}
|
}
|
||||||
if (!stati.isEmpty()) {
|
if (!stati.isEmpty()) {
|
||||||
String path= null;
|
String path= null;
|
||||||
if (orderedPaths != null && orderedPaths.length > 0) {
|
if (ifls != null && ifls.length > 0) {
|
||||||
path= orderedPaths[orderedPaths.length-1].getURI().getPath();
|
path= ifls[ifls.length-1].getURI().getPath();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
path= ast.getFilePath().toString();
|
path= ast.getFilePath().toString();
|
||||||
|
@ -271,74 +148,120 @@ abstract public class PDOMWriter {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private IIndexFileLocation[] extractSymbols(IASTTranslationUnit ast,
|
private void storeSymbolsInIndex(final Map symbolMap, IIndexFileLocation[] ifls, int linkageID, int configHash,
|
||||||
final Map symbolMap, int confighash, Collection contextIncludes) throws CoreException {
|
HashSet contextIncludes, IWritableIndex index, int readlockCount, boolean flushIndex,
|
||||||
LinkedHashSet/*<IIndexFileLocation>*/ orderedIFLs= new LinkedHashSet/*<IIndexFileLocation>*/();
|
ArrayList stati, IProgressMonitor pm) throws InterruptedException, CoreException {
|
||||||
ArrayList/*<IIndexFileLocation>*/ iflStack= new ArrayList/*<IIndexFileLocation>*/();
|
index.acquireWriteLock(readlockCount);
|
||||||
HashMap firstIncludePerTarget= new HashMap();
|
long start= System.currentTimeMillis();
|
||||||
|
try {
|
||||||
final IIndexFileLocation astLocation = findLocation(ast.getFilePath());
|
for (int i=0; i<ifls.length; i++) {
|
||||||
IIndexFileLocation aboveStackIFL = astLocation;
|
if (pm.isCanceled())
|
||||||
|
return;
|
||||||
|
|
||||||
|
final IIndexFileLocation ifl= ifls[i];
|
||||||
|
if (ifl != null) {
|
||||||
|
if (fShowActivity) {
|
||||||
|
System.out.println("Indexer: adding " + ifl.getURI()); //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
storeFileInIndex(index, ifl, symbolMap, linkageID, configHash, contextIncludes);
|
||||||
|
} catch (RuntimeException e) {
|
||||||
|
stati.add(CCorePlugin.createStatus(
|
||||||
|
NLS.bind(Messages.PDOMWriter_errorWhileParsing, ifl.getURI().getPath()), e));
|
||||||
|
break;
|
||||||
|
} catch (PDOMNotImplementedError e) {
|
||||||
|
stati.add(CCorePlugin.createStatus(
|
||||||
|
NLS.bind(Messages.PDOMWriter_errorWhileParsing, ifl.getURI().getPath()), e));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (i<ifls.length-1) {
|
||||||
|
updateInfo(0, 1, 0); // update header count
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
index.releaseWriteLock(readlockCount, flushIndex);
|
||||||
|
}
|
||||||
|
fStatistics.fAddToIndexTime+= System.currentTimeMillis()-start;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void resolveNames(final Map symbolMap, IIndexFileLocation[] ifls, ArrayList stati, IProgressMonitor pm) {
|
||||||
|
long start= System.currentTimeMillis();
|
||||||
|
for (int i=0; i<ifls.length; i++) {
|
||||||
|
if (pm.isCanceled()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
IIndexFileLocation path= ifls[i];
|
||||||
|
ArrayList[] arrayLists = ((ArrayList[]) symbolMap.get(path));
|
||||||
|
|
||||||
|
ArrayList names= arrayLists[2];
|
||||||
|
boolean reported= false;
|
||||||
|
for (Iterator j = names.iterator(); j.hasNext();) {
|
||||||
|
final IASTName[] na= (IASTName[]) j.next();
|
||||||
|
final IASTName name = na[0];
|
||||||
|
try {
|
||||||
|
final IBinding binding = name.resolveBinding();
|
||||||
|
if (binding instanceof IProblemBinding)
|
||||||
|
reportProblem((IProblemBinding) binding);
|
||||||
|
else if (name.isReference()) {
|
||||||
|
if (fSkipReferences == SKIP_TYPE_REFERENCES) {
|
||||||
|
if (isTypeReferenceBinding(binding) && !isInheritanceSpec(name)) {
|
||||||
|
na[0]= null;
|
||||||
|
fStatistics.fReferenceCount--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fStatistics.fReferenceCount++;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
fStatistics.fDeclarationCount++;
|
||||||
|
}
|
||||||
|
} catch (RuntimeException e) {
|
||||||
|
if (!reported) {
|
||||||
|
stati.add(CCorePlugin.createStatus(
|
||||||
|
NLS.bind(Messages.PDOMWriter_errorResolvingName, name.toString(), path.getURI().getPath()), e));
|
||||||
|
}
|
||||||
|
reported= true;
|
||||||
|
j.remove();
|
||||||
|
} catch (PDOMNotImplementedError e) {
|
||||||
|
if (!reported) {
|
||||||
|
stati.add(CCorePlugin.createStatus(
|
||||||
|
NLS.bind(Messages.PDOMWriter_errorResolvingName, name.toString(), path.getURI().getPath()), e));
|
||||||
|
}
|
||||||
|
reported= true;
|
||||||
|
j.remove();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fStatistics.fResolutionTime += System.currentTimeMillis()-start;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void extractSymbols(IASTTranslationUnit ast, final Map symbolMap, Collection contextIncludes) throws CoreException {
|
||||||
|
|
||||||
|
final HashSet contextIFLs= new HashSet();
|
||||||
|
final IIndexFileLocation astIFL = fResolver.resolveASTPath(ast.getFilePath());
|
||||||
|
|
||||||
|
// includes
|
||||||
IASTPreprocessorIncludeStatement[] includes = ast.getIncludeDirectives();
|
IASTPreprocessorIncludeStatement[] includes = ast.getIncludeDirectives();
|
||||||
for (int i= 0; i < includes.length; i++) {
|
for (int i= 0; i < includes.length; i++) {
|
||||||
final IASTPreprocessorIncludeStatement include = includes[i];
|
final IASTPreprocessorIncludeStatement include = includes[i];
|
||||||
|
final IASTFileLocation astLoc= include.getFileLocation();
|
||||||
// check if we have left a file.
|
final IIndexFileLocation sourceIFL= astLoc != null ? fResolver.resolveASTPath(astLoc.getFileName()) : astIFL; // command-line includes
|
||||||
final IASTFileLocation tmpLoc = include.getFileLocation();
|
final boolean updateSource= symbolMap.containsKey(sourceIFL);
|
||||||
final IIndexFileLocation nextIFL= tmpLoc != null ? findLocation(tmpLoc.getFileName()) : astLocation; // command-line includes
|
if (updateSource) {
|
||||||
while (!aboveStackIFL.equals(nextIFL)) {
|
addToMap(symbolMap, 0, sourceIFL, include);
|
||||||
if (!iflStack.isEmpty()) {
|
|
||||||
if (needToUpdate(aboveStackIFL, confighash)) {
|
|
||||||
prepareInMap(symbolMap, aboveStackIFL);
|
|
||||||
orderedIFLs.add(aboveStackIFL);
|
|
||||||
}
|
|
||||||
aboveStackIFL= (IIndexFileLocation) iflStack.remove(iflStack.size()-1);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
assert false; // logics in parser is broken, still do something useful
|
|
||||||
iflStack.add(aboveStackIFL);
|
|
||||||
aboveStackIFL= nextIFL;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
if (include.isActive()) {
|
||||||
// save include in map
|
if (!include.isResolved()) {
|
||||||
if (needToUpdate(nextIFL, confighash)) {
|
reportProblem(include);
|
||||||
prepareInMap(symbolMap, nextIFL);
|
}
|
||||||
addToMap(symbolMap, 0, nextIFL, include);
|
else if (updateSource) {
|
||||||
}
|
// the include was parsed, check if we want to update the included file in the index
|
||||||
|
final IIndexFileLocation targetIFL= fResolver.resolveASTPath(include.getPath());
|
||||||
// prepare to go into next level
|
if (symbolMap.containsKey(targetIFL) && contextIFLs.add(targetIFL)) {
|
||||||
if (include.isResolved()) {
|
contextIncludes.add(include);
|
||||||
iflStack.add(nextIFL);
|
|
||||||
aboveStackIFL= findLocation(include.getPath());
|
|
||||||
if (include.isActive()) {
|
|
||||||
if (!firstIncludePerTarget.containsKey(aboveStackIFL)) {
|
|
||||||
firstIncludePerTarget.put(aboveStackIFL, include);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (include.isActive()) {
|
|
||||||
reportProblem(include);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
iflStack.add(aboveStackIFL);
|
|
||||||
while (!iflStack.isEmpty()) {
|
|
||||||
aboveStackIFL= (IIndexFileLocation) iflStack.remove(iflStack.size()-1);
|
|
||||||
if (needToUpdate(aboveStackIFL, confighash)) {
|
|
||||||
prepareInMap(symbolMap, aboveStackIFL);
|
|
||||||
orderedIFLs.add(aboveStackIFL);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// extract context includes
|
|
||||||
for (Iterator iterator = orderedIFLs.iterator(); iterator.hasNext();) {
|
|
||||||
IndexFileLocation loc = (IndexFileLocation) iterator.next();
|
|
||||||
Object contextInclude= firstIncludePerTarget.get(loc);
|
|
||||||
if (contextInclude != null) {
|
|
||||||
contextIncludes.add(contextInclude);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// macros
|
// macros
|
||||||
|
@ -347,7 +270,7 @@ abstract public class PDOMWriter {
|
||||||
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
|
||||||
IIndexFileLocation path2 = findLocation(sourceLoc.getFileName());
|
IIndexFileLocation path2 = fResolver.resolveASTPath(sourceLoc.getFileName());
|
||||||
addToMap(symbolMap, 1, path2, macro);
|
addToMap(symbolMap, 1, path2, macro);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -368,13 +291,12 @@ abstract public class PDOMWriter {
|
||||||
if (name != null) {
|
if (name != null) {
|
||||||
IASTFileLocation nameLoc = name.getFileLocation();
|
IASTFileLocation nameLoc = name.getFileLocation();
|
||||||
if (nameLoc != null) {
|
if (nameLoc != null) {
|
||||||
IIndexFileLocation location = findLocation(nameLoc.getFileName());
|
IIndexFileLocation location = fResolver.resolveASTPath(nameLoc.getFileName());
|
||||||
addToMap(symbolMap, 2, location, new IASTName[]{name, caller});
|
addToMap(symbolMap, 2, location, new IASTName[]{name, caller});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return (IIndexFileLocation[]) orderedIFLs.toArray(new IIndexFileLocation[orderedIFLs.size()]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean isInheritanceSpec(IASTName name) {
|
protected boolean isInheritanceSpec(IASTName name) {
|
||||||
|
@ -439,16 +361,17 @@ abstract public class PDOMWriter {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private IIndexFragmentFile addToIndex(IWritableIndex index, IIndexFileLocation location, Map symbolMap, int configHash, Set contextIncludes) throws CoreException {
|
private IIndexFragmentFile storeFileInIndex(IWritableIndex index, IIndexFileLocation location, Map symbolMap,
|
||||||
|
int linkageID, int configHash, Set contextIncludes) throws CoreException {
|
||||||
Set clearedContexts= Collections.EMPTY_SET;
|
Set clearedContexts= Collections.EMPTY_SET;
|
||||||
IIndexFragmentFile file= index.getWritableFile(location);
|
IIndexFragmentFile file= index.getWritableFile(linkageID, location);
|
||||||
if (file != null) {
|
if (file != null) {
|
||||||
clearedContexts= new HashSet();
|
clearedContexts= new HashSet();
|
||||||
index.clearFile(file, clearedContexts);
|
index.clearFile(file, clearedContexts);
|
||||||
} else {
|
} else {
|
||||||
file= index.addFile(location);
|
file= index.addFile(linkageID, location);
|
||||||
}
|
}
|
||||||
file.setTimestamp(getLastModified(location));
|
file.setTimestamp(fResolver.getLastModified(location));
|
||||||
file.setScannerConfigurationHashcode(configHash);
|
file.setScannerConfigurationHashcode(configHash);
|
||||||
ArrayList[] lists= (ArrayList[]) symbolMap.get(location);
|
ArrayList[] lists= (ArrayList[]) symbolMap.get(location);
|
||||||
if (lists != null) {
|
if (lists != null) {
|
||||||
|
@ -470,13 +393,12 @@ abstract public class PDOMWriter {
|
||||||
final IncludeInformation info= includeInfos[i]= new IncludeInformation();
|
final IncludeInformation info= includeInfos[i]= new IncludeInformation();
|
||||||
info.fStatement= include;
|
info.fStatement= include;
|
||||||
if (include.isResolved()) {
|
if (include.isResolved()) {
|
||||||
info.fLocation= findLocation(include.getPath());
|
info.fLocation= fResolver.resolveASTPath(include.getPath());
|
||||||
info.fIsContext= include.isActive() &&
|
info.fIsContext= include.isActive() &&
|
||||||
(contextIncludes.contains(include) ||
|
(contextIncludes.contains(include) || clearedContexts.contains(info.fLocation));
|
||||||
clearedContexts.contains(info.fLocation));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
index.setFileContent(file, includeInfos, macros, names);
|
index.setFileContent(file, linkageID, includeInfos, macros, names);
|
||||||
}
|
}
|
||||||
return file;
|
return file;
|
||||||
}
|
}
|
||||||
|
@ -502,15 +424,4 @@ abstract public class PDOMWriter {
|
||||||
fInfo.fTotalSourcesEstimate+= totalEstimate;
|
fInfo.fTotalSourcesEstimate+= totalEstimate;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Obtains the timestamp of an index file location.
|
|
||||||
* @param location the location for which the timestamp is obtained.
|
|
||||||
* @return the timestamp.
|
|
||||||
* @throws CoreException
|
|
||||||
* @since 4.0
|
|
||||||
*/
|
|
||||||
protected long getLastModified(IIndexFileLocation location) throws CoreException {
|
|
||||||
return EFS.getStore(location.getURI()).fetchInfo().getLastModified();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,20 +20,20 @@ import java.io.ObjectOutputStream;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
import java.security.MessageDigest;
|
import java.security.MessageDigest;
|
||||||
import java.security.NoSuchAlgorithmException;
|
import java.security.NoSuchAlgorithmException;
|
||||||
|
import java.util.HashSet;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.zip.Deflater;
|
import java.util.zip.Deflater;
|
||||||
import java.util.zip.ZipEntry;
|
import java.util.zip.ZipEntry;
|
||||||
import java.util.zip.ZipOutputStream;
|
import java.util.zip.ZipOutputStream;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.CCorePlugin;
|
import org.eclipse.cdt.core.CCorePlugin;
|
||||||
|
import org.eclipse.cdt.core.index.IIndexFile;
|
||||||
import org.eclipse.cdt.core.index.IIndexLocationConverter;
|
import org.eclipse.cdt.core.index.IIndexLocationConverter;
|
||||||
import org.eclipse.cdt.core.index.ResourceContainerRelativeLocationConverter;
|
import org.eclipse.cdt.core.index.ResourceContainerRelativeLocationConverter;
|
||||||
import org.eclipse.cdt.core.model.ICProject;
|
import org.eclipse.cdt.core.model.ICProject;
|
||||||
import org.eclipse.cdt.core.model.LanguageManager;
|
import org.eclipse.cdt.core.model.LanguageManager;
|
||||||
import org.eclipse.cdt.internal.core.CCoreInternals;
|
import org.eclipse.cdt.internal.core.CCoreInternals;
|
||||||
import org.eclipse.cdt.internal.core.index.IndexFileLocation;
|
|
||||||
import org.eclipse.cdt.internal.core.pdom.indexer.IndexerPreferences;
|
import org.eclipse.cdt.internal.core.pdom.indexer.IndexerPreferences;
|
||||||
import org.eclipse.core.resources.IFile;
|
import org.eclipse.core.resources.IFile;
|
||||||
import org.eclipse.core.resources.IWorkspaceRoot;
|
import org.eclipse.core.resources.IWorkspaceRoot;
|
||||||
|
@ -144,27 +144,30 @@ public class TeamPDOMExportOperation implements IWorkspaceRunnable {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createChecksums(ICProject cproject, PDOM pdom, File target, IProgressMonitor monitor) throws CoreException {
|
private void createChecksums(ICProject cproject, PDOM pdom, File target, IProgressMonitor monitor) throws CoreException {
|
||||||
List locs;
|
HashSet fullPaths= new HashSet();
|
||||||
try {
|
try {
|
||||||
pdom.acquireReadLock();
|
pdom.acquireReadLock();
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
throw new OperationCanceledException();
|
throw new OperationCanceledException();
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
locs = pdom.getAllFileLocations();
|
IIndexFile[] ifiles= pdom.getAllFiles();
|
||||||
|
for (int i = 0; i < ifiles.length; i++) {
|
||||||
|
String fullPath= ifiles[i].getLocation().getFullPath();
|
||||||
|
if (fullPath != null) {
|
||||||
|
fullPaths.add(fullPath);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
pdom.releaseReadLock();
|
pdom.releaseReadLock();
|
||||||
}
|
}
|
||||||
int i=0;
|
int i=0;
|
||||||
IWorkspaceRoot root= ResourcesPlugin.getWorkspace().getRoot();
|
IWorkspaceRoot root= ResourcesPlugin.getWorkspace().getRoot();
|
||||||
IFile[] files= new IFile[locs.size()];
|
IFile[] files= new IFile[fullPaths.size()];
|
||||||
for (Iterator iterator = locs.iterator(); iterator.hasNext();) {
|
for (Iterator iterator = fullPaths.iterator(); iterator.hasNext();) {
|
||||||
IndexFileLocation floc = (IndexFileLocation) iterator.next();
|
String fullPath= (String) iterator.next();
|
||||||
String fullPath= floc.getFullPath();
|
files[i++]= root.getFile(new Path(fullPath));
|
||||||
if (fullPath != null) {
|
|
||||||
files[i++]= root.getFile(new Path(fullPath));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
Map map= Checksums.createChecksumMap(files, fMessageDigest, monitor);
|
Map map= Checksums.createChecksumMap(files, fMessageDigest, monitor);
|
||||||
writeChecksums(map, target);
|
writeChecksums(map, target);
|
||||||
|
|
|
@ -31,13 +31,11 @@ import java.util.zip.ZipFile;
|
||||||
import org.eclipse.cdt.core.CCorePlugin;
|
import org.eclipse.cdt.core.CCorePlugin;
|
||||||
import org.eclipse.cdt.core.dom.IPDOMIndexerTask;
|
import org.eclipse.cdt.core.dom.IPDOMIndexerTask;
|
||||||
import org.eclipse.cdt.core.index.IIndexFileLocation;
|
import org.eclipse.cdt.core.index.IIndexFileLocation;
|
||||||
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.ITranslationUnit;
|
import org.eclipse.cdt.core.model.ITranslationUnit;
|
||||||
import org.eclipse.cdt.internal.core.CCoreInternals;
|
import org.eclipse.cdt.internal.core.CCoreInternals;
|
||||||
import org.eclipse.cdt.internal.core.index.IIndexFragmentFile;
|
import org.eclipse.cdt.internal.core.index.IIndexFragmentFile;
|
||||||
import org.eclipse.cdt.internal.core.index.IndexFileLocation;
|
|
||||||
import org.eclipse.cdt.internal.core.pdom.indexer.IndexerPreferences;
|
import org.eclipse.cdt.internal.core.pdom.indexer.IndexerPreferences;
|
||||||
import org.eclipse.cdt.internal.core.pdom.indexer.Messages;
|
import org.eclipse.cdt.internal.core.pdom.indexer.Messages;
|
||||||
import org.eclipse.cdt.internal.core.pdom.indexer.PDOMIndexerTask;
|
import org.eclipse.cdt.internal.core.pdom.indexer.PDOMIndexerTask;
|
||||||
|
@ -68,9 +66,11 @@ public class TeamPDOMImportOperation implements IWorkspaceRunnable {
|
||||||
|
|
||||||
private static final class FileAndChecksum {
|
private static final class FileAndChecksum {
|
||||||
public ITranslationUnit fFile;
|
public ITranslationUnit fFile;
|
||||||
|
public IIndexFragmentFile fIFile;
|
||||||
public byte[] fChecksum;
|
public byte[] fChecksum;
|
||||||
public FileAndChecksum(ITranslationUnit tu, byte[] checksum) {
|
public FileAndChecksum(ITranslationUnit tu, IIndexFragmentFile ifile, byte[] checksum) {
|
||||||
fFile= tu;
|
fFile= tu;
|
||||||
|
fIFile= ifile;
|
||||||
fChecksum= checksum;
|
fChecksum= checksum;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -193,8 +193,6 @@ public class TeamPDOMImportOperation implements IWorkspaceRunnable {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkIndex(Map checksums, IProgressMonitor monitor) throws CoreException, InterruptedException {
|
private void checkIndex(Map checksums, IProgressMonitor monitor) throws CoreException, InterruptedException {
|
||||||
List filesToCheck= new ArrayList();
|
|
||||||
|
|
||||||
IPDOM obj= CCoreInternals.getPDOMManager().getPDOM(fProject);
|
IPDOM obj= CCoreInternals.getPDOMManager().getPDOM(fProject);
|
||||||
if (!(obj instanceof WritablePDOM)) {
|
if (!(obj instanceof WritablePDOM)) {
|
||||||
return;
|
return;
|
||||||
|
@ -203,20 +201,22 @@ public class TeamPDOMImportOperation implements IWorkspaceRunnable {
|
||||||
WritablePDOM pdom= (WritablePDOM) obj;
|
WritablePDOM pdom= (WritablePDOM) obj;
|
||||||
pdom.acquireReadLock();
|
pdom.acquireReadLock();
|
||||||
try {
|
try {
|
||||||
|
List filesToCheck= new ArrayList();
|
||||||
if (!pdom.isSupportedVersion()) {
|
if (!pdom.isSupportedVersion()) {
|
||||||
throw new CoreException(CCorePlugin.createStatus(
|
throw new CoreException(CCorePlugin.createStatus(
|
||||||
NLS.bind(Messages.PDOMImportTask_errorInvalidPDOMVersion, fProject.getElementName())));
|
NLS.bind(Messages.PDOMImportTask_errorInvalidPDOMVersion, fProject.getElementName())));
|
||||||
}
|
}
|
||||||
|
|
||||||
final IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
|
final IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
|
||||||
List filesToDelete= pdom.getAllFileLocations();
|
IIndexFragmentFile[] filesToDelete= pdom.getAllFiles();
|
||||||
for (Iterator i = filesToDelete.iterator(); i.hasNext();) {
|
for (int i = 0; i < filesToDelete.length; i++) {
|
||||||
checkMonitor(monitor);
|
checkMonitor(monitor);
|
||||||
|
IIndexFragmentFile ifile = filesToDelete[i];
|
||||||
|
|
||||||
byte[] checksum= null;
|
byte[] checksum= null;
|
||||||
ITranslationUnit tu= null;
|
ITranslationUnit tu= null;
|
||||||
|
|
||||||
IIndexFileLocation ifl = (IIndexFileLocation) i.next();
|
IIndexFileLocation ifl = ifile.getLocation();
|
||||||
String fullPathStr= ifl.getFullPath();
|
String fullPathStr= ifl.getFullPath();
|
||||||
if (fullPathStr != null) {
|
if (fullPathStr != null) {
|
||||||
Path fullPath= new Path(fullPathStr);
|
Path fullPath= new Path(fullPathStr);
|
||||||
|
@ -238,8 +238,8 @@ public class TeamPDOMImportOperation implements IWorkspaceRunnable {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (checksum != null) {
|
if (checksum != null) {
|
||||||
filesToCheck.add(new FileAndChecksum(tu, checksum));
|
filesToCheck.add(new FileAndChecksum(tu, ifile, checksum));
|
||||||
i.remove();
|
filesToDelete[i]= null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
|
@ -261,22 +261,22 @@ public class TeamPDOMImportOperation implements IWorkspaceRunnable {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void deleteFiles(WritablePDOM pdom, final int giveupReadlocks, List filesToDelete,
|
private void deleteFiles(WritablePDOM pdom, final int giveupReadlocks, IIndexFragmentFile[] filesToDelete,
|
||||||
List updateTimestamps, IProgressMonitor monitor) throws InterruptedException, CoreException {
|
List updateTimestamps, IProgressMonitor monitor) throws InterruptedException, CoreException {
|
||||||
pdom.acquireWriteLock(giveupReadlocks);
|
pdom.acquireWriteLock(giveupReadlocks);
|
||||||
try {
|
try {
|
||||||
for (Iterator i = filesToDelete.iterator(); i.hasNext();) {
|
for (int i = 0; i < filesToDelete.length; i++) {
|
||||||
checkMonitor(monitor);
|
IIndexFragmentFile ifile = filesToDelete[i];
|
||||||
|
if (ifile != null) {
|
||||||
IndexFileLocation ifl = (IndexFileLocation) i.next();
|
checkMonitor(monitor);
|
||||||
IIndexFragmentFile file= pdom.getFile(ifl);
|
pdom.clearFile(ifile, null);
|
||||||
pdom.clearFile(file, null);
|
}
|
||||||
}
|
}
|
||||||
for (Iterator i = updateTimestamps.iterator(); i.hasNext();) {
|
for (Iterator i = updateTimestamps.iterator(); i.hasNext();) {
|
||||||
checkMonitor(monitor);
|
checkMonitor(monitor);
|
||||||
|
|
||||||
FileAndChecksum fc = (FileAndChecksum) i.next();
|
FileAndChecksum fc = (FileAndChecksum) i.next();
|
||||||
IIndexFragmentFile file= pdom.getFile(IndexLocationFactory.getIFL(fc.fFile));
|
IIndexFragmentFile file= fc.fIFile;
|
||||||
if (file != null) {
|
if (file != null) {
|
||||||
IResource r= fc.fFile.getResource();
|
IResource r= fc.fFile.getResource();
|
||||||
if (r != null) {
|
if (r != null) {
|
||||||
|
|
|
@ -49,8 +49,8 @@ public class WritablePDOM extends PDOM implements IWritableIndexFragment {
|
||||||
super(dbPath, locationConverter, cache, linkageFactoryMappings);
|
super(dbPath, locationConverter, cache, linkageFactoryMappings);
|
||||||
}
|
}
|
||||||
|
|
||||||
public IIndexFragmentFile addFile(IIndexFileLocation location) throws CoreException {
|
public IIndexFragmentFile addFile(int linkageID, IIndexFileLocation location) throws CoreException {
|
||||||
return super.addFile(location);
|
return super.addFile(linkageID, location);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addFileContent(IIndexFragmentFile sourceFile,
|
public void addFileContent(IIndexFragmentFile sourceFile,
|
||||||
|
|
|
@ -54,10 +54,11 @@ public class PDOMFile implements IIndexFragmentFile {
|
||||||
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 LOCATION_REPRESENTATION = 16;
|
private static final int LOCATION_REPRESENTATION = 16;
|
||||||
private static final int TIME_STAMP = 20;
|
private static final int LINKAGE_ID= 20;
|
||||||
private static final int SCANNER_CONFIG_HASH= 28;
|
private static final int TIME_STAMP = 24;
|
||||||
|
private static final int SCANNER_CONFIG_HASH= 32;
|
||||||
|
|
||||||
private static final int RECORD_SIZE = 32;
|
private static final int RECORD_SIZE = 36;
|
||||||
|
|
||||||
public static class Comparator implements IBTreeComparator {
|
public static class Comparator implements IBTreeComparator {
|
||||||
private Database db;
|
private Database db;
|
||||||
|
@ -69,7 +70,11 @@ public class PDOMFile implements IIndexFragmentFile {
|
||||||
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 + LOCATION_REPRESENTATION));
|
IString name1 = db.getString(db.getInt(record1 + LOCATION_REPRESENTATION));
|
||||||
IString name2 = db.getString(db.getInt(record2 + LOCATION_REPRESENTATION));
|
IString name2 = db.getString(db.getInt(record2 + LOCATION_REPRESENTATION));
|
||||||
return name1.compare(name2, true);
|
int cmp= name1.compare(name2, true);
|
||||||
|
if (cmp == 0) {
|
||||||
|
cmp= db.getInt(record1+LINKAGE_ID) - db.getInt(record2+LINKAGE_ID);
|
||||||
|
}
|
||||||
|
return cmp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -78,7 +83,7 @@ public class PDOMFile implements IIndexFragmentFile {
|
||||||
this.record = record;
|
this.record = record;
|
||||||
}
|
}
|
||||||
|
|
||||||
public PDOMFile(PDOM pdom, IIndexFileLocation location) throws CoreException {
|
public PDOMFile(PDOM pdom, IIndexFileLocation location, int linkageID) 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);
|
||||||
|
@ -87,10 +92,12 @@ public class PDOMFile implements IIndexFragmentFile {
|
||||||
throw new CoreException(CCorePlugin.createStatus(Messages.getString("PDOMFile.toInternalProblem")+location.getURI())); //$NON-NLS-1$
|
throw new CoreException(CCorePlugin.createStatus(Messages.getString("PDOMFile.toInternalProblem")+location.getURI())); //$NON-NLS-1$
|
||||||
IString locationDBString = db.newString(locationString);
|
IString locationDBString = db.newString(locationString);
|
||||||
db.putInt(record + LOCATION_REPRESENTATION, locationDBString.getRecord());
|
db.putInt(record + LOCATION_REPRESENTATION, locationDBString.getRecord());
|
||||||
|
db.putInt(record + LINKAGE_ID, linkageID);
|
||||||
db.putLong(record + TIME_STAMP, 0);
|
db.putLong(record + TIME_STAMP, 0);
|
||||||
setFirstName(null);
|
setFirstName(null);
|
||||||
setFirstInclude(null);
|
setFirstInclude(null);
|
||||||
setFirstIncludedBy(null);
|
setFirstIncludedBy(null);
|
||||||
|
setTimestamp(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getRecord() {
|
public int getRecord() {
|
||||||
|
@ -124,6 +131,11 @@ public class PDOMFile implements IIndexFragmentFile {
|
||||||
db.free(oldRecord);
|
db.free(oldRecord);
|
||||||
db.putInt(record + LOCATION_REPRESENTATION, db.newString(internalLocation).getRecord());
|
db.putInt(record + LOCATION_REPRESENTATION, db.newString(internalLocation).getRecord());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getLinkageID() throws CoreException {
|
||||||
|
Database db = pdom.getDB();
|
||||||
|
return db.getInt(record + LINKAGE_ID);
|
||||||
|
}
|
||||||
|
|
||||||
public long getTimestamp() throws CoreException {
|
public long getTimestamp() throws CoreException {
|
||||||
Database db = pdom.getDB();
|
Database db = pdom.getDB();
|
||||||
|
@ -281,6 +293,7 @@ public class PDOMFile implements IIndexFragmentFile {
|
||||||
name.delete();
|
name.delete();
|
||||||
}
|
}
|
||||||
setFirstName(null);
|
setFirstName(null);
|
||||||
|
setTimestamp(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addIncludesTo(IncludeInformation[] includeInfos) throws CoreException {
|
public void addIncludesTo(IncludeInformation[] includeInfos) throws CoreException {
|
||||||
|
@ -374,38 +387,88 @@ public class PDOMFile implements IIndexFragmentFile {
|
||||||
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)
|
public static IIndexFragmentFile findFile(PDOM pdom, BTree btree, IIndexFileLocation location, int linkageID, IIndexLocationConverter strategy)
|
||||||
throws CoreException {
|
throws CoreException {
|
||||||
String internalRepresentation= strategy.toInternalFormat(location);
|
String internalRepresentation= strategy.toInternalFormat(location);
|
||||||
int record= 0;
|
int record= 0;
|
||||||
if(internalRepresentation!=null) {
|
if(internalRepresentation!=null) {
|
||||||
Finder finder = new Finder(pdom.getDB(), internalRepresentation);
|
Finder finder = new Finder(pdom.getDB(), internalRepresentation, linkageID);
|
||||||
btree.accept(finder);
|
btree.accept(finder);
|
||||||
record= finder.getRecord();
|
record= finder.getRecord();
|
||||||
}
|
}
|
||||||
return record != 0 ? new PDOMFile(pdom, record) : null;
|
return record != 0 ? new PDOMFile(pdom, record) : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static IIndexFragmentFile[] findFiles(PDOM pdom, BTree btree, IIndexFileLocation location, IIndexLocationConverter strategy)
|
||||||
|
throws CoreException {
|
||||||
|
String internalRepresentation= strategy.toInternalFormat(location);
|
||||||
|
if(internalRepresentation!=null) {
|
||||||
|
Finder finder = new Finder(pdom.getDB(), internalRepresentation, -1);
|
||||||
|
btree.accept(finder);
|
||||||
|
int[] records= finder.getRecords();
|
||||||
|
PDOMFile[] result= new PDOMFile[records.length];
|
||||||
|
for (int i = 0; i < result.length; i++) {
|
||||||
|
result[i]= new PDOMFile(pdom, records[i]);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
return new IIndexFragmentFile[0];
|
||||||
|
}
|
||||||
|
|
||||||
private static class Finder implements IBTreeVisitor {
|
private static class Finder implements IBTreeVisitor {
|
||||||
|
private static final int[] EMPTY = {};
|
||||||
private final Database db;
|
private final Database db;
|
||||||
private final String rawKey;
|
private final String rawKey;
|
||||||
private int record;
|
private int record;
|
||||||
|
private int[] records;
|
||||||
|
private final int linkageID;
|
||||||
|
|
||||||
public Finder(Database db, String internalRepresentation)
|
/**
|
||||||
throws CoreException
|
* Searches for a file with the given linkage id.
|
||||||
{
|
*/
|
||||||
|
public Finder(Database db, String internalRepresentation, int linkageID) {
|
||||||
this.db = db;
|
this.db = db;
|
||||||
this.rawKey = internalRepresentation;
|
this.rawKey = internalRepresentation;
|
||||||
|
this.linkageID= linkageID;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int[] getRecords() {
|
||||||
|
if (records == null) {
|
||||||
|
if (record == 0) {
|
||||||
|
return EMPTY;
|
||||||
|
}
|
||||||
|
return new int[] {record};
|
||||||
|
}
|
||||||
|
return records;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int compare(int record) throws CoreException {
|
public int compare(int record) throws CoreException {
|
||||||
IString name = db.getString(db.getInt(record + PDOMFile.LOCATION_REPRESENTATION));
|
IString name = db.getString(db.getInt(record + PDOMFile.LOCATION_REPRESENTATION));
|
||||||
return name.compare(rawKey, true);
|
int cmp= name.compare(rawKey, true);
|
||||||
|
if (cmp == 0 && linkageID >= 0) {
|
||||||
|
cmp= db.getInt(record + PDOMFile.LINKAGE_ID) - linkageID;
|
||||||
|
}
|
||||||
|
return cmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean visit(int record) throws CoreException {
|
public boolean visit(int record) throws CoreException {
|
||||||
this.record = record;
|
if (linkageID >= 0) {
|
||||||
return false;
|
this.record = record;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (this.record == 0) {
|
||||||
|
this.record= record;
|
||||||
|
}
|
||||||
|
else if (this.records == null) {
|
||||||
|
this.records= new int[] {this.record, record};
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
int[] cpy= new int[this.records.length+1];
|
||||||
|
System.arraycopy(this.records, 0, cpy, 0, this.records.length);
|
||||||
|
cpy[cpy.length-1]= record;
|
||||||
|
this.records= cpy;
|
||||||
|
}
|
||||||
|
return linkageID < 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getRecord() {
|
public int getRecord() {
|
||||||
|
@ -422,8 +485,8 @@ public class PDOMFile implements IIndexFragmentFile {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasNames() throws CoreException {
|
public boolean hasContent() throws CoreException {
|
||||||
return getFirstName()!=null || getFirstMacro() != null || getFirstInclude() != null;
|
return getTimestamp() != -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void convertIncludersToUnresolved() throws CoreException {
|
public void convertIncludersToUnresolved() throws CoreException {
|
||||||
|
|
|
@ -18,6 +18,9 @@ import java.util.Properties;
|
||||||
import org.eclipse.cdt.core.dom.IPDOMIndexer;
|
import org.eclipse.cdt.core.dom.IPDOMIndexer;
|
||||||
import org.eclipse.cdt.core.model.ICProject;
|
import org.eclipse.cdt.core.model.ICProject;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Abstract base class for all indexers.
|
||||||
|
*/
|
||||||
public abstract class AbstractPDOMIndexer implements IPDOMIndexer {
|
public abstract class AbstractPDOMIndexer implements IPDOMIndexer {
|
||||||
|
|
||||||
protected ICProject project;
|
protected ICProject project;
|
||||||
|
|
|
@ -74,7 +74,7 @@ public class DeltaAnalyzer {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void collectSources(ICContainer container, Collection sources) throws CoreException {
|
private void collectSources(ICContainer container, Collection sources) throws CoreException {
|
||||||
container.accept(new TranslationUnitCollector(sources, sources, true, new NullProgressMonitor()));
|
container.accept(new TranslationUnitCollector(sources, sources, new NullProgressMonitor()));
|
||||||
}
|
}
|
||||||
|
|
||||||
public ITranslationUnit[] getAddedTUs() {
|
public ITranslationUnit[] getAddedTUs() {
|
||||||
|
|
|
@ -18,9 +18,6 @@ public class Messages extends NLS {
|
||||||
public static String PDOMImportTask_errorInvalidArchive;
|
public static String PDOMImportTask_errorInvalidArchive;
|
||||||
public static String PDOMImportTask_errorInvalidPDOMVersion;
|
public static String PDOMImportTask_errorInvalidPDOMVersion;
|
||||||
public static String PDOMIndexerTask_collectingFilesTask;
|
public static String PDOMIndexerTask_collectingFilesTask;
|
||||||
public static String PDOMIndexerTask_errorWhileParsing;
|
|
||||||
public static String PDOMIndexerTask_parsingFileTask;
|
|
||||||
public static String PDOMIndexerTask_tooManyIndexProblems;
|
|
||||||
public static String TodoTaskUpdater_DeleteJob;
|
public static String TodoTaskUpdater_DeleteJob;
|
||||||
public static String TodoTaskUpdater_taskFormat;
|
public static String TodoTaskUpdater_taskFormat;
|
||||||
public static String TodoTaskUpdater_UpdateJob;
|
public static String TodoTaskUpdater_UpdateJob;
|
||||||
|
|
|
@ -6,21 +6,19 @@
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* QNX - Initial API and implementation
|
* QNX - Initial API and implementation
|
||||||
* Markus Schorn (Wind River Systems)
|
* Markus Schorn (Wind River Systems)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
package org.eclipse.cdt.internal.core.pdom.indexer.fast;
|
package org.eclipse.cdt.internal.core.pdom.indexer;
|
||||||
|
|
||||||
|
|
||||||
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.model.ITranslationUnit;
|
import org.eclipse.cdt.core.model.ITranslationUnit;
|
||||||
import org.eclipse.cdt.internal.core.pdom.indexer.AbstractPDOMIndexer;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Doug Schaefer
|
* Configures the abstract indexer to return tasks suitable for fast indexing.
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public class PDOMFastIndexer extends AbstractPDOMIndexer {
|
public class PDOMFastIndexer extends AbstractPDOMIndexer {
|
||||||
// Must match extension id
|
// Must match extension id
|
||||||
|
@ -30,8 +28,7 @@ public class PDOMFastIndexer extends AbstractPDOMIndexer {
|
||||||
return ID;
|
return ID;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IPDOMIndexerTask createTask(ITranslationUnit[] added,
|
public IPDOMIndexerTask createTask(ITranslationUnit[] added, ITranslationUnit[] changed, ITranslationUnit[] removed) {
|
||||||
ITranslationUnit[] changed, ITranslationUnit[] removed) {
|
|
||||||
return new PDOMFastIndexerTask(this, added, changed, removed);
|
return new PDOMFastIndexerTask(this, added, changed, removed);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -0,0 +1,30 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2006, 2007 QNX Software Systems 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:
|
||||||
|
* QNX - Initial API and implementation
|
||||||
|
* Markus Schorn (Wind River Systems)
|
||||||
|
*******************************************************************************/
|
||||||
|
|
||||||
|
package org.eclipse.cdt.internal.core.pdom.indexer;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.dom.ICodeReaderFactory;
|
||||||
|
import org.eclipse.cdt.core.model.ITranslationUnit;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Configures the abstract indexer to return tasks suitable for fast indexing.
|
||||||
|
*/
|
||||||
|
class PDOMFastIndexerTask extends PDOMIndexerTask {
|
||||||
|
public PDOMFastIndexerTask(PDOMFastIndexer indexer, ITranslationUnit[] added,
|
||||||
|
ITranslationUnit[] changed, ITranslationUnit[] removed) {
|
||||||
|
super(added, changed, removed, indexer, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected ICodeReaderFactory createReaderFactory() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
|
@ -6,16 +6,15 @@
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* QNX - Initial API and implementation
|
* QNX - Initial API and implementation
|
||||||
* Markus Schorn (Wind River Systems)
|
* Markus Schorn (Wind River Systems)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
package org.eclipse.cdt.internal.core.pdom.indexer.full;
|
package org.eclipse.cdt.internal.core.pdom.indexer;
|
||||||
|
|
||||||
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.model.ITranslationUnit;
|
import org.eclipse.cdt.core.model.ITranslationUnit;
|
||||||
import org.eclipse.cdt.internal.core.pdom.indexer.AbstractPDOMIndexer;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Full indexer does full parsing in order to gather index information.
|
* The Full indexer does full parsing in order to gather index information.
|
|
@ -0,0 +1,32 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2006, 2007 QNX Software Systems 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:
|
||||||
|
* QNX - Initial API and implementation
|
||||||
|
* Markus Schorn (Wind River Systems)
|
||||||
|
*******************************************************************************/
|
||||||
|
|
||||||
|
package org.eclipse.cdt.internal.core.pdom.indexer;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.dom.ICodeReaderFactory;
|
||||||
|
import org.eclipse.cdt.core.model.ITranslationUnit;
|
||||||
|
import org.eclipse.cdt.internal.core.dom.SavedCodeReaderFactory;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Configures the indexer task as a fast indexer task.
|
||||||
|
*/
|
||||||
|
class PDOMFullIndexerTask extends PDOMIndexerTask {
|
||||||
|
public PDOMFullIndexerTask(PDOMFullIndexer indexer, ITranslationUnit[] added,
|
||||||
|
ITranslationUnit[] changed, ITranslationUnit[] removed) {
|
||||||
|
super(added, changed, removed, indexer, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected ICodeReaderFactory createReaderFactory() {
|
||||||
|
return SavedCodeReaderFactory.getInstance();
|
||||||
|
}
|
||||||
|
}
|
|
@ -12,70 +12,44 @@
|
||||||
|
|
||||||
package org.eclipse.cdt.internal.core.pdom.indexer;
|
package org.eclipse.cdt.internal.core.pdom.indexer;
|
||||||
|
|
||||||
import java.net.URI;
|
|
||||||
import java.text.MessageFormat;
|
|
||||||
import java.text.NumberFormat;
|
import java.text.NumberFormat;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import org.eclipse.cdt.core.CCorePlugin;
|
import org.eclipse.cdt.core.CCorePlugin;
|
||||||
|
import org.eclipse.cdt.core.dom.ILinkage;
|
||||||
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.index.IIndex;
|
|
||||||
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.IIndexManager;
|
|
||||||
import org.eclipse.cdt.core.index.IndexLocationFactory;
|
|
||||||
import org.eclipse.cdt.core.model.AbstractLanguage;
|
import org.eclipse.cdt.core.model.AbstractLanguage;
|
||||||
import org.eclipse.cdt.core.model.CoreModelUtil;
|
|
||||||
import org.eclipse.cdt.core.model.ICProject;
|
import org.eclipse.cdt.core.model.ICProject;
|
||||||
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.model.LanguageManager;
|
import org.eclipse.cdt.core.model.LanguageManager;
|
||||||
import org.eclipse.cdt.core.parser.CodeReader;
|
|
||||||
import org.eclipse.cdt.core.parser.IExtendedScannerInfo;
|
|
||||||
import org.eclipse.cdt.core.parser.IScannerInfo;
|
import org.eclipse.cdt.core.parser.IScannerInfo;
|
||||||
import org.eclipse.cdt.core.parser.IScannerInfoProvider;
|
import org.eclipse.cdt.core.parser.IScannerInfoProvider;
|
||||||
import org.eclipse.cdt.core.parser.ScannerInfo;
|
import org.eclipse.cdt.core.parser.ScannerInfo;
|
||||||
import org.eclipse.cdt.internal.core.CContentTypes;
|
|
||||||
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.cdt.internal.core.index.IWritableIndexManager;
|
||||||
|
import org.eclipse.cdt.internal.core.pdom.AbstractIndexerTask;
|
||||||
import org.eclipse.cdt.internal.core.pdom.ITodoTaskUpdater;
|
import org.eclipse.cdt.internal.core.pdom.ITodoTaskUpdater;
|
||||||
import org.eclipse.cdt.internal.core.pdom.IndexerProgress;
|
import org.eclipse.cdt.internal.core.pdom.IndexerProgress;
|
||||||
import org.eclipse.cdt.internal.core.pdom.PDOMWriter;
|
|
||||||
import org.eclipse.cdt.internal.core.pdom.db.ChunkCache;
|
import org.eclipse.cdt.internal.core.pdom.db.ChunkCache;
|
||||||
import org.eclipse.core.resources.IProject;
|
import org.eclipse.core.resources.IProject;
|
||||||
import org.eclipse.core.resources.IResource;
|
|
||||||
import org.eclipse.core.resources.ResourcesPlugin;
|
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.core.runtime.IPath;
|
import org.eclipse.core.runtime.IPath;
|
||||||
import org.eclipse.core.runtime.IProgressMonitor;
|
import org.eclipse.core.runtime.IProgressMonitor;
|
||||||
import org.eclipse.core.runtime.IStatus;
|
|
||||||
import org.eclipse.core.runtime.Path;
|
|
||||||
import org.eclipse.core.runtime.Platform;
|
import org.eclipse.core.runtime.Platform;
|
||||||
import org.eclipse.core.runtime.content.IContentType;
|
import org.eclipse.core.runtime.content.IContentType;
|
||||||
|
|
||||||
public abstract class PDOMIndexerTask extends PDOMWriter implements IPDOMIndexerTask {
|
/**
|
||||||
private static final Object NO_CONTEXT = new Object();
|
* Configures the abstract indexer task suitable for indexing projects.
|
||||||
private static final int MAX_ERRORS = 500;
|
*/
|
||||||
|
public abstract class PDOMIndexerTask extends AbstractIndexerTask implements IPDOMIndexerTask {
|
||||||
private static final String TRUE = "true"; //$NON-NLS-1$
|
private static final String TRUE = "true"; //$NON-NLS-1$
|
||||||
|
|
||||||
private AbstractPDOMIndexer fIndexer;
|
private AbstractPDOMIndexer fIndexer;
|
||||||
protected Map/*<IIndexFileLocation, Object>*/ fContextMap = new HashMap/*<IIndexFileLocation, Object>*/();
|
|
||||||
private List fFilesUpFront= new ArrayList();
|
protected PDOMIndexerTask(ITranslationUnit[] addFiles, ITranslationUnit[] updateFiles, ITranslationUnit[] removeFiles,
|
||||||
private String fDummyFileName;
|
AbstractPDOMIndexer indexer, boolean isFastIndexer) {
|
||||||
private URI fDummyFileURI;
|
super(concat(addFiles, updateFiles), removeFiles, new ProjectIndexerInputAdapter(indexer.getProject()), isFastIndexer);
|
||||||
private int fUpdateFlags= IIndexManager.UPDATE_ALL;
|
|
||||||
private boolean fAllFilesProvided= true;
|
|
||||||
|
|
||||||
protected PDOMIndexerTask(AbstractPDOMIndexer indexer) {
|
|
||||||
fIndexer= indexer;
|
fIndexer= indexer;
|
||||||
setShowActivity(checkDebugOption(TRACE_ACTIVITY, TRUE));
|
setShowActivity(checkDebugOption(TRACE_ACTIVITY, TRUE));
|
||||||
setShowProblems(checkDebugOption(TRACE_PROBLEMS, TRUE));
|
setShowProblems(checkDebugOption(TRACE_PROBLEMS, TRUE));
|
||||||
|
@ -85,47 +59,42 @@ public abstract class PDOMIndexerTask extends PDOMWriter implements IPDOMIndexer
|
||||||
else if (checkProperty(IndexerPreferences.KEY_SKIP_TYPE_REFERENCES)) {
|
else if (checkProperty(IndexerPreferences.KEY_SKIP_TYPE_REFERENCES)) {
|
||||||
setSkipReferences(SKIP_TYPE_REFERENCES);
|
setSkipReferences(SKIP_TYPE_REFERENCES);
|
||||||
}
|
}
|
||||||
|
if (getIndexAllFiles()) {
|
||||||
|
setIndexFilesWithoutBuildConfiguration(true);
|
||||||
|
setIndexHeadersWithoutContext(true);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
setIndexFilesWithoutBuildConfiguration(false);
|
||||||
|
setIndexHeadersWithoutContext(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static ITranslationUnit[] concat(ITranslationUnit[] added, ITranslationUnit[] changed) {
|
||||||
|
ITranslationUnit[] result= new ITranslationUnit[added.length+changed.length];
|
||||||
|
System.arraycopy(added, 0, result, 0, added.length);
|
||||||
|
System.arraycopy(changed, 0, result, added.length, changed.length);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public final void setParseUpFront() {
|
||||||
|
setParseUpFront(fIndexer.getFilesToParseUpFront());
|
||||||
}
|
}
|
||||||
|
|
||||||
final public IPDOMIndexer getIndexer() {
|
|
||||||
|
public final IPDOMIndexer getIndexer() {
|
||||||
return fIndexer;
|
return fIndexer;
|
||||||
}
|
}
|
||||||
|
|
||||||
final public ICProject getProject() {
|
public final void run(IProgressMonitor monitor) throws InterruptedException {
|
||||||
return fIndexer.getProject();
|
long start = System.currentTimeMillis();
|
||||||
|
runTask(monitor);
|
||||||
|
traceEnd(start, fIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
final public IndexerProgress getProgressInformation() {
|
|
||||||
|
public IndexerProgress getProgressInformation() {
|
||||||
return super.getProgressInformation();
|
return super.getProgressInformation();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setUpateFlags(int flags) {
|
|
||||||
fUpdateFlags= flags;
|
|
||||||
}
|
|
||||||
|
|
||||||
final public boolean updateAll() {
|
|
||||||
return (fUpdateFlags & IIndexManager.UPDATE_ALL) != 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
final public boolean updateChangedTimestamps() {
|
|
||||||
return (fUpdateFlags & IIndexManager.UPDATE_CHECK_TIMESTAMPS) != 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
final public boolean updateChangedConfiguration() {
|
|
||||||
return (fUpdateFlags & IIndexManager.UPDATE_CHECK_CONFIGURATION) != 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
final public void setParseUpFront() {
|
|
||||||
fFilesUpFront.addAll(Arrays.asList(fIndexer.getFilesToParseUpFront()));
|
|
||||||
}
|
|
||||||
|
|
||||||
final public void setAllFilesProvided(boolean allFiles) {
|
|
||||||
fAllFilesProvided= allFiles;
|
|
||||||
}
|
|
||||||
|
|
||||||
final public boolean getAllFilesProvided() {
|
|
||||||
return fAllFilesProvided;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks whether a given debug option is enabled. See {@link IPDOMIndexerTask}
|
* Checks whether a given debug option is enabled. See {@link IPDOMIndexerTask}
|
||||||
|
@ -138,12 +107,7 @@ public abstract class PDOMIndexerTask extends PDOMWriter implements IPDOMIndexer
|
||||||
return internallyActivated || (trace != null && trace.equalsIgnoreCase(value));
|
return internallyActivated || (trace != null && trace.equalsIgnoreCase(value));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
private boolean getIndexAllFiles() {
|
||||||
* Figures out whether all files (sources without configuration, headers not included)
|
|
||||||
* should be parsed.
|
|
||||||
* @since 4.0
|
|
||||||
*/
|
|
||||||
final protected boolean getIndexAllFiles() {
|
|
||||||
return checkProperty(IndexerPreferences.KEY_INDEX_ALL_FILES);
|
return checkProperty(IndexerPreferences.KEY_INDEX_ALL_FILES);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -151,362 +115,63 @@ public abstract class PDOMIndexerTask extends PDOMWriter implements IPDOMIndexer
|
||||||
return TRUE.equals(getIndexer().getProperty(key));
|
return TRUE.equals(getIndexer().getProperty(key));
|
||||||
}
|
}
|
||||||
|
|
||||||
private IASTTranslationUnit createAST(ITranslationUnit tu, IScannerInfo scannerInfo, int options, IProgressMonitor pm) throws CoreException {
|
|
||||||
IPath path = tu.getLocation();
|
protected String getASTPathForParsingUpFront() {
|
||||||
if (path == null) {
|
final IProject project = getProject().getProject();
|
||||||
|
final IPath prjLocation= project.getLocation();
|
||||||
|
if (prjLocation == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
ILanguage language = tu.getLanguage();
|
return prjLocation.append(super.getASTPathForParsingUpFront()).toString();
|
||||||
if (!(language instanceof AbstractLanguage))
|
|
||||||
return null;
|
|
||||||
|
|
||||||
CodeReader codeReader = tu.getCodeReader();
|
|
||||||
if (codeReader == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
IASTTranslationUnit ast= createAST((AbstractLanguage) language, codeReader, scannerInfo, options, pm);
|
|
||||||
if (ast != null) {
|
|
||||||
ast.setIsHeaderUnit(tu.isHeaderUnit());
|
|
||||||
}
|
|
||||||
return ast;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
protected AbstractLanguage[] getLanguages(String filename) {
|
||||||
* Called to create the ast for a translation unit or a pre-parsed file.
|
IContentType ct= CCorePlugin.getContentType(filename);
|
||||||
* May return <code>null</code>.
|
if (ct != null) {
|
||||||
* @see #parseTUs(IWritableIndex, int, Collection, Collection, IProgressMonitor)
|
ILanguage l = LanguageManager.getInstance().getLanguage(ct);
|
||||||
* @since 4.0
|
if (l instanceof AbstractLanguage) {
|
||||||
*/
|
if (ct.getId().equals(CCorePlugin.CONTENT_TYPE_CXXHEADER) && l.getLinkageID() == ILinkage.CPP_LINKAGE_ID) {
|
||||||
abstract protected IASTTranslationUnit createAST(AbstractLanguage lang, CodeReader codeReader,
|
ILanguage l2= LanguageManager.getInstance().getLanguageForContentTypeID(CCorePlugin.CONTENT_TYPE_CHEADER);
|
||||||
IScannerInfo scanInfo, int options, IProgressMonitor pm) throws CoreException;
|
if (l2 instanceof AbstractLanguage) {
|
||||||
|
return new AbstractLanguage[] {(AbstractLanguage) l, (AbstractLanguage) l2};
|
||||||
/**
|
|
||||||
* Convenience method for subclasses, parses the files calling out to the methods
|
|
||||||
* {@link #createAST(AbstractLanguage, CodeReader, IScannerInfo, int, IProgressMonitor)},
|
|
||||||
* {@link #needToUpdate(IIndexFileLocation,int)},
|
|
||||||
* {@link #addSymbols(IASTTranslationUnit, IWritableIndex, int, IProgressMonitor)}
|
|
||||||
* {@link #postAddToIndex(IIndexFileLocation, IIndexFile)},
|
|
||||||
* {@link #getLastModified(IIndexFileLocation)} and
|
|
||||||
* {@link #findLocation(String)}
|
|
||||||
* @since 4.0
|
|
||||||
*/
|
|
||||||
protected void parseTUs(IWritableIndex index, int readlockCount, Collection sources, Collection headers, IProgressMonitor monitor) throws CoreException, InterruptedException {
|
|
||||||
try {
|
|
||||||
internalParseTUs(index, readlockCount, sources, headers, monitor);
|
|
||||||
}
|
|
||||||
finally {
|
|
||||||
index.flush();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void internalParseTUs(IWritableIndex index, int readlockCount, Collection sources, Collection headers, IProgressMonitor monitor) throws CoreException, InterruptedException {
|
|
||||||
TodoTaskUpdater taskUpdater = new TodoTaskUpdater();
|
|
||||||
|
|
||||||
int options= AbstractLanguage.OPTION_ADD_COMMENTS | AbstractLanguage.OPTION_NO_IMAGE_LOCATIONS;
|
|
||||||
if (checkProperty(IndexerPreferences.KEY_SKIP_ALL_REFERENCES)) {
|
|
||||||
options |= AbstractLanguage.OPTION_SKIP_FUNCTION_BODIES;
|
|
||||||
}
|
|
||||||
for (Iterator iter = fFilesUpFront.iterator(); iter.hasNext();) {
|
|
||||||
String upfront= (String) iter.next();
|
|
||||||
parseUpFront(upfront, options, index, readlockCount, taskUpdater, monitor);
|
|
||||||
}
|
|
||||||
|
|
||||||
// sources first
|
|
||||||
sources= sortByContentType(sources);
|
|
||||||
for (Iterator iter = sources.iterator(); iter.hasNext();) {
|
|
||||||
if (monitor.isCanceled())
|
|
||||||
return;
|
|
||||||
ITranslationUnit tu = (ITranslationUnit) iter.next();
|
|
||||||
final IIndexFileLocation ifl = IndexLocationFactory.getIFL(tu);
|
|
||||||
if (needToUpdate(ifl, 0)) {
|
|
||||||
parseTU(ifl, tu, options, index, readlockCount, taskUpdater, monitor);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// headers with context
|
|
||||||
headers= sortByContentType(headers);
|
|
||||||
for (Iterator iter = headers.iterator(); iter.hasNext();) {
|
|
||||||
if (monitor.isCanceled())
|
|
||||||
return;
|
|
||||||
ITranslationUnit tu = (ITranslationUnit) iter.next();
|
|
||||||
final IIndexFileLocation ifl = IndexLocationFactory.getIFL(tu);
|
|
||||||
if (!needToUpdate(ifl, 0)) {
|
|
||||||
iter.remove();
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
ITranslationUnit context= findContext(index, ifl);
|
|
||||||
if (context != null) {
|
|
||||||
parseTU(ifl, context, options, index, readlockCount, taskUpdater, monitor);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// headers without context
|
|
||||||
if (getIndexAllFiles()) {
|
|
||||||
for (Iterator iter = headers.iterator(); iter.hasNext();) {
|
|
||||||
if (monitor.isCanceled())
|
|
||||||
return;
|
|
||||||
ITranslationUnit tu = (ITranslationUnit) iter.next();
|
|
||||||
final IIndexFileLocation ifl = IndexLocationFactory.getIFL(tu);
|
|
||||||
if (!needToUpdate(ifl, 0)) {
|
|
||||||
iter.remove();
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
parseTU(ifl, tu, options, index, readlockCount, taskUpdater, monitor);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private Collection sortByContentType(Collection sources) {
|
|
||||||
HashMap ctToLists= new HashMap();
|
|
||||||
for (Iterator iterator = sources.iterator(); iterator.hasNext();) {
|
|
||||||
final ITranslationUnit tu = (ITranslationUnit) iterator.next();
|
|
||||||
final String ct= tu.getContentTypeId();
|
|
||||||
List list= (List) ctToLists.get(ct);
|
|
||||||
if (list == null) {
|
|
||||||
list= new ArrayList();
|
|
||||||
ctToLists.put(ct, list);
|
|
||||||
}
|
|
||||||
list.add(tu);
|
|
||||||
}
|
|
||||||
if (ctToLists.size() <= 1) {
|
|
||||||
return sources;
|
|
||||||
}
|
|
||||||
Collection result= new ArrayList(sources.size());
|
|
||||||
// do C++ first
|
|
||||||
List list= (List) ctToLists.remove(CCorePlugin.CONTENT_TYPE_CXXSOURCE);
|
|
||||||
if (list != null) {
|
|
||||||
result.addAll(list);
|
|
||||||
}
|
|
||||||
list= (List) ctToLists.remove(CCorePlugin.CONTENT_TYPE_CXXHEADER);
|
|
||||||
if (list != null) {
|
|
||||||
result.addAll(list);
|
|
||||||
}
|
|
||||||
for (Iterator iterator = ctToLists.values().iterator(); iterator.hasNext();) {
|
|
||||||
list = (List) iterator.next();
|
|
||||||
result.addAll(list);
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Convenience method to check whether a translation unit in the index is outdated
|
|
||||||
* with respect to its timestamp.
|
|
||||||
* @throws CoreException
|
|
||||||
* @since 4.0
|
|
||||||
*/
|
|
||||||
final protected boolean isOutdated(ITranslationUnit tu, IIndexFile indexFile) throws CoreException {
|
|
||||||
if (indexFile == null) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
IResource res= tu.getResource();
|
|
||||||
if (res != null) {
|
|
||||||
if (indexFile != null) {
|
|
||||||
if (res.getLocalTimeStamp() == indexFile.getTimestamp()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private void parseTU(IIndexFileLocation originator, ITranslationUnit tu, int options, IWritableIndex index,
|
|
||||||
int readlockCount, ITodoTaskUpdater taskUpdater, IProgressMonitor pm) throws CoreException, InterruptedException {
|
|
||||||
IPath path= tu.getPath();
|
|
||||||
try {
|
|
||||||
// skip if no scanner info
|
|
||||||
IScannerInfo scanner= tu.getScannerInfo(getIndexAllFiles());
|
|
||||||
if (scanner == null) {
|
|
||||||
updateInfo(0, 0, -1);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
final int configHash = computeHashCode(scanner);
|
|
||||||
if (needToUpdate(originator, configHash)) {
|
|
||||||
if (fShowActivity) {
|
|
||||||
System.out.println("Indexer: parsing " + path.toOSString()); //$NON-NLS-1$
|
|
||||||
}
|
|
||||||
pm.subTask(MessageFormat.format(Messages.PDOMIndexerTask_parsingFileTask,
|
|
||||||
new Object[]{path.lastSegment(), path.removeLastSegments(1).toString()}));
|
|
||||||
long start= System.currentTimeMillis();
|
|
||||||
IASTTranslationUnit ast= createAST(tu, scanner, options, pm);
|
|
||||||
fStatistics.fParsingTime += System.currentTimeMillis()-start;
|
|
||||||
if (ast != null) {
|
|
||||||
addSymbols(ast, index, readlockCount, false, configHash, taskUpdater, pm);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return new AbstractLanguage[] {(AbstractLanguage) l};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (CoreException e) {
|
return new AbstractLanguage[0];
|
||||||
swallowError(path, e);
|
|
||||||
}
|
|
||||||
catch (RuntimeException e) {
|
|
||||||
swallowError(path, e);
|
|
||||||
}
|
|
||||||
catch (Error e) {
|
|
||||||
swallowError(path, e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void parseUpFront(String file, int options, IWritableIndex index, int readlockCount,
|
protected IScannerInfo createDefaultScannerConfig(int linkageID) {
|
||||||
ITodoTaskUpdater taskUpdater, IProgressMonitor pm) throws CoreException, InterruptedException {
|
IProject project= getProject().getProject();
|
||||||
file= file.trim();
|
IScannerInfoProvider provider= CCorePlugin.getDefault().getScannerInfoProvider(project);
|
||||||
if (file.length() == 0) {
|
IScannerInfo scanInfo;
|
||||||
return;
|
if (provider != null) {
|
||||||
}
|
scanInfo= provider.getScannerInformation(project);
|
||||||
IPath path= new Path(file);
|
|
||||||
try {
|
|
||||||
if (fShowActivity) {
|
|
||||||
System.out.println("Indexer: parsing " + file + " up front"); //$NON-NLS-1$ //$NON-NLS-2$
|
|
||||||
}
|
|
||||||
pm.subTask(MessageFormat.format(Messages.PDOMIndexerTask_parsingFileTask,
|
|
||||||
new Object[]{path.lastSegment(), path.removeLastSegments(1).toString()}));
|
|
||||||
long start= System.currentTimeMillis();
|
|
||||||
|
|
||||||
IASTTranslationUnit ast= null;
|
|
||||||
final IProject project = getProject().getProject();
|
|
||||||
IContentType ct= CContentTypes.getContentType(project, file);
|
|
||||||
if (ct != null) {
|
|
||||||
ILanguage l = LanguageManager.getInstance().getLanguage(ct);
|
|
||||||
if (l instanceof AbstractLanguage) {
|
|
||||||
AbstractLanguage lang= (AbstractLanguage) l;
|
|
||||||
IScannerInfoProvider provider= CCorePlugin.getDefault().getScannerInfoProvider(project);
|
|
||||||
IScannerInfo scanInfo;
|
|
||||||
if (provider != null) {
|
|
||||||
scanInfo= provider.getScannerInformation(project);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
scanInfo= new ScannerInfo();
|
|
||||||
}
|
|
||||||
String code= "#include \"" + file + "\"\n"; //$NON-NLS-1$ //$NON-NLS-2$
|
|
||||||
if (fDummyFileName == null) {
|
|
||||||
fDummyFileName= project.getLocation().append("___").toString(); //$NON-NLS-1$
|
|
||||||
fDummyFileURI= findLocation(fDummyFileName).getURI();
|
|
||||||
}
|
|
||||||
CodeReader codeReader= new CodeReader(fDummyFileName, code.toCharArray());
|
|
||||||
ast= createAST(lang, codeReader, scanInfo, options, pm);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fStatistics.fParsingTime += System.currentTimeMillis()-start;
|
|
||||||
if (ast != null) {
|
|
||||||
addSymbols(ast, index, readlockCount, false, 0, taskUpdater, pm);
|
|
||||||
updateInfo(-1, +1, 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (CoreException e) {
|
|
||||||
swallowError(path, e);
|
|
||||||
}
|
|
||||||
catch (RuntimeException e) {
|
|
||||||
swallowError(path, e);
|
|
||||||
}
|
|
||||||
catch (Error e) {
|
|
||||||
swallowError(path, e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Overrides must call super.needToUpdate(). If <code>false</code> is returned
|
|
||||||
* this must be passed on to their caller:
|
|
||||||
* <pre>
|
|
||||||
* if (super.needToUpdate()) {
|
|
||||||
* // your code
|
|
||||||
* }
|
|
||||||
* return false;
|
|
||||||
*/
|
|
||||||
protected boolean needToUpdate(IIndexFileLocation fileLoc, int configHash) throws CoreException {
|
|
||||||
return fDummyFileURI==null || !fDummyFileURI.equals(fileLoc.getURI());
|
|
||||||
}
|
|
||||||
|
|
||||||
private void swallowError(IPath file, Throwable e) throws CoreException {
|
|
||||||
if (e instanceof CoreException) {
|
|
||||||
CCorePlugin.log(((CoreException) e).getStatus());
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
IStatus status= CCorePlugin.createStatus(
|
scanInfo= new ScannerInfo();
|
||||||
MessageFormat.format(Messages.PDOMIndexerTask_errorWhileParsing, new Object[]{file}), e);
|
|
||||||
CCorePlugin.log(status);
|
|
||||||
}
|
|
||||||
if (++fStatistics.fErrorCount > MAX_ERRORS) {
|
|
||||||
throw new CoreException(CCorePlugin.createStatus(
|
|
||||||
MessageFormat.format(Messages.PDOMIndexerTask_tooManyIndexProblems, new Object[]{getIndexer().getProject().getElementName()})));
|
|
||||||
}
|
}
|
||||||
|
return scanInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
private ITranslationUnit findContext(IIndex index, final IIndexFileLocation location) {
|
private ICProject getProject() {
|
||||||
Object cachedContext= fContextMap.get(location);
|
return getIndexer().getProject();
|
||||||
if (cachedContext != null) {
|
}
|
||||||
return cachedContext == NO_CONTEXT ? null : (ITranslationUnit) cachedContext;
|
|
||||||
}
|
|
||||||
|
|
||||||
fContextMap.put(location, NO_CONTEXT); // prevent recursion
|
protected final IWritableIndex createIndex() {
|
||||||
IIndexFile pdomFile;
|
|
||||||
try {
|
try {
|
||||||
final ICProject project= getIndexer().getProject();
|
return ((IWritableIndexManager) CCorePlugin.getIndexManager()).getWritableIndex(getProject());
|
||||||
pdomFile = index.getFile(location);
|
|
||||||
if (pdomFile != null) {
|
|
||||||
final IIndexInclude contextInclude= pdomFile.getParsedInContext();
|
|
||||||
if (contextInclude != null) {
|
|
||||||
final IIndexFileLocation loc= contextInclude.getIncludedByLocation();
|
|
||||||
ITranslationUnit context= getSourceUnit(project, loc);
|
|
||||||
if (context == null) {
|
|
||||||
context= findContext(index, loc);
|
|
||||||
}
|
|
||||||
if (context != null) {
|
|
||||||
fContextMap.put(location, context);
|
|
||||||
return context;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// fallback to other includes
|
|
||||||
IIndexInclude[] includedBy = index.findIncludedBy(pdomFile, IIndex.DEPTH_ZERO);
|
|
||||||
for (int i = includedBy.length-1; i >=0; i--) {
|
|
||||||
final IIndexFileLocation loc= includedBy[i].getIncludedByLocation();
|
|
||||||
ITranslationUnit context= getSourceUnit(project, loc);
|
|
||||||
if (context == null) {
|
|
||||||
context= findContext(index, loc);
|
|
||||||
}
|
|
||||||
if (context != null) {
|
|
||||||
fContextMap.put(location, context);
|
|
||||||
return context;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (CoreException e) {
|
} catch (CoreException e) {
|
||||||
CCorePlugin.log(e);
|
CCorePlugin.log(e);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private ITranslationUnit getSourceUnit(final ICProject project, final IIndexFileLocation location)
|
protected final ITodoTaskUpdater createTodoTaskUpdater() {
|
||||||
throws CoreException {
|
return new TodoTaskUpdater();
|
||||||
ITranslationUnit tu= CoreModelUtil.findTranslationUnitForLocation(location, getIndexer().getProject());
|
|
||||||
if (tu != null) {
|
|
||||||
if (tu.isSourceUnit()) {
|
|
||||||
return tu;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Conveninence method for subclasses, removes a translation unit from the index.
|
|
||||||
* @since 4.0
|
|
||||||
*/
|
|
||||||
protected void removeTU(IWritableIndex index, ITranslationUnit tu, int readlocks) throws CoreException, InterruptedException {
|
|
||||||
index.acquireWriteLock(readlocks);
|
|
||||||
try {
|
|
||||||
IIndexFragmentFile file = (IIndexFragmentFile) index.getFile(IndexLocationFactory.getIFL(tu));
|
|
||||||
if (file != null)
|
|
||||||
index.clearFile(file, null);
|
|
||||||
} finally {
|
|
||||||
index.releaseWriteLock(readlocks);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void traceEnd(long start, IWritableIndex index) {
|
protected void traceEnd(long start, IWritableIndex index) {
|
||||||
if (checkDebugOption(IPDOMIndexerTask.TRACE_STATISTICS, TRUE)) {
|
if (checkDebugOption(IPDOMIndexerTask.TRACE_STATISTICS, TRUE)) {
|
||||||
IndexerProgress info= getProgressInformation();
|
IndexerProgress info= getProgressInformation();
|
||||||
|
@ -558,69 +223,6 @@ public abstract class PDOMIndexerTask extends PDOMWriter implements IPDOMIndexer
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected long getLastModified(IIndexFileLocation location) throws CoreException {
|
|
||||||
String fullPath= location.getFullPath();
|
|
||||||
if (fullPath != null) {
|
|
||||||
IResource res= ResourcesPlugin.getWorkspace().getRoot().findMember(fullPath);
|
|
||||||
if (res != null) {
|
|
||||||
return res.getLocalTimeStamp();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return super.getLastModified(location);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected static int computeHashCode(IScannerInfo scannerInfo) {
|
|
||||||
int result= 0;
|
|
||||||
Map macros= scannerInfo.getDefinedSymbols();
|
|
||||||
if (macros != null) {
|
|
||||||
for (Iterator i = macros.entrySet().iterator(); i.hasNext();) {
|
|
||||||
Map.Entry entry = (Map.Entry) i.next();
|
|
||||||
String key = (String) entry.getKey();
|
|
||||||
String value = (String) entry.getValue();
|
|
||||||
result= addToHashcode(result, key);
|
|
||||||
if (value != null && value.length() > 0) {
|
|
||||||
result= addToHashcode(result, value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
String[] a= scannerInfo.getIncludePaths();
|
|
||||||
if (a != null) {
|
|
||||||
for (int i = 0; i < a.length; i++) {
|
|
||||||
result= addToHashcode(result, a[i]);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (scannerInfo instanceof IExtendedScannerInfo) {
|
|
||||||
IExtendedScannerInfo esi= (IExtendedScannerInfo) scannerInfo;
|
|
||||||
a= esi.getIncludeFiles();
|
|
||||||
if (a != null) {
|
|
||||||
for (int i = 0; i < a.length; i++) {
|
|
||||||
result= addToHashcode(result, a[i]);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
a= esi.getLocalIncludePath();
|
|
||||||
if (a != null) {
|
|
||||||
for (int i = 0; i < a.length; i++) {
|
|
||||||
result= addToHashcode(result, a[i]);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
a= esi.getMacroFiles();
|
|
||||||
if (a != null) {
|
|
||||||
for (int i = 0; i < a.length; i++) {
|
|
||||||
result= addToHashcode(result, a[i]);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static int addToHashcode(int result, String key) {
|
|
||||||
return result*31 + key.hashCode();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected ICProject getCProject() {
|
protected ICProject getCProject() {
|
||||||
return fIndexer.project;
|
return fIndexer.project;
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,21 +6,18 @@
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* QNX - Initial API and implementation
|
* QNX - Initial API and implementation
|
||||||
* Markus Schorn (Wind River Systems)
|
* Markus Schorn (Wind River Systems)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
package org.eclipse.cdt.internal.core.pdom.indexer.nulli;
|
package org.eclipse.cdt.internal.core.pdom.indexer;
|
||||||
|
|
||||||
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.model.ITranslationUnit;
|
import org.eclipse.cdt.core.model.ITranslationUnit;
|
||||||
import org.eclipse.cdt.internal.core.pdom.indexer.AbstractPDOMIndexer;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Doug Schaefer
|
* Configures the abstract indexer to do nothing.
|
||||||
*
|
|
||||||
* The Null Indexer which does nothing.
|
|
||||||
*/
|
*/
|
||||||
public class PDOMNullIndexer extends AbstractPDOMIndexer {
|
public class PDOMNullIndexer extends AbstractPDOMIndexer {
|
||||||
|
|
|
@ -32,6 +32,9 @@ import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.core.runtime.IProgressMonitor;
|
import org.eclipse.core.runtime.IProgressMonitor;
|
||||||
import org.eclipse.osgi.util.NLS;
|
import org.eclipse.osgi.util.NLS;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A task for rebuilding an index, works for all indexers.
|
||||||
|
*/
|
||||||
public class PDOMRebuildTask implements IPDOMIndexerTask {
|
public class PDOMRebuildTask implements IPDOMIndexerTask {
|
||||||
protected static final String TRUE= String.valueOf(true);
|
protected static final String TRUE= String.valueOf(true);
|
||||||
protected static final ITranslationUnit[] NO_TUS = new ITranslationUnit[0];
|
protected static final ITranslationUnit[] NO_TUS = new ITranslationUnit[0];
|
||||||
|
@ -55,7 +58,7 @@ public class PDOMRebuildTask implements IPDOMIndexerTask {
|
||||||
return fIndexer;
|
return fIndexer;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void run(IProgressMonitor monitor) {
|
public void run(IProgressMonitor monitor) throws InterruptedException {
|
||||||
monitor.subTask(NLS.bind(Messages.PDOMIndexerTask_collectingFilesTask,
|
monitor.subTask(NLS.bind(Messages.PDOMIndexerTask_collectingFilesTask,
|
||||||
fIndexer.getProject().getElementName()));
|
fIndexer.getProject().getElementName()));
|
||||||
|
|
||||||
|
@ -102,15 +105,14 @@ public class PDOMRebuildTask implements IPDOMIndexerTask {
|
||||||
boolean allFiles= TRUE.equals(fIndexer.getProperty(IndexerPreferences.KEY_INDEX_ALL_FILES));
|
boolean allFiles= TRUE.equals(fIndexer.getProperty(IndexerPreferences.KEY_INDEX_ALL_FILES));
|
||||||
List sources= new ArrayList();
|
List sources= new ArrayList();
|
||||||
List headers= allFiles ? sources : null;
|
List headers= allFiles ? sources : null;
|
||||||
TranslationUnitCollector collector= new TranslationUnitCollector(sources, headers, allFiles, monitor);
|
TranslationUnitCollector collector= new TranslationUnitCollector(sources, headers, monitor);
|
||||||
project.accept(collector);
|
project.accept(collector);
|
||||||
ITranslationUnit[] tus= (ITranslationUnit[]) sources.toArray(new ITranslationUnit[sources.size()]);
|
ITranslationUnit[] tus= (ITranslationUnit[]) sources.toArray(new ITranslationUnit[sources.size()]);
|
||||||
fDelegate= fIndexer.createTask(tus, NO_TUS, NO_TUS);
|
fDelegate= fIndexer.createTask(tus, NO_TUS, NO_TUS);
|
||||||
if (fDelegate instanceof PDOMIndexerTask) {
|
if (fDelegate instanceof PDOMIndexerTask) {
|
||||||
final PDOMIndexerTask delegate = (PDOMIndexerTask) fDelegate;
|
final PDOMIndexerTask delegate = (PDOMIndexerTask) fDelegate;
|
||||||
delegate.setUpateFlags(IIndexManager.UPDATE_ALL);
|
delegate.setUpdateFlags(IIndexManager.UPDATE_ALL);
|
||||||
delegate.setParseUpFront();
|
delegate.setParseUpFront();
|
||||||
delegate.setAllFilesProvided(allFiles);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,6 +28,9 @@ import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.core.runtime.IProgressMonitor;
|
import org.eclipse.core.runtime.IProgressMonitor;
|
||||||
import org.eclipse.osgi.util.NLS;
|
import org.eclipse.osgi.util.NLS;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A task for updating an index, suitable for all indexers.
|
||||||
|
*/
|
||||||
public class PDOMUpdateTask implements IPDOMIndexerTask {
|
public class PDOMUpdateTask implements IPDOMIndexerTask {
|
||||||
protected static final String TRUE= String.valueOf(true);
|
protected static final String TRUE= String.valueOf(true);
|
||||||
protected static final ITranslationUnit[] NO_TUS = new ITranslationUnit[0];
|
protected static final ITranslationUnit[] NO_TUS = new ITranslationUnit[0];
|
||||||
|
@ -54,7 +57,7 @@ public class PDOMUpdateTask implements IPDOMIndexerTask {
|
||||||
return fIndexer;
|
return fIndexer;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void run(IProgressMonitor monitor) {
|
public void run(IProgressMonitor monitor) throws InterruptedException {
|
||||||
monitor.subTask(NLS.bind(Messages.PDOMIndexerTask_collectingFilesTask,
|
monitor.subTask(NLS.bind(Messages.PDOMIndexerTask_collectingFilesTask,
|
||||||
fIndexer.getProject().getElementName()));
|
fIndexer.getProject().getElementName()));
|
||||||
|
|
||||||
|
@ -75,9 +78,8 @@ public class PDOMUpdateTask implements IPDOMIndexerTask {
|
||||||
}
|
}
|
||||||
|
|
||||||
private synchronized void createDelegate(ICProject project, IProgressMonitor monitor) throws CoreException {
|
private synchronized void createDelegate(ICProject project, IProgressMonitor monitor) throws CoreException {
|
||||||
boolean allFiles= TRUE.equals(fIndexer.getProperty(IndexerPreferences.KEY_INDEX_ALL_FILES));
|
|
||||||
HashSet set= new HashSet();
|
HashSet set= new HashSet();
|
||||||
TranslationUnitCollector collector= new TranslationUnitCollector(set, set, allFiles, monitor);
|
TranslationUnitCollector collector= new TranslationUnitCollector(set, set, monitor);
|
||||||
if (fFilesAndFolders == null) {
|
if (fFilesAndFolders == null) {
|
||||||
project.accept(collector);
|
project.accept(collector);
|
||||||
}
|
}
|
||||||
|
@ -91,8 +93,7 @@ public class PDOMUpdateTask implements IPDOMIndexerTask {
|
||||||
fDelegate= fIndexer.createTask(tus, NO_TUS, NO_TUS);
|
fDelegate= fIndexer.createTask(tus, NO_TUS, NO_TUS);
|
||||||
if (fDelegate instanceof PDOMIndexerTask) {
|
if (fDelegate instanceof PDOMIndexerTask) {
|
||||||
final PDOMIndexerTask task = (PDOMIndexerTask) fDelegate;
|
final PDOMIndexerTask task = (PDOMIndexerTask) fDelegate;
|
||||||
task.setUpateFlags(fUpdateOptions);
|
task.setUpdateFlags(fUpdateOptions);
|
||||||
task.setAllFilesProvided(allFiles);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,164 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2007 Wind River Systems, Inc. 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:
|
||||||
|
* Markus Schorn - initial API and implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.cdt.internal.core.pdom.indexer;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.HashMap;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.CCorePlugin;
|
||||||
|
import org.eclipse.cdt.core.index.IIndexFileLocation;
|
||||||
|
import org.eclipse.cdt.core.index.IndexLocationFactory;
|
||||||
|
import org.eclipse.cdt.core.model.AbstractLanguage;
|
||||||
|
import org.eclipse.cdt.core.model.CModelException;
|
||||||
|
import org.eclipse.cdt.core.model.CoreModel;
|
||||||
|
import org.eclipse.cdt.core.model.CoreModelUtil;
|
||||||
|
import org.eclipse.cdt.core.model.ICProject;
|
||||||
|
import org.eclipse.cdt.core.model.ILanguage;
|
||||||
|
import org.eclipse.cdt.core.model.ITranslationUnit;
|
||||||
|
import org.eclipse.cdt.core.parser.CodeReader;
|
||||||
|
import org.eclipse.cdt.core.parser.IScannerInfo;
|
||||||
|
import org.eclipse.cdt.core.parser.ScannerInfo;
|
||||||
|
import org.eclipse.cdt.internal.core.pdom.IndexerInputAdapter;
|
||||||
|
import org.eclipse.core.resources.IResource;
|
||||||
|
import org.eclipse.core.resources.ResourcesPlugin;
|
||||||
|
import org.eclipse.core.runtime.CoreException;
|
||||||
|
import org.eclipse.core.runtime.IPath;
|
||||||
|
import org.eclipse.core.runtime.Path;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provides information about translation-units.
|
||||||
|
* @since 5.0
|
||||||
|
*/
|
||||||
|
public class ProjectIndexerInputAdapter extends IndexerInputAdapter {
|
||||||
|
private final static boolean CASE_SENSITIVE_FILES= !new File("a").equals(new File("A")); //$NON-NLS-1$//$NON-NLS-2$
|
||||||
|
|
||||||
|
private final ICProject fCProject;
|
||||||
|
private HashMap fIflCache= new HashMap();
|
||||||
|
|
||||||
|
public ProjectIndexerInputAdapter(ICProject cproject) {
|
||||||
|
fCProject= cproject;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IIndexFileLocation resolveASTPath(String astPath) {
|
||||||
|
IIndexFileLocation result= (IIndexFileLocation) fIflCache.get(astPath);
|
||||||
|
if (result == null) {
|
||||||
|
result= IndexLocationFactory.getIFLExpensive(fCProject, astPath);
|
||||||
|
fIflCache.put(astPath, result);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IIndexFileLocation resolveIncludeFile(String includePath) {
|
||||||
|
IIndexFileLocation result= (IIndexFileLocation) fIflCache.get(includePath);
|
||||||
|
if (result == null) {
|
||||||
|
File location= new File(includePath);
|
||||||
|
if (!location.exists()) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
result= IndexLocationFactory.getIFLExpensive(fCProject, includePath);
|
||||||
|
if (result.getFullPath() == null && !CASE_SENSITIVE_FILES) {
|
||||||
|
try {
|
||||||
|
String canonicalPath= location.getCanonicalPath();
|
||||||
|
if (!includePath.equals(canonicalPath)) {
|
||||||
|
result= IndexLocationFactory.getExternalIFL(canonicalPath);
|
||||||
|
fIflCache.put(canonicalPath, result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (IOException e) {
|
||||||
|
// just use the original
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fIflCache.put(includePath, result);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getASTPath(IIndexFileLocation ifl) {
|
||||||
|
IPath path= IndexLocationFactory.getAbsolutePath(ifl);
|
||||||
|
if (path != null) {
|
||||||
|
return path.toString();
|
||||||
|
}
|
||||||
|
return ifl.getURI().getPath();
|
||||||
|
}
|
||||||
|
|
||||||
|
public IScannerInfo getBuildConfiguration(int linkageID, Object tu) {
|
||||||
|
IScannerInfo info= ((ITranslationUnit) tu).getScannerInfo(true);
|
||||||
|
if (info == null) {
|
||||||
|
info= new ScannerInfo();
|
||||||
|
}
|
||||||
|
return info;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getLastModified(IIndexFileLocation ifl) {
|
||||||
|
String fullPath= ifl.getFullPath();
|
||||||
|
if (fullPath != null) {
|
||||||
|
IResource res= ResourcesPlugin.getWorkspace().getRoot().findMember(new Path(fullPath));
|
||||||
|
if (res != null) {
|
||||||
|
return res.getLocalTimeStamp();
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
IPath location= IndexLocationFactory.getAbsolutePath(ifl);
|
||||||
|
if (location != null) {
|
||||||
|
return location.toFile().lastModified();
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public AbstractLanguage[] getLanguages(Object tuo) {
|
||||||
|
ITranslationUnit tu= (ITranslationUnit) tuo;
|
||||||
|
try {
|
||||||
|
ILanguage lang= tu.getLanguage();
|
||||||
|
if (lang instanceof AbstractLanguage) {
|
||||||
|
return new AbstractLanguage[] {(AbstractLanguage) lang};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (CoreException e) {
|
||||||
|
CCorePlugin.log(e);
|
||||||
|
}
|
||||||
|
return new AbstractLanguage[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isFileBuildConfigured(Object tuo) {
|
||||||
|
ITranslationUnit tu= (ITranslationUnit) tuo;
|
||||||
|
return !CoreModel.isScannerInformationEmpty(tu.getResource());
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isSourceUnit(Object tuo) {
|
||||||
|
ITranslationUnit tu= (ITranslationUnit) tuo;
|
||||||
|
return tu.isSourceUnit();
|
||||||
|
}
|
||||||
|
|
||||||
|
public IIndexFileLocation resolveFile(Object tuo) {
|
||||||
|
ITranslationUnit tu= (ITranslationUnit) tuo;
|
||||||
|
return IndexLocationFactory.getIFL(tu);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean canBePartOfSDK(IIndexFileLocation ifl) {
|
||||||
|
return ifl.getFullPath() == null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Object getInputFile(IIndexFileLocation location) {
|
||||||
|
try {
|
||||||
|
return CoreModelUtil.findTranslationUnitForLocation(location, fCProject);
|
||||||
|
} catch (CModelException e) {
|
||||||
|
CCorePlugin.log(e);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CodeReader getCodeReader(Object tuo) {
|
||||||
|
ITranslationUnit tu= (ITranslationUnit) tuo;
|
||||||
|
return tu.getCodeReader();
|
||||||
|
}
|
||||||
|
}
|
|
@ -13,7 +13,6 @@ package org.eclipse.cdt.internal.core.pdom.indexer;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.model.CoreModel;
|
|
||||||
import org.eclipse.cdt.core.model.ICElement;
|
import org.eclipse.cdt.core.model.ICElement;
|
||||||
import org.eclipse.cdt.core.model.ICElementVisitor;
|
import org.eclipse.cdt.core.model.ICElementVisitor;
|
||||||
import org.eclipse.cdt.core.model.ITranslationUnit;
|
import org.eclipse.cdt.core.model.ITranslationUnit;
|
||||||
|
@ -23,13 +22,11 @@ import org.eclipse.core.runtime.IProgressMonitor;
|
||||||
final class TranslationUnitCollector implements ICElementVisitor {
|
final class TranslationUnitCollector implements ICElementVisitor {
|
||||||
private final Collection fSources;
|
private final Collection fSources;
|
||||||
private final Collection fHeaders;
|
private final Collection fHeaders;
|
||||||
private final boolean fAllFiles;
|
|
||||||
private final IProgressMonitor fProgressMonitor;
|
private final IProgressMonitor fProgressMonitor;
|
||||||
|
|
||||||
public TranslationUnitCollector(Collection sources, Collection headers, boolean allFiles, IProgressMonitor pm) {
|
public TranslationUnitCollector(Collection sources, Collection headers, IProgressMonitor pm) {
|
||||||
fSources= sources;
|
fSources= sources;
|
||||||
fHeaders= headers;
|
fHeaders= headers;
|
||||||
fAllFiles = allFiles;
|
|
||||||
fProgressMonitor= pm;
|
fProgressMonitor= pm;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -41,9 +38,7 @@ final class TranslationUnitCollector implements ICElementVisitor {
|
||||||
case ICElement.C_UNIT:
|
case ICElement.C_UNIT:
|
||||||
ITranslationUnit tu = (ITranslationUnit)element;
|
ITranslationUnit tu = (ITranslationUnit)element;
|
||||||
if (tu.isSourceUnit()) {
|
if (tu.isSourceUnit()) {
|
||||||
if (fAllFiles || !CoreModel.isScannerInformationEmpty(tu.getResource())) {
|
fSources.add(tu);
|
||||||
fSources.add(tu);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else if (fHeaders != null && tu.isHeaderUnit()) {
|
else if (fHeaders != null && tu.isHeaderUnit()) {
|
||||||
fHeaders.add(tu);
|
fHeaders.add(tu);
|
||||||
|
|
|
@ -1,215 +0,0 @@
|
||||||
/*******************************************************************************
|
|
||||||
* Copyright (c) 2006, 2007 QNX Software Systems 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:
|
|
||||||
* QNX - Initial API and implementation
|
|
||||||
* Markus Schorn (Wind River Systems)
|
|
||||||
*******************************************************************************/
|
|
||||||
|
|
||||||
package org.eclipse.cdt.internal.core.pdom.indexer.fast;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.LinkedList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import org.eclipse.cdt.core.CCorePlugin;
|
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
|
||||||
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.AbstractLanguage;
|
|
||||||
import org.eclipse.cdt.core.model.CoreModel;
|
|
||||||
import org.eclipse.cdt.core.model.ITranslationUnit;
|
|
||||||
import org.eclipse.cdt.core.parser.CodeReader;
|
|
||||||
import org.eclipse.cdt.core.parser.IScannerInfo;
|
|
||||||
import org.eclipse.cdt.core.parser.ParserUtil;
|
|
||||||
import org.eclipse.cdt.internal.core.index.IWritableIndex;
|
|
||||||
import org.eclipse.cdt.internal.core.index.IWritableIndexManager;
|
|
||||||
import org.eclipse.cdt.internal.core.index.IndexBasedCodeReaderFactory;
|
|
||||||
import org.eclipse.cdt.internal.core.index.IndexBasedCodeReaderFactory.CallbackHandler;
|
|
||||||
import org.eclipse.cdt.internal.core.index.IndexBasedCodeReaderFactory.IndexFileInfo;
|
|
||||||
import org.eclipse.cdt.internal.core.pdom.indexer.PDOMIndexerTask;
|
|
||||||
import org.eclipse.core.runtime.CoreException;
|
|
||||||
import org.eclipse.core.runtime.IProgressMonitor;
|
|
||||||
|
|
||||||
class PDOMFastIndexerTask extends PDOMIndexerTask implements CallbackHandler {
|
|
||||||
private List fChanged = new LinkedList();
|
|
||||||
private List fRemoved = new ArrayList();
|
|
||||||
private IWritableIndex fIndex;
|
|
||||||
private IndexBasedCodeReaderFactory fCodeReaderFactory;
|
|
||||||
private Map fIflCache;
|
|
||||||
private int fCurrentConfigHash= 0;
|
|
||||||
|
|
||||||
public PDOMFastIndexerTask(PDOMFastIndexer indexer, ITranslationUnit[] added,
|
|
||||||
ITranslationUnit[] changed, ITranslationUnit[] removed) {
|
|
||||||
super(indexer);
|
|
||||||
fChanged.addAll(Arrays.asList(added));
|
|
||||||
fChanged.addAll(Arrays.asList(changed));
|
|
||||||
fRemoved.addAll(Arrays.asList(removed));
|
|
||||||
updateInfo(0, 0, fChanged.size() + fRemoved.size());
|
|
||||||
}
|
|
||||||
|
|
||||||
public void run(IProgressMonitor monitor) {
|
|
||||||
long start = System.currentTimeMillis();
|
|
||||||
try {
|
|
||||||
// separate headers remove files that have no scanner configuration
|
|
||||||
final boolean filterFiles= !getIndexAllFiles() && getAllFilesProvided();
|
|
||||||
List headers= new ArrayList();
|
|
||||||
List sources= fChanged;
|
|
||||||
for (Iterator iter = fChanged.iterator(); iter.hasNext();) {
|
|
||||||
ITranslationUnit tu = (ITranslationUnit) iter.next();
|
|
||||||
if (tu.isSourceUnit()) {
|
|
||||||
if (filterFiles && CoreModel.isScannerInformationEmpty(tu.getResource())) {
|
|
||||||
iter.remove();
|
|
||||||
updateInfo(0, 0, -1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
headers.add(tu);
|
|
||||||
iter.remove();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!setupIndexAndReaderFactory()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
fIndex.acquireReadLock();
|
|
||||||
try {
|
|
||||||
registerTUsInReaderFactory(sources);
|
|
||||||
registerTUsInReaderFactory(headers);
|
|
||||||
|
|
||||||
Iterator i= fRemoved.iterator();
|
|
||||||
while (i.hasNext()) {
|
|
||||||
if (monitor.isCanceled())
|
|
||||||
return;
|
|
||||||
ITranslationUnit tu = (ITranslationUnit)i.next();
|
|
||||||
removeTU(fIndex, tu, 1);
|
|
||||||
if (tu.isSourceUnit()) {
|
|
||||||
updateInfo(1, 0, 0);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
updateInfo(0, 1, -1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
parseTUs(fIndex, 1, sources, headers, monitor);
|
|
||||||
if (monitor.isCanceled()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
finally {
|
|
||||||
fIndex.releaseReadLock();
|
|
||||||
}
|
|
||||||
} catch (CoreException e) {
|
|
||||||
CCorePlugin.log(e);
|
|
||||||
} catch (InterruptedException e) {
|
|
||||||
}
|
|
||||||
traceEnd(start, fIndex);
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean setupIndexAndReaderFactory() throws CoreException {
|
|
||||||
fIndex= ((IWritableIndexManager) CCorePlugin.getIndexManager()).getWritableIndex(getProject());
|
|
||||||
if (fIndex == null) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
fIndex.resetCacheCounters();
|
|
||||||
fIflCache = new HashMap/*<String,IIndexFileLocation>*/();
|
|
||||||
fCodeReaderFactory = new IndexBasedCodeReaderFactory(getCProject(), fIndex, fIflCache);
|
|
||||||
fCodeReaderFactory.setCallbackHandler(this);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void registerTUsInReaderFactory(Collection tus) throws CoreException {
|
|
||||||
int removed= 0;
|
|
||||||
for (Iterator iter = tus.iterator(); iter.hasNext();) {
|
|
||||||
ITranslationUnit tu = (ITranslationUnit) iter.next();
|
|
||||||
IIndexFileLocation ifl = IndexLocationFactory.getIFL(tu);
|
|
||||||
IndexFileInfo info= fCodeReaderFactory.createFileInfo(ifl);
|
|
||||||
if (updateAll()) {
|
|
||||||
info.fRequested= IndexFileInfo.REQUESTED;
|
|
||||||
}
|
|
||||||
else if (updateChangedTimestamps() && isOutdated(tu, info.fFile)) {
|
|
||||||
info.fRequested= IndexFileInfo.REQUESTED;
|
|
||||||
}
|
|
||||||
else if (updateChangedConfiguration()) {
|
|
||||||
info.fRequested= IndexFileInfo.REQUESTED_IF_CONFIG_CHANGED;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
iter.remove();
|
|
||||||
removed++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
updateInfo(0, 0, -removed);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected IIndexFileLocation findLocation(String absolutePath) {
|
|
||||||
IIndexFileLocation result = (IIndexFileLocation) fIflCache.get(absolutePath);
|
|
||||||
if(result==null) {
|
|
||||||
result = IndexLocationFactory.getIFLExpensive(getCProject(), absolutePath);
|
|
||||||
fIflCache.put(absolutePath, result);
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected IASTTranslationUnit createAST(AbstractLanguage lang, CodeReader codeReader, IScannerInfo scanInfo, int options, IProgressMonitor pm) throws CoreException {
|
|
||||||
// get the AST in a "Fast" way
|
|
||||||
IASTTranslationUnit ast= lang.getASTTranslationUnit(codeReader, scanInfo, fCodeReaderFactory, fIndex, options, ParserUtil.getParserLogService());
|
|
||||||
if (pm.isCanceled()) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
// Clear the macros
|
|
||||||
fCodeReaderFactory.clearMacroAttachements();
|
|
||||||
return ast;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected boolean needToUpdate(IIndexFileLocation location, int confighash) throws CoreException {
|
|
||||||
if (super.needToUpdate(location, confighash)) {
|
|
||||||
// file is requested or is not yet indexed.
|
|
||||||
IndexFileInfo info= fCodeReaderFactory.createFileInfo(location);
|
|
||||||
return needToUpdate(info, confighash);
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean needToUpdate(IndexFileInfo info) throws CoreException {
|
|
||||||
return needToUpdate(info, fCurrentConfigHash);
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean needToUpdate(IndexFileInfo info, int confighash) throws CoreException {
|
|
||||||
if (info.fFile == null) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (confighash != 0 && info.fRequested == IndexFileInfo.REQUESTED_IF_CONFIG_CHANGED) {
|
|
||||||
int oldhash= info.fFile.getScannerConfigurationHashcode();
|
|
||||||
if (oldhash == 0 || oldhash==confighash) {
|
|
||||||
info.fRequested= IndexFileInfo.NOT_REQUESTED;
|
|
||||||
updateInfo(0, 0, -1);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
info.fRequested= IndexFileInfo.REQUESTED;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return info.fRequested != IndexFileInfo.NOT_REQUESTED;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected boolean postAddToIndex(IIndexFileLocation path, IIndexFile file)
|
|
||||||
throws CoreException {
|
|
||||||
IndexFileInfo info= fCodeReaderFactory.createFileInfo(path);
|
|
||||||
info.fFile= file;
|
|
||||||
assert !info.hasCachedMacros();
|
|
||||||
if (info.fRequested != IndexFileInfo.NOT_REQUESTED) {
|
|
||||||
info.fRequested= IndexFileInfo.NOT_REQUESTED;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,215 +0,0 @@
|
||||||
/*******************************************************************************
|
|
||||||
* Copyright (c) 2006, 2007 QNX Software Systems 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:
|
|
||||||
* QNX - Initial API and implementation
|
|
||||||
* Markus Schorn (Wind River Systems)
|
|
||||||
*******************************************************************************/
|
|
||||||
|
|
||||||
package org.eclipse.cdt.internal.core.pdom.indexer.full;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.LinkedList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import org.eclipse.cdt.core.CCorePlugin;
|
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
|
||||||
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.AbstractLanguage;
|
|
||||||
import org.eclipse.cdt.core.model.CoreModel;
|
|
||||||
import org.eclipse.cdt.core.model.ITranslationUnit;
|
|
||||||
import org.eclipse.cdt.core.parser.CodeReader;
|
|
||||||
import org.eclipse.cdt.core.parser.IScannerInfo;
|
|
||||||
import org.eclipse.cdt.core.parser.ParserUtil;
|
|
||||||
import org.eclipse.cdt.internal.core.dom.SavedCodeReaderFactory;
|
|
||||||
import org.eclipse.cdt.internal.core.index.IIndexFragmentFile;
|
|
||||||
import org.eclipse.cdt.internal.core.index.IWritableIndex;
|
|
||||||
import org.eclipse.cdt.internal.core.index.IWritableIndexManager;
|
|
||||||
import org.eclipse.cdt.internal.core.pdom.indexer.PDOMIndexerTask;
|
|
||||||
import org.eclipse.core.runtime.CoreException;
|
|
||||||
import org.eclipse.core.runtime.IProgressMonitor;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Doug Schaefer
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
class PDOMFullIndexerTask extends PDOMIndexerTask {
|
|
||||||
private final static Object REQUIRED= new Object();
|
|
||||||
private final static Object MISSING = new Object();
|
|
||||||
private final static Object SKIP= new Object();
|
|
||||||
private final static Object REQUIRED_IF_CONFIG_CHANGED= new Object();
|
|
||||||
|
|
||||||
private List fChanged = new LinkedList();
|
|
||||||
private List fRemoved = new ArrayList();
|
|
||||||
private IWritableIndex fIndex = null;
|
|
||||||
private Map filePathsToParse = new HashMap/*<IIndexFileLocation, Object>*/();
|
|
||||||
private Map fIflCache = new HashMap/*<String, IIndexFileLocation>*/();
|
|
||||||
|
|
||||||
public PDOMFullIndexerTask(PDOMFullIndexer indexer, ITranslationUnit[] added,
|
|
||||||
ITranslationUnit[] changed, ITranslationUnit[] removed) {
|
|
||||||
super(indexer);
|
|
||||||
fChanged.addAll(Arrays.asList(added));
|
|
||||||
fChanged.addAll(Arrays.asList(changed));
|
|
||||||
fRemoved.addAll(Arrays.asList(removed));
|
|
||||||
updateInfo(0, 0, fChanged.size() + fRemoved.size());
|
|
||||||
}
|
|
||||||
|
|
||||||
public void run(IProgressMonitor monitor) {
|
|
||||||
long start = System.currentTimeMillis();
|
|
||||||
try {
|
|
||||||
// separate headers remove files that have no scanner configuration
|
|
||||||
final boolean filterFiles= !getIndexAllFiles() && getAllFilesProvided();
|
|
||||||
List headers= new ArrayList();
|
|
||||||
List sources= fChanged;
|
|
||||||
for (Iterator iter = fChanged.iterator(); iter.hasNext();) {
|
|
||||||
ITranslationUnit tu = (ITranslationUnit) iter.next();
|
|
||||||
if (tu.isSourceUnit()) {
|
|
||||||
if (filterFiles && CoreModel.isScannerInformationEmpty(tu.getResource())) {
|
|
||||||
iter.remove();
|
|
||||||
updateInfo(0, 0, -1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
headers.add(tu);
|
|
||||||
iter.remove();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!setupIndex()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
registerTUsInReaderFactory(sources);
|
|
||||||
registerTUsInReaderFactory(headers);
|
|
||||||
|
|
||||||
Iterator i= fRemoved.iterator();
|
|
||||||
while (i.hasNext()) {
|
|
||||||
if (monitor.isCanceled())
|
|
||||||
return;
|
|
||||||
ITranslationUnit tu = (ITranslationUnit)i.next();
|
|
||||||
removeTU(fIndex, tu, 0);
|
|
||||||
if (tu.isSourceUnit()) {
|
|
||||||
updateInfo(1, 0, 0);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
updateInfo(0, 1, -1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fIndex.acquireReadLock();
|
|
||||||
try {
|
|
||||||
parseTUs(fIndex, 1, sources, headers, monitor);
|
|
||||||
}
|
|
||||||
finally {
|
|
||||||
fIndex.releaseReadLock();
|
|
||||||
}
|
|
||||||
} catch (CoreException e) {
|
|
||||||
CCorePlugin.log(e);
|
|
||||||
} catch (InterruptedException e) {
|
|
||||||
}
|
|
||||||
traceEnd(start, fIndex);
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean setupIndex() throws CoreException {
|
|
||||||
// there is no mechanism to clear dirty files from the cache, so flush it.
|
|
||||||
SavedCodeReaderFactory.getInstance().getCodeReaderCache().flush();
|
|
||||||
|
|
||||||
fIndex = ((IWritableIndexManager) CCorePlugin.getIndexManager()).getWritableIndex(getProject());
|
|
||||||
if (fIndex == null) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
fIndex.resetCacheCounters();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void registerTUsInReaderFactory(Collection/*<ITranslationUnit>*/ sources)
|
|
||||||
throws CoreException {
|
|
||||||
int removed= 0;
|
|
||||||
filePathsToParse= new HashMap/*<IIndexFileLocation, Object>*/();
|
|
||||||
for (Iterator iter = sources.iterator(); iter.hasNext();) {
|
|
||||||
ITranslationUnit tu = (ITranslationUnit) iter.next();
|
|
||||||
IIndexFileLocation ifl= IndexLocationFactory.getIFL(tu);
|
|
||||||
if (updateAll()) {
|
|
||||||
filePathsToParse.put(ifl, REQUIRED);
|
|
||||||
}
|
|
||||||
else if (updateChangedTimestamps() && isOutdated(tu, fIndex.getFile(ifl))) {
|
|
||||||
filePathsToParse.put(ifl, REQUIRED);
|
|
||||||
}
|
|
||||||
else if (updateChangedConfiguration()) {
|
|
||||||
filePathsToParse.put(ifl, REQUIRED_IF_CONFIG_CHANGED);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
iter.remove();
|
|
||||||
removed++;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
updateInfo(0, 0, -removed);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected IIndexFileLocation findLocation(String absolutePath) {
|
|
||||||
IIndexFileLocation result = (IIndexFileLocation) fIflCache.get(absolutePath);
|
|
||||||
if(result==null) {
|
|
||||||
result = IndexLocationFactory.getIFLExpensive(getCProject(), absolutePath);
|
|
||||||
fIflCache.put(absolutePath, result);
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected IASTTranslationUnit createAST(AbstractLanguage lang, CodeReader codeReader, IScannerInfo scanInfo, int options, IProgressMonitor pm) throws CoreException {
|
|
||||||
SavedCodeReaderFactory codeReaderFactory= SavedCodeReaderFactory.getInstance();
|
|
||||||
IASTTranslationUnit ast= lang.getASTTranslationUnit(codeReader, scanInfo, codeReaderFactory, null, options, ParserUtil.getParserLogService());
|
|
||||||
if (pm.isCanceled()) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return ast;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean needToUpdate(IIndexFileLocation location, int confighash) throws CoreException {
|
|
||||||
if (super.needToUpdate(location, confighash)) {
|
|
||||||
Object required= filePathsToParse.get(location);
|
|
||||||
if (required == null) {
|
|
||||||
required= MISSING;
|
|
||||||
// bug 197311, don't attempt to update files in fragments of other projects.
|
|
||||||
IIndexFragmentFile file= (IIndexFragmentFile) fIndex.getFile(location);
|
|
||||||
if (file != null && !fIndex.isWritableFile(file)) {
|
|
||||||
required= SKIP;
|
|
||||||
}
|
|
||||||
filePathsToParse.put(location, required);
|
|
||||||
}
|
|
||||||
else if (confighash != 0 && required == REQUIRED_IF_CONFIG_CHANGED) {
|
|
||||||
IIndexFile file= fIndex.getFile(location);
|
|
||||||
if (file != null) {
|
|
||||||
int oldConfig= file.getScannerConfigurationHashcode();
|
|
||||||
if (oldConfig == 0 || oldConfig == confighash) {
|
|
||||||
required= SKIP;
|
|
||||||
updateInfo(0, 0, -1);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
required= REQUIRED;
|
|
||||||
}
|
|
||||||
filePathsToParse.put(location, required);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return required != SKIP;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected boolean postAddToIndex(IIndexFileLocation location, IIndexFile file)
|
|
||||||
throws CoreException {
|
|
||||||
Object required= filePathsToParse.get(location);
|
|
||||||
filePathsToParse.put(location, SKIP);
|
|
||||||
return required == REQUIRED;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -9,10 +9,7 @@
|
||||||
# Markus Schorn (Wind River Systems)
|
# Markus Schorn (Wind River Systems)
|
||||||
###############################################################################
|
###############################################################################
|
||||||
PDOMIndexerTask_collectingFilesTask=Collecting files (project ''{0}'')
|
PDOMIndexerTask_collectingFilesTask=Collecting files (project ''{0}'')
|
||||||
PDOMIndexerTask_tooManyIndexProblems=Too many problems while indexing project ''{0}'', stopping indexer.
|
|
||||||
PDOMImportTask_errorInvalidPDOMVersion=The version of the cdt-index to import for project {0} does not match
|
PDOMImportTask_errorInvalidPDOMVersion=The version of the cdt-index to import for project {0} does not match
|
||||||
PDOMIndexerTask_parsingFileTask=parsing {0} ({1})
|
|
||||||
PDOMIndexerTask_errorWhileParsing=Error while parsing {0}.
|
|
||||||
PDOMImportTask_errorInvalidArchive=Invalid Archive: {0}
|
PDOMImportTask_errorInvalidArchive=Invalid Archive: {0}
|
||||||
|
|
||||||
# {0} - task tag, {1} - task message.
|
# {0} - task tag, {1} - task message.
|
||||||
|
|
|
@ -25,3 +25,6 @@ TeamPDOMExportOperation_taskExportIndex=Export team shared index
|
||||||
TeamPDOMExportOperation_subtaskCreateDatabase=Creating database
|
TeamPDOMExportOperation_subtaskCreateDatabase=Creating database
|
||||||
TeamPDOMExportOperation_errorWriteTempFile=Cannot write to temporary file
|
TeamPDOMExportOperation_errorWriteTempFile=Cannot write to temporary file
|
||||||
TeamPDOMExportOperation_errorCreateArchive=Error creating archive
|
TeamPDOMExportOperation_errorCreateArchive=Error creating archive
|
||||||
|
AbstractIndexerTask_parsingFileTask=parsing {0} ({1})
|
||||||
|
AbstractIndexerTask_errorWhileParsing=Error while parsing {0}.
|
||||||
|
AbstractIndexerTask_tooManyIndexProblems=Too many errors while indexing, stopping indexer.
|
||||||
|
|
|
@ -531,19 +531,19 @@
|
||||||
id="nullindexer"
|
id="nullindexer"
|
||||||
name="%CDTIndexer.nullindexer"
|
name="%CDTIndexer.nullindexer"
|
||||||
point="org.eclipse.cdt.core.CIndexer">
|
point="org.eclipse.cdt.core.CIndexer">
|
||||||
<run class="org.eclipse.cdt.internal.core.pdom.indexer.nulli.PDOMNullIndexer"/>
|
<run class="org.eclipse.cdt.internal.core.pdom.indexer.PDOMNullIndexer"/>
|
||||||
</extension>
|
</extension>
|
||||||
<extension
|
<extension
|
||||||
id="fastIndexer"
|
id="fastIndexer"
|
||||||
name="%fastIndexer.name"
|
name="%fastIndexer.name"
|
||||||
point="org.eclipse.cdt.core.CIndexer">
|
point="org.eclipse.cdt.core.CIndexer">
|
||||||
<run class="org.eclipse.cdt.internal.core.pdom.indexer.fast.PDOMFastIndexer"/>
|
<run class="org.eclipse.cdt.internal.core.pdom.indexer.PDOMFastIndexer"/>
|
||||||
</extension>
|
</extension>
|
||||||
<extension
|
<extension
|
||||||
name="%CDTIndexer.domsourceindexer"
|
name="%CDTIndexer.domsourceindexer"
|
||||||
id="domsourceindexer"
|
id="domsourceindexer"
|
||||||
point="org.eclipse.cdt.core.CIndexer">
|
point="org.eclipse.cdt.core.CIndexer">
|
||||||
<run class="org.eclipse.cdt.internal.core.pdom.indexer.full.PDOMFullIndexer"/>
|
<run class="org.eclipse.cdt.internal.core.pdom.indexer.PDOMFullIndexer"/>
|
||||||
</extension>
|
</extension>
|
||||||
<extension
|
<extension
|
||||||
point="org.eclipse.core.variables.dynamicVariables">
|
point="org.eclipse.core.variables.dynamicVariables">
|
||||||
|
|
|
@ -53,7 +53,6 @@ import org.eclipse.cdt.internal.core.model.DeltaProcessor;
|
||||||
import org.eclipse.cdt.internal.core.model.IBufferFactory;
|
import org.eclipse.cdt.internal.core.model.IBufferFactory;
|
||||||
import org.eclipse.cdt.internal.core.model.Util;
|
import org.eclipse.cdt.internal.core.model.Util;
|
||||||
import org.eclipse.cdt.internal.core.pdom.PDOMManager;
|
import org.eclipse.cdt.internal.core.pdom.PDOMManager;
|
||||||
import org.eclipse.cdt.internal.core.pdom.indexer.fast.PDOMFastIndexer;
|
|
||||||
import org.eclipse.cdt.internal.core.settings.model.CProjectDescriptionManager;
|
import org.eclipse.cdt.internal.core.settings.model.CProjectDescriptionManager;
|
||||||
import org.eclipse.core.resources.IProject;
|
import org.eclipse.core.resources.IProject;
|
||||||
import org.eclipse.core.resources.IProjectDescription;
|
import org.eclipse.core.resources.IProjectDescription;
|
||||||
|
@ -103,7 +102,7 @@ public class CCorePlugin extends Plugin {
|
||||||
public static final String INDEXER_SIMPLE_ID = "CIndexer"; //$NON-NLS-1$
|
public static final String INDEXER_SIMPLE_ID = "CIndexer"; //$NON-NLS-1$
|
||||||
public static final String INDEXER_UNIQ_ID = PLUGIN_ID + "." + INDEXER_SIMPLE_ID; //$NON-NLS-1$
|
public static final String INDEXER_UNIQ_ID = PLUGIN_ID + "." + INDEXER_SIMPLE_ID; //$NON-NLS-1$
|
||||||
public static final String PREF_INDEXER = "indexer"; //$NON-NLS-1$
|
public static final String PREF_INDEXER = "indexer"; //$NON-NLS-1$
|
||||||
public static final String DEFAULT_INDEXER = PDOMFastIndexer.ID;
|
public static final String DEFAULT_INDEXER = IPDOMManager.ID_FAST_INDEXER;
|
||||||
|
|
||||||
public final static String ERROR_PARSER_SIMPLE_ID = "ErrorParser"; //$NON-NLS-1$
|
public final static String ERROR_PARSER_SIMPLE_ID = "ErrorParser"; //$NON-NLS-1$
|
||||||
public final static String ERROR_PARSER_UNIQ_ID = PLUGIN_ID + "." + ERROR_PARSER_SIMPLE_ID; //$NON-NLS-1$
|
public final static String ERROR_PARSER_UNIQ_ID = PLUGIN_ID + "." + ERROR_PARSER_SIMPLE_ID; //$NON-NLS-1$
|
||||||
|
|
|
@ -43,6 +43,7 @@ import org.eclipse.ui.WorkbenchException;
|
||||||
import org.eclipse.ui.handlers.IHandlerService;
|
import org.eclipse.ui.handlers.IHandlerService;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.CCorePlugin;
|
import org.eclipse.cdt.core.CCorePlugin;
|
||||||
|
import org.eclipse.cdt.core.dom.ILinkage;
|
||||||
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;
|
||||||
|
@ -98,7 +99,11 @@ public class BaseUITestCase extends BaseTestCase {
|
||||||
|
|
||||||
index.acquireReadLock();
|
index.acquireReadLock();
|
||||||
try {
|
try {
|
||||||
IIndexFile pfile= index.getFile(IndexLocationFactory.getWorkspaceIFL(file));
|
IIndexFile pfile= index.getFile(ILinkage.CPP_LINKAGE_ID, IndexLocationFactory.getWorkspaceIFL(file));
|
||||||
|
if (pfile != null && pfile.getTimestamp() >= file.getLocalTimeStamp()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
pfile= index.getFile(ILinkage.C_LINKAGE_ID, IndexLocationFactory.getWorkspaceIFL(file));
|
||||||
if (pfile != null && pfile.getTimestamp() >= file.getLocalTimeStamp()) {
|
if (pfile != null && pfile.getTimestamp() >= file.getLocalTimeStamp()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -615,11 +615,11 @@ public class BasicCallHierarchyTest extends CallHierarchyBaseTest {
|
||||||
editor.selectAndReveal(content1.indexOf("sf"), 0);
|
editor.selectAndReveal(content1.indexOf("sf"), 0);
|
||||||
openCallHierarchy(editor);
|
openCallHierarchy(editor);
|
||||||
tree = getCHTreeViewer().getTree();
|
tree = getCHTreeViewer().getTree();
|
||||||
i0= checkTreeNode(tree, 0, "sf()");
|
checkTreeNode(tree, 0, "sf()");
|
||||||
assertEquals(1, tree.getItemCount());
|
assertEquals(1, tree.getItemCount());
|
||||||
|
|
||||||
i1= checkTreeNode(i0, 0, "sf()"); // sf()[f2] <- sf()[f2]
|
i1= checkTreeNode(tree, 0, 0, "sf()"); // sf()[f2] <- sf()[f2]
|
||||||
checkTreeNode(i0, 1, null); // not called by gf()
|
checkTreeNode(tree, 0, 1, null); // not called by gf()
|
||||||
|
|
||||||
expandTreeItem(i1);
|
expandTreeItem(i1);
|
||||||
checkTreeNode(i1, 0, null);
|
checkTreeNode(i1, 0, null);
|
||||||
|
|
|
@ -170,11 +170,11 @@ public class CallHierarchyAcrossProjectsTest extends CallHierarchyBaseTest {
|
||||||
openCallHierarchy(editor);
|
openCallHierarchy(editor);
|
||||||
TreeViewer tv = getCHTreeViewer();
|
TreeViewer tv = getCHTreeViewer();
|
||||||
|
|
||||||
TreeItem item= checkTreeNode(tv.getTree(), 0, "MyClass::method3()");
|
checkTreeNode(tv.getTree(), 0, "MyClass::method3()");
|
||||||
TreeItem nextItem= checkTreeNode(item, 0, "MyClass::method2()");
|
TreeItem item= checkTreeNode(tv.getTree(), 0, 0, "MyClass::method2()");
|
||||||
checkTreeNode(item, 1, null); item= nextItem;
|
checkTreeNode(tv.getTree(), 0, 1, null);
|
||||||
tv.setExpandedState(item.getData(), true);
|
tv.setExpandedState(item.getData(), true);
|
||||||
nextItem= checkTreeNode(item, 0, "MyClass::method1()");
|
TreeItem nextItem= checkTreeNode(item, 0, "MyClass::method1()");
|
||||||
checkTreeNode(item, 1, null); item= nextItem;
|
checkTreeNode(item, 1, null); item= nextItem;
|
||||||
tv.setExpandedState(item.getData(), true);
|
tv.setExpandedState(item.getData(), true);
|
||||||
checkTreeNode(item, 0, null);
|
checkTreeNode(item, 0, null);
|
||||||
|
@ -220,10 +220,10 @@ public class CallHierarchyAcrossProjectsTest extends CallHierarchyBaseTest {
|
||||||
openCallHierarchy(editor);
|
openCallHierarchy(editor);
|
||||||
TreeViewer tv = getCHTreeViewer();
|
TreeViewer tv = getCHTreeViewer();
|
||||||
|
|
||||||
TreeItem item= checkTreeNode(tv.getTree(), 0, "MyClass::method3()");
|
checkTreeNode(tv.getTree(), 0, "MyClass::method3()");
|
||||||
TreeItem item0= checkTreeNode(item, 0, "MyClass::method1()");
|
TreeItem item0= checkTreeNode(tv.getTree(), 0, 0, "MyClass::method1()");
|
||||||
TreeItem item1= checkTreeNode(item, 1, "MyClass::method2()");
|
TreeItem item1= checkTreeNode(tv.getTree(), 0, 1, "MyClass::method2()");
|
||||||
checkTreeNode(item, 2, null); item= null;
|
checkTreeNode(tv.getTree(), 0, 2, null);
|
||||||
|
|
||||||
// method 1
|
// method 1
|
||||||
tv.setExpandedState(item0.getData(), true);
|
tv.setExpandedState(item0.getData(), true);
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
package org.eclipse.cdt.internal.ui.includebrowser;
|
package org.eclipse.cdt.internal.ui.includebrowser;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.core.runtime.IProgressMonitor;
|
import org.eclipse.core.runtime.IProgressMonitor;
|
||||||
|
@ -154,9 +155,16 @@ public class IBContentProvider extends AsyncTreeContentProvider {
|
||||||
private IIndexInclude[] findIncludedBy(IIndex index, IIndexFileLocation ifl, IProgressMonitor pm) {
|
private IIndexInclude[] findIncludedBy(IIndex index, IIndexFileLocation ifl, IProgressMonitor pm) {
|
||||||
try {
|
try {
|
||||||
if (ifl != null) {
|
if (ifl != null) {
|
||||||
IIndexFile file= index.getFile(ifl);
|
IIndexFile[] files= index.getFiles(ifl);
|
||||||
if (file != null) {
|
if (files.length == 1) {
|
||||||
return index.findIncludedBy(file);
|
return index.findIncludedBy(files[0]);
|
||||||
|
}
|
||||||
|
if (files.length > 0) {
|
||||||
|
ArrayList list= new ArrayList();
|
||||||
|
for (int i = 0; i < files.length; i++) {
|
||||||
|
list.addAll(Arrays.asList(index.findIncludedBy(files[i])));
|
||||||
|
}
|
||||||
|
return (IIndexInclude[]) list.toArray(new IIndexInclude[list.size()]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -169,9 +177,16 @@ public class IBContentProvider extends AsyncTreeContentProvider {
|
||||||
public IIndexInclude[] findIncludesTo(IIndex index, IIndexFileLocation ifl, IProgressMonitor pm) {
|
public IIndexInclude[] findIncludesTo(IIndex index, IIndexFileLocation ifl, IProgressMonitor pm) {
|
||||||
try {
|
try {
|
||||||
if (ifl != null) {
|
if (ifl != null) {
|
||||||
IIndexFile file= index.getFile(ifl);
|
IIndexFile[] files= index.getFiles(ifl);
|
||||||
if (file != null) {
|
if (files.length == 1) {
|
||||||
return index.findIncludes(file);
|
return index.findIncludes(files[0]);
|
||||||
|
}
|
||||||
|
if (files.length > 0) {
|
||||||
|
ArrayList list= new ArrayList();
|
||||||
|
for (int i = 0; i < files.length; i++) {
|
||||||
|
list.addAll(Arrays.asList(index.findIncludes(files[i])));
|
||||||
|
}
|
||||||
|
return (IIndexInclude[]) list.toArray(new IIndexInclude[list.size()]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -168,15 +168,16 @@ public class IndexUI {
|
||||||
if (tu != null) {
|
if (tu != null) {
|
||||||
IIndexFileLocation location= IndexLocationFactory.getIFL(tu);
|
IIndexFileLocation location= IndexLocationFactory.getIFL(tu);
|
||||||
if (location != null) {
|
if (location != null) {
|
||||||
IIndexFile file= index.getFile(location);
|
IIndexFile[] files= index.getFiles(location);
|
||||||
if (file != null) {
|
for (int i = 0; i < files.length; i++) {
|
||||||
|
IIndexFile file = files[i];
|
||||||
String elementName= element.getElementName();
|
String elementName= element.getElementName();
|
||||||
int idx= elementName.lastIndexOf(":")+1; //$NON-NLS-1$
|
int idx= elementName.lastIndexOf(":")+1; //$NON-NLS-1$
|
||||||
ISourceRange pos= sf.getSourceRange();
|
ISourceRange pos= sf.getSourceRange();
|
||||||
IRegion region = getConvertedRegion(tu, file, pos.getIdStartPos()+idx, pos.getIdLength()-idx);
|
IRegion region = getConvertedRegion(tu, file, pos.getIdStartPos()+idx, pos.getIdLength()-idx);
|
||||||
IIndexName[] names= file.findNames(region.getOffset(), region.getLength());
|
IIndexName[] names= file.findNames(region.getOffset(), region.getLength());
|
||||||
for (int i = 0; i < names.length; i++) {
|
for (int j = 0; j < names.length; j++) {
|
||||||
IIndexName name = names[i];
|
IIndexName name = names[j];
|
||||||
if (!name.isReference() && elementName.endsWith(new String(name.toCharArray()))) {
|
if (!name.isReference() && elementName.endsWith(new String(name.toCharArray()))) {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
@ -195,8 +196,8 @@ public class IndexUI {
|
||||||
if (tu != null) {
|
if (tu != null) {
|
||||||
IIndexFileLocation location= IndexLocationFactory.getIFL(tu);
|
IIndexFileLocation location= IndexLocationFactory.getIFL(tu);
|
||||||
if (location != null) {
|
if (location != null) {
|
||||||
IIndexFile file= index.getFile(location);
|
IIndexFile[] files= index.getFiles(location);
|
||||||
return file != null;
|
return files.length > 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -218,8 +219,9 @@ public class IndexUI {
|
||||||
if (tu != null) {
|
if (tu != null) {
|
||||||
IIndexFileLocation location= IndexLocationFactory.getIFL(tu);
|
IIndexFileLocation location= IndexLocationFactory.getIFL(tu);
|
||||||
if (location != null) {
|
if (location != null) {
|
||||||
IIndexFile file= index.getFile(location);
|
IIndexFile[] files= index.getFiles(location);
|
||||||
if (file != null) {
|
for (int j=0; j<files.length; j++) {
|
||||||
|
IIndexFile file= files[j];
|
||||||
String elementName= include.getElementName();
|
String elementName= include.getElementName();
|
||||||
elementName= elementName.substring(elementName.lastIndexOf('/')+1);
|
elementName= elementName.substring(elementName.lastIndexOf('/')+1);
|
||||||
ISourceRange pos= include.getSourceRange();
|
ISourceRange pos= include.getSourceRange();
|
||||||
|
|
Loading…
Add table
Reference in a new issue