Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--core/org.eclipse.cdt.core.tests/indexer/org/eclipse/cdt/core/indexer/tests/DependencyTests.java13
-rw-r--r--core/org.eclipse.cdt.core.tests/indexer/org/eclipse/cdt/core/indexer/tests/IndexManagerTests.java207
-rw-r--r--core/org.eclipse.cdt.core/dependency/org/eclipse/cdt/internal/core/sourcedependency/UpdateDependency.java2
-rw-r--r--core/org.eclipse.cdt.core/index/ChangeLog31
-rw-r--r--core/org.eclipse.cdt.core/index/org/eclipse/cdt/core/index/IIndexDelta.java18
-rw-r--r--core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/IEntryResult.java1
-rw-r--r--core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/IIndexerOutput.java9
-rw-r--r--core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/impl/BlocksIndexInput.java8
-rw-r--r--core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/impl/EntryResult.java15
-rw-r--r--core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/impl/GammaCompressedIndexBlock.java24
-rw-r--r--core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/impl/IIndexConstants.java2
-rw-r--r--core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/impl/InMemoryIndex.java32
-rw-r--r--core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/impl/IncludeEntry.java15
-rw-r--r--core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/impl/Index.java5
-rw-r--r--core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/impl/IndexDelta.java20
-rw-r--r--core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/impl/IndexedFileHashedArray.java4
-rw-r--r--core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/impl/IndexerOutput.java30
-rw-r--r--core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/impl/MergeFactory.java7
-rw-r--r--core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/impl/Util.java26
-rw-r--r--core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/impl/WordEntry.java94
-rw-r--r--core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/search/indexing/AbstractIndexer.java127
-rw-r--r--core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/search/indexing/AddCompilationUnitToIndex.java4
-rw-r--r--core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/search/indexing/AddFileToIndex.java19
-rw-r--r--core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/search/indexing/AddFolderToIndex.java7
-rw-r--r--core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/search/indexing/CleanEncounteredHeaders.java56
-rw-r--r--core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/search/indexing/IndexManager.java51
-rw-r--r--core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/search/indexing/IndexerModelListener.java2
-rw-r--r--core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/search/indexing/SourceIndexer.java3
-rw-r--r--core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/search/indexing/SourceIndexerRequestor.java502
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/DeltaProcessor.java2
-rw-r--r--core/org.eclipse.cdt.core/search/ChangeLog3
-rw-r--r--core/org.eclipse.cdt.core/search/org/eclipse/cdt/core/search/OrPattern.java2
-rw-r--r--core/org.eclipse.cdt.core/search/org/eclipse/cdt/internal/core/search/matching/CSearchPattern.java5
-rw-r--r--core/org.eclipse.cdt.core/search/org/eclipse/cdt/internal/core/search/matching/ClassDeclarationPattern.java3
-rw-r--r--core/org.eclipse.cdt.core/search/org/eclipse/cdt/internal/core/search/matching/FieldDeclarationPattern.java2
-rw-r--r--core/org.eclipse.cdt.core/search/org/eclipse/cdt/internal/core/search/matching/IncludePattern.java2
-rw-r--r--core/org.eclipse.cdt.core/search/org/eclipse/cdt/internal/core/search/matching/MacroDeclarationPattern.java2
-rw-r--r--core/org.eclipse.cdt.core/search/org/eclipse/cdt/internal/core/search/matching/MatchLocator.java199
-rw-r--r--core/org.eclipse.cdt.core/search/org/eclipse/cdt/internal/core/search/matching/MethodDeclarationPattern.java2
-rw-r--r--core/org.eclipse.cdt.core/search/org/eclipse/cdt/internal/core/search/matching/NamespaceDeclarationPattern.java2
40 files changed, 830 insertions, 728 deletions
diff --git a/core/org.eclipse.cdt.core.tests/indexer/org/eclipse/cdt/core/indexer/tests/DependencyTests.java b/core/org.eclipse.cdt.core.tests/indexer/org/eclipse/cdt/core/indexer/tests/DependencyTests.java
index 2dfd006bdda..b25d15f3685 100644
--- a/core/org.eclipse.cdt.core.tests/indexer/org/eclipse/cdt/core/indexer/tests/DependencyTests.java
+++ b/core/org.eclipse.cdt.core.tests/indexer/org/eclipse/cdt/core/indexer/tests/DependencyTests.java
@@ -14,10 +14,15 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.Set;
+
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
+
import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.core.index.IIndexChangeListener;
+import org.eclipse.cdt.core.index.IIndexDelta;
+import org.eclipse.cdt.core.index.IndexChangeEvent;
import org.eclipse.cdt.core.model.ICProject;
import org.eclipse.cdt.core.search.BasicSearchResultCollector;
import org.eclipse.cdt.core.search.ICSearchConstants;
@@ -89,6 +94,11 @@ import org.eclipse.core.runtime.Platform;
super.setUp();
//Create temp project
testProject = createProject("DepTestProject");
+ IPath pathLoc = CCorePlugin.getDefault().getStateLocation();
+
+ File indexFile = new File(pathLoc.append("281274758.index").toOSString());
+ if (indexFile.exists())
+ indexFile.delete();
testProject.setSessionProperty(IndexManager.activationKey,new Boolean(true));
@@ -208,7 +218,6 @@ import org.eclipse.core.runtime.Platform;
public void testDepTable() throws Exception{
//Add a file to the project
-
IFile cH = importFile("c.h","resources/dependency/c.h");
IFile aH = importFile("a.h","resources/dependency/a.h");
IFile Inc1H = importFile("Inc1.h","resources/dependency/Inc1.h");
@@ -220,7 +229,7 @@ import org.eclipse.core.runtime.Platform;
PathCollector pathCollector = new PathCollector();
getTableRefs(dH, pathCollector);
-
+
String[] dHModel = {IPath.SEPARATOR + "DepTestProject" + IPath.SEPARATOR + "DepTest2.cpp", IPath.SEPARATOR + "DepTestProject" + IPath.SEPARATOR + "DepTest.cpp", IPath.SEPARATOR + "DepTestProject" + IPath.SEPARATOR + "DepTest2.h"};
String[] iPath = pathCollector.getPaths();
diff --git a/core/org.eclipse.cdt.core.tests/indexer/org/eclipse/cdt/core/indexer/tests/IndexManagerTests.java b/core/org.eclipse.cdt.core.tests/indexer/org/eclipse/cdt/core/indexer/tests/IndexManagerTests.java
index 18352cc1c5e..a4261154ae2 100644
--- a/core/org.eclipse.cdt.core.tests/indexer/org/eclipse/cdt/core/indexer/tests/IndexManagerTests.java
+++ b/core/org.eclipse.cdt.core.tests/indexer/org/eclipse/cdt/core/indexer/tests/IndexManagerTests.java
@@ -14,12 +14,18 @@ import java.io.File;
import java.io.FileInputStream;
import java.io.FileWriter;
import java.io.IOException;
+import java.nio.ByteBuffer;
+import java.nio.channels.FileChannel;
+import java.security.MessageDigest;
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.core.index.IIndexChangeListener;
+import org.eclipse.cdt.core.index.IIndexDelta;
+import org.eclipse.cdt.core.index.IndexChangeEvent;
import org.eclipse.cdt.core.model.ICProject;
import org.eclipse.cdt.internal.core.index.IEntryResult;
import org.eclipse.cdt.internal.core.index.IIndex;
@@ -41,14 +47,15 @@ import org.eclipse.core.runtime.Path;
/**
* @author bgheorgh
*/
-public class IndexManagerTests extends TestCase {
+public class IndexManagerTests extends TestCase implements IIndexChangeListener {
IFile file;
IFileDocument fileDoc;
IProject testProject;
NullProgressMonitor monitor;
IndexManager indexManager;
-
- public static final int TIMEOUT = 5000;
+ boolean fileIndexed;
+
+ public static final int TIMEOUT = 50;
/**
* Constructor for IndexManagerTest.
* @param name
@@ -69,6 +76,12 @@ public class IndexManagerTests extends TestCase {
//Create temp project
testProject = createProject("IndexerTestProject");
+ IPath pathLoc = CCorePlugin.getDefault().getStateLocation();
+
+ File indexFile = new File(pathLoc.append("3915980774.index").toOSString());
+ if (indexFile.exists())
+ indexFile.delete();
+
testProject.setSessionProperty(IndexManager.activationKey,new Boolean(true));
@@ -77,6 +90,7 @@ public class IndexManagerTests extends TestCase {
indexManager = CCorePlugin.getDefault().getCoreModel().getIndexManager();
indexManager.reset();
+ indexManager.addIndexChangeListener(this);
}
/*
* @see TestCase#tearDown()
@@ -84,6 +98,7 @@ public class IndexManagerTests extends TestCase {
protected void tearDown() {
try {
super.tearDown();
+ indexManager.removeIndexChangeListener(this);
} catch (Exception e1) {
}
//Delete project
@@ -120,6 +135,7 @@ public class IndexManagerTests extends TestCase {
suite.addTest(new IndexManagerTests("testIndexContents"));
suite.addTest(new IndexManagerTests("testMacros"));
suite.addTest(new IndexManagerTests("testRefs"));
+ suite.addTest(new IndexManagerTests("testExactDeclarations"));
suite.addTest(new IndexManagerTests("testRemoveFileFromIndex"));
suite.addTest(new IndexManagerTests("testRemoveProjectFromIndex"));
suite.addTest(new IndexManagerTests("testIndexShutdown"));
@@ -153,9 +169,12 @@ public class IndexManagerTests extends TestCase {
* Start of tests
*/
public void testIndexAll() throws Exception {
+
//Add a file to the project
+ fileIndexed = false;
importFile("mail.cpp","resources/indexer/mail.cpp");
- Thread.sleep(5000);
+ while (fileIndexed != true){ Thread.sleep(TIMEOUT);}
+
IIndex ind = indexManager.getIndex(testProject.getFullPath(),true,true);
assertTrue("Index exists for project",ind != null);
@@ -188,27 +207,32 @@ public class IndexManagerTests extends TestCase {
}
public void testAddNewFileToIndex() throws Exception{
+
+
//Add a file to the project
+ fileIndexed = false;
importFile("mail.cpp","resources/indexer/mail.cpp");
- //Enable indexing on the created project
- //By doing this, we force the Index Manager to indexAll()
+ while (fileIndexed != true){ Thread.sleep(TIMEOUT);}
- Thread.sleep(10000);
//Make sure project got added to index
IPath testProjectPath = testProject.getFullPath();
IIndex ind = indexManager.getIndex(testProjectPath,true,true);
assertTrue("Index exists for project",ind != null);
//Add a new file to the project, give it some time to index
+ fileIndexed = false;
importFile("DocumentManager.h","resources/indexer/DocumentManager.h");
+ while (fileIndexed != true){ Thread.sleep(TIMEOUT);}
+
+ fileIndexed = false;
importFile("DocumentManager.cpp","resources/indexer/DocumentManager.cpp");
-
- Thread.sleep(10000);
+ while (fileIndexed != true){ Thread.sleep(TIMEOUT);}
+
ind = indexManager.getIndex(testProjectPath,true,true);
char[] prefix = "typeDecl/C/CDocumentManager".toCharArray();
- String [] entryResultModel ={"EntryResult: word=typeDecl/C/CDocumentManager, refs={ 1, 2 }"};
+ String [] entryResultModel ={"EntryResult: word=typeDecl/C/CDocumentManager, refs={ 2 }"};
IEntryResult[] eresults =ind.queryEntries(prefix);
-
+ IEntryResult[] bogRe = ind.queryEntries(IIndexConstants.TYPE_DECL);
assertTrue("Entry Result exists", eresults != null);
if (eresults.length != entryResultModel.length)
@@ -221,10 +245,13 @@ public class IndexManagerTests extends TestCase {
}
public void testRemoveProjectFromIndex() throws Exception{
+
+
//Add a file to the project
+ fileIndexed = false;
importFile("mail.cpp","resources/indexer/mail.cpp");
+ while (fileIndexed != true){ Thread.sleep(TIMEOUT);}
- Thread.sleep(TIMEOUT);
//Make sure project got added to index
IPath testProjectPath = testProject.getFullPath();
IIndex ind = indexManager.getIndex(testProjectPath,true,true);
@@ -253,25 +280,34 @@ public class IndexManagerTests extends TestCase {
}
public void testRemoveFileFromIndex() throws Exception{
- //Add a file to the project
- importFile("mail.cpp","resources/indexer/mail.cpp");
-
- Thread.sleep(TIMEOUT);
- //Make sure project got added to index
- IPath testProjectPath = testProject.getFullPath();
- IIndex ind = indexManager.getIndex(testProjectPath,true,true);
- assertTrue("Index exists for project",ind != null);
- //Add a new file to the project
- importFile("DocumentManager.h","resources/indexer/DocumentManager.h");
- importFile("DocumentManager.cpp","resources/indexer/DocumentManager.cpp");
- Thread.sleep(10000);
+
+ //Add a file to the project
+ fileIndexed = false;
+ importFile("mail.cpp","resources/indexer/mail.cpp");
+ while (fileIndexed != true){ Thread.sleep(TIMEOUT);}
+
+ //Make sure project got added to index
+ IPath testProjectPath = testProject.getFullPath();
+ IIndex ind = indexManager.getIndex(testProjectPath,true,true);
+ assertTrue("Index exists for project",ind != null);
+ //Add a new file to the project, give it some time to index
+ fileIndexed = false;
+ importFile("DocumentManager.h","resources/indexer/DocumentManager.h");
+ while (fileIndexed != true){ Thread.sleep(TIMEOUT);}
+
+ fileIndexed = false;
+ importFile("DocumentManager.cpp","resources/indexer/DocumentManager.cpp");
+ while (fileIndexed != true){ Thread.sleep(TIMEOUT);}
+
+ ind = indexManager.getIndex(testProjectPath,true,true);
+
//Do a "before" deletion comparison
- ind = indexManager.getIndex(testProjectPath,true,true);
+ //ind = indexManager.getIndex(testProjectPath,true,true);
char[] prefix = "typeDecl/".toCharArray();
IEntryResult[] eresults = ind.queryEntries(prefix);
assertTrue("Entry result found for typdeDecl/", eresults != null);
- String [] entryResultBeforeModel ={"EntryResult: word=typeDecl/C/CDocumentManager, refs={ 1, 2 }", "EntryResult: word=typeDecl/C/Mail, refs={ 3 }", "EntryResult: word=typeDecl/C/Unknown, refs={ 3 }", "EntryResult: word=typeDecl/C/container, refs={ 3 }", "EntryResult: word=typeDecl/C/first_class, refs={ 3 }", "EntryResult: word=typeDecl/C/postcard, refs={ 3 }", "EntryResult: word=typeDecl/D/Mail, refs={ 3 }", "EntryResult: word=typeDecl/D/first_class, refs={ 3 }", "EntryResult: word=typeDecl/D/postcard, refs={ 3 }", "EntryResult: word=typeDecl/V/, refs={ 1, 2 }", "EntryResult: word=typeDecl/V/PO_Box, refs={ 3 }", "EntryResult: word=typeDecl/V/index, refs={ 3 }", "EntryResult: word=typeDecl/V/mail, refs={ 3 }", "EntryResult: word=typeDecl/V/size, refs={ 3 }", "EntryResult: word=typeDecl/V/temp, refs={ 3 }", "EntryResult: word=typeDecl/V/x, refs={ 3 }"};
+ String [] entryResultBeforeModel ={"EntryResult: word=typeDecl/C/CDocumentManager, refs={ 2 }", "EntryResult: word=typeDecl/C/Mail, refs={ 3 }", "EntryResult: word=typeDecl/C/Unknown, refs={ 3 }", "EntryResult: word=typeDecl/C/container, refs={ 3 }", "EntryResult: word=typeDecl/C/first_class, refs={ 3 }", "EntryResult: word=typeDecl/C/postcard, refs={ 3 }", "EntryResult: word=typeDecl/D/Mail, refs={ 3 }", "EntryResult: word=typeDecl/D/first_class, refs={ 3 }", "EntryResult: word=typeDecl/D/postcard, refs={ 3 }", "EntryResult: word=typeDecl/V/, refs={ 1, 2 }", "EntryResult: word=typeDecl/V/PO_Box, refs={ 3 }", "EntryResult: word=typeDecl/V/index, refs={ 3 }", "EntryResult: word=typeDecl/V/mail, refs={ 3 }", "EntryResult: word=typeDecl/V/size, refs={ 3 }", "EntryResult: word=typeDecl/V/temp, refs={ 3 }", "EntryResult: word=typeDecl/V/x, refs={ 3 }"};
if (eresults.length != entryResultBeforeModel.length)
fail("Entry Result length different from model");
@@ -291,7 +327,7 @@ public class IndexManagerTests extends TestCase {
eresults = ind.queryEntries(prefix);
assertTrue("Entry exists", eresults != null);
- String [] entryResultAfterModel ={"EntryResult: word=typeDecl/C/CDocumentManager, refs={ 1, 2 }", "EntryResult: word=typeDecl/V/, refs={ 1, 2 }"};
+ String [] entryResultAfterModel ={"EntryResult: word=typeDecl/C/CDocumentManager, refs={ 2 }", "EntryResult: word=typeDecl/V/, refs={ 1, 2 }"};
if (eresults.length != entryResultAfterModel.length)
fail("Entry Result length different from model");
@@ -302,10 +338,12 @@ public class IndexManagerTests extends TestCase {
}
public void testIndexContents() throws Exception{
+
//Add a new file to the project, give it some time to index
+ fileIndexed = false;
importFile("extramail.cpp","resources/indexer/extramail.cpp");
-
- Thread.sleep(TIMEOUT);
+ while (fileIndexed != true){ Thread.sleep(TIMEOUT);}
+
//Make sure project got added to index
IPath testProjectPath = testProject.getFullPath();
IIndex ind = indexManager.getIndex(testProjectPath,true,true);
@@ -416,10 +454,11 @@ public class IndexManagerTests extends TestCase {
}
public void testRefs() throws Exception{
- //Add a new file to the project, give it some time to index
+ //Add a new file to the project, give it some time to index
+ fileIndexed = false;
importFile("reftest.cpp","resources/indexer/reftest.cpp");
-
- Thread.sleep(TIMEOUT);
+ while (fileIndexed != true){ Thread.sleep(TIMEOUT);}
+
//Make sure project got added to index
IPath testProjectPath = testProject.getFullPath();
IIndex ind = indexManager.getIndex(testProjectPath,true,true);
@@ -486,12 +525,95 @@ public class IndexManagerTests extends TestCase {
}
}
+ public void testExactDeclarations() throws Exception
+ {
+
+ fileIndexed = false;
+ importFile("a.h","resources/dependency/a.h");
+ while (fileIndexed != true){ Thread.sleep(TIMEOUT);}
+
+ //Make sure project got added to index
+ IPath testProjectPath = testProject.getFullPath();
+ IIndex ind = indexManager.getIndex(testProjectPath,true,true);
+ assertTrue("Index exists for project",ind != null);
+
+ fileIndexed = false;
+ importFile("DepTest3.h","resources/dependency/DepTest3.h");
+ while (fileIndexed != true){ Thread.sleep(TIMEOUT);}
+
+ fileIndexed = false;
+ importFile("DepTest3.cpp","resources/dependency/DepTest3.cpp");
+ while (fileIndexed != true){ Thread.sleep(TIMEOUT);}
+
+
+ IEntryResult[] eResult = ind.queryEntries(IIndexConstants.CLASS_DECL);
+ IQueryResult[] qResult = ind.queryPrefix(IIndexConstants.CLASS_DECL);
+
+ assertTrue("Expected 2 files indexed", qResult.length == 2);
+ assertTrue("Checking DepTest3.h location", qResult[0].getPath().equals("/IndexerTestProject/DepTest3.h"));
+ assertTrue("Checking a.h location", qResult[1].getPath().equals("/IndexerTestProject/a.h"));
+
+ assertTrue("Expect 2 class declaration entries", eResult.length == 2);
+
+ int[] DepTest3FileRefs = {2};
+
+ int[] fileRefs = eResult[0].getFileReferences();
+
+ assertTrue("Check DepTest3 File Refs number", fileRefs.length == 1);
+
+ for (int i=0; i<fileRefs.length; i++){
+ assertTrue("Verify DepTest3 File Ref",fileRefs[i] == DepTest3FileRefs[i]);
+ }
+
+ int[] aFileRefs = {3};
+
+ fileRefs = eResult[1].getFileReferences();
+
+ assertTrue("Check a.h File Refs number", fileRefs.length == 1);
+
+ for (int i=0; i<fileRefs.length; i++){
+ assertTrue("Verify a.h File Ref",fileRefs[i] == aFileRefs[i]);
+ }
+
+ }
+
+ public void testMD5() throws Exception
+ {
+ fileIndexed = false;
+ importFile("extramail.cpp","resources/indexer/extramail.cpp");
+ //importFile("mail.cpp","resources/indexer/mail.cpp");
+
+ while (fileIndexed != true){ Thread.sleep(TIMEOUT);}
+
+ MessageDigest md = MessageDigest.getInstance("MD5");
+ //MessageDigest md = MessageDigest.getInstance("SHA");
+ String fileName = testProject.getFile("extramail.cpp").getLocation().toOSString();
+ //String fileName = testProject.getFile("mail.cpp").getLocation().toOSString();
+
+ long startTime = System.currentTimeMillis();
+
+ FileInputStream stream = new FileInputStream(fileName);
+ FileChannel channel = stream.getChannel();
+
+ ByteBuffer byteBuffer = ByteBuffer.allocate((int)channel.size());
+ channel.read(byteBuffer);
+ byteBuffer.rewind();
+
+ md.update(byteBuffer.array());
+ byte[] messageDigest = md.digest();
+
+ //System.out.println("Elapsed Time: " + (System.currentTimeMillis() - startTime) + " ms");
+
+
+ }
+
public void testMacros() throws Exception
{
//Add a new file to the project, give it some time to index
+ fileIndexed = false;
importFile("extramail.cpp","resources/indexer/extramail.cpp");
-
- Thread.sleep(TIMEOUT);
+ while (fileIndexed != true){ Thread.sleep(TIMEOUT);}
+
//Make sure project got added to index
IPath testProjectPath = testProject.getFullPath();
IIndex ind = indexManager.getIndex(testProjectPath,true,true);
@@ -513,9 +635,10 @@ public class IndexManagerTests extends TestCase {
public void testIndexShutdown() throws Exception{
//Add a new file to the project, give it some time to index
+ fileIndexed = false;
importFile("reftest.cpp","resources/indexer/reftest.cpp");
-
- Thread.sleep(TIMEOUT);
+ while (fileIndexed != true){ Thread.sleep(TIMEOUT);}
+
//Make sure project got added to index
IPath testProjectPath = testProject.getFullPath();
IIndex ind = indexManager.getIndex(testProjectPath,true,true);
@@ -549,9 +672,10 @@ public class IndexManagerTests extends TestCase {
public void testForwardDeclarations() throws Exception{
//Add a new file to the project, give it some time to index
+ fileIndexed = false;
importFile("reftest.cpp","resources/indexer/reftest.cpp");
-
- Thread.sleep(TIMEOUT);
+ while (fileIndexed != true){ Thread.sleep(TIMEOUT);}
+
//Make sure project got added to index
IPath testProjectPath = testProject.getFullPath();
IIndex ind = indexManager.getIndex(testProjectPath,true,true);
@@ -585,4 +709,11 @@ public class IndexManagerTests extends TestCase {
}
}
+public void indexChanged(IndexChangeEvent event) {
+ IIndexDelta delta = event.getDelta();
+ if (delta.getDeltaType() == IIndexDelta.MERGE_DELTA){
+ fileIndexed = true;
+ }
+}
+
}
diff --git a/core/org.eclipse.cdt.core/dependency/org/eclipse/cdt/internal/core/sourcedependency/UpdateDependency.java b/core/org.eclipse.cdt.core/dependency/org/eclipse/cdt/internal/core/sourcedependency/UpdateDependency.java
index b4ed77d0fad..20ba9ba99d3 100644
--- a/core/org.eclipse.cdt.core/dependency/org/eclipse/cdt/internal/core/sourcedependency/UpdateDependency.java
+++ b/core/org.eclipse.cdt.core/dependency/org/eclipse/cdt/internal/core/sourcedependency/UpdateDependency.java
@@ -99,7 +99,7 @@ public class UpdateDependency implements IJob {
if (fileToReindex!=null && fileToReindex.exists() ) {
// if (VERBOSE)
// System.out.println("Going to reindex " + fileToReindex.getName());
- indexManager.addSource(fileToReindex,fileToReindex.getProject().getProject().getFullPath(), false);
+ indexManager.addSource(fileToReindex,fileToReindex.getProject().getProject().getFullPath());
}
}
return false;
diff --git a/core/org.eclipse.cdt.core/index/ChangeLog b/core/org.eclipse.cdt.core/index/ChangeLog
index b16493ec3dd..74078e8db8e 100644
--- a/core/org.eclipse.cdt.core/index/ChangeLog
+++ b/core/org.eclipse.cdt.core/index/ChangeLog
@@ -1,3 +1,34 @@
+2004-11-02 Bogdan Gheorghe
+ Partial Fix for Bug 74427: Indexer needs to store more info
+
+ * index/org/eclipse/cdt/core/index/IIndexDelta.java
+ * index/org/eclipse/cdt/internal/core/index/IEntryResult.java
+ * index/org/eclipse/cdt/internal/core/index/IIndexerOutput.java
+ * index/org/eclipse/cdt/internal/core/index/impl/BlocksIndexInput.java
+ * index/org/eclipse/cdt/internal/core/index/impl/EntryResult.java
+ * index/org/eclipse/cdt/internal/core/index/impl/GammaCompressedIndexBlock.java
+ * index/org/eclipse/cdt/internal/core/index/impl/IIndexConstants.java
+ * index/org/eclipse/cdt/internal/core/index/impl/IncludeEntry.java
+ * index/org/eclipse/cdt/internal/core/index/impl/Index.java
+ * index/org/eclipse/cdt/internal/core/index/impl/IndexDelta.java
+ * index/org/eclipse/cdt/internal/core/index/impl/IndexedFileHashedArray.java
+ * index/org/eclipse/cdt/internal/core/index/impl/IndexerOutput.java
+ * index/org/eclipse/cdt/internal/core/index/impl/InMemoryIndex.java
+ * index/org/eclipse/cdt/internal/core/index/impl/MergeFactory.java
+ * index/org/eclipse/cdt/internal/core/index/impl/Util.java
+ * index/org/eclipse/cdt/internal/core/index/impl/WordEntry.java
+ * index/org/eclipse/cdt/internal/core/search/indexing/AbstractIndexer.java
+ * index/org/eclipse/cdt/internal/core/search/indexing/AddCompilationUnitToIndex.java
+ * index/org/eclipse/cdt/internal/core/search/indexing/AddFileToIndex.java
+ * index/org/eclipse/cdt/internal/core/search/indexing/AddFolderToIndex.java
+ * index/org/eclipse/cdt/internal/core/search/indexing/CleanEncounteredHeaders.java
+ * index/org/eclipse/cdt/internal/core/search/indexing/IndexerModelListener.java
+ * index/org/eclipse/cdt/internal/core/search/indexing/IndexManager.java
+ * index/org/eclipse/cdt/internal/core/search/indexing/SourceIndexer.java
+ * index/org/eclipse/cdt/internal/core/search/indexing/SourceIndexerRequestor.java
+ * dependency/org/eclipse/cdt/internal/core/sourcedependency/UpdateDependency.java
+ * model/org/eclipse/cdt/internal/core/model/DeltaProcessor.java
+
2004-08-19 Bogdan Gheorghe
Fix for Bug 71500: [Indexer] all headers get indexed on project open
diff --git a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/core/index/IIndexDelta.java b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/core/index/IIndexDelta.java
index d2a50d441c0..e2e1f5614ba 100644
--- a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/core/index/IIndexDelta.java
+++ b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/core/index/IIndexDelta.java
@@ -16,6 +16,20 @@ import java.util.ArrayList;
import org.eclipse.core.resources.IProject;
public interface IIndexDelta {
+
+ public class IndexDeltaType {
+
+ private IndexDeltaType( int value )
+ {
+ this.value = value;
+ }
+ private final int value;
+ }
+
+ public static final IndexDeltaType MERGE_DELTA = new IndexDeltaType( 0 );
+
+ public static final IndexDeltaType INDEX_FINISHED_DELTA = new IndexDeltaType( 1 );
+
/**
* @return Returns the files.
*/
@@ -24,5 +38,9 @@ public interface IIndexDelta {
* @return Returns the project.
*/
public IProject getProject();
+ /**
+ * @return Returns the delta type.
+ */
+ public IndexDeltaType getDeltaType();
}
diff --git a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/IEntryResult.java b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/IEntryResult.java
index 3df76889235..7f0d72d23eb 100644
--- a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/IEntryResult.java
+++ b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/IEntryResult.java
@@ -11,6 +11,7 @@
package org.eclipse.cdt.internal.core.index;
public interface IEntryResult {
+ public int[] getIndexFlags();
public int[] getFileReferences();
public char[] getWord();
}
diff --git a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/IIndexerOutput.java b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/IIndexerOutput.java
index 19d575bb697..0157dc05f60 100644
--- a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/IIndexerOutput.java
+++ b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/IIndexerOutput.java
@@ -10,6 +10,8 @@
*******************************************************************************/
package org.eclipse.cdt.internal.core.index;
+import org.eclipse.cdt.internal.core.index.impl.IndexedFile;
+
/**
* This class represents the output from an indexer to an index
* for a single document.
@@ -17,8 +19,11 @@ package org.eclipse.cdt.internal.core.index;
public interface IIndexerOutput {
public void addDocument(IDocument document);
- public void addRef(char[] word);
- public void addRef(String word);
+ public void addRef(char[] word, int indexFlags);
+ public void addRef(String word, int indexFlags);
+ public IndexedFile getIndexedFile(String path);
+ public IndexedFile addSecondaryIndexedFile(IDocument document);
+ public IndexedFile addSecondaryExternalIndexedFile(String path);
//For Dep Tree
public void addIncludeRef(char[] word);
public void addIncludeRef(String word);
diff --git a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/impl/BlocksIndexInput.java b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/impl/BlocksIndexInput.java
index 77fc70fa078..6cdfc110b63 100644
--- a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/impl/BlocksIndexInput.java
+++ b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/impl/BlocksIndexInput.java
@@ -245,7 +245,7 @@ public class BlocksIndexInput extends IndexInput {
case -1 :
WordEntry entry = getEntry(pattern);
if (entry == null) return null;
- return new IEntryResult[]{ new EntryResult(entry.getWord(), entry.getRefs()) };
+ return new IEntryResult[]{ new EntryResult(entry.getWord(), entry.getRefs(), entry.getRefsIndexFlags()) };
case 0 :
blockNums = summary.getAllBlockNums();
break;
@@ -267,7 +267,7 @@ public class BlocksIndexInput extends IndexInput {
if (count == entries.length){
System.arraycopy(entries, 0, entries = new IEntryResult[count*2], 0, count);
}
- entries[count++] = new EntryResult(entry.getWord(), entry.getRefs());
+ entries[count++] = new EntryResult(entry.getWord(), entry.getRefs(), entry.getRefsIndexFlags());
found = true;
} else {
if (found) break;
@@ -297,7 +297,7 @@ public class BlocksIndexInput extends IndexInput {
if (count == entries.length){
System.arraycopy(entries, 0, entries = new IEntryResult[count*2], 0, count);
}
- entries[count++] = new EntryResult(entry.getWord(), entry.getRefs());
+ entries[count++] = new EntryResult(entry.getWord(), entry.getRefs(), entry.getRefsIndexFlags());
found = true;
} else {
if (found) break;
@@ -410,7 +410,7 @@ public class BlocksIndexInput extends IndexInput {
boolean endOfBlock= !currentIncludeIndexBlock.nextEntry(currentIncludeEntry);
if (endOfBlock) {
currentIncludeIndexBlock= getIndexBlock(++currentIncludeBlockNum);
- currentIncludeIndexBlock.nextEntry(currentWordEntry);
+ currentIncludeIndexBlock.nextEntry(currentIncludeEntry);
}
}
/* (non-Javadoc)
diff --git a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/impl/EntryResult.java b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/impl/EntryResult.java
index 32867e1cec8..15ceaf4a55e 100644
--- a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/impl/EntryResult.java
+++ b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/impl/EntryResult.java
@@ -17,10 +17,12 @@ import org.eclipse.cdt.internal.core.index.IEntryResult;
public class EntryResult implements IEntryResult {
private char[] word;
private int[] fileRefs;
+ private int[] indexFlags;
-public EntryResult(char[] word, int[] refs) {
+public EntryResult(char[] word, int[] refs, int[] indexFlags) {
this.word = word;
this.fileRefs = refs;
+ this.indexFlags = indexFlags;
}
public boolean equals(Object anObject){
@@ -37,6 +39,13 @@ public boolean equals(Object anObject){
for (int i = 0; i < length; i++){
if (refs[i] != otherRefs[i]) return false;
}
+
+ int[] indexRefs, indexOtherRefs;
+ if ((length = (indexRefs = this.indexFlags).length) != (indexOtherRefs = anEntryResult.indexFlags).length) return false;
+ for (int i = 0; i < length; i++){
+ if (indexRefs[i] != indexOtherRefs[i]) return false;
+ }
+
return true;
}
return false;
@@ -64,5 +73,9 @@ public String toString(){
buffer.append(" }"); //$NON-NLS-1$
return buffer.toString();
}
+
+public int[] getIndexFlags() {
+ return indexFlags;
+}
}
diff --git a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/impl/GammaCompressedIndexBlock.java b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/impl/GammaCompressedIndexBlock.java
index fce8d1733c0..820c65e0c69 100644
--- a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/impl/GammaCompressedIndexBlock.java
+++ b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/impl/GammaCompressedIndexBlock.java
@@ -47,6 +47,7 @@ public class GammaCompressedIndexBlock extends IndexBlock {
codeStream.writeUTF(word, prefixLen, word.length);
int n= entry.getNumRefs();
codeStream.writeGamma(n);
+ //encode file references
int prevRef= 0;
for (int i= 0; i < n; ++i) {
int ref= entry.getRef(i);
@@ -55,6 +56,16 @@ public class GammaCompressedIndexBlock extends IndexBlock {
codeStream.writeGamma(ref - prevRef);
prevRef= ref;
}
+ //encode index bit field
+ //FUTURE USE: For index parms etc.
+ /*if (entry.fRefs.length != entry.fRefsIndexFlags.length)
+ throw new IndexOutOfBoundsException();
+
+ for (int i=0; i < n; ++i) {
+ int indexField = entry.getIndexFlag(i);
+ codeStream.writeGamma(indexField);
+ }*/
+
}
/**
* @see IndexBlock#addEntry
@@ -133,9 +144,20 @@ public class GammaCompressedIndexBlock extends IndexBlock {
int ref= prevRef + readCodeStream.readGamma();
if (ref < prevRef)
throw new InternalError();
- entry.addRef(ref);
+ entry.addRef(ref,0);
prevRef= ref;
}
+
+ /* //Now read in the index bit fields
+ //FUTURE USE: For index parms etc.
+ for (int i=0; i<n; ++i) {
+ int indexField = readCodeStream.readGamma();
+ //The index fields are encoded in the same order as
+ //the file refs read above. So the first one belongs
+ //to whatever the first file reference is
+ entry.fRefsIndexFlags[i]=indexField;
+ }*/
+
offset= readCodeStream.byteLength();
prevWord= word;
return true;
diff --git a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/impl/IIndexConstants.java b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/impl/IIndexConstants.java
index f464514d5d6..c66b976ec3f 100644
--- a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/impl/IIndexConstants.java
+++ b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/impl/IIndexConstants.java
@@ -17,7 +17,7 @@ public interface IIndexConstants {
/**
* The signature of the index file.
*/
- public static final String SIGNATURE= "INDEX FILE 0.014"; //$NON-NLS-1$
+ public static final String SIGNATURE= "INDEX FILE 0.015"; //$NON-NLS-1$
/**
* The separator for files in the index file.
*/
diff --git a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/impl/InMemoryIndex.java b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/impl/InMemoryIndex.java
index bd041b1754f..ca81de5a211 100644
--- a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/impl/InMemoryIndex.java
+++ b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/impl/InMemoryIndex.java
@@ -57,6 +57,13 @@ public class InMemoryIndex {
return indexedFile;
}
+ public IndexedFile addExternalFilePath(String path){
+ IndexedFile indexedFile = this.files.add(path);
+ this.footprint += indexedFile.footprint() + 4;
+ this.sortedFiles = null;
+ return indexedFile;
+ }
+
public void addIncludeRef(IndexedFile indexedFile, char[] include) {
addIncludeRef(include, indexedFile.getFileNumber());
}
@@ -88,9 +95,7 @@ public class InMemoryIndex {
entry.addRef(fileNum);
this.includes.add(entry);
this.sortedIncludeEntries= null;
- //TODO: BOG FIGURE OUT FOOTPRINT
- //this.footprint += entry.getClass(); //footprint();
- //
+ this.footprint += entry.footprint();
} else {
this.footprint += entry.addRef(fileNum);
}
@@ -99,38 +104,41 @@ public class InMemoryIndex {
/**
* Adds the references of the word to the index (reference = number of the file the word belongs to).
*/
- protected void addRef(char[] word, int[] references) {
+ protected void addRef(char[] word, int[] references, int[] indexFlags) {
int size= references.length;
int i= 0;
while (i < size) {
if (references[i] != 0)
- addRef(word, references[i]);
+ addRef(word, references[i], indexFlags[i]);
i++;
}
}
/**
* Looks if the word already exists in the index and add the fileNum to this word.
* If the word does not exist, it adds it in the index.
+ * @param indexFlags
*/
- protected void addRef(char[] word, int fileNum) {
+ protected void addRef(char[] word, int fileNum, int indexFlags) {
WordEntry entry= this.words.get(word);
if (entry == null) {
entry= new WordEntry(word);
- entry.addRef(fileNum);
+ //entry.addRef(fileNum, indexFlags);
+ entry.addRef(indexFlags, indexFlags);
this.words.add(entry);
this.sortedWordEntries= null;
this.footprint += entry.footprint();
} else {
- this.footprint += entry.addRef(fileNum);
+ //this.footprint += entry.addRef(fileNum, indexFlags);
+ this.footprint += entry.addRef(indexFlags, indexFlags);
}
}
- public void addRef(IndexedFile indexedFile, char[] word) {
- addRef(word, indexedFile.getFileNumber());
+ public void addRef(IndexedFile indexedFile, char[] word, int indexFlags) {
+ addRef(word, indexedFile.getFileNumber(), indexFlags);
}
- public void addRef(IndexedFile indexedFile, String word) {
- addRef(word.toCharArray(), indexedFile.getFileNumber());
+ public void addRef(IndexedFile indexedFile, String word, int indexFlags) {
+ addRef(word.toCharArray(), indexedFile.getFileNumber(), indexFlags);
}
public void addRelatives(IndexedFile indexedFile, String inclusion, String parent) {
diff --git a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/impl/IncludeEntry.java b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/impl/IncludeEntry.java
index 7f1b76bc494..3ff8ba0fbde 100644
--- a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/impl/IncludeEntry.java
+++ b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/impl/IncludeEntry.java
@@ -167,7 +167,7 @@ public class IncludeEntry {
fRefs[position++]= map;
}
fNumRefs= position;
-
+
//to be changed!
System.arraycopy(fRefs, 0, (fRefs= new int[fNumRefs]), 0, fNumRefs);
Util.sort(fRefs);
@@ -224,4 +224,17 @@ public class IncludeEntry {
tempBuffer.append("} >"); //$NON-NLS-1$
return tempBuffer.toString();
}
+
+ /**
+ * @return
+ */
+ public long footprint() {
+ //Size of Object + (number of fields * size of Fields) +
+ //(Size of ArrayListObject + (Number of Nodes * sizeof Node)) + (Size of ArrayObject + (Number of fFile * sizeof char)) +
+ //(Size of ArrayListObject + (Number of Nodes * sizeof Node)) +
+ //(Size of ArrayObject + (Number of refs * sizeof int))
+ return 8 + (8 * 4) +
+ (8 + fChild.size() * (8 + 2 * 4)) + (8 + fFile.length * 2) +
+ (8 + fParent.size() * (8 + 2 * 4)) + (8 + fRefs.length * 4);
+ }
}
diff --git a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/impl/Index.java b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/impl/Index.java
index 5724f318b5d..69841fbb7c9 100644
--- a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/impl/Index.java
+++ b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/impl/Index.java
@@ -18,6 +18,7 @@ import java.util.List;
import java.util.Map;
import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.core.index.IIndexDelta;
import org.eclipse.cdt.internal.core.index.IDocument;
import org.eclipse.cdt.internal.core.index.IEntryResult;
import org.eclipse.cdt.internal.core.index.IIndex;
@@ -275,6 +276,10 @@ public class Index implements IIndex {
state= MERGED;
//flush the CDT log
CCorePlugin.getDefault().cdtLog.flushLog();
+
+ //Send out notification to listeners;
+ IndexDelta indexDelta = new IndexDelta(null,null,IIndexDelta.MERGE_DELTA);
+ CCorePlugin.getDefault().getCoreModel().getIndexManager().notifyListeners(indexDelta);
}
}
/**
diff --git a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/impl/IndexDelta.java b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/impl/IndexDelta.java
index 3aa52ce80df..f5f571965c6 100644
--- a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/impl/IndexDelta.java
+++ b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/impl/IndexDelta.java
@@ -19,6 +19,7 @@ public class IndexDelta implements IIndexDelta {
private ArrayList files = null;
private IProject project = null;
+ private IndexDeltaType deltaType = null;
/**
* @param filesTrav
@@ -26,10 +27,20 @@ public class IndexDelta implements IIndexDelta {
*
*/
public IndexDelta(IProject project, ArrayList filesTrav) {
+ this(project,filesTrav,null);
+ }
+
+ /**
+ * @param filesTrav
+ * @param project
+ *
+ */
+ public IndexDelta(IProject project, ArrayList filesTrav, IndexDeltaType indexDeltaType) {
this.project = project;
this.files = filesTrav;
+ this.deltaType = indexDeltaType;
}
-
+
/**
* @return Returns the files.
*/
@@ -42,4 +53,11 @@ public class IndexDelta implements IIndexDelta {
public IProject getProject() {
return project;
}
+
+ /**
+ * @see org.eclipse.cdt.core.index.IIndexDelta#getDeltaType()
+ */
+ public IndexDeltaType getDeltaType() {
+ return deltaType;
+ }
}
diff --git a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/impl/IndexedFileHashedArray.java b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/impl/IndexedFileHashedArray.java
index 713b9761b3a..024cc42da0c 100644
--- a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/impl/IndexedFileHashedArray.java
+++ b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/impl/IndexedFileHashedArray.java
@@ -35,6 +35,10 @@ public IndexedFile add(IDocument document) {
return add(new IndexedFile(document, ++lastId));
}
+public IndexedFile add(String path){
+ return add(new IndexedFile(path, ++lastId));
+}
+
private IndexedFile add(IndexedFile file) {
int length = elements.length;
String path = file.getPath();
diff --git a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/impl/IndexerOutput.java b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/impl/IndexerOutput.java
index 396761894ce..d50be9d3802 100644
--- a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/impl/IndexerOutput.java
+++ b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/impl/IndexerOutput.java
@@ -43,17 +43,17 @@ public class IndexerOutput implements IIndexerOutput {
/**
* Adds a reference to the given word to the inMemoryIndex.
*/
- public void addRef(char[] word) {
+ public void addRef(char[] word, int indexFlags) {
if (indexedFile == null) {
throw new IllegalStateException();
}
- index.addRef(indexedFile, word);
+ index.addRef(indexedFile, word, indexFlags);
}
/**
* Adds a reference to the given word to the inMemoryIndex.
*/
- public void addRef(String word) {
- addRef(word.toCharArray());
+ public void addRef(String word, int indexFlags) {
+ addRef(word.toCharArray(), indexFlags);
}
public void addRelatives(String inclusion, String parent) {
@@ -74,4 +74,26 @@ public class IndexerOutput implements IIndexerOutput {
addIncludeRef(word.toCharArray());
}
+ public IndexedFile getIndexedFile(String path) {
+ return index.getIndexedFile(path);
+ }
+
+ /**
+ * Adds a file to the InMemoryIndex but does not supplant the current
+ * file being indexed. This method is to be used if the current file being indexed
+ * needs to make reference to a file that has not been added to the index as of yet.
+ */
+ public IndexedFile addSecondaryIndexedFile(IDocument document) {
+ return index.addDocument(document);
+ }
+
+ /**
+ * Adds a file to the InMemoryIndex but does not supplant the current
+ * file being indexed. This method is to be used if the current file being indexed
+ * needs to make reference to an external file that has not been added to the index as of yet.
+ */
+ public IndexedFile addSecondaryExternalIndexedFile(String path) {
+ return index.addExternalFilePath(path);
+ }
+
}
diff --git a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/impl/MergeFactory.java b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/impl/MergeFactory.java
index 6bddc463ac5..f7e83c14969 100644
--- a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/impl/MergeFactory.java
+++ b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/impl/MergeFactory.java
@@ -199,17 +199,20 @@ public class MergeFactory {
else
compare= Util.compare(word1.getWord(), word2.getWord());
if (compare < 0) {
+ word1.catRefs(word1);
word1.mapRefs(mappingOld);
mergeOutput.addWord(word1);
oldInput.moveToNextWordEntry();
} else if (compare > 0) {
+ word2.catRefs(word2);
word2.mapRefs(mappingAdds);
mergeOutput.addWord(word2);
addsInput.moveToNextWordEntry();
} else {
+ word1.catRefs(word1);
word1.mapRefs(mappingOld);
word2.mapRefs(mappingAdds);
- word1.addRefs(word2.getRefs());
+ word1.addRefs(word2.getRefs(),word2.getRefsIndexFlags());
mergeOutput.addWord(word1);
addsInput.moveToNextWordEntry();
oldInput.moveToNextWordEntry();
@@ -223,7 +226,7 @@ public class MergeFactory {
*/
protected void mergeIncludes() throws IOException {
int compare;
-
+
while (oldInput.hasMoreIncludes() || addsInput.hasMoreIncludes()) {
IncludeEntry inc1= oldInput.getCurrentIncludeEntry();
IncludeEntry inc2= addsInput.getCurrentIncludeEntry();
diff --git a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/impl/Util.java b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/impl/Util.java
index 3ff79dcf8bc..76cfb43cf40 100644
--- a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/impl/Util.java
+++ b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/impl/Util.java
@@ -91,7 +91,14 @@ public class Util {
quickSort(list, left, original_right);
}
}
- private static void quickSort(int[] list, int left, int right) {
+ private static void quickSort(int[] list, int left, int right, int[] dependentList) {
+
+ //If we are sorting 2 arrays, make sure that they are the same length
+ if (dependentList != null){
+ if (list.length != dependentList.length)
+ return;
+ }
+
int original_left= left;
int original_right= right;
int mid= list[(left + right) / 2];
@@ -106,15 +113,22 @@ public class Util {
int tmp= list[left];
list[left]= list[right];
list[right]= tmp;
+
+ if (dependentList != null){
+ int depTmp = dependentList[left];
+ dependentList[left]=dependentList[right];
+ dependentList[right]=depTmp;
+ }
+
left++;
right--;
}
} while (left <= right);
if (original_left < right) {
- quickSort(list, original_left, right);
+ quickSort(list, original_left, right, dependentList);
}
if (left < original_right) {
- quickSort(list, left, original_right);
+ quickSort(list, left, original_right, dependentList);
}
}
private static void quickSort(String[] list, int left, int right) {
@@ -303,7 +317,11 @@ public class Util {
}
public static void sort(int[] list) {
if (list.length > 1)
- quickSort(list, 0, list.length - 1);
+ quickSort(list, 0, list.length - 1, null);
+ }
+ public static void sort(int[] list, int[] dependentList) {
+ if (list.length > 1)
+ quickSort(list, 0, list.length - 1, dependentList);
}
public static void sort(String[] list) {
if (list.length > 1)
diff --git a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/impl/WordEntry.java b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/impl/WordEntry.java
index 7b09ff2df9f..dfd0e293a56 100644
--- a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/impl/WordEntry.java
+++ b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/impl/WordEntry.java
@@ -10,12 +10,15 @@
*******************************************************************************/
package org.eclipse.cdt.internal.core.index.impl;
+import org.eclipse.cdt.core.parser.util.ObjectSet;
import org.eclipse.cdt.internal.core.CharOperation;
public class WordEntry {
protected char[] fWord;
protected int fNumRefs;
protected int[] fRefs;
+ protected int[] fRefsIndexFlags;
+
public WordEntry() {
this(CharOperation.NO_CHAR);
}
@@ -23,55 +26,75 @@ public class WordEntry {
fWord= word;
fNumRefs= 0;
fRefs= new int[1];
+ fRefsIndexFlags = new int[1];
}
/**
* Adds a reference and records the change in footprint.
*/
- public int addRef(int fileNum) {
+ public int addRef(int fileNum, int indexFlags) {
if (fNumRefs > 0 && fRefs[fNumRefs - 1] == fileNum) {
return 0;
}
if (fNumRefs < fRefs.length) {
+ int tempNumRefs = fNumRefs;
fRefs[fNumRefs++]= fileNum;
+ //Add index flags
+ fRefsIndexFlags[tempNumRefs]=indexFlags;
return 0;
}
// For rt.jar, 73265 word entries are created. 51997 have 1 ref, then 9438, 3738, 1980, 1214, 779, 547, 429, 371 etc.
int newSize= fNumRefs < 4 ? 4 : fNumRefs * 2; // so will start @ 1, grow to 4, 8, 16, 32, 64 etc.
System.arraycopy(fRefs, 0, fRefs= new int[newSize], 0, fNumRefs);
+ // Resize the index flags array at this time as well
+ System.arraycopy(fRefsIndexFlags,0,fRefsIndexFlags=new int[newSize],0,fNumRefs);
+
+ int tempNumRefs=fNumRefs;
fRefs[fNumRefs++]= fileNum;
+ fRefsIndexFlags[tempNumRefs]=indexFlags;
+
return (newSize - fNumRefs + 1) * 4;
}
/**
* Adds a set of references and records the change in footprint.
*/
- public void addRefs(int[] refs) {
+ public void addRefs(int[] refs, int[] indexRefs) {
int[] newRefs= new int[fNumRefs + refs.length];
+ int[] newIndexRefs = new int[fNumRefs + indexRefs.length];
int pos1= 0;
int pos2= 0;
int posNew= 0;
int compare;
int r1= 0;
int r2= 0;
+ int i1=0;
+ int i2=0;
while (pos1 < fNumRefs || pos2 < refs.length) {
if (pos1 >= fNumRefs) {
r2= refs[pos2];
+ i2= indexRefs[pos2];
compare= -1;
} else if (pos2 >= refs.length) {
compare= 1;
r1= fRefs[pos1];
+ i1= fRefsIndexFlags[pos1];
} else {
r1= fRefs[pos1];
r2= refs[pos2];
+
+ i1=fRefsIndexFlags[pos1];
+ i2=indexRefs[pos2];
compare= r2 - r1;
}
if (compare > 0) {
newRefs[posNew]= r1;
+ newIndexRefs[posNew]=i1;
posNew++;
pos1++;
} else {
if (r2 != 0) {
newRefs[posNew]= r2;
+ newIndexRefs[posNew]=i2;
posNew++;
}
pos2++;
@@ -79,18 +102,15 @@ public class WordEntry {
}
fRefs= newRefs;
fNumRefs= posNew;
- /*for (int i = 0; i < refs.length; i++)
- addRef(refs[i]);
- int[] newRefs = new int[fNumRefs];
- System.arraycopy(fRefs, 0, newRefs, 0, fNumRefs);
- fRefs = newRefs;
- Util.sort(fRefs);*/
+ fRefsIndexFlags=newIndexRefs;
}
/**
* Returns the size of the wordEntry
*/
public int footprint() {
- return 8 + (3 * 4) + (8 + fWord.length * 2) + (8 + fRefs.length * 4);
+ //Size of Object + (number of fields * size of Fields) + (Size of ArrayObject + (Number of chars * sizeof Chars)) +
+ //(Size of ArrayObject + (Number of refs * sizeof int)) + (Size of ArrayObject + (Number of indexRefs * sizeof int))
+ return 8 + (4 * 4) + (8 + fWord.length * 2) + (8 + fRefs.length * 4) + (8 + fRefsIndexFlags.length * 4);
}
/**
* Returns the number of references, e.g. the number of files this word appears in.
@@ -106,6 +126,13 @@ public class WordEntry {
throw new IndexOutOfBoundsException();
}
/**
+ * returns the index bit field in the i position
+ */
+ public int getIndexFlag(int i) {
+ if (i < fNumRefs) return fRefsIndexFlags[i];
+ throw new IndexOutOfBoundsException();
+ }
+ /**
* Returns the references of the wordEntry (the number of the files it appears in).
*/
public int[] getRefs() {
@@ -114,6 +141,14 @@ public class WordEntry {
return result;
}
/**
+ * Returns the wordEntry's references index flags
+ */
+ public int[] getRefsIndexFlags() {
+ int[] result= new int[fNumRefs];
+ System.arraycopy(fRefsIndexFlags, 0, result, 0, fNumRefs);
+ return result;
+ }
+ /**
* returns the word of the wordEntry.
*/
public char[] getWord() {
@@ -128,20 +163,31 @@ public class WordEntry {
*/
public void mapRefs(int[] mappings) {
int position= 0;
-
+ int position2= 0;
+
for (int i= 0; i < fNumRefs; i++) {
//Take care that the reference is actually within the bounds of the mapping
int map= -1;
+ int map2= -1;
+
if(fRefs[i] >= 0 && fRefs[i] < mappings.length)
map= mappings[fRefs[i]];
if (map != -1 && map != 0)
fRefs[position++]= map;
+
+ if (fRefsIndexFlags[i] >= 0 && fRefsIndexFlags[i] < mappings.length)
+ map2 = mappings[fRefsIndexFlags[i]];
+ if (map2 != -1 && map2 != 0)
+ fRefsIndexFlags[position2++] = map2;
+
}
fNumRefs= position;
//to be changed!
System.arraycopy(fRefs, 0, (fRefs= new int[fNumRefs]), 0, fNumRefs);
- Util.sort(fRefs);
+ System.arraycopy(fRefsIndexFlags, 0, (fRefsIndexFlags = new int[fNumRefs]),0,fNumRefs);
+
+ Util.sort(fRefs, fRefsIndexFlags);
}
/**
* Clears the wordEntry.
@@ -149,6 +195,7 @@ public class WordEntry {
public void reset(char[] word) {
for (int i= fNumRefs; i-- > 0;) {
fRefs[i]= 0;
+ fRefsIndexFlags[i]=0;
}
fNumRefs= 0;
fWord= word;
@@ -156,5 +203,30 @@ public class WordEntry {
public String toString() {
return new String(fWord);
}
+ /**
+ * @param word
+ */
+ public void catRefs(WordEntry word) {
+ int[] wordFileRefs = word.fRefs;
+ int[] wordIndexFlags=word.fRefsIndexFlags;
+ ObjectSet set = new ObjectSet(4);
+
+ for (int i=0; i<wordFileRefs.length; i++){
+ //if (wordIndexFlags[i] != 0)
+ // set.put(new Integer(wordIndexFlags[i]));
+ if (wordFileRefs[i] != 0)
+ set.put(new Integer(wordFileRefs[i]));
+ }
+
+ int[] mergedArray = new int[set.size()];
+ for (int i=0; i<set.size(); i++){
+ mergedArray[i] = ((Integer) set.keyAt(i)).intValue();
+ }
+
+ System.arraycopy(mergedArray,0,(fRefs = new int[set.size()]),0,set.size());
+ fNumRefs = set.size();
+
+ Util.sort(fRefs);
+ }
}
diff --git a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/search/indexing/AbstractIndexer.java b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/search/indexing/AbstractIndexer.java
index 4da882daebf..8c0d2739bce 100644
--- a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/search/indexing/AbstractIndexer.java
+++ b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/search/indexing/AbstractIndexer.java
@@ -71,7 +71,7 @@ public abstract class AbstractIndexer implements IIndexer, IIndexConstants, ICSe
System.out.println("(" + Thread.currentThread() + ") " + log); //$NON-NLS-1$//$NON-NLS-2$
}
- public void addClassSpecifier(IASTClassSpecifier classSpecification){
+ public void addClassSpecifier(IASTClassSpecifier classSpecification, int indexFlag){
if (classSpecification.getClassKind().equals(ASTClassKind.CLASS))
{
@@ -84,7 +84,7 @@ public abstract class AbstractIndexer implements IIndexer, IIndexConstants, ICSe
if (typeSpec instanceof IASTClassSpecifier){
IASTClassSpecifier baseClassSpec = (IASTClassSpecifier) typeSpec;
char[][] baseFullyQualifiedName = baseClassSpec.getFullyQualifiedNameCharArrays();
- this.output.addRef(encodeTypeEntry(baseFullyQualifiedName,DERIVED,ICSearchConstants.DECLARATIONS));
+ this.output.addRef(encodeTypeEntry(baseFullyQualifiedName,DERIVED,ICSearchConstants.DECLARATIONS),indexFlag);
}
} catch (ASTNotImplementedException e) {}
}
@@ -96,12 +96,12 @@ public abstract class AbstractIndexer implements IIndexer, IIndexConstants, ICSe
if (decl instanceof IASTClassSpecifier){
IASTClassSpecifier friendClassSpec = (IASTClassSpecifier) decl;
char[][] baseFullyQualifiedName = friendClassSpec.getFullyQualifiedNameCharArrays();
- this.output.addRef(encodeTypeEntry(baseFullyQualifiedName,FRIEND,ICSearchConstants.DECLARATIONS));
+ this.output.addRef(encodeTypeEntry(baseFullyQualifiedName,FRIEND,ICSearchConstants.DECLARATIONS),indexFlag);
}
else if (decl instanceof IASTElaboratedTypeSpecifier){
IASTElaboratedTypeSpecifier friendClassSpec = (IASTElaboratedTypeSpecifier) decl;
char[][] baseFullyQualifiedName = friendClassSpec.getFullyQualifiedNameCharArrays();
- this.output.addRef(encodeTypeEntry(baseFullyQualifiedName,FRIEND,ICSearchConstants.DECLARATIONS));
+ this.output.addRef(encodeTypeEntry(baseFullyQualifiedName,FRIEND,ICSearchConstants.DECLARATIONS),indexFlag);
}
else if (decl instanceof IASTFunction){
@@ -112,7 +112,7 @@ public abstract class AbstractIndexer implements IIndexer, IIndexConstants, ICSe
}
- this.output.addRef(encodeTypeEntry(classSpecification.getFullyQualifiedNameCharArrays(),CLASS, ICSearchConstants.DECLARATIONS));
+ this.output.addRef(encodeTypeEntry(classSpecification.getFullyQualifiedNameCharArrays(),CLASS, ICSearchConstants.DECLARATIONS),indexFlag);
}
else if (classSpecification.getClassKind().equals(ASTClassKind.STRUCT))
{
@@ -125,7 +125,7 @@ public abstract class AbstractIndexer implements IIndexer, IIndexConstants, ICSe
if (typeSpec instanceof IASTClassSpecifier){
IASTClassSpecifier baseClassSpec = (IASTClassSpecifier) typeSpec;
char[][] baseFullyQualifiedName = baseClassSpec.getFullyQualifiedNameCharArrays();
- this.output.addRef(encodeTypeEntry(baseFullyQualifiedName,DERIVED,ICSearchConstants.DECLARATIONS));
+ this.output.addRef(encodeTypeEntry(baseFullyQualifiedName,DERIVED,ICSearchConstants.DECLARATIONS),indexFlag);
}
} catch (ASTNotImplementedException e) {}
}
@@ -137,12 +137,12 @@ public abstract class AbstractIndexer implements IIndexer, IIndexConstants, ICSe
if (decl instanceof IASTClassSpecifier){
IASTClassSpecifier friendClassSpec = (IASTClassSpecifier) decl;
char[][] baseFullyQualifiedName = friendClassSpec.getFullyQualifiedNameCharArrays();
- this.output.addRef(encodeTypeEntry(baseFullyQualifiedName,FRIEND,ICSearchConstants.DECLARATIONS));
+ this.output.addRef(encodeTypeEntry(baseFullyQualifiedName,FRIEND,ICSearchConstants.DECLARATIONS),indexFlag);
}
else if (decl instanceof IASTElaboratedTypeSpecifier){
IASTElaboratedTypeSpecifier friendClassSpec = (IASTElaboratedTypeSpecifier) decl;
char[][] baseFullyQualifiedName = friendClassSpec.getFullyQualifiedNameCharArrays();
- this.output.addRef(encodeTypeEntry(baseFullyQualifiedName,FRIEND,ICSearchConstants.DECLARATIONS));
+ this.output.addRef(encodeTypeEntry(baseFullyQualifiedName,FRIEND,ICSearchConstants.DECLARATIONS),indexFlag);
}
else if (decl instanceof IASTFunction){
@@ -152,16 +152,16 @@ public abstract class AbstractIndexer implements IIndexer, IIndexConstants, ICSe
}
}
- this.output.addRef(encodeTypeEntry(classSpecification.getFullyQualifiedNameCharArrays(),STRUCT, ICSearchConstants.DECLARATIONS));
+ this.output.addRef(encodeTypeEntry(classSpecification.getFullyQualifiedNameCharArrays(),STRUCT, ICSearchConstants.DECLARATIONS),indexFlag);
}
else if (classSpecification.getClassKind().equals(ASTClassKind.UNION))
{
- this.output.addRef(encodeTypeEntry(classSpecification.getFullyQualifiedNameCharArrays(),UNION, ICSearchConstants.DECLARATIONS));
+ this.output.addRef(encodeTypeEntry(classSpecification.getFullyQualifiedNameCharArrays(),UNION, ICSearchConstants.DECLARATIONS),indexFlag);
}
}
- public void addEnumerationSpecifier(IASTEnumerationSpecifier enumeration) {
- this.output.addRef(encodeTypeEntry(enumeration.getFullyQualifiedNameCharArrays(), ENUM, ICSearchConstants.DECLARATIONS));
+ public void addEnumerationSpecifier(IASTEnumerationSpecifier enumeration, int indexFlag) {
+ this.output.addRef(encodeTypeEntry(enumeration.getFullyQualifiedNameCharArrays(), ENUM, ICSearchConstants.DECLARATIONS),indexFlag);
Iterator i = enumeration.getEnumerators();
while (i.hasNext())
@@ -169,8 +169,8 @@ public abstract class AbstractIndexer implements IIndexer, IIndexConstants, ICSe
IASTEnumerator en = (IASTEnumerator) i.next();
char[][] enumeratorFullName =
createEnumeratorFullyQualifiedName(en);
-
- this.output.addRef(encodeEntry( enumeratorFullName, ENUMTOR_DECL, ENUMTOR_DECL_LENGTH ));
+
+ this.output.addRef(encodeEntry( enumeratorFullName, ENUMTOR_DECL, ENUMTOR_DECL_LENGTH ),indexFlag);
}
}
@@ -188,71 +188,71 @@ public abstract class AbstractIndexer implements IIndexer, IIndexConstants, ICSe
return enumeratorFullName;
}
- public void addEnumeratorReference(IASTEnumerator enumerator) {
- this.output.addRef(encodeEntry(createEnumeratorFullyQualifiedName(enumerator),ENUMTOR_REF,ENUMTOR_REF_LENGTH));
+ public void addEnumeratorReference(IASTEnumerator enumerator, int indexFlag) {
+ this.output.addRef(encodeEntry(createEnumeratorFullyQualifiedName(enumerator),ENUMTOR_REF,ENUMTOR_REF_LENGTH),indexFlag);
}
- public void addMacro(IASTMacro macro) {
+ public void addMacro(IASTMacro macro, int indexFlag) {
char[][] macroName = new char[][] { macro.getNameCharArray() };
- this.output.addRef(encodeEntry(macroName,MACRO_DECL,MACRO_DECL_LENGTH));
+ this.output.addRef(encodeEntry(macroName,MACRO_DECL,MACRO_DECL_LENGTH),indexFlag);
}
- public void addEnumerationReference(IASTEnumerationSpecifier enumeration) {
- this.output.addRef(encodeTypeEntry(enumeration.getFullyQualifiedNameCharArrays(), ENUM, ICSearchConstants.REFERENCES));
+ public void addEnumerationReference(IASTEnumerationSpecifier enumeration, int indexFlag) {
+ this.output.addRef(encodeTypeEntry(enumeration.getFullyQualifiedNameCharArrays(), ENUM, ICSearchConstants.REFERENCES),indexFlag);
}
- public void addVariable(IASTVariable variable) {
- this.output.addRef(encodeTypeEntry(variable.getFullyQualifiedNameCharArrays(), VAR, ICSearchConstants.DECLARATIONS));
+ public void addVariable(IASTVariable variable, int indexFlag) {
+ this.output.addRef(encodeTypeEntry(variable.getFullyQualifiedNameCharArrays(), VAR, ICSearchConstants.DECLARATIONS),indexFlag);
}
- public void addVariableReference(IASTVariable variable) {
- this.output.addRef(encodeTypeEntry(variable.getFullyQualifiedNameCharArrays(), VAR, ICSearchConstants.REFERENCES));
+ public void addVariableReference(IASTVariable variable, int indexFlag) {
+ this.output.addRef(encodeTypeEntry(variable.getFullyQualifiedNameCharArrays(), VAR, ICSearchConstants.REFERENCES),indexFlag);
}
- public void addParameterReference( IASTParameterDeclaration parameter ){
- this.output.addRef( encodeTypeEntry( new char[][] { parameter.getNameCharArray() }, VAR, ICSearchConstants.REFERENCES));
+ public void addParameterReference( IASTParameterDeclaration parameter, int indexFlag ){
+ this.output.addRef( encodeTypeEntry( new char[][] { parameter.getNameCharArray() }, VAR, ICSearchConstants.REFERENCES),indexFlag);
}
- public void addTypedefDeclaration(IASTTypedefDeclaration typedef) {
- this.output.addRef(encodeEntry(typedef.getFullyQualifiedNameCharArrays(), TYPEDEF_DECL, TYPEDEF_DECL_LENGTH));
+ public void addTypedefDeclaration(IASTTypedefDeclaration typedef, int indexFlag) {
+ this.output.addRef(encodeEntry(typedef.getFullyQualifiedNameCharArrays(), TYPEDEF_DECL, TYPEDEF_DECL_LENGTH),indexFlag);
}
- public void addFieldDeclaration(IASTField field) {
- this.output.addRef(encodeEntry(field.getFullyQualifiedNameCharArrays(),FIELD_DECL,FIELD_DECL_LENGTH));
+ public void addFieldDeclaration(IASTField field, int indexFlag) {
+ this.output.addRef(encodeEntry(field.getFullyQualifiedNameCharArrays(),FIELD_DECL,FIELD_DECL_LENGTH),indexFlag);
}
- public void addFieldReference(IASTField field) {
- this.output.addRef(encodeEntry(field.getFullyQualifiedNameCharArrays(),FIELD_REF,FIELD_REF_LENGTH));
+ public void addFieldReference(IASTField field, int indexFlag) {
+ this.output.addRef(encodeEntry(field.getFullyQualifiedNameCharArrays(),FIELD_REF,FIELD_REF_LENGTH),indexFlag);
}
- public void addMethodDeclaration(IASTMethod method) {
- this.output.addRef(encodeEntry(method.getFullyQualifiedNameCharArrays(),METHOD_DECL,METHOD_DECL_LENGTH));
+ public void addMethodDeclaration(IASTMethod method, int indexFlag) {
+ this.output.addRef(encodeEntry(method.getFullyQualifiedNameCharArrays(),METHOD_DECL,METHOD_DECL_LENGTH),indexFlag);
Iterator i=method.getParameters();
while (i.hasNext()){
Object parm = i.next();
if (parm instanceof IASTParameterDeclaration){
IASTParameterDeclaration parmDecl = (IASTParameterDeclaration) parm;
- this.output.addRef(encodeTypeEntry(new char[][]{parmDecl.getNameCharArray()}, VAR, ICSearchConstants.DECLARATIONS));
+ this.output.addRef(encodeTypeEntry(new char[][]{parmDecl.getNameCharArray()}, VAR, ICSearchConstants.DECLARATIONS),indexFlag);
}
}
}
- public void addMethodReference(IASTMethod method) {
- this.output.addRef(encodeEntry(method.getFullyQualifiedNameCharArrays(),METHOD_REF,METHOD_REF_LENGTH));
+ public void addMethodReference(IASTMethod method, int indexFlag) {
+ this.output.addRef(encodeEntry(method.getFullyQualifiedNameCharArrays(),METHOD_REF,METHOD_REF_LENGTH),indexFlag);
}
- public void addElaboratedForwardDeclaration(IASTElaboratedTypeSpecifier elaboratedType) {
+ public void addElaboratedForwardDeclaration(IASTElaboratedTypeSpecifier elaboratedType, int indexFlag) {
if (elaboratedType.getClassKind().equals(ASTClassKind.CLASS))
{
- this.output.addRef(encodeTypeEntry(elaboratedType.getFullyQualifiedNameCharArrays(),FWD_CLASS, ICSearchConstants.DECLARATIONS));
+ this.output.addRef(encodeTypeEntry(elaboratedType.getFullyQualifiedNameCharArrays(),FWD_CLASS, ICSearchConstants.DECLARATIONS),indexFlag);
}
else if (elaboratedType.getClassKind().equals(ASTClassKind.STRUCT))
{
- this.output.addRef(encodeTypeEntry(elaboratedType.getFullyQualifiedNameCharArrays(),FWD_STRUCT, ICSearchConstants.DECLARATIONS));
+ this.output.addRef(encodeTypeEntry(elaboratedType.getFullyQualifiedNameCharArrays(),FWD_STRUCT, ICSearchConstants.DECLARATIONS),indexFlag);
}
else if (elaboratedType.getClassKind().equals(ASTClassKind.UNION))
{
- this.output.addRef(encodeTypeEntry(elaboratedType.getFullyQualifiedNameCharArrays(),FWD_UNION, ICSearchConstants.DECLARATIONS));
+ this.output.addRef(encodeTypeEntry(elaboratedType.getFullyQualifiedNameCharArrays(),FWD_UNION, ICSearchConstants.DECLARATIONS),indexFlag);
}
}
@@ -270,37 +270,37 @@ public abstract class AbstractIndexer implements IIndexer, IIndexConstants, ICSe
}
- public void addFunctionDeclaration(IASTFunction function){
- this.output.addRef(encodeEntry(function.getFullyQualifiedNameCharArrays(),FUNCTION_DECL,FUNCTION_DECL_LENGTH));
+ public void addFunctionDeclaration(IASTFunction function, int indexFlag){
+ this.output.addRef(encodeEntry(function.getFullyQualifiedNameCharArrays(),FUNCTION_DECL,FUNCTION_DECL_LENGTH),indexFlag);
Iterator i=function.getParameters();
while (i.hasNext()){
Object parm = i.next();
if (parm instanceof IASTParameterDeclaration){
IASTParameterDeclaration parmDecl = (IASTParameterDeclaration) parm;
- this.output.addRef(encodeTypeEntry(new char[][]{parmDecl.getNameCharArray()}, VAR, ICSearchConstants.DECLARATIONS));
+ this.output.addRef(encodeTypeEntry(new char[][]{parmDecl.getNameCharArray()}, VAR, ICSearchConstants.DECLARATIONS),indexFlag);
}
}
}
- public void addFunctionReference(IASTFunction function){
- this.output.addRef(encodeEntry(function.getFullyQualifiedNameCharArrays(),FUNCTION_REF,FUNCTION_REF_LENGTH));
+ public void addFunctionReference(IASTFunction function, int indexFlag){
+ this.output.addRef(encodeEntry(function.getFullyQualifiedNameCharArrays(),FUNCTION_REF,FUNCTION_REF_LENGTH),indexFlag);
}
public void addNameReference(){
}
- public void addNamespaceDefinition(IASTNamespaceDefinition namespace){
- this.output.addRef(encodeEntry(namespace.getFullyQualifiedNameCharArrays(),NAMESPACE_DECL,NAMESPACE_DECL_LENGTH));
+ public void addNamespaceDefinition(IASTNamespaceDefinition namespace, int indexFlag){
+ this.output.addRef(encodeEntry(namespace.getFullyQualifiedNameCharArrays(),NAMESPACE_DECL,NAMESPACE_DECL_LENGTH),indexFlag);
}
- public void addNamespaceReference(IASTNamespaceDefinition namespace) {
- this.output.addRef(encodeEntry(namespace.getFullyQualifiedNameCharArrays(),NAMESPACE_REF,NAMESPACE_REF_LENGTH));
+ public void addNamespaceReference(IASTNamespaceDefinition namespace, int indexFlag) {
+ this.output.addRef(encodeEntry(namespace.getFullyQualifiedNameCharArrays(),NAMESPACE_REF,NAMESPACE_REF_LENGTH),indexFlag);
}
- public void addTypedefReference( IASTTypedefDeclaration typedef ){
- this.output.addRef( encodeTypeEntry( typedef.getFullyQualifiedNameCharArrays(), TYPEDEF, ICSearchConstants.REFERENCES) );
+ public void addTypedefReference( IASTTypedefDeclaration typedef, int indexFlag ){
+ this.output.addRef( encodeTypeEntry( typedef.getFullyQualifiedNameCharArrays(), TYPEDEF, ICSearchConstants.REFERENCES),indexFlag );
}
private void addSuperTypeReference(int modifiers, char[] packageName, char[] typeName, char[][] enclosingTypeNames, char classOrInterface, char[] superTypeName, char superClassOrInterface){
@@ -311,7 +311,7 @@ public abstract class AbstractIndexer implements IIndexer, IIndexConstants, ICSe
//this.output.addRef(CharOperation.concat(TYPE_REF, CharOperation.lastSegment(typeName, '.')));
}
- public void addClassReference(IASTTypeSpecifier reference){
+ public void addClassReference(IASTTypeSpecifier reference, int indexFlag){
char[][] fullyQualifiedName = null;
ASTClassKind classKind = null;
@@ -328,18 +328,18 @@ public abstract class AbstractIndexer implements IIndexer, IIndexConstants, ICSe
if (classKind.equals(ASTClassKind.CLASS))
{
- this.output.addRef(encodeTypeEntry(fullyQualifiedName,CLASS, ICSearchConstants.REFERENCES));
+ this.output.addRef(encodeTypeEntry(fullyQualifiedName,CLASS, ICSearchConstants.REFERENCES),indexFlag);
}
else if (classKind.equals(ASTClassKind.STRUCT))
{
- this.output.addRef(encodeTypeEntry(fullyQualifiedName,STRUCT,ICSearchConstants.REFERENCES));
+ this.output.addRef(encodeTypeEntry(fullyQualifiedName,STRUCT,ICSearchConstants.REFERENCES),indexFlag);
}
else if (classKind.equals(ASTClassKind.UNION))
{
- this.output.addRef(encodeTypeEntry(fullyQualifiedName,UNION,ICSearchConstants.REFERENCES));
+ this.output.addRef(encodeTypeEntry(fullyQualifiedName,UNION,ICSearchConstants.REFERENCES),indexFlag);
}
}
- public void addForwardClassReference(IASTTypeSpecifier reference){
+ public void addForwardClassReference(IASTTypeSpecifier reference, int indexFlag){
char[][] fullyQualifiedName = null;
ASTClassKind classKind = null;
@@ -354,15 +354,15 @@ public abstract class AbstractIndexer implements IIndexer, IIndexConstants, ICSe
if (classKind.equals(ASTClassKind.CLASS))
{
- this.output.addRef(encodeTypeEntry(fullyQualifiedName,FWD_CLASS, ICSearchConstants.REFERENCES));
+ this.output.addRef(encodeTypeEntry(fullyQualifiedName,FWD_CLASS, ICSearchConstants.REFERENCES),indexFlag);
}
else if (classKind.equals(ASTClassKind.STRUCT))
{
- this.output.addRef(encodeTypeEntry(fullyQualifiedName,FWD_STRUCT,ICSearchConstants.REFERENCES));
+ this.output.addRef(encodeTypeEntry(fullyQualifiedName,FWD_STRUCT,ICSearchConstants.REFERENCES),indexFlag);
}
else if (classKind.equals(ASTClassKind.UNION))
{
- this.output.addRef(encodeTypeEntry(fullyQualifiedName,FWD_UNION,ICSearchConstants.REFERENCES));
+ this.output.addRef(encodeTypeEntry(fullyQualifiedName,FWD_UNION,ICSearchConstants.REFERENCES),indexFlag);
}
}
/**
@@ -828,13 +828,16 @@ public abstract class AbstractIndexer implements IIndexer, IIndexConstants, ICSe
return bestPrefix( prefix, (char)0, incName, null, matchMode, isCaseSenstive );
}
- public void addInclude(IASTInclusion inclusion, IASTInclusion parent){
+ public void addInclude(IASTInclusion inclusion, IASTInclusion parent, int fileNumber){
this.output.addIncludeRef(inclusion.getFullFileName());
this.output.addRelatives(inclusion.getFullFileName(),(parent != null ) ? parent.getFullFileName() : null);
+
//Add Dep Table entry
char[][] incName = new char[1][];
incName[0] = inclusion.getFullFileName().toCharArray();
- this.output.addRef(encodeEntry(incName, INCLUDE_REF, INCLUDE_REF_LENGTH));
+ //TODO: Kludge! Get rid of BOGUS entry - need to restructure Dep Tree to use reference indexes
+ int BOGUS_ENTRY = 1;
+ this.output.addRef(encodeEntry(incName, INCLUDE_REF, INCLUDE_REF_LENGTH),fileNumber);
}
}
diff --git a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/search/indexing/AddCompilationUnitToIndex.java b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/search/indexing/AddCompilationUnitToIndex.java
index 49121a3b9bd..a67bdfb70d3 100644
--- a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/search/indexing/AddCompilationUnitToIndex.java
+++ b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/search/indexing/AddCompilationUnitToIndex.java
@@ -21,8 +21,8 @@ import org.eclipse.core.runtime.IPath;
public class AddCompilationUnitToIndex extends AddFileToIndex {
char[] contents;
- public AddCompilationUnitToIndex(IFile resource, IPath indexedContainer, IndexManager manager, boolean checkEncounteredHeaders) {
- super(resource, indexedContainer, manager, checkEncounteredHeaders);
+ public AddCompilationUnitToIndex(IFile resource, IPath indexedContainer, IndexManager manager) {
+ super(resource, indexedContainer, manager);
}
protected boolean indexDocument(IIndex index) throws IOException {
if (!initializeContents()) return false;
diff --git a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/search/indexing/AddFileToIndex.java b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/search/indexing/AddFileToIndex.java
index c0a7ec346d5..57d42486214 100644
--- a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/search/indexing/AddFileToIndex.java
+++ b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/search/indexing/AddFileToIndex.java
@@ -12,39 +12,26 @@ package org.eclipse.cdt.internal.core.search.indexing;
import java.io.IOException;
-import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.ICLogConstants;
-import org.eclipse.cdt.core.filetype.ICFileType;
import org.eclipse.cdt.internal.core.index.IIndex;
import org.eclipse.cdt.internal.core.search.processing.JobManager;
import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
public abstract class AddFileToIndex extends IndexRequest {
IFile resource;
- private boolean checkEncounteredHeaders;
+
- public AddFileToIndex(IFile resource, IPath indexPath, IndexManager manager, boolean checkEncounteredHeaders) {
+ public AddFileToIndex(IFile resource, IPath indexPath, IndexManager manager) {
super(indexPath, manager);
this.resource = resource;
- this.checkEncounteredHeaders = checkEncounteredHeaders;
}
public boolean execute(IProgressMonitor progressMonitor) {
if (progressMonitor != null && progressMonitor.isCanceled()) return true;
- if (checkEncounteredHeaders) {
- IProject resourceProject = resource.getProject();
- /* Check to see if this is a header file */
- ICFileType type = CCorePlugin.getDefault().getFileType(resourceProject,resource.getName());
-
- /* See if this file has been encountered before */
- if (type.isHeader() &&
- manager.haveEncounteredHeader(resourceProject.getFullPath(),resource.getLocation()))
- return true;
- }
+
/* ensure no concurrent write access to index */
IIndex index = manager.getIndex(this.indexPath, true, /*reuse index file*/ true /*create if none*/);
if (index == null) return true;
diff --git a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/search/indexing/AddFolderToIndex.java b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/search/indexing/AddFolderToIndex.java
index d8781d5b82e..58a9782ea35 100644
--- a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/search/indexing/AddFolderToIndex.java
+++ b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/search/indexing/AddFolderToIndex.java
@@ -102,13 +102,12 @@ class AddFolderToIndex extends IndexRequest {
private void scheduleJobs() {
//Schedule the source jobs first, then the headers
for (int i=0; i<sourceFilesToIndex.size(); i++)
- this.manager.addSource((IFile)sourceFilesToIndex.get(i), this.indexPath, true);
+ this.manager.addSource((IFile)sourceFilesToIndex.get(i), this.indexPath);
for (int i=0;i<headerFilesToIndex.size(); i++)
- this.manager.addSource((IFile)headerFilesToIndex.get(i), this.indexPath, true);
+ this.manager.addSource((IFile)headerFilesToIndex.get(i), this.indexPath);
+
- CleanEncounteredHeaders cleanHeaders = new CleanEncounteredHeaders(this.manager);
- this.manager.request(cleanHeaders);
}
public String toString() {
diff --git a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/search/indexing/CleanEncounteredHeaders.java b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/search/indexing/CleanEncounteredHeaders.java
deleted file mode 100644
index ee2b67d0a70..00000000000
--- a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/search/indexing/CleanEncounteredHeaders.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Created on Aug 19, 2004
- *
- * TODO To change the template for this generated file go to
- * Window - Preferences - Java - Code Style - Code Templates
- */
-package org.eclipse.cdt.internal.core.search.indexing;
-
-import org.eclipse.cdt.internal.core.search.processing.IJob;
-import org.eclipse.core.runtime.IProgressMonitor;
-
-/**
- * @author bgheorgh
- *
- * TODO To change the template for this generated type comment go to
- * Window - Preferences - Java - Code Style - Code Templates
- */
-public class CleanEncounteredHeaders implements IJob {
-
- IndexManager manager = null;
-
- public CleanEncounteredHeaders(IndexManager manager){
- this.manager = manager;
- }
- /* (non-Javadoc)
- * @see org.eclipse.cdt.internal.core.search.processing.IJob#execute(org.eclipse.core.runtime.IProgressMonitor)
- */
- public boolean execute(IProgressMonitor progress) {
-
- //Clean out the headers
- this.manager.resetEncounteredHeaders();
- return true;
- }
- /* (non-Javadoc)
- * @see org.eclipse.cdt.internal.core.search.processing.IJob#belongsTo(java.lang.String)
- */
- public boolean belongsTo(String jobFamily) {
- // TODO Auto-generated method stub
- return false;
- }
- /* (non-Javadoc)
- * @see org.eclipse.cdt.internal.core.search.processing.IJob#cancel()
- */
- public void cancel() {
- // TODO Auto-generated method stub
-
- }
- /* (non-Javadoc)
- * @see org.eclipse.cdt.internal.core.search.processing.IJob#isReadyToRun()
- */
- public boolean isReadyToRun() {
- // TODO Auto-generated method stub
- return true;
- }
-
-}
diff --git a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/search/indexing/IndexManager.java b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/search/indexing/IndexManager.java
index 22360542718..eb856292816 100644
--- a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/search/indexing/IndexManager.java
+++ b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/search/indexing/IndexManager.java
@@ -30,7 +30,6 @@ import org.eclipse.cdt.core.index.IIndexChangeListener;
import org.eclipse.cdt.core.index.IndexChangeEvent;
import org.eclipse.cdt.core.model.ICModelMarker;
import org.eclipse.cdt.core.parser.ParserTimeOut;
-import org.eclipse.cdt.core.parser.util.ObjectSet;
import org.eclipse.cdt.internal.core.CharOperation;
import org.eclipse.cdt.internal.core.Util;
import org.eclipse.cdt.internal.core.index.IIndex;
@@ -82,8 +81,6 @@ public class IndexManager extends JobManager implements IIndexConstants {
private File savedIndexNamesFile =
new File(getCCorePluginWorkingLocation().append("savedIndexNames.txt").toOSString()); //$NON-NLS-1$
- private SimpleLookupTable encounteredHeaders = null;
-
public static Integer SAVED_STATE = new Integer(0);
public static Integer UPDATING_STATE = new Integer(1);
public static Integer UNKNOWN_STATE = new Integer(2);
@@ -155,7 +152,7 @@ public class IndexManager extends JobManager implements IIndexConstants {
* Note: the actual operation is performed in background
* @param checkEncounteredHeaders TODO
*/
- public void addSource(IFile resource, IPath indexedContainers, boolean checkEncounteredHeaders){
+ public void addSource(IFile resource, IPath indexedContainers){
IProject project = resource.getProject();
@@ -168,7 +165,7 @@ public class IndexManager extends JobManager implements IIndexConstants {
if (CCorePlugin.getDefault() == null) return;
if (indexEnabled){
- AddCompilationUnitToIndex job = new AddCompilationUnitToIndex(resource, indexedContainers, this, checkEncounteredHeaders);
+ AddCompilationUnitToIndex job = new AddCompilationUnitToIndex(resource, indexedContainers, this);
//If we are in WAITING mode, we need to kick ourselves into enablement
if (!jobSet.add(job.resource.getLocation()) &&
@@ -275,32 +272,6 @@ public class IndexManager extends JobManager implements IIndexConstants {
return index;
}
- /**
- * Returns the index for a given project, according to the following algorithm:
- * - if index is already in memory: answers this one back
- * - if (reuseExistingFile) then read it and return this index and record it in memory
- * - if (createIfMissing) then create a new empty index and record it in memory
- *
- * Warning: Does not check whether index is consistent (not being used)
- */
- public synchronized boolean haveEncounteredHeader(IPath projectPath, IPath filePath) {
-
- SimpleLookupTable headerTable = getEncounteredHeaders();
- // Path is already canonical per construction
- ObjectSet headers = (ObjectSet) headerTable.get(projectPath);
- if (headers == null) {
- //First time for the project, must create a new ObjectSet
- headers = new ObjectSet(4);
- headerTable.put(projectPath, headers);
- }
-
- if (headers.containsKey(filePath.toOSString()))
- return true;
-
- headers.put(filePath.toOSString());
-
- return false;
- }
private SimpleLookupTable getIndexStates() {
if (indexStates != null) return indexStates;
@@ -318,23 +289,6 @@ public class IndexManager extends JobManager implements IIndexConstants {
return this.indexStates;
}
- private SimpleLookupTable getEncounteredHeaders(){
-
- if (encounteredHeaders == null){
- this.encounteredHeaders = new SimpleLookupTable();
- }
-
-
- return this.encounteredHeaders;
- }
-
- /**
- * Resets the headers table
- */
- public void resetEncounteredHeaders() {
- this.encounteredHeaders = null;
- }
-
private IPath getCCorePluginWorkingLocation() {
if (this.cCorePluginLocation != null) return this.cCorePluginLocation;
@@ -603,7 +557,6 @@ public class IndexManager extends JobManager implements IIndexConstants {
this.indexes = new HashMap(5);
this.monitors = new HashMap(5);
this.indexStates = null;
- this.encounteredHeaders = null;
}
if (this.timeoutThread == null){
diff --git a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/search/indexing/IndexerModelListener.java b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/search/indexing/IndexerModelListener.java
index 4dd02b766b6..632552d7922 100644
--- a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/search/indexing/IndexerModelListener.java
+++ b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/search/indexing/IndexerModelListener.java
@@ -69,7 +69,7 @@ public class IndexerModelListener implements IElementChangedListener {
switch(tempResource.getType())
{
case IResource.FILE:
- indexManager.addSource((IFile) tempResource,tempResource.getProject().getFullPath(), false);
+ indexManager.addSource((IFile) tempResource,tempResource.getProject().getFullPath());
break;
case IResource.FOLDER:
diff --git a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/search/indexing/SourceIndexer.java b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/search/indexing/SourceIndexer.java
index beba8936ca4..41eaff5f1ee 100644
--- a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/search/indexing/SourceIndexer.java
+++ b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/search/indexing/SourceIndexer.java
@@ -21,6 +21,7 @@ import java.util.ArrayList;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.ICLogConstants;
+import org.eclipse.cdt.core.index.IIndexDelta;
import org.eclipse.cdt.core.model.CoreModel;
import org.eclipse.cdt.core.parser.CodeReader;
import org.eclipse.cdt.core.parser.IParser;
@@ -154,7 +155,7 @@ public class SourceIndexer extends AbstractIndexer {
//Report events
ArrayList filesTrav = requestor.getFilesTraversed();
- IndexDelta indexDelta = new IndexDelta(resourceFile.getProject(),filesTrav);
+ IndexDelta indexDelta = new IndexDelta(resourceFile.getProject(),filesTrav, IIndexDelta.INDEX_FINISHED_DELTA);
CCorePlugin.getDefault().getCoreModel().getIndexManager().notifyListeners(indexDelta);
//Release all resources
parser=null;
diff --git a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/search/indexing/SourceIndexerRequestor.java b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/search/indexing/SourceIndexerRequestor.java
index 76b88eb1805..bc3fe1131cf 100644
--- a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/search/indexing/SourceIndexerRequestor.java
+++ b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/search/indexing/SourceIndexerRequestor.java
@@ -70,6 +70,8 @@ import org.eclipse.cdt.core.parser.ast.IASTUsingDirective;
import org.eclipse.cdt.core.parser.ast.IASTVariable;
import org.eclipse.cdt.core.parser.ast.IASTVariableReference;
import org.eclipse.cdt.internal.core.Util;
+import org.eclipse.cdt.internal.core.index.impl.IFileDocument;
+import org.eclipse.cdt.internal.core.index.impl.IndexedFile;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IProject;
@@ -124,9 +126,7 @@ public class SourceIndexerRequestor implements ISourceElementRequestor, IIndexCo
this.filesTraversed = new ArrayList(15);
this.filesTraversed.add(resourceFile.getLocation().toOSString());
}
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#acceptProblem(org.eclipse.cdt.core.parser.IProblem)
- */
+
public boolean acceptProblem(IProblem problem) {
if( areProblemMarkersEnabled() && shouldRecordProblem( problem ) ){
IASTInclusion include = peekInclude();
@@ -155,101 +155,62 @@ public class SourceIndexerRequestor implements ISourceElementRequestor, IIndexCo
return IndexProblemHandler.ruleOnProblem( problem, ParserMode.COMPLETE_PARSE );
}
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#acceptMacro(org.eclipse.cdt.core.parser.ast.IASTMacro)
- */
public void acceptMacro(IASTMacro macro) {
- // TODO Auto-generated method stub
- indexer.addMacro(macro);
+ //Check to see if this reference actually occurs in the file being indexed
+ //or if it occurs in another file
+ int indexFlag = calculateIndexFlags();
+
+ indexer.addMacro(macro, indexFlag);
}
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#acceptVariable(org.eclipse.cdt.core.parser.ast.IASTVariable)
- */
public void acceptVariable(IASTVariable variable) {
- // TODO Auto-generated method stub
- //System.out.println("acceptVariable");
- indexer.addVariable(variable);
+ //Check to see if this reference actually occurs in the file being indexed
+ //or if it occurs in another file
+ int indexFlag = calculateIndexFlags();
+
+ indexer.addVariable(variable, indexFlag);
}
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#acceptFunctionDeclaration(org.eclipse.cdt.core.parser.ast.IASTFunction)
- */
public void acceptFunctionDeclaration(IASTFunction function) {
- // TODO Auto-generated method stub
- //System.out.println("acceptFunctionDeclaration");
- indexer.addFunctionDeclaration(function);
- }
+ //Check to see if this reference actually occurs in the file being indexed
+ //or if it occurs in another file
+ int indexFlag = calculateIndexFlags();
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#acceptUsingDirective(org.eclipse.cdt.core.parser.ast.IASTUsingDirective)
- */
- public void acceptUsingDirective(IASTUsingDirective usageDirective) {
- // TODO Auto-generated method stub
- //System.out.println("acceptUsingDirective");
+ indexer.addFunctionDeclaration(function, indexFlag);
}
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#acceptUsingDeclaration(org.eclipse.cdt.core.parser.ast.IASTUsingDeclaration)
- */
- public void acceptUsingDeclaration(IASTUsingDeclaration usageDeclaration) {
- // TODO Auto-generated method stub
- //System.out.println("acceptUsingDeclaration");
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#acceptASMDefinition(org.eclipse.cdt.core.parser.ast.IASTASMDefinition)
- */
- public void acceptASMDefinition(IASTASMDefinition asmDefinition) {
- // TODO Auto-generated method stub
- //System.out.println("acceptASMDefinition");
- }
+ public void acceptUsingDirective(IASTUsingDirective usageDirective) {}
+ public void acceptUsingDeclaration(IASTUsingDeclaration usageDeclaration) {}
+ public void acceptASMDefinition(IASTASMDefinition asmDefinition) {}
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#acceptTypedef(org.eclipse.cdt.core.parser.ast.IASTTypedef)
- */
public void acceptTypedefDeclaration(IASTTypedefDeclaration typedef) {
- // TODO Auto-generated method stub
- indexer.addTypedefDeclaration(typedef);
+ //Check to see if this reference actually occurs in the file being indexed
+ //or if it occurs in another file
+ int indexFlag = calculateIndexFlags();
+
+ indexer.addTypedefDeclaration(typedef,indexFlag);
}
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#acceptEnumerationSpecifier(org.eclipse.cdt.core.parser.ast.IASTEnumerationSpecifier)
- */
public void acceptEnumerationSpecifier(IASTEnumerationSpecifier enumeration) {
- // TODO Auto-generated method stub
- //System.out.println("acceptEnumSpecifier");
- indexer.addEnumerationSpecifier(enumeration);
+ //Check to see if this reference actually occurs in the file being indexed
+ //or if it occurs in another file
+ int indexFlag = calculateIndexFlags();
+
+ indexer.addEnumerationSpecifier(enumeration,indexFlag);
}
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#enterFunctionBody(org.eclipse.cdt.core.parser.ast.IASTFunction)
- */
public void enterFunctionBody(IASTFunction function) {
- // TODO Auto-generated method stub
- indexer.addFunctionDeclaration(function);
- //indexer.addFunctionDefinition();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#exitFunctionBody(org.eclipse.cdt.core.parser.ast.IASTFunction)
- */
- public void exitFunctionBody(IASTFunction function) {
- // TODO Auto-generated method stub
- //System.out.println("exitFunctionBody");
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#enterCompilationUnit(org.eclipse.cdt.core.parser.ast.IASTCompilationUnit)
- */
- public void enterCompilationUnit(IASTCompilationUnit compilationUnit) {
- // TODO Auto-generated method stub
- //System.out.println("enterCompilationUnit");
+ //Check to see if this reference actually occurs in the file being indexed
+ //or if it occurs in another file
+ int indexFlag = calculateIndexFlags();
+
+ indexer.addFunctionDeclaration(function,indexFlag);
+
}
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#enterInclusion(org.eclipse.cdt.core.parser.ast.IASTInclusion)
- */
+ public void exitFunctionBody(IASTFunction function) {}
+ public void enterCompilationUnit(IASTCompilationUnit compilationUnit) {}
+
public void enterInclusion(IASTInclusion inclusion) {
if( areProblemMarkersEnabled() ){
IPath newPath = new Path(inclusion.getFullFileName());
@@ -262,7 +223,7 @@ public class SourceIndexerRequestor implements ISourceElementRequestor, IIndexCo
}
IASTInclusion parent = peekInclude();
- indexer.addInclude(inclusion, parent);
+ indexer.addInclude(inclusion, parent,indexer.output.getIndexedFile(resourceFile.getFullPath().toString()).getFileNumber());
//Push on stack
pushInclude(inclusion);
//Add to traversed files
@@ -273,294 +234,235 @@ public class SourceIndexerRequestor implements ISourceElementRequestor, IIndexCo
ICFileType type = CCorePlugin.getDefault().getFileType(resourceProject,
inclusion.getFullFileName());
- /* See if this file has been encountered before */
- if (type.isHeader())
- CCorePlugin.getDefault().getCoreModel().getIndexManager().haveEncounteredHeader(resourceProject.getFullPath(),new Path(inclusion.getFullFileName()));
+
}
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#enterNamespaceDefinition(org.eclipse.cdt.core.parser.ast.IASTNamespaceDefinition)
- */
public void enterNamespaceDefinition(IASTNamespaceDefinition namespaceDefinition) {
- // TODO Auto-generated method stub
- //System.out.println("enterNamespaceDefinition");
- indexer.addNamespaceDefinition(namespaceDefinition);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#enterClassSpecifier(org.eclipse.cdt.core.parser.ast.IASTClassSpecifier)
- */
- public void enterClassSpecifier(IASTClassSpecifier classSpecification) {
- // TODO Auto-generated method stub
+ //Check to see if this reference actually occurs in the file being indexed
+ //or if it occurs in another file
+ int indexFlag = calculateIndexFlags();
- //System.out.println("New class spec: " + classSpecification.getName());
- //System.out.println("enterClassSpecifier");
-
+ indexer.addNamespaceDefinition(namespaceDefinition, indexFlag);
}
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#enterLinkageSpecification(org.eclipse.cdt.core.parser.ast.IASTLinkageSpecification)
- */
- public void enterLinkageSpecification(IASTLinkageSpecification linkageSpec) {
- // TODO Auto-generated method stub
- //System.out.println("enterLinkageSpecification");
- }
+ public void enterClassSpecifier(IASTClassSpecifier classSpecification) {}
+ public void enterLinkageSpecification(IASTLinkageSpecification linkageSpec) {}
+ public void enterTemplateDeclaration(IASTTemplateDeclaration declaration) {}
+ public void enterTemplateSpecialization(IASTTemplateSpecialization specialization) {}
+ public void enterTemplateInstantiation(IASTTemplateInstantiation instantiation) {}
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#enterTemplateDeclaration(org.eclipse.cdt.core.parser.ast.IASTTemplateDeclaration)
- */
- public void enterTemplateDeclaration(IASTTemplateDeclaration declaration) {
- // TODO Auto-generated method stub
- //System.out.println("enterTemplateDeclaration");
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#enterTemplateSpecialization(org.eclipse.cdt.core.parser.ast.IASTTemplateSpecialization)
- */
- public void enterTemplateSpecialization(IASTTemplateSpecialization specialization) {
- // TODO Auto-generated method stub
- //System.out.println("enterTemplateSpecialization");
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#enterTemplateExplicitInstantiation(org.eclipse.cdt.core.parser.ast.IASTTemplateInstantiation)
- */
- public void enterTemplateInstantiation(IASTTemplateInstantiation instantiation) {
- // TODO Auto-generated method stub
- //System.out.println("enterTemplateExplicitInstantiation");
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#acceptMethodDeclaration(org.eclipse.cdt.core.parser.ast.IASTMethod)
- */
public void acceptMethodDeclaration(IASTMethod method) {
- // TODO Auto-generated method stub
- //System.out.println("acceptMethodDeclaration");
- indexer.addMethodDeclaration(method);
+ //Check to see if this reference actually occurs in the file being indexed
+ //or if it occurs in another file
+ int indexFlag = calculateIndexFlags();
+
+ indexer.addMethodDeclaration(method, indexFlag);
}
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#enterMethodBody(org.eclipse.cdt.core.parser.ast.IASTMethod)
- */
public void enterMethodBody(IASTMethod method) {
- // TODO Auto-generated method stub
- //System.out.println("enterMethodBody " + method.getName());
- indexer.addMethodDeclaration(method);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#exitMethodBody(org.eclipse.cdt.core.parser.ast.IASTMethod)
- */
- public void exitMethodBody(IASTMethod method) {
- // TODO Auto-generated method stub
- //System.out.println("exitMethodBody");
+ //Check to see if this reference actually occurs in the file being indexed
+ //or if it occurs in another file
+ int indexFlag = calculateIndexFlags();
+
+ indexer.addMethodDeclaration(method, indexFlag);
}
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#acceptField(org.eclipse.cdt.core.parser.ast.IASTField)
- */
+ public void exitMethodBody(IASTMethod method) {}
+
public void acceptField(IASTField field) {
- // TODO Auto-generated method stub
- // System.out.println("acceptField");
- indexer.addFieldDeclaration(field);
+ //Check to see if this reference actually occurs in the file being indexed
+ //or if it occurs in another file
+ int indexFlag = calculateIndexFlags();
+
+ indexer.addFieldDeclaration(field, indexFlag);
}
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#acceptClassReference(org.eclipse.cdt.core.parser.ast.IASTClassSpecifier, int)
- */
public void acceptClassReference(IASTClassReference reference) {
- // TODO Auto-generated method stub
- //System.out.println("acceptClassReference");
+ //Check to see if this reference actually occurs in the file being indexed
+ //or if it occurs in another file
+ int indexFlag = calculateIndexFlags();
+
if (reference.getReferencedElement() instanceof IASTClassSpecifier)
- indexer.addClassReference((IASTClassSpecifier)reference.getReferencedElement());
+ indexer.addClassReference((IASTClassSpecifier)reference.getReferencedElement(), indexFlag);
else if (reference.getReferencedElement() instanceof IASTElaboratedTypeSpecifier)
{
- indexer.addForwardClassReference((IASTTypeSpecifier) reference.getReferencedElement());
+ indexer.addForwardClassReference((IASTTypeSpecifier) reference.getReferencedElement(), indexFlag);
}
}
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#exitTemplateDeclaration(org.eclipse.cdt.core.parser.ast.IASTTemplateDeclaration)
- */
- public void exitTemplateDeclaration(IASTTemplateDeclaration declaration) {
- // TODO Auto-generated method stub
- //System.out.println("exitTemplateDeclaration");
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#exitTemplateSpecialization(org.eclipse.cdt.core.parser.ast.IASTTemplateSpecialization)
- */
- public void exitTemplateSpecialization(IASTTemplateSpecialization specialization) {
- // TODO Auto-generated method stub
- //System.out.println("exitTemplateSpecialization");
-
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#exitTemplateExplicitInstantiation(org.eclipse.cdt.core.parser.ast.IASTTemplateInstantiation)
- */
- public void exitTemplateExplicitInstantiation(IASTTemplateInstantiation instantiation) {
- // TODO Auto-generated method stub
- //System.out.println("exitTemplateExplicitInstantiation");
-
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#exitLinkageSpecification(org.eclipse.cdt.core.parser.ast.IASTLinkageSpecification)
+ /**
+ * @return
*/
- public void exitLinkageSpecification(IASTLinkageSpecification linkageSpec) {
- // TODO Auto-generated method stub
- //System.out.println("exitLinkageSpecification");
+ private int calculateIndexFlags() {
+ int fileNum= 0;
+
+ //Initialize the file number to be the file number for the file that triggerd
+ //the indexing. Note that we should always be able to get a number for this as
+ //the first step in the Source Indexer is to add the file being indexed to the index
+ //which actually creates an entry for the file in the index.
+
+ IndexedFile mainIndexFile = indexer.output.getIndexedFile(resourceFile.getFullPath().toString());
+ if (mainIndexFile != null)
+ fileNum = mainIndexFile.getFileNumber();
+
+ IASTInclusion include = peekInclude();
+ if (include != null){
+ //We are not in the file that has triggered the index. Thus, we need to find the
+ //file number for the current file (if it has one). If the current file does not
+ //have a file number, we need to add it to the index.
+ IFile tempFile = CCorePlugin.getWorkspace().getRoot().getFileForLocation(new Path(include.getFullFileName()));
+ String filePath = "";
+ if (tempFile != null){
+ //File is local to workspace
+ filePath = tempFile.getFullPath().toString();
+ }
+ else{
+ //File is external to workspace
+ filePath = include.getFullFileName();
+ }
+
+ IndexedFile indFile = indexer.output.getIndexedFile(filePath);
+ if (indFile != null){
+ fileNum = indFile.getFileNumber();
+ }
+ else {
+ //Need to add file to index
+ if (tempFile != null){
+ indFile = indexer.output.addSecondaryIndexedFile(new IFileDocument(tempFile));
+ if (indFile != null)
+ fileNum = indFile.getFileNumber();
+ }
+ else {
+ indFile = indexer.output.addSecondaryExternalIndexedFile(include.getFullFileName());
+ if (indFile != null)
+ fileNum = indFile.getFileNumber();
+ }
+ }
+
+ }
+
+ return fileNum;
}
+
+ public void exitTemplateDeclaration(IASTTemplateDeclaration declaration) {}
+ public void exitTemplateSpecialization(IASTTemplateSpecialization specialization) {}
+ public void exitTemplateExplicitInstantiation(IASTTemplateInstantiation instantiation) {}
+ public void exitLinkageSpecification(IASTLinkageSpecification linkageSpec) {}
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#exitClassSpecifier(org.eclipse.cdt.core.parser.ast.IASTClassSpecifier)
- */
public void exitClassSpecifier(IASTClassSpecifier classSpecification) {
- // TODO Auto-generated method stub
- indexer.addClassSpecifier(classSpecification);
- //System.out.println("exitClassSpecifier");
+ //Check to see if this reference actually occurs in the file being indexed
+ //or if it occurs in another file
+ int indexFlag = calculateIndexFlags();
+
+ indexer.addClassSpecifier(classSpecification, indexFlag);
}
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#exitNamespaceDefinition(org.eclipse.cdt.core.parser.ast.IASTNamespaceDefinition)
- */
- public void exitNamespaceDefinition(IASTNamespaceDefinition namespaceDefinition) {
- // TODO Auto-generated method stub
- //System.out.println("exitNamespaceDefinition");
- }
+ public void exitNamespaceDefinition(IASTNamespaceDefinition namespaceDefinition) {}
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#exitInclusion(org.eclipse.cdt.core.parser.ast.IASTInclusion)
- */
public void exitInclusion(IASTInclusion inclusion) {
// TODO Auto-generated method stub
popInclude();
}
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#exitCompilationUnit(org.eclipse.cdt.core.parser.ast.IASTCompilationUnit)
- */
- public void exitCompilationUnit(IASTCompilationUnit compilationUnit) {
- // TODO Auto-generated method stub
- //System.out.println("exitCompilationUnit");
-
-}
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#acceptAbstractTypeSpecDeclaration(org.eclipse.cdt.core.parser.ast.IASTAbstractTypeSpecifierDeclaration)
- */
- public void acceptAbstractTypeSpecDeclaration(IASTAbstractTypeSpecifierDeclaration abstractDeclaration) {
- // TODO Auto-generated method stub
-
- }
+ public void exitCompilationUnit(IASTCompilationUnit compilationUnit) {}
+
+ public void acceptAbstractTypeSpecDeclaration(IASTAbstractTypeSpecifierDeclaration abstractDeclaration) {}
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#acceptTypedefReference(org.eclipse.cdt.core.parser.ast.IASTTypedefReference)
- */
public void acceptTypedefReference(IASTTypedefReference reference) {
- // TODO Auto-generated method stub
- if( reference.getReferencedElement() instanceof IASTTypedefDeclaration )
- indexer.addTypedefReference( (IASTTypedefDeclaration) reference.getReferencedElement() );
+ //Check to see if this reference actually occurs in the file being indexed
+ //or if it occurs in another file
+ int indexFlag = calculateIndexFlags();
+ if( reference.getReferencedElement() instanceof IASTTypedefDeclaration )
+ indexer.addTypedefReference( (IASTTypedefDeclaration) reference.getReferencedElement(),indexFlag);
}
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#acceptNamespaceReference(org.eclipse.cdt.core.parser.ast.IASTNamespaceReference)
- */
+
public void acceptNamespaceReference(IASTNamespaceReference reference) {
- // TODO Auto-generated method stub
+ //Check to see if this reference actually occurs in the file being indexed
+ //or if it occurs in another file
+ int indexFlag = calculateIndexFlags();
+
if (reference.getReferencedElement() instanceof IASTNamespaceDefinition)
- indexer.addNamespaceReference((IASTNamespaceDefinition)reference.getReferencedElement());
+ indexer.addNamespaceReference((IASTNamespaceDefinition)reference.getReferencedElement(),indexFlag);
}
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#acceptEnumerationReference(org.eclipse.cdt.core.parser.ast.IASTEnumerationReference)
- */
+
public void acceptEnumerationReference(IASTEnumerationReference reference) {
- // TODO Auto-generated method stub
+ //Check to see if this reference actually occurs in the file being indexed
+ //or if it occurs in another file
+ int indexFlag = calculateIndexFlags();
+
if (reference.getReferencedElement() instanceof IASTEnumerationSpecifier)
- indexer.addEnumerationReference((IASTEnumerationSpecifier) reference.getReferencedElement());
+ indexer.addEnumerationReference((IASTEnumerationSpecifier) reference.getReferencedElement(),indexFlag);
}
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#acceptVariableReference(org.eclipse.cdt.core.parser.ast.IASTVariableReference)
- */
+
public void acceptVariableReference(IASTVariableReference reference) {
- // TODO Auto-generated method stub
+ //Check to see if this reference actually occurs in the file being indexed
+ //or if it occurs in another file
+ int indexFlag = calculateIndexFlags();
+
if (reference.getReferencedElement() instanceof IASTVariable)
- indexer.addVariableReference((IASTVariable)reference.getReferencedElement());
-
+ indexer.addVariableReference((IASTVariable)reference.getReferencedElement(),indexFlag);
}
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#acceptFunctionReference(org.eclipse.cdt.core.parser.ast.IASTFunctionReference)
- */
+
public void acceptFunctionReference(IASTFunctionReference reference) {
+ //Check to see if this reference actually occurs in the file being indexed
+ //or if it occurs in another file
+ int indexFlag = calculateIndexFlags();
+
if (reference.getReferencedElement() instanceof IASTFunction)
- indexer.addFunctionReference((IASTFunction) reference.getReferencedElement());
+ indexer.addFunctionReference((IASTFunction) reference.getReferencedElement(), indexFlag);
}
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#acceptFieldReference(org.eclipse.cdt.core.parser.ast.IASTFieldReference)
- */
+
public void acceptFieldReference(IASTFieldReference reference) {
+ //Check to see if this reference actually occurs in the file being indexed
+ //or if it occurs in another file
+ int indexFlag = calculateIndexFlags();
+
if (reference.getReferencedElement() instanceof IASTField)
- indexer.addFieldReference((IASTField) reference.getReferencedElement());
+ indexer.addFieldReference((IASTField) reference.getReferencedElement(),indexFlag);
}
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#acceptMethodReference(org.eclipse.cdt.core.parser.ast.IASTMethodReference)
- */
+
public void acceptMethodReference(IASTMethodReference reference) {
+ //Check to see if this reference actually occurs in the file being indexed
+ //or if it occurs in another file
+ int indexFlag = calculateIndexFlags();
+
if (reference.getReferencedElement() instanceof IASTMethod)
- indexer.addMethodReference((IASTMethod) reference.getReferencedElement());
+ indexer.addMethodReference((IASTMethod) reference.getReferencedElement(),indexFlag);
}
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#acceptElaboratedForewardDeclaration(org.eclipse.cdt.core.parser.ast.IASTElaboratedTypeSpecifier)
- */
+
public void acceptElaboratedForewardDeclaration(IASTElaboratedTypeSpecifier elaboratedType){
- indexer.addElaboratedForwardDeclaration(elaboratedType);
- }
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#enterCodeBlock(org.eclipse.cdt.core.parser.ast.IASTScope)
- */
- public void enterCodeBlock(IASTCodeScope scope) {
- // TODO Auto-generated method stub
+ //Check to see if this reference actually occurs in the file being indexed
+ //or if it occurs in another file
+ int indexFlag = calculateIndexFlags();
- }
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#exitCodeBlock(org.eclipse.cdt.core.parser.ast.IASTScope)
- */
- public void exitCodeBlock(IASTCodeScope scope) {
- // TODO Auto-generated method stub
+ indexer.addElaboratedForwardDeclaration(elaboratedType, indexFlag);
+ }
+
+ public void enterCodeBlock(IASTCodeScope scope) {}
+ public void exitCodeBlock(IASTCodeScope scope) {}
+ public void acceptEnumeratorReference(IASTEnumeratorReference reference){
+ //Check to see if this reference actually occurs in the file being indexed
+ //or if it occurs in another file
+ int indexFlag = calculateIndexFlags();
- }
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#acceptEnumeratorReference(org.eclipse.cdt.core.parser.ast.IASTEnumerationReference)
- */
- public void acceptEnumeratorReference(IASTEnumeratorReference reference)
- {
if( reference.getReferencedElement() instanceof IASTEnumerator )
- indexer.addEnumeratorReference( (IASTEnumerator)reference.getReferencedElement() );
+ indexer.addEnumeratorReference( (IASTEnumerator)reference.getReferencedElement(), indexFlag);
}
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#acceptParameterReference(org.eclipse.cdt.internal.core.parser.ast.complete.ASTParameterReference)
- */
- public void acceptParameterReference(IASTParameterReference reference)
- {
+
+ public void acceptParameterReference(IASTParameterReference reference){
+ //Check to see if this reference actually occurs in the file being indexed
+ //or if it occurs in another file
+ int indexFlag = calculateIndexFlags();
+
if( reference.getReferencedElement() instanceof IASTParameterDeclaration )
- indexer.addParameterReference( (IASTParameterDeclaration) reference.getReferencedElement() );
+ indexer.addParameterReference( (IASTParameterDeclaration) reference.getReferencedElement(), indexFlag);
}
- public void acceptTemplateParameterReference( IASTTemplateParameterReference reference ){
- if( reference.getReferencedElement() instanceof IASTTemplateParameterReference ){
- //TODO
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#acceptFriendDeclaration(org.eclipse.cdt.core.parser.ast.IASTDeclaration)
- */
- public void acceptFriendDeclaration(IASTDeclaration declaration) {
- // TODO Auto-generated method stub
-
- }
+ public void acceptTemplateParameterReference( IASTTemplateParameterReference reference ){}
+ public void acceptFriendDeclaration(IASTDeclaration declaration) {}
private void pushInclude( IASTInclusion inclusion ){
includeStack.addFirst( currentInclude );
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/DeltaProcessor.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/DeltaProcessor.java
index 7ac803e2a56..fa6b7c5ec33 100644
--- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/DeltaProcessor.java
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/DeltaProcessor.java
@@ -593,7 +593,7 @@ public class DeltaProcessor {
case ICElement.C_UNIT:
IFile file = (IFile) delta.getResource();
IProject filesProject = file.getProject();
- indexManager.addSource(file, filesProject.getFullPath(), false);
+ indexManager.addSource(file, filesProject.getFullPath());
break;
}
diff --git a/core/org.eclipse.cdt.core/search/ChangeLog b/core/org.eclipse.cdt.core/search/ChangeLog
index 64450d2b0e8..0bc129690a9 100644
--- a/core/org.eclipse.cdt.core/search/ChangeLog
+++ b/core/org.eclipse.cdt.core/search/ChangeLog
@@ -1,3 +1,6 @@
+2004-11-02 Bogdan Gheorghe
+ Partial Fix for 74427: Indexer needs to store more info
+
2004-08-11 Bogdan Gheorghe
Fix for 71964: Search parses too many times
diff --git a/core/org.eclipse.cdt.core/search/org/eclipse/cdt/core/search/OrPattern.java b/core/org.eclipse.cdt.core/search/org/eclipse/cdt/core/search/OrPattern.java
index 931eba2d935..490dce5cbcf 100644
--- a/core/org.eclipse.cdt.core/search/org/eclipse/cdt/core/search/OrPattern.java
+++ b/core/org.eclipse.cdt.core/search/org/eclipse/cdt/core/search/OrPattern.java
@@ -89,7 +89,7 @@ public class OrPattern extends CSearchPattern {
}
}
- public void feedIndexRequestor( IIndexSearchRequestor requestor, int detailLevel, int[] references, IndexInput input, ICSearchScope scope )
+ public void feedIndexRequestor( IIndexSearchRequestor requestor, int detailLevel, int[] references, int[] indexFlags, IndexInput input, ICSearchScope scope )
throws IOException {
//never called for OrPattern
}
diff --git a/core/org.eclipse.cdt.core/search/org/eclipse/cdt/internal/core/search/matching/CSearchPattern.java b/core/org.eclipse.cdt.core/search/org/eclipse/cdt/internal/core/search/matching/CSearchPattern.java
index 79745aa4510..fb87f07f877 100644
--- a/core/org.eclipse.cdt.core/search/org/eclipse/cdt/internal/core/search/matching/CSearchPattern.java
+++ b/core/org.eclipse.cdt.core/search/org/eclipse/cdt/internal/core/search/matching/CSearchPattern.java
@@ -700,8 +700,9 @@ public abstract class CSearchPattern implements ICSearchConstants, ICSearchPatte
IEntryResult entry = entries[i];
resetIndexInfo();
decodeIndexEntry(entry);
+
if (matchIndexEntry()){
- feedIndexRequestor(requestor, detailLevel, entry.getFileReferences(), input, scope);
+ feedIndexRequestor(requestor, detailLevel, entry.getFileReferences(), entry.getIndexFlags(), input, scope);
}
}
}
@@ -709,7 +710,7 @@ public abstract class CSearchPattern implements ICSearchConstants, ICSearchPatte
/**
* Feed the requestor according to the current search pattern
*/
- public abstract void feedIndexRequestor(IIndexSearchRequestor requestor, int detailLevel, int[] references, IndexInput input, ICSearchScope scope) throws IOException ;
+ public abstract void feedIndexRequestor(IIndexSearchRequestor requestor, int detailLevel, int[] references, int[] indexFlags, IndexInput input, ICSearchScope scope) throws IOException ;
/**
* Called to reset any variables used in the decoding of index entries,
diff --git a/core/org.eclipse.cdt.core/search/org/eclipse/cdt/internal/core/search/matching/ClassDeclarationPattern.java b/core/org.eclipse.cdt.core/search/org/eclipse/cdt/internal/core/search/matching/ClassDeclarationPattern.java
index b696dba2946..3ac6bd002ce 100644
--- a/core/org.eclipse.cdt.core/search/org/eclipse/cdt/internal/core/search/matching/ClassDeclarationPattern.java
+++ b/core/org.eclipse.cdt.core/search/org/eclipse/cdt/internal/core/search/matching/ClassDeclarationPattern.java
@@ -154,7 +154,7 @@ public class ClassDeclarationPattern extends CSearchPattern {
protected boolean isForward;
- public void feedIndexRequestor(IIndexSearchRequestor requestor, int detailLevel, int[] references, IndexInput input, ICSearchScope scope) throws IOException {
+ public void feedIndexRequestor(IIndexSearchRequestor requestor, int detailLevel, int[] references, int[] indexFlags, IndexInput input, ICSearchScope scope) throws IOException {
boolean isClass = decodedType == CLASS_SUFFIX;
for (int i = 0, max = references.length; i < max; i++) {
IndexedFile file = input.getIndexedFile(references[i]);
@@ -253,4 +253,5 @@ public class ClassDeclarationPattern extends CSearchPattern {
return true;
}
+
}
diff --git a/core/org.eclipse.cdt.core/search/org/eclipse/cdt/internal/core/search/matching/FieldDeclarationPattern.java b/core/org.eclipse.cdt.core/search/org/eclipse/cdt/internal/core/search/matching/FieldDeclarationPattern.java
index 8e7c1eaebfc..c19e1b6fc69 100644
--- a/core/org.eclipse.cdt.core/search/org/eclipse/cdt/internal/core/search/matching/FieldDeclarationPattern.java
+++ b/core/org.eclipse.cdt.core/search/org/eclipse/cdt/internal/core/search/matching/FieldDeclarationPattern.java
@@ -158,7 +158,7 @@ public class FieldDeclarationPattern extends CSearchPattern {
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.search.matching.CSearchPattern#feedIndexRequestor(org.eclipse.cdt.internal.core.search.IIndexSearchRequestor, int, int[], org.eclipse.cdt.internal.core.index.impl.IndexInput, org.eclipse.cdt.core.search.ICSearchScope)
*/
- public void feedIndexRequestor(IIndexSearchRequestor requestor, int detailLevel, int[] references, IndexInput input, ICSearchScope scope) throws IOException {
+ public void feedIndexRequestor(IIndexSearchRequestor requestor, int detailLevel, int[] references, int[] indexFlags, IndexInput input, ICSearchScope scope) throws IOException {
for (int i = 0, max = references.length; i < max; i++) {
IndexedFile file = input.getIndexedFile(references[i]);
String path;
diff --git a/core/org.eclipse.cdt.core/search/org/eclipse/cdt/internal/core/search/matching/IncludePattern.java b/core/org.eclipse.cdt.core/search/org/eclipse/cdt/internal/core/search/matching/IncludePattern.java
index cedd57a1b48..a3497759311 100644
--- a/core/org.eclipse.cdt.core/search/org/eclipse/cdt/internal/core/search/matching/IncludePattern.java
+++ b/core/org.eclipse.cdt.core/search/org/eclipse/cdt/internal/core/search/matching/IncludePattern.java
@@ -50,7 +50,7 @@ public class IncludePattern extends CSearchPattern {
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.search.matching.CSearchPattern#feedIndexRequestor(org.eclipse.cdt.internal.core.search.IIndexSearchRequestor, int, int[], org.eclipse.cdt.internal.core.index.impl.IndexInput, org.eclipse.cdt.core.search.ICSearchScope)
*/
- public void feedIndexRequestor(IIndexSearchRequestor requestor, int detailLevel, int[] references, IndexInput input, ICSearchScope scope) throws IOException {
+ public void feedIndexRequestor(IIndexSearchRequestor requestor, int detailLevel, int[] references, int[] indexFlags, IndexInput input, ICSearchScope scope) throws IOException {
for (int i = 0, max = references.length; i < max; i++) {
IndexedFile file = input.getIndexedFile(references[i]);
String path;
diff --git a/core/org.eclipse.cdt.core/search/org/eclipse/cdt/internal/core/search/matching/MacroDeclarationPattern.java b/core/org.eclipse.cdt.core/search/org/eclipse/cdt/internal/core/search/matching/MacroDeclarationPattern.java
index 6eb949a4e44..22b4f15434c 100644
--- a/core/org.eclipse.cdt.core/search/org/eclipse/cdt/internal/core/search/matching/MacroDeclarationPattern.java
+++ b/core/org.eclipse.cdt.core/search/org/eclipse/cdt/internal/core/search/matching/MacroDeclarationPattern.java
@@ -67,7 +67,7 @@ public class MacroDeclarationPattern extends CSearchPattern {
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.search.matching.CSearchPattern#feedIndexRequestor(org.eclipse.cdt.internal.core.search.IIndexSearchRequestor, int, int[], org.eclipse.cdt.internal.core.index.impl.IndexInput, org.eclipse.cdt.core.search.ICSearchScope)
*/
- public void feedIndexRequestor(IIndexSearchRequestor requestor, int detailLevel, int[] references, IndexInput input, ICSearchScope scope) throws IOException {
+ public void feedIndexRequestor(IIndexSearchRequestor requestor, int detailLevel, int[] references, int[] indexFlags, IndexInput input, ICSearchScope scope) throws IOException {
for (int i = 0, max = references.length; i < max; i++) {
IndexedFile file = input.getIndexedFile(references[i]);
String path;
diff --git a/core/org.eclipse.cdt.core/search/org/eclipse/cdt/internal/core/search/matching/MatchLocator.java b/core/org.eclipse.cdt.core/search/org/eclipse/cdt/internal/core/search/matching/MatchLocator.java
index e051cb8d3c4..f056b2af970 100644
--- a/core/org.eclipse.cdt.core/search/org/eclipse/cdt/internal/core/search/matching/MatchLocator.java
+++ b/core/org.eclipse.cdt.core/search/org/eclipse/cdt/internal/core/search/matching/MatchLocator.java
@@ -18,7 +18,6 @@ import java.io.InputStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
-import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
@@ -76,7 +75,6 @@ import org.eclipse.cdt.core.parser.ast.IASTUsingDeclaration;
import org.eclipse.cdt.core.parser.ast.IASTUsingDirective;
import org.eclipse.cdt.core.parser.ast.IASTVariable;
import org.eclipse.cdt.core.parser.ast.IASTVariableReference;
-import org.eclipse.cdt.core.parser.util.ObjectSet;
import org.eclipse.cdt.core.search.ICSearchPattern;
import org.eclipse.cdt.core.search.ICSearchResultCollector;
import org.eclipse.cdt.core.search.ICSearchScope;
@@ -106,12 +104,7 @@ public class MatchLocator implements IMatchLocator{
ArrayList matchStorage;
- protected ObjectSet encounteredHeaders;
- protected ObjectSet tempHeaderSet;
-
public static boolean VERBOSE = false;
-
- private boolean checkForMatch = true;
/**
*
*/
@@ -152,173 +145,138 @@ public class MatchLocator implements IMatchLocator{
*/
public void acceptParameterReference(IASTParameterReference reference)
{
- if (checkForMatch)
- check( REFERENCES, reference );
+ check( REFERENCES, reference );
}
public void acceptTemplateParameterReference(IASTTemplateParameterReference reference)
{
- if (checkForMatch)
- check( REFERENCES, reference );
+ check( REFERENCES, reference );
}
public void acceptTypedefDeclaration(IASTTypedefDeclaration typedef){
lastDeclaration = typedef;
-
- if (checkForMatch)
- check( DECLARATIONS, typedef );
+ check( DECLARATIONS, typedef );
}
public void acceptTypedefReference( IASTTypedefReference reference ){
- if (checkForMatch)
- check( REFERENCES, reference );
+ check( REFERENCES, reference );
}
public void acceptEnumeratorReference(IASTEnumeratorReference reference){
- if (checkForMatch)
check( REFERENCES, reference );
}
public void acceptMacro(IASTMacro macro){
- if (checkForMatch)
- check( DECLARATIONS, macro );
+ check( DECLARATIONS, macro );
}
public void acceptVariable(IASTVariable variable){
lastDeclaration = variable;
- if (checkForMatch){
- check( DECLARATIONS, variable );
-
- //A declaration is a definition unless...:
- //it contains the extern specifier or a linkage-spec and no initializer
- if( variable.getInitializerClause() != null ||
- ( !variable.isExtern() && !(currentScope instanceof IASTLinkageSpecification) ) ){
- check( DEFINITIONS, variable );
- }
+ check( DECLARATIONS, variable );
+ //A declaration is a definition unless...:
+ //it contains the extern specifier or a linkage-spec and no initializer
+ if( variable.getInitializerClause() != null ||
+ ( !variable.isExtern() && !(currentScope instanceof IASTLinkageSpecification) ) ){
+ check( DEFINITIONS, variable );
}
}
public void acceptField(IASTField field){
lastDeclaration = field;
-
- if (checkForMatch){
- if( currentScope instanceof IASTClassSpecifier ){
- check( DECLARATIONS, field );
- if( !field.isStatic() ){
- check( DEFINITIONS, field );
- }
- } else {
- check( DEFINITIONS, field );
+ if( currentScope instanceof IASTClassSpecifier ){
+ check( DECLARATIONS, field );
+ if( !field.isStatic() ){
+ check( DEFINITIONS, field );
}
+ } else {
+ check( DEFINITIONS, field );
}
}
public void acceptEnumerationSpecifier(IASTEnumerationSpecifier enumeration){
lastDeclaration = enumeration;
-
- if (checkForMatch){
- check( DECLARATIONS, enumeration );
- Iterator iter = enumeration.getEnumerators();
- while( iter.hasNext() ){
- IASTEnumerator enumerator = (IASTEnumerator) iter.next();
- lastDeclaration = enumerator;
- check ( DECLARATIONS, enumerator );
- }
- }
+ check( DECLARATIONS, enumeration );
+ Iterator iter = enumeration.getEnumerators();
+ while( iter.hasNext() ){
+ IASTEnumerator enumerator = (IASTEnumerator) iter.next();
+ lastDeclaration = enumerator;
+ check ( DECLARATIONS, enumerator );
+ }
}
public void acceptFunctionDeclaration(IASTFunction function){
lastDeclaration = function;
-
- if (checkForMatch)
- check( DECLARATIONS, function );
+ check( DECLARATIONS, function );
}
public void acceptMethodDeclaration(IASTMethod method){
lastDeclaration = method;
-
- if (checkForMatch)
- check( DECLARATIONS, method );
+ check( DECLARATIONS, method );
}
public void acceptClassReference(IASTClassReference reference) {
- if (checkForMatch)
- check( REFERENCES, reference );
+ check( REFERENCES, reference );
}
public void acceptNamespaceReference( IASTNamespaceReference reference ){
- if (checkForMatch)
- check( REFERENCES, reference );
+ check( REFERENCES, reference );
}
public void acceptVariableReference( IASTVariableReference reference ){
- if (checkForMatch)
- check( REFERENCES, reference );
+ check( REFERENCES, reference );
}
public void acceptFieldReference( IASTFieldReference reference ){
- if (checkForMatch)
- check( REFERENCES, reference );
+ check( REFERENCES, reference );
}
public void acceptEnumerationReference( IASTEnumerationReference reference ){
- if (checkForMatch)
- check( REFERENCES, reference );
+ check( REFERENCES, reference );
}
public void acceptFunctionReference( IASTFunctionReference reference ){
- if (checkForMatch)
- check( REFERENCES, reference );
+ check( REFERENCES, reference );
}
public void acceptMethodReference( IASTMethodReference reference ){
- if (checkForMatch)
- check( REFERENCES, reference );
+ check( REFERENCES, reference );
}
public void enterFunctionBody(IASTFunction function){
lastDeclaration = function;
- if (checkForMatch)
- {
- if( !function.previouslyDeclared() )
- check( DECLARATIONS, function );
-
- check( DEFINITIONS, function );
+ if( !function.previouslyDeclared() )
+ check( DECLARATIONS, function );
- Iterator parms =function.getParameters();
- while (parms.hasNext()){
- Object tempParm = parms.next();
- if (tempParm instanceof IASTParameterDeclaration){
- check( DECLARATIONS, ((IASTParameterDeclaration)tempParm));
- }
+ check( DEFINITIONS, function );
+
+ Iterator parms =function.getParameters();
+ while (parms.hasNext()){
+ Object tempParm = parms.next();
+ if (tempParm instanceof IASTParameterDeclaration){
+ check( DECLARATIONS, ((IASTParameterDeclaration)tempParm));
}
}
-
pushScope( function );
}
public void enterMethodBody(IASTMethod method) {
lastDeclaration = method;
-
- if (checkForMatch){
- if( !method.previouslyDeclared() )
- check( DECLARATIONS, method );
-
- check( DEFINITIONS, method );
-
+ if( !method.previouslyDeclared() )
+ check( DECLARATIONS, method );
- Iterator parms =method.getParameters();
- while (parms.hasNext()){
- Object tempParm = parms.next();
- if (tempParm instanceof IASTParameterDeclaration){
- check( DECLARATIONS, ((IASTParameterDeclaration)tempParm));
- }
+ check( DEFINITIONS, method );
+
+
+ Iterator parms =method.getParameters();
+ while (parms.hasNext()){
+ Object tempParm = parms.next();
+ if (tempParm instanceof IASTParameterDeclaration){
+ check( DECLARATIONS, ((IASTParameterDeclaration)tempParm));
}
}
-
pushScope( method );
}
@@ -328,22 +286,14 @@ public class MatchLocator implements IMatchLocator{
public void enterNamespaceDefinition(IASTNamespaceDefinition namespaceDefinition) {
lastDeclaration = namespaceDefinition;
-
- if (checkForMatch){
- check( DECLARATIONS, namespaceDefinition );
- check( DEFINITIONS, namespaceDefinition );
- }
-
+ check( DECLARATIONS, namespaceDefinition );
+ check( DEFINITIONS, namespaceDefinition );
pushScope( namespaceDefinition );
}
public void enterClassSpecifier(IASTClassSpecifier classSpecification) {
lastDeclaration = classSpecification;
-
- if (checkForMatch){
- check( DECLARATIONS, classSpecification );
- }
-
+ check( DECLARATIONS, classSpecification );
pushScope( classSpecification );
}
@@ -356,10 +306,7 @@ public class MatchLocator implements IMatchLocator{
}
public void exitClassSpecifier(IASTClassSpecifier classSpecification) {
- if (checkForMatch){
- check(DECLARATIONS, classSpecification);
- }
-
+ check(DECLARATIONS, classSpecification);
popScope();
}
@@ -376,20 +323,7 @@ public class MatchLocator implements IMatchLocator{
IPath path = new Path( includePath );
IResource resource = null;
- if (!encounteredHeaders.containsKey(includePath)){
- //this header has not been seen before
- searchStack.addFirst(new Boolean(checkForMatch));
- checkForMatch = true;
- if (!tempHeaderSet.containsKey(includePath)){
- tempHeaderSet.put(includePath);
- }
- }
- else{
- //this header has been seen before; don't bother processing it
- searchStack.addFirst(new Boolean(checkForMatch));
- checkForMatch = false;
- }
-
+
if( workspaceRoot != null ){
resource = workspaceRoot.getFileForLocation( path );
// if( resource == null ){
@@ -420,19 +354,12 @@ public class MatchLocator implements IMatchLocator{
currentPath = (IPath) obj;
currentResource = null;
}
-
- //set match for current level
- Boolean check= (Boolean) searchStack.removeFirst();
- checkForMatch = check.booleanValue();
}
public void locateMatches( String [] paths, IWorkspace workspace, IWorkingCopy[] workingCopies ) throws InterruptedException{
matchStorage = new ArrayList();
- encounteredHeaders= new ObjectSet(32);
- tempHeaderSet = new ObjectSet(32);
-
workspaceRoot = (workspace != null) ? workspace.getRoot() : null;
HashMap wcPaths = new HashMap();
@@ -477,10 +404,6 @@ public class MatchLocator implements IMatchLocator{
if (!searchScope.encloses(pathString)) continue;
- IFile tempFile=workspaceRoot.getFile(new Path(pathString));
- IPath tempLocation =tempFile.getLocation();
- if ((tempLocation != null) && (encounteredHeaders.containsKey(tempLocation.toOSString()))) continue;
-
CodeReader reader = null;
realPath = null;
@@ -540,9 +463,6 @@ public class MatchLocator implements IMatchLocator{
}
}
- //Set checkForMatch to true
- checkForMatch = true;
-
//Get the scanner info
IScannerInfo scanInfo = new ScannerInfo();
IScannerInfoProvider provider = CCorePlugin.getDefault().getScannerInfoProvider(project);
@@ -589,11 +509,8 @@ public class MatchLocator implements IMatchLocator{
vmErr.printStackTrace();
}
} finally {
- encounteredHeaders.addAll(tempHeaderSet);
- tempHeaderSet.clear();
scopeStack.clear();
resourceStack.clear();
- searchStack.clear();
lastDeclaration = null;
currentScope = null;
parser = null;
@@ -725,8 +642,6 @@ public class MatchLocator implements IMatchLocator{
private IASTScope currentScope = null;
private LinkedList scopeStack = new LinkedList();
-
- private LinkedList searchStack = new LinkedList();
/* (non-Javadoc)
* @see org.eclipse.cdt.core.parser.ISourceElementRequestor#acceptElaboratedForewardDeclaration(org.eclipse.cdt.core.parser.ast.IASTElaboratedTypeSpecifier)
diff --git a/core/org.eclipse.cdt.core/search/org/eclipse/cdt/internal/core/search/matching/MethodDeclarationPattern.java b/core/org.eclipse.cdt.core/search/org/eclipse/cdt/internal/core/search/matching/MethodDeclarationPattern.java
index 5aa009f3b1a..36143ab15ad 100644
--- a/core/org.eclipse.cdt.core/search/org/eclipse/cdt/internal/core/search/matching/MethodDeclarationPattern.java
+++ b/core/org.eclipse.cdt.core/search/org/eclipse/cdt/internal/core/search/matching/MethodDeclarationPattern.java
@@ -168,7 +168,7 @@ public class MethodDeclarationPattern extends CSearchPattern {
return true;
}
- public void feedIndexRequestor(IIndexSearchRequestor requestor, int detailLevel, int[] references, IndexInput input, ICSearchScope scope) throws IOException {
+ public void feedIndexRequestor(IIndexSearchRequestor requestor, int detailLevel, int[] references, int[] indexFlags, IndexInput input, ICSearchScope scope) throws IOException {
for (int i = 0, max = references.length; i < max; i++) {
IndexedFile file = input.getIndexedFile(references[i]);
String path;
diff --git a/core/org.eclipse.cdt.core/search/org/eclipse/cdt/internal/core/search/matching/NamespaceDeclarationPattern.java b/core/org.eclipse.cdt.core/search/org/eclipse/cdt/internal/core/search/matching/NamespaceDeclarationPattern.java
index 54249b25c15..f8abbf1c50f 100644
--- a/core/org.eclipse.cdt.core/search/org/eclipse/cdt/internal/core/search/matching/NamespaceDeclarationPattern.java
+++ b/core/org.eclipse.cdt.core/search/org/eclipse/cdt/internal/core/search/matching/NamespaceDeclarationPattern.java
@@ -79,7 +79,7 @@ public class NamespaceDeclarationPattern extends CSearchPattern {
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.search.matching.CSearchPattern#feedIndexRequestor(org.eclipse.cdt.internal.core.search.IIndexSearchRequestor, int, int[], org.eclipse.cdt.internal.core.index.impl.IndexInput, org.eclipse.cdt.core.search.ICSearchScope)
*/
- public void feedIndexRequestor(IIndexSearchRequestor requestor, int detailLevel, int[] references, IndexInput input, ICSearchScope scope) throws IOException {
+ public void feedIndexRequestor(IIndexSearchRequestor requestor, int detailLevel, int[] references, int[] indexFlags, IndexInput input, ICSearchScope scope) throws IOException {
for (int i = 0, max = references.length; i < max; i++) {
IndexedFile file = input.getIndexedFile(references[i]);
String path;

Back to the top