1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-15 12:15:47 +02:00

Partial Fix for Bug 74427: Indexer needs to store more info

Add more info to the index notification mechanism
Updated Indexer Tests to use new notification mechanism
This commit is contained in:
Bogdan Gheorghe 2004-11-02 06:43:17 +00:00
parent 83261630e4
commit 2473fc9bad
40 changed files with 850 additions and 748 deletions

View file

@ -14,10 +14,15 @@ import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Iterator; import java.util.Iterator;
import java.util.Set; import java.util.Set;
import junit.framework.Test; import junit.framework.Test;
import junit.framework.TestCase; import junit.framework.TestCase;
import junit.framework.TestSuite; import junit.framework.TestSuite;
import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.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.model.ICProject;
import org.eclipse.cdt.core.search.BasicSearchResultCollector; import org.eclipse.cdt.core.search.BasicSearchResultCollector;
import org.eclipse.cdt.core.search.ICSearchConstants; import org.eclipse.cdt.core.search.ICSearchConstants;
@ -89,6 +94,11 @@ import org.eclipse.core.runtime.Platform;
super.setUp(); super.setUp();
//Create temp project //Create temp project
testProject = createProject("DepTestProject"); 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)); testProject.setSessionProperty(IndexManager.activationKey,new Boolean(true));
@ -208,7 +218,6 @@ import org.eclipse.core.runtime.Platform;
public void testDepTable() throws Exception{ public void testDepTable() throws Exception{
//Add a file to the project //Add a file to the project
IFile cH = importFile("c.h","resources/dependency/c.h"); IFile cH = importFile("c.h","resources/dependency/c.h");
IFile aH = importFile("a.h","resources/dependency/a.h"); IFile aH = importFile("a.h","resources/dependency/a.h");
IFile Inc1H = importFile("Inc1.h","resources/dependency/Inc1.h"); IFile Inc1H = importFile("Inc1.h","resources/dependency/Inc1.h");
@ -220,7 +229,7 @@ import org.eclipse.core.runtime.Platform;
PathCollector pathCollector = new PathCollector(); PathCollector pathCollector = new PathCollector();
getTableRefs(dH, 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[] 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(); String[] iPath = pathCollector.getPaths();

View file

@ -14,12 +14,18 @@ import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.io.FileWriter; import java.io.FileWriter;
import java.io.IOException; import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.channels.FileChannel;
import java.security.MessageDigest;
import junit.framework.Test; import junit.framework.Test;
import junit.framework.TestCase; import junit.framework.TestCase;
import junit.framework.TestSuite; import junit.framework.TestSuite;
import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.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.model.ICProject;
import org.eclipse.cdt.internal.core.index.IEntryResult; import org.eclipse.cdt.internal.core.index.IEntryResult;
import org.eclipse.cdt.internal.core.index.IIndex; import org.eclipse.cdt.internal.core.index.IIndex;
@ -41,14 +47,15 @@ import org.eclipse.core.runtime.Path;
/** /**
* @author bgheorgh * @author bgheorgh
*/ */
public class IndexManagerTests extends TestCase { public class IndexManagerTests extends TestCase implements IIndexChangeListener {
IFile file; IFile file;
IFileDocument fileDoc; IFileDocument fileDoc;
IProject testProject; IProject testProject;
NullProgressMonitor monitor; NullProgressMonitor monitor;
IndexManager indexManager; IndexManager indexManager;
boolean fileIndexed;
public static final int TIMEOUT = 5000;
public static final int TIMEOUT = 50;
/** /**
* Constructor for IndexManagerTest. * Constructor for IndexManagerTest.
* @param name * @param name
@ -69,6 +76,12 @@ public class IndexManagerTests extends TestCase {
//Create temp project //Create temp project
testProject = createProject("IndexerTestProject"); 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)); testProject.setSessionProperty(IndexManager.activationKey,new Boolean(true));
@ -77,6 +90,7 @@ public class IndexManagerTests extends TestCase {
indexManager = CCorePlugin.getDefault().getCoreModel().getIndexManager(); indexManager = CCorePlugin.getDefault().getCoreModel().getIndexManager();
indexManager.reset(); indexManager.reset();
indexManager.addIndexChangeListener(this);
} }
/* /*
* @see TestCase#tearDown() * @see TestCase#tearDown()
@ -84,6 +98,7 @@ public class IndexManagerTests extends TestCase {
protected void tearDown() { protected void tearDown() {
try { try {
super.tearDown(); super.tearDown();
indexManager.removeIndexChangeListener(this);
} catch (Exception e1) { } catch (Exception e1) {
} }
//Delete project //Delete project
@ -120,6 +135,7 @@ public class IndexManagerTests extends TestCase {
suite.addTest(new IndexManagerTests("testIndexContents")); suite.addTest(new IndexManagerTests("testIndexContents"));
suite.addTest(new IndexManagerTests("testMacros")); suite.addTest(new IndexManagerTests("testMacros"));
suite.addTest(new IndexManagerTests("testRefs")); suite.addTest(new IndexManagerTests("testRefs"));
suite.addTest(new IndexManagerTests("testExactDeclarations"));
suite.addTest(new IndexManagerTests("testRemoveFileFromIndex")); suite.addTest(new IndexManagerTests("testRemoveFileFromIndex"));
suite.addTest(new IndexManagerTests("testRemoveProjectFromIndex")); suite.addTest(new IndexManagerTests("testRemoveProjectFromIndex"));
suite.addTest(new IndexManagerTests("testIndexShutdown")); suite.addTest(new IndexManagerTests("testIndexShutdown"));
@ -153,9 +169,12 @@ public class IndexManagerTests extends TestCase {
* Start of tests * Start of tests
*/ */
public void testIndexAll() throws Exception { public void testIndexAll() throws Exception {
//Add a file to the project //Add a file to the project
fileIndexed = false;
importFile("mail.cpp","resources/indexer/mail.cpp"); importFile("mail.cpp","resources/indexer/mail.cpp");
Thread.sleep(5000); while (fileIndexed != true){ Thread.sleep(TIMEOUT);}
IIndex ind = indexManager.getIndex(testProject.getFullPath(),true,true); IIndex ind = indexManager.getIndex(testProject.getFullPath(),true,true);
assertTrue("Index exists for project",ind != null); assertTrue("Index exists for project",ind != null);
@ -188,27 +207,32 @@ public class IndexManagerTests extends TestCase {
} }
public void testAddNewFileToIndex() throws Exception{ public void testAddNewFileToIndex() throws Exception{
//Add a file to the project
importFile("mail.cpp","resources/indexer/mail.cpp");
//Enable indexing on the created project
//By doing this, we force the Index Manager to indexAll()
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 //Make sure project got added to index
IPath testProjectPath = testProject.getFullPath(); IPath testProjectPath = testProject.getFullPath();
IIndex ind = indexManager.getIndex(testProjectPath,true,true); IIndex ind = indexManager.getIndex(testProjectPath,true,true);
assertTrue("Index exists for project",ind != null); assertTrue("Index exists for project",ind != null);
//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("DocumentManager.h","resources/indexer/DocumentManager.h"); importFile("DocumentManager.h","resources/indexer/DocumentManager.h");
while (fileIndexed != true){ Thread.sleep(TIMEOUT);}
fileIndexed = false;
importFile("DocumentManager.cpp","resources/indexer/DocumentManager.cpp"); importFile("DocumentManager.cpp","resources/indexer/DocumentManager.cpp");
while (fileIndexed != true){ Thread.sleep(TIMEOUT);}
Thread.sleep(10000);
ind = indexManager.getIndex(testProjectPath,true,true); ind = indexManager.getIndex(testProjectPath,true,true);
char[] prefix = "typeDecl/C/CDocumentManager".toCharArray(); 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[] eresults =ind.queryEntries(prefix);
IEntryResult[] bogRe = ind.queryEntries(IIndexConstants.TYPE_DECL);
assertTrue("Entry Result exists", eresults != null); assertTrue("Entry Result exists", eresults != null);
if (eresults.length != entryResultModel.length) if (eresults.length != entryResultModel.length)
@ -221,10 +245,13 @@ public class IndexManagerTests extends TestCase {
} }
public void testRemoveProjectFromIndex() throws Exception{ public void testRemoveProjectFromIndex() throws Exception{
//Add a file to the project
importFile("mail.cpp","resources/indexer/mail.cpp");
Thread.sleep(TIMEOUT);
//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 //Make sure project got added to index
IPath testProjectPath = testProject.getFullPath(); IPath testProjectPath = testProject.getFullPath();
IIndex ind = indexManager.getIndex(testProjectPath,true,true); IIndex ind = indexManager.getIndex(testProjectPath,true,true);
@ -253,25 +280,34 @@ public class IndexManagerTests extends TestCase {
} }
public void testRemoveFileFromIndex() throws Exception{ public void testRemoveFileFromIndex() throws Exception{
//Add a file to the project
importFile("mail.cpp","resources/indexer/mail.cpp"); //Add a file to the project
fileIndexed = false;
Thread.sleep(TIMEOUT); importFile("mail.cpp","resources/indexer/mail.cpp");
//Make sure project got added to index while (fileIndexed != true){ Thread.sleep(TIMEOUT);}
IPath testProjectPath = testProject.getFullPath();
IIndex ind = indexManager.getIndex(testProjectPath,true,true); //Make sure project got added to index
assertTrue("Index exists for project",ind != null); IPath testProjectPath = testProject.getFullPath();
//Add a new file to the project IIndex ind = indexManager.getIndex(testProjectPath,true,true);
importFile("DocumentManager.h","resources/indexer/DocumentManager.h"); assertTrue("Index exists for project",ind != null);
importFile("DocumentManager.cpp","resources/indexer/DocumentManager.cpp"); //Add a new file to the project, give it some time to index
Thread.sleep(10000); 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 //Do a "before" deletion comparison
ind = indexManager.getIndex(testProjectPath,true,true); //ind = indexManager.getIndex(testProjectPath,true,true);
char[] prefix = "typeDecl/".toCharArray(); char[] prefix = "typeDecl/".toCharArray();
IEntryResult[] eresults = ind.queryEntries(prefix); IEntryResult[] eresults = ind.queryEntries(prefix);
assertTrue("Entry result found for typdeDecl/", eresults != null); 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) if (eresults.length != entryResultBeforeModel.length)
fail("Entry Result length different from model"); fail("Entry Result length different from model");
@ -291,7 +327,7 @@ public class IndexManagerTests extends TestCase {
eresults = ind.queryEntries(prefix); eresults = ind.queryEntries(prefix);
assertTrue("Entry exists", eresults != null); 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) if (eresults.length != entryResultAfterModel.length)
fail("Entry Result length different from model"); fail("Entry Result length different from model");
@ -302,10 +338,12 @@ public class IndexManagerTests extends TestCase {
} }
public void testIndexContents() throws Exception{ public void testIndexContents() 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("extramail.cpp","resources/indexer/extramail.cpp"); importFile("extramail.cpp","resources/indexer/extramail.cpp");
while (fileIndexed != true){ Thread.sleep(TIMEOUT);}
Thread.sleep(TIMEOUT);
//Make sure project got added to index //Make sure project got added to index
IPath testProjectPath = testProject.getFullPath(); IPath testProjectPath = testProject.getFullPath();
IIndex ind = indexManager.getIndex(testProjectPath,true,true); IIndex ind = indexManager.getIndex(testProjectPath,true,true);
@ -416,10 +454,11 @@ public class IndexManagerTests extends TestCase {
} }
public void testRefs() throws Exception{ 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"); importFile("reftest.cpp","resources/indexer/reftest.cpp");
while (fileIndexed != true){ Thread.sleep(TIMEOUT);}
Thread.sleep(TIMEOUT);
//Make sure project got added to index //Make sure project got added to index
IPath testProjectPath = testProject.getFullPath(); IPath testProjectPath = testProject.getFullPath();
IIndex ind = indexManager.getIndex(testProjectPath,true,true); 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 public void testMacros() 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("extramail.cpp","resources/indexer/extramail.cpp"); importFile("extramail.cpp","resources/indexer/extramail.cpp");
while (fileIndexed != true){ Thread.sleep(TIMEOUT);}
Thread.sleep(TIMEOUT);
//Make sure project got added to index //Make sure project got added to index
IPath testProjectPath = testProject.getFullPath(); IPath testProjectPath = testProject.getFullPath();
IIndex ind = indexManager.getIndex(testProjectPath,true,true); IIndex ind = indexManager.getIndex(testProjectPath,true,true);
@ -513,9 +635,10 @@ public class IndexManagerTests extends TestCase {
public void testIndexShutdown() throws Exception{ public void testIndexShutdown() 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"); importFile("reftest.cpp","resources/indexer/reftest.cpp");
while (fileIndexed != true){ Thread.sleep(TIMEOUT);}
Thread.sleep(TIMEOUT);
//Make sure project got added to index //Make sure project got added to index
IPath testProjectPath = testProject.getFullPath(); IPath testProjectPath = testProject.getFullPath();
IIndex ind = indexManager.getIndex(testProjectPath,true,true); IIndex ind = indexManager.getIndex(testProjectPath,true,true);
@ -549,9 +672,10 @@ public class IndexManagerTests extends TestCase {
public void testForwardDeclarations() throws Exception{ public void testForwardDeclarations() 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"); importFile("reftest.cpp","resources/indexer/reftest.cpp");
while (fileIndexed != true){ Thread.sleep(TIMEOUT);}
Thread.sleep(TIMEOUT);
//Make sure project got added to index //Make sure project got added to index
IPath testProjectPath = testProject.getFullPath(); IPath testProjectPath = testProject.getFullPath();
IIndex ind = indexManager.getIndex(testProjectPath,true,true); 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;
}
}
} }

View file

@ -99,7 +99,7 @@ public class UpdateDependency implements IJob {
if (fileToReindex!=null && fileToReindex.exists() ) { if (fileToReindex!=null && fileToReindex.exists() ) {
// if (VERBOSE) // if (VERBOSE)
// System.out.println("Going to reindex " + fileToReindex.getName()); // System.out.println("Going to reindex " + fileToReindex.getName());
indexManager.addSource(fileToReindex,fileToReindex.getProject().getProject().getFullPath(), false); indexManager.addSource(fileToReindex,fileToReindex.getProject().getProject().getFullPath());
} }
} }
return false; return false;

View file

@ -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 2004-08-19 Bogdan Gheorghe
Fix for Bug 71500: [Indexer] all headers get indexed on project open Fix for Bug 71500: [Indexer] all headers get indexed on project open

View file

@ -16,6 +16,20 @@ import java.util.ArrayList;
import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IProject;
public interface IIndexDelta { 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. * @return Returns the files.
*/ */
@ -24,5 +38,9 @@ public interface IIndexDelta {
* @return Returns the project. * @return Returns the project.
*/ */
public IProject getProject(); public IProject getProject();
/**
* @return Returns the delta type.
*/
public IndexDeltaType getDeltaType();
} }

View file

@ -11,6 +11,7 @@
package org.eclipse.cdt.internal.core.index; package org.eclipse.cdt.internal.core.index;
public interface IEntryResult { public interface IEntryResult {
public int[] getIndexFlags();
public int[] getFileReferences(); public int[] getFileReferences();
public char[] getWord(); public char[] getWord();
} }

View file

@ -10,6 +10,8 @@
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.core.index; 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 * This class represents the output from an indexer to an index
* for a single document. * for a single document.
@ -17,8 +19,11 @@ package org.eclipse.cdt.internal.core.index;
public interface IIndexerOutput { public interface IIndexerOutput {
public void addDocument(IDocument document); public void addDocument(IDocument document);
public void addRef(char[] word); public void addRef(char[] word, int indexFlags);
public void addRef(String word); 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 //For Dep Tree
public void addIncludeRef(char[] word); public void addIncludeRef(char[] word);
public void addIncludeRef(String word); public void addIncludeRef(String word);

View file

@ -245,7 +245,7 @@ public class BlocksIndexInput extends IndexInput {
case -1 : case -1 :
WordEntry entry = getEntry(pattern); WordEntry entry = getEntry(pattern);
if (entry == null) return null; 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 : case 0 :
blockNums = summary.getAllBlockNums(); blockNums = summary.getAllBlockNums();
break; break;
@ -267,7 +267,7 @@ public class BlocksIndexInput extends IndexInput {
if (count == entries.length){ if (count == entries.length){
System.arraycopy(entries, 0, entries = new IEntryResult[count*2], 0, count); 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; found = true;
} else { } else {
if (found) break; if (found) break;
@ -297,7 +297,7 @@ public class BlocksIndexInput extends IndexInput {
if (count == entries.length){ if (count == entries.length){
System.arraycopy(entries, 0, entries = new IEntryResult[count*2], 0, count); 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; found = true;
} else { } else {
if (found) break; if (found) break;
@ -410,7 +410,7 @@ public class BlocksIndexInput extends IndexInput {
boolean endOfBlock= !currentIncludeIndexBlock.nextEntry(currentIncludeEntry); boolean endOfBlock= !currentIncludeIndexBlock.nextEntry(currentIncludeEntry);
if (endOfBlock) { if (endOfBlock) {
currentIncludeIndexBlock= getIndexBlock(++currentIncludeBlockNum); currentIncludeIndexBlock= getIndexBlock(++currentIncludeBlockNum);
currentIncludeIndexBlock.nextEntry(currentWordEntry); currentIncludeIndexBlock.nextEntry(currentIncludeEntry);
} }
} }
/* (non-Javadoc) /* (non-Javadoc)

View file

@ -17,10 +17,12 @@ import org.eclipse.cdt.internal.core.index.IEntryResult;
public class EntryResult implements IEntryResult { public class EntryResult implements IEntryResult {
private char[] word; private char[] word;
private int[] fileRefs; private int[] fileRefs;
private int[] indexFlags;
public EntryResult(char[] word, int[] refs) { public EntryResult(char[] word, int[] refs, int[] indexFlags) {
this.word = word; this.word = word;
this.fileRefs = refs; this.fileRefs = refs;
this.indexFlags = indexFlags;
} }
public boolean equals(Object anObject){ public boolean equals(Object anObject){
@ -37,6 +39,13 @@ public boolean equals(Object anObject){
for (int i = 0; i < length; i++){ for (int i = 0; i < length; i++){
if (refs[i] != otherRefs[i]) return false; 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 true;
} }
return false; return false;
@ -64,5 +73,9 @@ public String toString(){
buffer.append(" }"); //$NON-NLS-1$ buffer.append(" }"); //$NON-NLS-1$
return buffer.toString(); return buffer.toString();
} }
public int[] getIndexFlags() {
return indexFlags;
}
} }

View file

@ -47,6 +47,7 @@ public class GammaCompressedIndexBlock extends IndexBlock {
codeStream.writeUTF(word, prefixLen, word.length); codeStream.writeUTF(word, prefixLen, word.length);
int n= entry.getNumRefs(); int n= entry.getNumRefs();
codeStream.writeGamma(n); codeStream.writeGamma(n);
//encode file references
int prevRef= 0; int prevRef= 0;
for (int i= 0; i < n; ++i) { for (int i= 0; i < n; ++i) {
int ref= entry.getRef(i); int ref= entry.getRef(i);
@ -55,6 +56,16 @@ public class GammaCompressedIndexBlock extends IndexBlock {
codeStream.writeGamma(ref - prevRef); codeStream.writeGamma(ref - prevRef);
prevRef= ref; 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 * @see IndexBlock#addEntry
@ -133,9 +144,20 @@ public class GammaCompressedIndexBlock extends IndexBlock {
int ref= prevRef + readCodeStream.readGamma(); int ref= prevRef + readCodeStream.readGamma();
if (ref < prevRef) if (ref < prevRef)
throw new InternalError(); throw new InternalError();
entry.addRef(ref); entry.addRef(ref,0);
prevRef= ref; 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(); offset= readCodeStream.byteLength();
prevWord= word; prevWord= word;
return true; return true;

View file

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

View file

@ -57,6 +57,13 @@ public class InMemoryIndex {
return indexedFile; 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) { public void addIncludeRef(IndexedFile indexedFile, char[] include) {
addIncludeRef(include, indexedFile.getFileNumber()); addIncludeRef(include, indexedFile.getFileNumber());
} }
@ -88,9 +95,7 @@ public class InMemoryIndex {
entry.addRef(fileNum); entry.addRef(fileNum);
this.includes.add(entry); this.includes.add(entry);
this.sortedIncludeEntries= null; this.sortedIncludeEntries= null;
//TODO: BOG FIGURE OUT FOOTPRINT this.footprint += entry.footprint();
//this.footprint += entry.getClass(); //footprint();
//
} else { } else {
this.footprint += entry.addRef(fileNum); 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). * 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 size= references.length;
int i= 0; int i= 0;
while (i < size) { while (i < size) {
if (references[i] != 0) if (references[i] != 0)
addRef(word, references[i]); addRef(word, references[i], indexFlags[i]);
i++; i++;
} }
} }
/** /**
* Looks if the word already exists in the index and add the fileNum to this word. * 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. * 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); WordEntry entry= this.words.get(word);
if (entry == null) { if (entry == null) {
entry= new WordEntry(word); entry= new WordEntry(word);
entry.addRef(fileNum); //entry.addRef(fileNum, indexFlags);
entry.addRef(indexFlags, indexFlags);
this.words.add(entry); this.words.add(entry);
this.sortedWordEntries= null; this.sortedWordEntries= null;
this.footprint += entry.footprint(); this.footprint += entry.footprint();
} else { } 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) { public void addRef(IndexedFile indexedFile, char[] word, int indexFlags) {
addRef(word, indexedFile.getFileNumber()); addRef(word, indexedFile.getFileNumber(), indexFlags);
} }
public void addRef(IndexedFile indexedFile, String word) { public void addRef(IndexedFile indexedFile, String word, int indexFlags) {
addRef(word.toCharArray(), indexedFile.getFileNumber()); addRef(word.toCharArray(), indexedFile.getFileNumber(), indexFlags);
} }
public void addRelatives(IndexedFile indexedFile, String inclusion, String parent) { public void addRelatives(IndexedFile indexedFile, String inclusion, String parent) {

View file

@ -167,7 +167,7 @@ public class IncludeEntry {
fRefs[position++]= map; fRefs[position++]= map;
} }
fNumRefs= position; fNumRefs= position;
//to be changed! //to be changed!
System.arraycopy(fRefs, 0, (fRefs= new int[fNumRefs]), 0, fNumRefs); System.arraycopy(fRefs, 0, (fRefs= new int[fNumRefs]), 0, fNumRefs);
Util.sort(fRefs); Util.sort(fRefs);
@ -224,4 +224,17 @@ public class IncludeEntry {
tempBuffer.append("} >"); //$NON-NLS-1$ tempBuffer.append("} >"); //$NON-NLS-1$
return tempBuffer.toString(); 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);
}
} }

View file

@ -18,6 +18,7 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import org.eclipse.cdt.core.CCorePlugin; 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.IDocument;
import org.eclipse.cdt.internal.core.index.IEntryResult; import org.eclipse.cdt.internal.core.index.IEntryResult;
import org.eclipse.cdt.internal.core.index.IIndex; import org.eclipse.cdt.internal.core.index.IIndex;
@ -275,6 +276,10 @@ public class Index implements IIndex {
state= MERGED; state= MERGED;
//flush the CDT log //flush the CDT log
CCorePlugin.getDefault().cdtLog.flushLog(); CCorePlugin.getDefault().cdtLog.flushLog();
//Send out notification to listeners;
IndexDelta indexDelta = new IndexDelta(null,null,IIndexDelta.MERGE_DELTA);
CCorePlugin.getDefault().getCoreModel().getIndexManager().notifyListeners(indexDelta);
} }
} }
/** /**

View file

@ -19,6 +19,7 @@ public class IndexDelta implements IIndexDelta {
private ArrayList files = null; private ArrayList files = null;
private IProject project = null; private IProject project = null;
private IndexDeltaType deltaType = null;
/** /**
* @param filesTrav * @param filesTrav
@ -26,10 +27,20 @@ public class IndexDelta implements IIndexDelta {
* *
*/ */
public IndexDelta(IProject project, ArrayList filesTrav) { public IndexDelta(IProject project, ArrayList filesTrav) {
this.project = project; this(project,filesTrav,null);
this.files = filesTrav;
} }
/**
* @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. * @return Returns the files.
*/ */
@ -42,4 +53,11 @@ public class IndexDelta implements IIndexDelta {
public IProject getProject() { public IProject getProject() {
return project; return project;
} }
/**
* @see org.eclipse.cdt.core.index.IIndexDelta#getDeltaType()
*/
public IndexDeltaType getDeltaType() {
return deltaType;
}
} }

View file

@ -35,6 +35,10 @@ public IndexedFile add(IDocument document) {
return add(new IndexedFile(document, ++lastId)); return add(new IndexedFile(document, ++lastId));
} }
public IndexedFile add(String path){
return add(new IndexedFile(path, ++lastId));
}
private IndexedFile add(IndexedFile file) { private IndexedFile add(IndexedFile file) {
int length = elements.length; int length = elements.length;
String path = file.getPath(); String path = file.getPath();

View file

@ -43,17 +43,17 @@ public class IndexerOutput implements IIndexerOutput {
/** /**
* Adds a reference to the given word to the inMemoryIndex. * 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) { if (indexedFile == null) {
throw new IllegalStateException(); throw new IllegalStateException();
} }
index.addRef(indexedFile, word); index.addRef(indexedFile, word, indexFlags);
} }
/** /**
* Adds a reference to the given word to the inMemoryIndex. * Adds a reference to the given word to the inMemoryIndex.
*/ */
public void addRef(String word) { public void addRef(String word, int indexFlags) {
addRef(word.toCharArray()); addRef(word.toCharArray(), indexFlags);
} }
public void addRelatives(String inclusion, String parent) { public void addRelatives(String inclusion, String parent) {
@ -74,4 +74,26 @@ public class IndexerOutput implements IIndexerOutput {
addIncludeRef(word.toCharArray()); 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);
}
} }

View file

@ -199,17 +199,20 @@ public class MergeFactory {
else else
compare= Util.compare(word1.getWord(), word2.getWord()); compare= Util.compare(word1.getWord(), word2.getWord());
if (compare < 0) { if (compare < 0) {
word1.catRefs(word1);
word1.mapRefs(mappingOld); word1.mapRefs(mappingOld);
mergeOutput.addWord(word1); mergeOutput.addWord(word1);
oldInput.moveToNextWordEntry(); oldInput.moveToNextWordEntry();
} else if (compare > 0) { } else if (compare > 0) {
word2.catRefs(word2);
word2.mapRefs(mappingAdds); word2.mapRefs(mappingAdds);
mergeOutput.addWord(word2); mergeOutput.addWord(word2);
addsInput.moveToNextWordEntry(); addsInput.moveToNextWordEntry();
} else { } else {
word1.catRefs(word1);
word1.mapRefs(mappingOld); word1.mapRefs(mappingOld);
word2.mapRefs(mappingAdds); word2.mapRefs(mappingAdds);
word1.addRefs(word2.getRefs()); word1.addRefs(word2.getRefs(),word2.getRefsIndexFlags());
mergeOutput.addWord(word1); mergeOutput.addWord(word1);
addsInput.moveToNextWordEntry(); addsInput.moveToNextWordEntry();
oldInput.moveToNextWordEntry(); oldInput.moveToNextWordEntry();
@ -223,7 +226,7 @@ public class MergeFactory {
*/ */
protected void mergeIncludes() throws IOException { protected void mergeIncludes() throws IOException {
int compare; int compare;
while (oldInput.hasMoreIncludes() || addsInput.hasMoreIncludes()) { while (oldInput.hasMoreIncludes() || addsInput.hasMoreIncludes()) {
IncludeEntry inc1= oldInput.getCurrentIncludeEntry(); IncludeEntry inc1= oldInput.getCurrentIncludeEntry();
IncludeEntry inc2= addsInput.getCurrentIncludeEntry(); IncludeEntry inc2= addsInput.getCurrentIncludeEntry();

View file

@ -91,7 +91,14 @@ public class Util {
quickSort(list, left, original_right); 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_left= left;
int original_right= right; int original_right= right;
int mid= list[(left + right) / 2]; int mid= list[(left + right) / 2];
@ -106,15 +113,22 @@ public class Util {
int tmp= list[left]; int tmp= list[left];
list[left]= list[right]; list[left]= list[right];
list[right]= tmp; list[right]= tmp;
if (dependentList != null){
int depTmp = dependentList[left];
dependentList[left]=dependentList[right];
dependentList[right]=depTmp;
}
left++; left++;
right--; right--;
} }
} while (left <= right); } while (left <= right);
if (original_left < right) { if (original_left < right) {
quickSort(list, original_left, right); quickSort(list, original_left, right, dependentList);
} }
if (left < original_right) { 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) { private static void quickSort(String[] list, int left, int right) {
@ -303,7 +317,11 @@ public class Util {
} }
public static void sort(int[] list) { public static void sort(int[] list) {
if (list.length > 1) 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) { public static void sort(String[] list) {
if (list.length > 1) if (list.length > 1)

View file

@ -10,12 +10,15 @@
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.core.index.impl; package org.eclipse.cdt.internal.core.index.impl;
import org.eclipse.cdt.core.parser.util.ObjectSet;
import org.eclipse.cdt.internal.core.CharOperation; import org.eclipse.cdt.internal.core.CharOperation;
public class WordEntry { public class WordEntry {
protected char[] fWord; protected char[] fWord;
protected int fNumRefs; protected int fNumRefs;
protected int[] fRefs; protected int[] fRefs;
protected int[] fRefsIndexFlags;
public WordEntry() { public WordEntry() {
this(CharOperation.NO_CHAR); this(CharOperation.NO_CHAR);
} }
@ -23,55 +26,75 @@ public class WordEntry {
fWord= word; fWord= word;
fNumRefs= 0; fNumRefs= 0;
fRefs= new int[1]; fRefs= new int[1];
fRefsIndexFlags = new int[1];
} }
/** /**
* Adds a reference and records the change in footprint. * 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) { if (fNumRefs > 0 && fRefs[fNumRefs - 1] == fileNum) {
return 0; return 0;
} }
if (fNumRefs < fRefs.length) { if (fNumRefs < fRefs.length) {
int tempNumRefs = fNumRefs;
fRefs[fNumRefs++]= fileNum; fRefs[fNumRefs++]= fileNum;
//Add index flags
fRefsIndexFlags[tempNumRefs]=indexFlags;
return 0; return 0;
} }
// For rt.jar, 73265 word entries are created. 51997 have 1 ref, then 9438, 3738, 1980, 1214, 779, 547, 429, 371 etc. // 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. 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); 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; fRefs[fNumRefs++]= fileNum;
fRefsIndexFlags[tempNumRefs]=indexFlags;
return (newSize - fNumRefs + 1) * 4; return (newSize - fNumRefs + 1) * 4;
} }
/** /**
* Adds a set of references and records the change in footprint. * 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[] newRefs= new int[fNumRefs + refs.length];
int[] newIndexRefs = new int[fNumRefs + indexRefs.length];
int pos1= 0; int pos1= 0;
int pos2= 0; int pos2= 0;
int posNew= 0; int posNew= 0;
int compare; int compare;
int r1= 0; int r1= 0;
int r2= 0; int r2= 0;
int i1=0;
int i2=0;
while (pos1 < fNumRefs || pos2 < refs.length) { while (pos1 < fNumRefs || pos2 < refs.length) {
if (pos1 >= fNumRefs) { if (pos1 >= fNumRefs) {
r2= refs[pos2]; r2= refs[pos2];
i2= indexRefs[pos2];
compare= -1; compare= -1;
} else if (pos2 >= refs.length) { } else if (pos2 >= refs.length) {
compare= 1; compare= 1;
r1= fRefs[pos1]; r1= fRefs[pos1];
i1= fRefsIndexFlags[pos1];
} else { } else {
r1= fRefs[pos1]; r1= fRefs[pos1];
r2= refs[pos2]; r2= refs[pos2];
i1=fRefsIndexFlags[pos1];
i2=indexRefs[pos2];
compare= r2 - r1; compare= r2 - r1;
} }
if (compare > 0) { if (compare > 0) {
newRefs[posNew]= r1; newRefs[posNew]= r1;
newIndexRefs[posNew]=i1;
posNew++; posNew++;
pos1++; pos1++;
} else { } else {
if (r2 != 0) { if (r2 != 0) {
newRefs[posNew]= r2; newRefs[posNew]= r2;
newIndexRefs[posNew]=i2;
posNew++; posNew++;
} }
pos2++; pos2++;
@ -79,18 +102,15 @@ public class WordEntry {
} }
fRefs= newRefs; fRefs= newRefs;
fNumRefs= posNew; fNumRefs= posNew;
/*for (int i = 0; i < refs.length; i++) fRefsIndexFlags=newIndexRefs;
addRef(refs[i]);
int[] newRefs = new int[fNumRefs];
System.arraycopy(fRefs, 0, newRefs, 0, fNumRefs);
fRefs = newRefs;
Util.sort(fRefs);*/
} }
/** /**
* Returns the size of the wordEntry * Returns the size of the wordEntry
*/ */
public int footprint() { 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. * Returns the number of references, e.g. the number of files this word appears in.
@ -105,6 +125,13 @@ public class WordEntry {
if (i < fNumRefs) return fRefs[i]; if (i < fNumRefs) return fRefs[i];
throw new IndexOutOfBoundsException(); 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). * Returns the references of the wordEntry (the number of the files it appears in).
*/ */
@ -113,6 +140,14 @@ public class WordEntry {
System.arraycopy(fRefs, 0, result, 0, fNumRefs); System.arraycopy(fRefs, 0, result, 0, fNumRefs);
return result; 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. * returns the word of the wordEntry.
*/ */
@ -128,20 +163,31 @@ public class WordEntry {
*/ */
public void mapRefs(int[] mappings) { public void mapRefs(int[] mappings) {
int position= 0; int position= 0;
int position2= 0;
for (int i= 0; i < fNumRefs; i++) { for (int i= 0; i < fNumRefs; i++) {
//Take care that the reference is actually within the bounds of the mapping //Take care that the reference is actually within the bounds of the mapping
int map= -1; int map= -1;
int map2= -1;
if(fRefs[i] >= 0 && fRefs[i] < mappings.length) if(fRefs[i] >= 0 && fRefs[i] < mappings.length)
map= mappings[fRefs[i]]; map= mappings[fRefs[i]];
if (map != -1 && map != 0) if (map != -1 && map != 0)
fRefs[position++]= map; 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; fNumRefs= position;
//to be changed! //to be changed!
System.arraycopy(fRefs, 0, (fRefs= new int[fNumRefs]), 0, fNumRefs); 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. * Clears the wordEntry.
@ -149,6 +195,7 @@ public class WordEntry {
public void reset(char[] word) { public void reset(char[] word) {
for (int i= fNumRefs; i-- > 0;) { for (int i= fNumRefs; i-- > 0;) {
fRefs[i]= 0; fRefs[i]= 0;
fRefsIndexFlags[i]=0;
} }
fNumRefs= 0; fNumRefs= 0;
fWord= word; fWord= word;
@ -156,5 +203,30 @@ public class WordEntry {
public String toString() { public String toString() {
return new String(fWord); 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);
}
} }

View file

@ -71,7 +71,7 @@ public abstract class AbstractIndexer implements IIndexer, IIndexConstants, ICSe
System.out.println("(" + Thread.currentThread() + ") " + log); //$NON-NLS-1$//$NON-NLS-2$ 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)) if (classSpecification.getClassKind().equals(ASTClassKind.CLASS))
{ {
@ -84,7 +84,7 @@ public abstract class AbstractIndexer implements IIndexer, IIndexConstants, ICSe
if (typeSpec instanceof IASTClassSpecifier){ if (typeSpec instanceof IASTClassSpecifier){
IASTClassSpecifier baseClassSpec = (IASTClassSpecifier) typeSpec; IASTClassSpecifier baseClassSpec = (IASTClassSpecifier) typeSpec;
char[][] baseFullyQualifiedName = baseClassSpec.getFullyQualifiedNameCharArrays(); char[][] baseFullyQualifiedName = baseClassSpec.getFullyQualifiedNameCharArrays();
this.output.addRef(encodeTypeEntry(baseFullyQualifiedName,DERIVED,ICSearchConstants.DECLARATIONS)); this.output.addRef(encodeTypeEntry(baseFullyQualifiedName,DERIVED,ICSearchConstants.DECLARATIONS),indexFlag);
} }
} catch (ASTNotImplementedException e) {} } catch (ASTNotImplementedException e) {}
} }
@ -96,12 +96,12 @@ public abstract class AbstractIndexer implements IIndexer, IIndexConstants, ICSe
if (decl instanceof IASTClassSpecifier){ if (decl instanceof IASTClassSpecifier){
IASTClassSpecifier friendClassSpec = (IASTClassSpecifier) decl; IASTClassSpecifier friendClassSpec = (IASTClassSpecifier) decl;
char[][] baseFullyQualifiedName = friendClassSpec.getFullyQualifiedNameCharArrays(); 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){ else if (decl instanceof IASTElaboratedTypeSpecifier){
IASTElaboratedTypeSpecifier friendClassSpec = (IASTElaboratedTypeSpecifier) decl; IASTElaboratedTypeSpecifier friendClassSpec = (IASTElaboratedTypeSpecifier) decl;
char[][] baseFullyQualifiedName = friendClassSpec.getFullyQualifiedNameCharArrays(); 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){ 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)) else if (classSpecification.getClassKind().equals(ASTClassKind.STRUCT))
{ {
@ -125,7 +125,7 @@ public abstract class AbstractIndexer implements IIndexer, IIndexConstants, ICSe
if (typeSpec instanceof IASTClassSpecifier){ if (typeSpec instanceof IASTClassSpecifier){
IASTClassSpecifier baseClassSpec = (IASTClassSpecifier) typeSpec; IASTClassSpecifier baseClassSpec = (IASTClassSpecifier) typeSpec;
char[][] baseFullyQualifiedName = baseClassSpec.getFullyQualifiedNameCharArrays(); char[][] baseFullyQualifiedName = baseClassSpec.getFullyQualifiedNameCharArrays();
this.output.addRef(encodeTypeEntry(baseFullyQualifiedName,DERIVED,ICSearchConstants.DECLARATIONS)); this.output.addRef(encodeTypeEntry(baseFullyQualifiedName,DERIVED,ICSearchConstants.DECLARATIONS),indexFlag);
} }
} catch (ASTNotImplementedException e) {} } catch (ASTNotImplementedException e) {}
} }
@ -137,12 +137,12 @@ public abstract class AbstractIndexer implements IIndexer, IIndexConstants, ICSe
if (decl instanceof IASTClassSpecifier){ if (decl instanceof IASTClassSpecifier){
IASTClassSpecifier friendClassSpec = (IASTClassSpecifier) decl; IASTClassSpecifier friendClassSpec = (IASTClassSpecifier) decl;
char[][] baseFullyQualifiedName = friendClassSpec.getFullyQualifiedNameCharArrays(); 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){ else if (decl instanceof IASTElaboratedTypeSpecifier){
IASTElaboratedTypeSpecifier friendClassSpec = (IASTElaboratedTypeSpecifier) decl; IASTElaboratedTypeSpecifier friendClassSpec = (IASTElaboratedTypeSpecifier) decl;
char[][] baseFullyQualifiedName = friendClassSpec.getFullyQualifiedNameCharArrays(); 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){ 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)) 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) { public void addEnumerationSpecifier(IASTEnumerationSpecifier enumeration, int indexFlag) {
this.output.addRef(encodeTypeEntry(enumeration.getFullyQualifiedNameCharArrays(), ENUM, ICSearchConstants.DECLARATIONS)); this.output.addRef(encodeTypeEntry(enumeration.getFullyQualifiedNameCharArrays(), ENUM, ICSearchConstants.DECLARATIONS),indexFlag);
Iterator i = enumeration.getEnumerators(); Iterator i = enumeration.getEnumerators();
while (i.hasNext()) while (i.hasNext())
@ -169,8 +169,8 @@ public abstract class AbstractIndexer implements IIndexer, IIndexConstants, ICSe
IASTEnumerator en = (IASTEnumerator) i.next(); IASTEnumerator en = (IASTEnumerator) i.next();
char[][] enumeratorFullName = char[][] enumeratorFullName =
createEnumeratorFullyQualifiedName(en); 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; return enumeratorFullName;
} }
public void addEnumeratorReference(IASTEnumerator enumerator) { public void addEnumeratorReference(IASTEnumerator enumerator, int indexFlag) {
this.output.addRef(encodeEntry(createEnumeratorFullyQualifiedName(enumerator),ENUMTOR_REF,ENUMTOR_REF_LENGTH)); 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() }; 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) { public void addEnumerationReference(IASTEnumerationSpecifier enumeration, int indexFlag) {
this.output.addRef(encodeTypeEntry(enumeration.getFullyQualifiedNameCharArrays(), ENUM, ICSearchConstants.REFERENCES)); this.output.addRef(encodeTypeEntry(enumeration.getFullyQualifiedNameCharArrays(), ENUM, ICSearchConstants.REFERENCES),indexFlag);
} }
public void addVariable(IASTVariable variable) { public void addVariable(IASTVariable variable, int indexFlag) {
this.output.addRef(encodeTypeEntry(variable.getFullyQualifiedNameCharArrays(), VAR, ICSearchConstants.DECLARATIONS)); this.output.addRef(encodeTypeEntry(variable.getFullyQualifiedNameCharArrays(), VAR, ICSearchConstants.DECLARATIONS),indexFlag);
} }
public void addVariableReference(IASTVariable variable) { public void addVariableReference(IASTVariable variable, int indexFlag) {
this.output.addRef(encodeTypeEntry(variable.getFullyQualifiedNameCharArrays(), VAR, ICSearchConstants.REFERENCES)); this.output.addRef(encodeTypeEntry(variable.getFullyQualifiedNameCharArrays(), VAR, ICSearchConstants.REFERENCES),indexFlag);
} }
public void addParameterReference( IASTParameterDeclaration parameter ){ public void addParameterReference( IASTParameterDeclaration parameter, int indexFlag ){
this.output.addRef( encodeTypeEntry( new char[][] { parameter.getNameCharArray() }, VAR, ICSearchConstants.REFERENCES)); this.output.addRef( encodeTypeEntry( new char[][] { parameter.getNameCharArray() }, VAR, ICSearchConstants.REFERENCES),indexFlag);
} }
public void addTypedefDeclaration(IASTTypedefDeclaration typedef) { public void addTypedefDeclaration(IASTTypedefDeclaration typedef, int indexFlag) {
this.output.addRef(encodeEntry(typedef.getFullyQualifiedNameCharArrays(), TYPEDEF_DECL, TYPEDEF_DECL_LENGTH)); this.output.addRef(encodeEntry(typedef.getFullyQualifiedNameCharArrays(), TYPEDEF_DECL, TYPEDEF_DECL_LENGTH),indexFlag);
} }
public void addFieldDeclaration(IASTField field) { public void addFieldDeclaration(IASTField field, int indexFlag) {
this.output.addRef(encodeEntry(field.getFullyQualifiedNameCharArrays(),FIELD_DECL,FIELD_DECL_LENGTH)); this.output.addRef(encodeEntry(field.getFullyQualifiedNameCharArrays(),FIELD_DECL,FIELD_DECL_LENGTH),indexFlag);
} }
public void addFieldReference(IASTField field) { public void addFieldReference(IASTField field, int indexFlag) {
this.output.addRef(encodeEntry(field.getFullyQualifiedNameCharArrays(),FIELD_REF,FIELD_REF_LENGTH)); this.output.addRef(encodeEntry(field.getFullyQualifiedNameCharArrays(),FIELD_REF,FIELD_REF_LENGTH),indexFlag);
} }
public void addMethodDeclaration(IASTMethod method) { public void addMethodDeclaration(IASTMethod method, int indexFlag) {
this.output.addRef(encodeEntry(method.getFullyQualifiedNameCharArrays(),METHOD_DECL,METHOD_DECL_LENGTH)); this.output.addRef(encodeEntry(method.getFullyQualifiedNameCharArrays(),METHOD_DECL,METHOD_DECL_LENGTH),indexFlag);
Iterator i=method.getParameters(); Iterator i=method.getParameters();
while (i.hasNext()){ while (i.hasNext()){
Object parm = i.next(); Object parm = i.next();
if (parm instanceof IASTParameterDeclaration){ if (parm instanceof IASTParameterDeclaration){
IASTParameterDeclaration parmDecl = (IASTParameterDeclaration) parm; 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) { public void addMethodReference(IASTMethod method, int indexFlag) {
this.output.addRef(encodeEntry(method.getFullyQualifiedNameCharArrays(),METHOD_REF,METHOD_REF_LENGTH)); 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)) 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)) 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)) 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){ public void addFunctionDeclaration(IASTFunction function, int indexFlag){
this.output.addRef(encodeEntry(function.getFullyQualifiedNameCharArrays(),FUNCTION_DECL,FUNCTION_DECL_LENGTH)); this.output.addRef(encodeEntry(function.getFullyQualifiedNameCharArrays(),FUNCTION_DECL,FUNCTION_DECL_LENGTH),indexFlag);
Iterator i=function.getParameters(); Iterator i=function.getParameters();
while (i.hasNext()){ while (i.hasNext()){
Object parm = i.next(); Object parm = i.next();
if (parm instanceof IASTParameterDeclaration){ if (parm instanceof IASTParameterDeclaration){
IASTParameterDeclaration parmDecl = (IASTParameterDeclaration) parm; 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){ public void addFunctionReference(IASTFunction function, int indexFlag){
this.output.addRef(encodeEntry(function.getFullyQualifiedNameCharArrays(),FUNCTION_REF,FUNCTION_REF_LENGTH)); this.output.addRef(encodeEntry(function.getFullyQualifiedNameCharArrays(),FUNCTION_REF,FUNCTION_REF_LENGTH),indexFlag);
} }
public void addNameReference(){ public void addNameReference(){
} }
public void addNamespaceDefinition(IASTNamespaceDefinition namespace){ public void addNamespaceDefinition(IASTNamespaceDefinition namespace, int indexFlag){
this.output.addRef(encodeEntry(namespace.getFullyQualifiedNameCharArrays(),NAMESPACE_DECL,NAMESPACE_DECL_LENGTH)); this.output.addRef(encodeEntry(namespace.getFullyQualifiedNameCharArrays(),NAMESPACE_DECL,NAMESPACE_DECL_LENGTH),indexFlag);
} }
public void addNamespaceReference(IASTNamespaceDefinition namespace) { public void addNamespaceReference(IASTNamespaceDefinition namespace, int indexFlag) {
this.output.addRef(encodeEntry(namespace.getFullyQualifiedNameCharArrays(),NAMESPACE_REF,NAMESPACE_REF_LENGTH)); this.output.addRef(encodeEntry(namespace.getFullyQualifiedNameCharArrays(),NAMESPACE_REF,NAMESPACE_REF_LENGTH),indexFlag);
} }
public void addTypedefReference( IASTTypedefDeclaration typedef ){ public void addTypedefReference( IASTTypedefDeclaration typedef, int indexFlag ){
this.output.addRef( encodeTypeEntry( typedef.getFullyQualifiedNameCharArrays(), TYPEDEF, ICSearchConstants.REFERENCES) ); 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){ 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, '.'))); //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; char[][] fullyQualifiedName = null;
ASTClassKind classKind = null; ASTClassKind classKind = null;
@ -328,18 +328,18 @@ public abstract class AbstractIndexer implements IIndexer, IIndexConstants, ICSe
if (classKind.equals(ASTClassKind.CLASS)) 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)) 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)) 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; char[][] fullyQualifiedName = null;
ASTClassKind classKind = null; ASTClassKind classKind = null;
@ -354,15 +354,15 @@ public abstract class AbstractIndexer implements IIndexer, IIndexConstants, ICSe
if (classKind.equals(ASTClassKind.CLASS)) 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)) 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)) 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 ); 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.addIncludeRef(inclusion.getFullFileName());
this.output.addRelatives(inclusion.getFullFileName(),(parent != null ) ? parent.getFullFileName() : null); this.output.addRelatives(inclusion.getFullFileName(),(parent != null ) ? parent.getFullFileName() : null);
//Add Dep Table entry //Add Dep Table entry
char[][] incName = new char[1][]; char[][] incName = new char[1][];
incName[0] = inclusion.getFullFileName().toCharArray(); 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);
} }
} }

View file

@ -21,8 +21,8 @@ import org.eclipse.core.runtime.IPath;
public class AddCompilationUnitToIndex extends AddFileToIndex { public class AddCompilationUnitToIndex extends AddFileToIndex {
char[] contents; char[] contents;
public AddCompilationUnitToIndex(IFile resource, IPath indexedContainer, IndexManager manager, boolean checkEncounteredHeaders) { public AddCompilationUnitToIndex(IFile resource, IPath indexedContainer, IndexManager manager) {
super(resource, indexedContainer, manager, checkEncounteredHeaders); super(resource, indexedContainer, manager);
} }
protected boolean indexDocument(IIndex index) throws IOException { protected boolean indexDocument(IIndex index) throws IOException {
if (!initializeContents()) return false; if (!initializeContents()) return false;

View file

@ -12,39 +12,26 @@ package org.eclipse.cdt.internal.core.search.indexing;
import java.io.IOException; import java.io.IOException;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.ICLogConstants; 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.index.IIndex;
import org.eclipse.cdt.internal.core.search.processing.JobManager; import org.eclipse.cdt.internal.core.search.processing.JobManager;
import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IProgressMonitor;
public abstract class AddFileToIndex extends IndexRequest { public abstract class AddFileToIndex extends IndexRequest {
IFile resource; 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); super(indexPath, manager);
this.resource = resource; this.resource = resource;
this.checkEncounteredHeaders = checkEncounteredHeaders;
} }
public boolean execute(IProgressMonitor progressMonitor) { public boolean execute(IProgressMonitor progressMonitor) {
if (progressMonitor != null && progressMonitor.isCanceled()) return true; 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 */ /* ensure no concurrent write access to index */
IIndex index = manager.getIndex(this.indexPath, true, /*reuse index file*/ true /*create if none*/); IIndex index = manager.getIndex(this.indexPath, true, /*reuse index file*/ true /*create if none*/);
if (index == null) return true; if (index == null) return true;

View file

@ -102,13 +102,12 @@ class AddFolderToIndex extends IndexRequest {
private void scheduleJobs() { private void scheduleJobs() {
//Schedule the source jobs first, then the headers //Schedule the source jobs first, then the headers
for (int i=0; i<sourceFilesToIndex.size(); i++) 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++) 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() { public String toString() {

View file

@ -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;
}
}

View file

@ -30,7 +30,6 @@ import org.eclipse.cdt.core.index.IIndexChangeListener;
import org.eclipse.cdt.core.index.IndexChangeEvent; import org.eclipse.cdt.core.index.IndexChangeEvent;
import org.eclipse.cdt.core.model.ICModelMarker; import org.eclipse.cdt.core.model.ICModelMarker;
import org.eclipse.cdt.core.parser.ParserTimeOut; 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.CharOperation;
import org.eclipse.cdt.internal.core.Util; import org.eclipse.cdt.internal.core.Util;
import org.eclipse.cdt.internal.core.index.IIndex; import org.eclipse.cdt.internal.core.index.IIndex;
@ -82,8 +81,6 @@ public class IndexManager extends JobManager implements IIndexConstants {
private File savedIndexNamesFile = private File savedIndexNamesFile =
new File(getCCorePluginWorkingLocation().append("savedIndexNames.txt").toOSString()); //$NON-NLS-1$ 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 SAVED_STATE = new Integer(0);
public static Integer UPDATING_STATE = new Integer(1); public static Integer UPDATING_STATE = new Integer(1);
public static Integer UNKNOWN_STATE = new Integer(2); 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 * Note: the actual operation is performed in background
* @param checkEncounteredHeaders TODO * @param checkEncounteredHeaders TODO
*/ */
public void addSource(IFile resource, IPath indexedContainers, boolean checkEncounteredHeaders){ public void addSource(IFile resource, IPath indexedContainers){
IProject project = resource.getProject(); IProject project = resource.getProject();
@ -168,7 +165,7 @@ public class IndexManager extends JobManager implements IIndexConstants {
if (CCorePlugin.getDefault() == null) return; if (CCorePlugin.getDefault() == null) return;
if (indexEnabled){ 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 we are in WAITING mode, we need to kick ourselves into enablement
if (!jobSet.add(job.resource.getLocation()) && if (!jobSet.add(job.resource.getLocation()) &&
@ -275,32 +272,6 @@ public class IndexManager extends JobManager implements IIndexConstants {
return index; 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() { private SimpleLookupTable getIndexStates() {
if (indexStates != null) return indexStates; if (indexStates != null) return indexStates;
@ -318,23 +289,6 @@ public class IndexManager extends JobManager implements IIndexConstants {
return this.indexStates; 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() { private IPath getCCorePluginWorkingLocation() {
if (this.cCorePluginLocation != null) return this.cCorePluginLocation; if (this.cCorePluginLocation != null) return this.cCorePluginLocation;
@ -603,7 +557,6 @@ public class IndexManager extends JobManager implements IIndexConstants {
this.indexes = new HashMap(5); this.indexes = new HashMap(5);
this.monitors = new HashMap(5); this.monitors = new HashMap(5);
this.indexStates = null; this.indexStates = null;
this.encounteredHeaders = null;
} }
if (this.timeoutThread == null){ if (this.timeoutThread == null){

View file

@ -69,7 +69,7 @@ public class IndexerModelListener implements IElementChangedListener {
switch(tempResource.getType()) switch(tempResource.getType())
{ {
case IResource.FILE: case IResource.FILE:
indexManager.addSource((IFile) tempResource,tempResource.getProject().getFullPath(), false); indexManager.addSource((IFile) tempResource,tempResource.getProject().getFullPath());
break; break;
case IResource.FOLDER: case IResource.FOLDER:

View file

@ -21,6 +21,7 @@ import java.util.ArrayList;
import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.ICLogConstants; 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.model.CoreModel;
import org.eclipse.cdt.core.parser.CodeReader; import org.eclipse.cdt.core.parser.CodeReader;
import org.eclipse.cdt.core.parser.IParser; import org.eclipse.cdt.core.parser.IParser;
@ -154,7 +155,7 @@ public class SourceIndexer extends AbstractIndexer {
//Report events //Report events
ArrayList filesTrav = requestor.getFilesTraversed(); 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); CCorePlugin.getDefault().getCoreModel().getIndexManager().notifyListeners(indexDelta);
//Release all resources //Release all resources
parser=null; parser=null;

View file

@ -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.IASTVariable;
import org.eclipse.cdt.core.parser.ast.IASTVariableReference; import org.eclipse.cdt.core.parser.ast.IASTVariableReference;
import org.eclipse.cdt.internal.core.Util; 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.IFile;
import org.eclipse.core.resources.IMarker; import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IProject;
@ -124,9 +126,7 @@ public class SourceIndexerRequestor implements ISourceElementRequestor, IIndexCo
this.filesTraversed = new ArrayList(15); this.filesTraversed = new ArrayList(15);
this.filesTraversed.add(resourceFile.getLocation().toOSString()); 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) { public boolean acceptProblem(IProblem problem) {
if( areProblemMarkersEnabled() && shouldRecordProblem( problem ) ){ if( areProblemMarkersEnabled() && shouldRecordProblem( problem ) ){
IASTInclusion include = peekInclude(); IASTInclusion include = peekInclude();
@ -155,101 +155,62 @@ public class SourceIndexerRequestor implements ISourceElementRequestor, IIndexCo
return IndexProblemHandler.ruleOnProblem( problem, ParserMode.COMPLETE_PARSE ); 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) { public void acceptMacro(IASTMacro macro) {
// TODO Auto-generated method stub //Check to see if this reference actually occurs in the file being indexed
indexer.addMacro(macro); //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) { public void acceptVariable(IASTVariable variable) {
// TODO Auto-generated method stub //Check to see if this reference actually occurs in the file being indexed
//System.out.println("acceptVariable"); //or if it occurs in another file
indexer.addVariable(variable); 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) { public void acceptFunctionDeclaration(IASTFunction function) {
// TODO Auto-generated method stub //Check to see if this reference actually occurs in the file being indexed
//System.out.println("acceptFunctionDeclaration"); //or if it occurs in another file
indexer.addFunctionDeclaration(function); int indexFlag = calculateIndexFlags();
indexer.addFunctionDeclaration(function, indexFlag);
} }
/* (non-Javadoc) public void acceptUsingDirective(IASTUsingDirective usageDirective) {}
* @see org.eclipse.cdt.core.parser.ISourceElementRequestor#acceptUsingDirective(org.eclipse.cdt.core.parser.ast.IASTUsingDirective) public void acceptUsingDeclaration(IASTUsingDeclaration usageDeclaration) {}
*/ public void acceptASMDefinition(IASTASMDefinition asmDefinition) {}
public void acceptUsingDirective(IASTUsingDirective usageDirective) {
// TODO Auto-generated method stub
//System.out.println("acceptUsingDirective");
}
/* (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");
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.parser.ISourceElementRequestor#acceptTypedef(org.eclipse.cdt.core.parser.ast.IASTTypedef)
*/
public void acceptTypedefDeclaration(IASTTypedefDeclaration typedef) { public void acceptTypedefDeclaration(IASTTypedefDeclaration typedef) {
// TODO Auto-generated method stub //Check to see if this reference actually occurs in the file being indexed
indexer.addTypedefDeclaration(typedef); //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) { public void acceptEnumerationSpecifier(IASTEnumerationSpecifier enumeration) {
// TODO Auto-generated method stub //Check to see if this reference actually occurs in the file being indexed
//System.out.println("acceptEnumSpecifier"); //or if it occurs in another file
indexer.addEnumerationSpecifier(enumeration); 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) { public void enterFunctionBody(IASTFunction function) {
// TODO Auto-generated method stub //Check to see if this reference actually occurs in the file being indexed
indexer.addFunctionDeclaration(function); //or if it occurs in another file
//indexer.addFunctionDefinition(); int indexFlag = calculateIndexFlags();
indexer.addFunctionDeclaration(function,indexFlag);
} }
/* (non-Javadoc) public void exitFunctionBody(IASTFunction function) {}
* @see org.eclipse.cdt.core.parser.ISourceElementRequestor#exitFunctionBody(org.eclipse.cdt.core.parser.ast.IASTFunction) public void enterCompilationUnit(IASTCompilationUnit compilationUnit) {}
*/
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");
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.parser.ISourceElementRequestor#enterInclusion(org.eclipse.cdt.core.parser.ast.IASTInclusion)
*/
public void enterInclusion(IASTInclusion inclusion) { public void enterInclusion(IASTInclusion inclusion) {
if( areProblemMarkersEnabled() ){ if( areProblemMarkersEnabled() ){
IPath newPath = new Path(inclusion.getFullFileName()); IPath newPath = new Path(inclusion.getFullFileName());
@ -262,7 +223,7 @@ public class SourceIndexerRequestor implements ISourceElementRequestor, IIndexCo
} }
IASTInclusion parent = peekInclude(); IASTInclusion parent = peekInclude();
indexer.addInclude(inclusion, parent); indexer.addInclude(inclusion, parent,indexer.output.getIndexedFile(resourceFile.getFullPath().toString()).getFileNumber());
//Push on stack //Push on stack
pushInclude(inclusion); pushInclude(inclusion);
//Add to traversed files //Add to traversed files
@ -273,294 +234,235 @@ public class SourceIndexerRequestor implements ISourceElementRequestor, IIndexCo
ICFileType type = CCorePlugin.getDefault().getFileType(resourceProject, ICFileType type = CCorePlugin.getDefault().getFileType(resourceProject,
inclusion.getFullFileName()); 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
//System.out.println("New class spec: " + classSpecification.getName());
//System.out.println("enterClassSpecifier");
} }
/* (non-Javadoc) public void enterNamespaceDefinition(IASTNamespaceDefinition namespaceDefinition) {
* @see org.eclipse.cdt.core.parser.ISourceElementRequestor#enterLinkageSpecification(org.eclipse.cdt.core.parser.ast.IASTLinkageSpecification) //Check to see if this reference actually occurs in the file being indexed
*/ //or if it occurs in another file
public void enterLinkageSpecification(IASTLinkageSpecification linkageSpec) { int indexFlag = calculateIndexFlags();
// TODO Auto-generated method stub
//System.out.println("enterLinkageSpecification"); indexer.addNamespaceDefinition(namespaceDefinition, indexFlag);
} }
/* (non-Javadoc) public void enterClassSpecifier(IASTClassSpecifier classSpecification) {}
* @see org.eclipse.cdt.core.parser.ISourceElementRequestor#enterTemplateDeclaration(org.eclipse.cdt.core.parser.ast.IASTTemplateDeclaration) public void enterLinkageSpecification(IASTLinkageSpecification linkageSpec) {}
*/ public void enterTemplateDeclaration(IASTTemplateDeclaration declaration) {}
public void enterTemplateDeclaration(IASTTemplateDeclaration declaration) { public void enterTemplateSpecialization(IASTTemplateSpecialization specialization) {}
// TODO Auto-generated method stub public void enterTemplateInstantiation(IASTTemplateInstantiation instantiation) {}
//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) { public void acceptMethodDeclaration(IASTMethod method) {
// TODO Auto-generated method stub //Check to see if this reference actually occurs in the file being indexed
//System.out.println("acceptMethodDeclaration"); //or if it occurs in another file
indexer.addMethodDeclaration(method); 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) { public void enterMethodBody(IASTMethod method) {
// TODO Auto-generated method stub //Check to see if this reference actually occurs in the file being indexed
//System.out.println("enterMethodBody " + method.getName()); //or if it occurs in another file
indexer.addMethodDeclaration(method); int indexFlag = calculateIndexFlags();
indexer.addMethodDeclaration(method, indexFlag);
} }
/* (non-Javadoc) public void exitMethodBody(IASTMethod method) {}
* @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");
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.parser.ISourceElementRequestor#acceptField(org.eclipse.cdt.core.parser.ast.IASTField)
*/
public void acceptField(IASTField field) { public void acceptField(IASTField field) {
// TODO Auto-generated method stub //Check to see if this reference actually occurs in the file being indexed
// System.out.println("acceptField"); //or if it occurs in another file
indexer.addFieldDeclaration(field); 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) { public void acceptClassReference(IASTClassReference reference) {
// TODO Auto-generated method stub //Check to see if this reference actually occurs in the file being indexed
//System.out.println("acceptClassReference"); //or if it occurs in another file
int indexFlag = calculateIndexFlags();
if (reference.getReferencedElement() instanceof IASTClassSpecifier) if (reference.getReferencedElement() instanceof IASTClassSpecifier)
indexer.addClassReference((IASTClassSpecifier)reference.getReferencedElement()); indexer.addClassReference((IASTClassSpecifier)reference.getReferencedElement(), indexFlag);
else if (reference.getReferencedElement() instanceof IASTElaboratedTypeSpecifier) 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) * @return
*/ */
public void exitTemplateDeclaration(IASTTemplateDeclaration declaration) { private int calculateIndexFlags() {
// TODO Auto-generated method stub int fileNum= 0;
//System.out.println("exitTemplateDeclaration");
//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#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)
*/
public void exitLinkageSpecification(IASTLinkageSpecification linkageSpec) {
// TODO Auto-generated method stub
//System.out.println("exitLinkageSpecification");
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.parser.ISourceElementRequestor#exitClassSpecifier(org.eclipse.cdt.core.parser.ast.IASTClassSpecifier)
*/
public void exitClassSpecifier(IASTClassSpecifier classSpecification) { public void exitClassSpecifier(IASTClassSpecifier classSpecification) {
// TODO Auto-generated method stub //Check to see if this reference actually occurs in the file being indexed
indexer.addClassSpecifier(classSpecification); //or if it occurs in another file
//System.out.println("exitClassSpecifier"); int indexFlag = calculateIndexFlags();
indexer.addClassSpecifier(classSpecification, indexFlag);
} }
/* (non-Javadoc) public void exitNamespaceDefinition(IASTNamespaceDefinition namespaceDefinition) {}
* @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");
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.parser.ISourceElementRequestor#exitInclusion(org.eclipse.cdt.core.parser.ast.IASTInclusion)
*/
public void exitInclusion(IASTInclusion inclusion) { public void exitInclusion(IASTInclusion inclusion) {
// TODO Auto-generated method stub // TODO Auto-generated method stub
popInclude(); popInclude();
} }
/* (non-Javadoc) public void exitCompilationUnit(IASTCompilationUnit compilationUnit) {}
* @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
}
/* (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() );
}
/* (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
if (reference.getReferencedElement() instanceof IASTNamespaceDefinition)
indexer.addNamespaceReference((IASTNamespaceDefinition)reference.getReferencedElement());
}
/* (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
if (reference.getReferencedElement() instanceof IASTEnumerationSpecifier)
indexer.addEnumerationReference((IASTEnumerationSpecifier) reference.getReferencedElement());
}
/* (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
if (reference.getReferencedElement() instanceof IASTVariable)
indexer.addVariableReference((IASTVariable)reference.getReferencedElement());
public void acceptAbstractTypeSpecDeclaration(IASTAbstractTypeSpecifierDeclaration abstractDeclaration) {}
public void acceptTypedefReference(IASTTypedefReference 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 IASTTypedefDeclaration )
indexer.addTypedefReference( (IASTTypedefDeclaration) reference.getReferencedElement(),indexFlag);
} }
/* (non-Javadoc)
* @see org.eclipse.cdt.core.parser.ISourceElementRequestor#acceptFunctionReference(org.eclipse.cdt.core.parser.ast.IASTFunctionReference) public void acceptNamespaceReference(IASTNamespaceReference 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 IASTNamespaceDefinition)
indexer.addNamespaceReference((IASTNamespaceDefinition)reference.getReferencedElement(),indexFlag);
}
public void acceptEnumerationReference(IASTEnumerationReference 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 IASTEnumerationSpecifier)
indexer.addEnumerationReference((IASTEnumerationSpecifier) reference.getReferencedElement(),indexFlag);
}
public void acceptVariableReference(IASTVariableReference 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 IASTVariable)
indexer.addVariableReference((IASTVariable)reference.getReferencedElement(),indexFlag);
}
public void acceptFunctionReference(IASTFunctionReference reference) { 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) 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) { 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) 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) { 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) 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){ public void acceptElaboratedForewardDeclaration(IASTElaboratedTypeSpecifier elaboratedType){
indexer.addElaboratedForwardDeclaration(elaboratedType); //Check to see if this reference actually occurs in the file being indexed
//or if it occurs in another file
int indexFlag = calculateIndexFlags();
indexer.addElaboratedForwardDeclaration(elaboratedType, indexFlag);
} }
/* (non-Javadoc)
* @see org.eclipse.cdt.core.parser.ISourceElementRequestor#enterCodeBlock(org.eclipse.cdt.core.parser.ast.IASTScope) public void enterCodeBlock(IASTCodeScope scope) {}
*/ public void exitCodeBlock(IASTCodeScope scope) {}
public void enterCodeBlock(IASTCodeScope scope) { public void acceptEnumeratorReference(IASTEnumeratorReference 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();
}
/* (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
}
/* (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 ) 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)
{
if( reference.getReferencedElement() instanceof IASTParameterDeclaration )
indexer.addParameterReference( (IASTParameterDeclaration) reference.getReferencedElement() );
} }
public void acceptTemplateParameterReference( IASTTemplateParameterReference reference ){ public void acceptParameterReference(IASTParameterReference reference){
if( reference.getReferencedElement() instanceof IASTTemplateParameterReference ){ //Check to see if this reference actually occurs in the file being indexed
//TODO //or if it occurs in another file
} int indexFlag = calculateIndexFlags();
}
/* (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
} if( reference.getReferencedElement() instanceof IASTParameterDeclaration )
indexer.addParameterReference( (IASTParameterDeclaration) reference.getReferencedElement(), indexFlag);
}
public void acceptTemplateParameterReference( IASTTemplateParameterReference reference ){}
public void acceptFriendDeclaration(IASTDeclaration declaration) {}
private void pushInclude( IASTInclusion inclusion ){ private void pushInclude( IASTInclusion inclusion ){
includeStack.addFirst( currentInclude ); includeStack.addFirst( currentInclude );

View file

@ -593,7 +593,7 @@ public class DeltaProcessor {
case ICElement.C_UNIT: case ICElement.C_UNIT:
IFile file = (IFile) delta.getResource(); IFile file = (IFile) delta.getResource();
IProject filesProject = file.getProject(); IProject filesProject = file.getProject();
indexManager.addSource(file, filesProject.getFullPath(), false); indexManager.addSource(file, filesProject.getFullPath());
break; break;
} }

View file

@ -1,3 +1,6 @@
2004-11-02 Bogdan Gheorghe
Partial Fix for 74427: Indexer needs to store more info
2004-08-11 Bogdan Gheorghe 2004-08-11 Bogdan Gheorghe
Fix for 71964: Search parses too many times Fix for 71964: Search parses too many times

View file

@ -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 { throws IOException {
//never called for OrPattern //never called for OrPattern
} }

View file

@ -700,8 +700,9 @@ public abstract class CSearchPattern implements ICSearchConstants, ICSearchPatte
IEntryResult entry = entries[i]; IEntryResult entry = entries[i];
resetIndexInfo(); resetIndexInfo();
decodeIndexEntry(entry); decodeIndexEntry(entry);
if (matchIndexEntry()){ 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 * 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, * Called to reset any variables used in the decoding of index entries,

View file

@ -154,7 +154,7 @@ public class ClassDeclarationPattern extends CSearchPattern {
protected boolean isForward; 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; boolean isClass = decodedType == CLASS_SUFFIX;
for (int i = 0, max = references.length; i < max; i++) { for (int i = 0, max = references.length; i < max; i++) {
IndexedFile file = input.getIndexedFile(references[i]); IndexedFile file = input.getIndexedFile(references[i]);
@ -253,4 +253,5 @@ public class ClassDeclarationPattern extends CSearchPattern {
return true; return true;
} }
} }

View file

@ -158,7 +158,7 @@ public class FieldDeclarationPattern extends CSearchPattern {
/* (non-Javadoc) /* (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) * @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++) { for (int i = 0, max = references.length; i < max; i++) {
IndexedFile file = input.getIndexedFile(references[i]); IndexedFile file = input.getIndexedFile(references[i]);
String path; String path;

View file

@ -50,7 +50,7 @@ public class IncludePattern extends CSearchPattern {
/* (non-Javadoc) /* (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) * @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++) { for (int i = 0, max = references.length; i < max; i++) {
IndexedFile file = input.getIndexedFile(references[i]); IndexedFile file = input.getIndexedFile(references[i]);
String path; String path;

View file

@ -67,7 +67,7 @@ public class MacroDeclarationPattern extends CSearchPattern {
/* (non-Javadoc) /* (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) * @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++) { for (int i = 0, max = references.length; i < max; i++) {
IndexedFile file = input.getIndexedFile(references[i]); IndexedFile file = input.getIndexedFile(references[i]);
String path; String path;

View file

@ -18,7 +18,6 @@ import java.io.InputStream;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator; import java.util.Iterator;
import java.util.LinkedList; 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.IASTUsingDirective;
import org.eclipse.cdt.core.parser.ast.IASTVariable; import org.eclipse.cdt.core.parser.ast.IASTVariable;
import org.eclipse.cdt.core.parser.ast.IASTVariableReference; 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.ICSearchPattern;
import org.eclipse.cdt.core.search.ICSearchResultCollector; import org.eclipse.cdt.core.search.ICSearchResultCollector;
import org.eclipse.cdt.core.search.ICSearchScope; import org.eclipse.cdt.core.search.ICSearchScope;
@ -106,12 +104,7 @@ public class MatchLocator implements IMatchLocator{
ArrayList matchStorage; ArrayList matchStorage;
protected ObjectSet encounteredHeaders;
protected ObjectSet tempHeaderSet;
public static boolean VERBOSE = false; public static boolean VERBOSE = false;
private boolean checkForMatch = true;
/** /**
* *
*/ */
@ -152,173 +145,138 @@ public class MatchLocator implements IMatchLocator{
*/ */
public void acceptParameterReference(IASTParameterReference reference) public void acceptParameterReference(IASTParameterReference reference)
{ {
if (checkForMatch) check( REFERENCES, reference );
check( REFERENCES, reference );
} }
public void acceptTemplateParameterReference(IASTTemplateParameterReference reference) public void acceptTemplateParameterReference(IASTTemplateParameterReference reference)
{ {
if (checkForMatch) check( REFERENCES, reference );
check( REFERENCES, reference );
} }
public void acceptTypedefDeclaration(IASTTypedefDeclaration typedef){ public void acceptTypedefDeclaration(IASTTypedefDeclaration typedef){
lastDeclaration = typedef; lastDeclaration = typedef;
check( DECLARATIONS, typedef );
if (checkForMatch)
check( DECLARATIONS, typedef );
} }
public void acceptTypedefReference( IASTTypedefReference reference ){ public void acceptTypedefReference( IASTTypedefReference reference ){
if (checkForMatch) check( REFERENCES, reference );
check( REFERENCES, reference );
} }
public void acceptEnumeratorReference(IASTEnumeratorReference reference){ public void acceptEnumeratorReference(IASTEnumeratorReference reference){
if (checkForMatch)
check( REFERENCES, reference ); check( REFERENCES, reference );
} }
public void acceptMacro(IASTMacro macro){ public void acceptMacro(IASTMacro macro){
if (checkForMatch) check( DECLARATIONS, macro );
check( DECLARATIONS, macro );
} }
public void acceptVariable(IASTVariable variable){ public void acceptVariable(IASTVariable variable){
lastDeclaration = variable; lastDeclaration = variable;
if (checkForMatch){ check( DECLARATIONS, variable );
check( DECLARATIONS, variable ); //A declaration is a definition unless...:
//it contains the extern specifier or a linkage-spec and no initializer
//A declaration is a definition unless...: if( variable.getInitializerClause() != null ||
//it contains the extern specifier or a linkage-spec and no initializer ( !variable.isExtern() && !(currentScope instanceof IASTLinkageSpecification) ) ){
if( variable.getInitializerClause() != null || check( DEFINITIONS, variable );
( !variable.isExtern() && !(currentScope instanceof IASTLinkageSpecification) ) ){
check( DEFINITIONS, variable );
}
} }
} }
public void acceptField(IASTField field){ public void acceptField(IASTField field){
lastDeclaration = field; lastDeclaration = field;
if( currentScope instanceof IASTClassSpecifier ){
if (checkForMatch){ check( DECLARATIONS, field );
if( currentScope instanceof IASTClassSpecifier ){ if( !field.isStatic() ){
check( DECLARATIONS, field ); check( DEFINITIONS, field );
if( !field.isStatic() ){
check( DEFINITIONS, field );
}
} else {
check( DEFINITIONS, field );
} }
} else {
check( DEFINITIONS, field );
} }
} }
public void acceptEnumerationSpecifier(IASTEnumerationSpecifier enumeration){ public void acceptEnumerationSpecifier(IASTEnumerationSpecifier enumeration){
lastDeclaration = enumeration; lastDeclaration = enumeration;
check( DECLARATIONS, enumeration );
if (checkForMatch){ Iterator iter = enumeration.getEnumerators();
check( DECLARATIONS, enumeration ); while( iter.hasNext() ){
Iterator iter = enumeration.getEnumerators(); IASTEnumerator enumerator = (IASTEnumerator) iter.next();
while( iter.hasNext() ){ lastDeclaration = enumerator;
IASTEnumerator enumerator = (IASTEnumerator) iter.next(); check ( DECLARATIONS, enumerator );
lastDeclaration = enumerator; }
check ( DECLARATIONS, enumerator );
}
}
} }
public void acceptFunctionDeclaration(IASTFunction function){ public void acceptFunctionDeclaration(IASTFunction function){
lastDeclaration = function; lastDeclaration = function;
check( DECLARATIONS, function );
if (checkForMatch)
check( DECLARATIONS, function );
} }
public void acceptMethodDeclaration(IASTMethod method){ public void acceptMethodDeclaration(IASTMethod method){
lastDeclaration = method; lastDeclaration = method;
check( DECLARATIONS, method );
if (checkForMatch)
check( DECLARATIONS, method );
} }
public void acceptClassReference(IASTClassReference reference) { public void acceptClassReference(IASTClassReference reference) {
if (checkForMatch) check( REFERENCES, reference );
check( REFERENCES, reference );
} }
public void acceptNamespaceReference( IASTNamespaceReference reference ){ public void acceptNamespaceReference( IASTNamespaceReference reference ){
if (checkForMatch) check( REFERENCES, reference );
check( REFERENCES, reference );
} }
public void acceptVariableReference( IASTVariableReference reference ){ public void acceptVariableReference( IASTVariableReference reference ){
if (checkForMatch) check( REFERENCES, reference );
check( REFERENCES, reference );
} }
public void acceptFieldReference( IASTFieldReference reference ){ public void acceptFieldReference( IASTFieldReference reference ){
if (checkForMatch) check( REFERENCES, reference );
check( REFERENCES, reference );
} }
public void acceptEnumerationReference( IASTEnumerationReference reference ){ public void acceptEnumerationReference( IASTEnumerationReference reference ){
if (checkForMatch) check( REFERENCES, reference );
check( REFERENCES, reference );
} }
public void acceptFunctionReference( IASTFunctionReference reference ){ public void acceptFunctionReference( IASTFunctionReference reference ){
if (checkForMatch) check( REFERENCES, reference );
check( REFERENCES, reference );
} }
public void acceptMethodReference( IASTMethodReference reference ){ public void acceptMethodReference( IASTMethodReference reference ){
if (checkForMatch) check( REFERENCES, reference );
check( REFERENCES, reference );
} }
public void enterFunctionBody(IASTFunction function){ public void enterFunctionBody(IASTFunction function){
lastDeclaration = function; lastDeclaration = function;
if (checkForMatch) if( !function.previouslyDeclared() )
{ check( DECLARATIONS, function );
if( !function.previouslyDeclared() )
check( DECLARATIONS, function );
check( DEFINITIONS, function );
Iterator parms =function.getParameters(); check( DEFINITIONS, function );
while (parms.hasNext()){
Object tempParm = parms.next(); Iterator parms =function.getParameters();
if (tempParm instanceof IASTParameterDeclaration){ while (parms.hasNext()){
check( DECLARATIONS, ((IASTParameterDeclaration)tempParm)); Object tempParm = parms.next();
} if (tempParm instanceof IASTParameterDeclaration){
check( DECLARATIONS, ((IASTParameterDeclaration)tempParm));
} }
} }
pushScope( function ); pushScope( function );
} }
public void enterMethodBody(IASTMethod method) { public void enterMethodBody(IASTMethod method) {
lastDeclaration = method; lastDeclaration = method;
if( !method.previouslyDeclared() )
check( DECLARATIONS, method );
check( DEFINITIONS, method );
if (checkForMatch){
if( !method.previouslyDeclared() ) Iterator parms =method.getParameters();
check( DECLARATIONS, method ); while (parms.hasNext()){
Object tempParm = parms.next();
check( DEFINITIONS, method ); if (tempParm instanceof IASTParameterDeclaration){
check( DECLARATIONS, ((IASTParameterDeclaration)tempParm));
Iterator parms =method.getParameters();
while (parms.hasNext()){
Object tempParm = parms.next();
if (tempParm instanceof IASTParameterDeclaration){
check( DECLARATIONS, ((IASTParameterDeclaration)tempParm));
}
} }
} }
pushScope( method ); pushScope( method );
} }
@ -328,22 +286,14 @@ public class MatchLocator implements IMatchLocator{
public void enterNamespaceDefinition(IASTNamespaceDefinition namespaceDefinition) { public void enterNamespaceDefinition(IASTNamespaceDefinition namespaceDefinition) {
lastDeclaration = namespaceDefinition; lastDeclaration = namespaceDefinition;
check( DECLARATIONS, namespaceDefinition );
if (checkForMatch){ check( DEFINITIONS, namespaceDefinition );
check( DECLARATIONS, namespaceDefinition );
check( DEFINITIONS, namespaceDefinition );
}
pushScope( namespaceDefinition ); pushScope( namespaceDefinition );
} }
public void enterClassSpecifier(IASTClassSpecifier classSpecification) { public void enterClassSpecifier(IASTClassSpecifier classSpecification) {
lastDeclaration = classSpecification; lastDeclaration = classSpecification;
check( DECLARATIONS, classSpecification );
if (checkForMatch){
check( DECLARATIONS, classSpecification );
}
pushScope( classSpecification ); pushScope( classSpecification );
} }
@ -356,10 +306,7 @@ public class MatchLocator implements IMatchLocator{
} }
public void exitClassSpecifier(IASTClassSpecifier classSpecification) { public void exitClassSpecifier(IASTClassSpecifier classSpecification) {
if (checkForMatch){ check(DECLARATIONS, classSpecification);
check(DECLARATIONS, classSpecification);
}
popScope(); popScope();
} }
@ -376,20 +323,7 @@ public class MatchLocator implements IMatchLocator{
IPath path = new Path( includePath ); IPath path = new Path( includePath );
IResource resource = null; 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 ){ if( workspaceRoot != null ){
resource = workspaceRoot.getFileForLocation( path ); resource = workspaceRoot.getFileForLocation( path );
// if( resource == null ){ // if( resource == null ){
@ -420,19 +354,12 @@ public class MatchLocator implements IMatchLocator{
currentPath = (IPath) obj; currentPath = (IPath) obj;
currentResource = null; 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{ public void locateMatches( String [] paths, IWorkspace workspace, IWorkingCopy[] workingCopies ) throws InterruptedException{
matchStorage = new ArrayList(); matchStorage = new ArrayList();
encounteredHeaders= new ObjectSet(32);
tempHeaderSet = new ObjectSet(32);
workspaceRoot = (workspace != null) ? workspace.getRoot() : null; workspaceRoot = (workspace != null) ? workspace.getRoot() : null;
HashMap wcPaths = new HashMap(); HashMap wcPaths = new HashMap();
@ -477,10 +404,6 @@ public class MatchLocator implements IMatchLocator{
if (!searchScope.encloses(pathString)) continue; 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; CodeReader reader = null;
realPath = null; realPath = null;
@ -540,9 +463,6 @@ public class MatchLocator implements IMatchLocator{
} }
} }
//Set checkForMatch to true
checkForMatch = true;
//Get the scanner info //Get the scanner info
IScannerInfo scanInfo = new ScannerInfo(); IScannerInfo scanInfo = new ScannerInfo();
IScannerInfoProvider provider = CCorePlugin.getDefault().getScannerInfoProvider(project); IScannerInfoProvider provider = CCorePlugin.getDefault().getScannerInfoProvider(project);
@ -589,11 +509,8 @@ public class MatchLocator implements IMatchLocator{
vmErr.printStackTrace(); vmErr.printStackTrace();
} }
} finally { } finally {
encounteredHeaders.addAll(tempHeaderSet);
tempHeaderSet.clear();
scopeStack.clear(); scopeStack.clear();
resourceStack.clear(); resourceStack.clear();
searchStack.clear();
lastDeclaration = null; lastDeclaration = null;
currentScope = null; currentScope = null;
parser = null; parser = null;
@ -725,8 +642,6 @@ public class MatchLocator implements IMatchLocator{
private IASTScope currentScope = null; private IASTScope currentScope = null;
private LinkedList scopeStack = new LinkedList(); private LinkedList scopeStack = new LinkedList();
private LinkedList searchStack = new LinkedList();
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.core.parser.ISourceElementRequestor#acceptElaboratedForewardDeclaration(org.eclipse.cdt.core.parser.ast.IASTElaboratedTypeSpecifier) * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#acceptElaboratedForewardDeclaration(org.eclipse.cdt.core.parser.ast.IASTElaboratedTypeSpecifier)

View file

@ -168,7 +168,7 @@ public class MethodDeclarationPattern extends CSearchPattern {
return true; 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++) { for (int i = 0, max = references.length; i < max; i++) {
IndexedFile file = input.getIndexedFile(references[i]); IndexedFile file = input.getIndexedFile(references[i]);
String path; String path;

View file

@ -79,7 +79,7 @@ public class NamespaceDeclarationPattern extends CSearchPattern {
/* (non-Javadoc) /* (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) * @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++) { for (int i = 0, max = references.length; i < max; i++) {
IndexedFile file = input.getIndexedFile(references[i]); IndexedFile file = input.getIndexedFile(references[i]);
String path; String path;