mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-23 14:42:11 +02:00
Patch for Bogdan (Fancy Pants) Gheorghe
This patch adds macro declarations to the index.
This commit is contained in:
parent
42cf54e708
commit
ff9ca80b0c
7 changed files with 67 additions and 7 deletions
|
@ -1,3 +1,6 @@
|
|||
2003-08-11 Bogdan Gheorghe
|
||||
- Added testMacros to IndexManagerTests
|
||||
|
||||
2003-08-05 Andrew Niefer
|
||||
- refactoring Parser Symbol Table function names
|
||||
- added ParserSymbolTableTest.testConstructors()
|
||||
|
|
|
@ -15,6 +15,7 @@ import java.io.FileInputStream;
|
|||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Iterator;
|
||||
|
||||
import junit.framework.Test;
|
||||
|
@ -88,7 +89,14 @@ public class IndexManagerTests extends TestCase {
|
|||
|
||||
public static Test suite() {
|
||||
TestSuite suite = new TestSuite();
|
||||
|
||||
suite.addTest(new IndexManagerTests("testAddNewFileToIndex"));
|
||||
suite.addTest(new IndexManagerTests("testRemoveProjectFromIndex"));
|
||||
suite.addTest(new IndexManagerTests("testRefs"));
|
||||
suite.addTest(new IndexManagerTests("testMacros"));
|
||||
suite.addTest(new IndexManagerTests("testDependencyTree"));
|
||||
suite.addTest(new IndexManagerTests("testIndexShutdown"));
|
||||
|
||||
return suite;
|
||||
//return new TestSuite(IndexManagerTests.class);
|
||||
}
|
||||
|
@ -167,13 +175,12 @@ public class IndexManagerTests extends TestCase {
|
|||
|
||||
if (eresults.length != entryResultModel.length)
|
||||
fail("Entry Result length different from model");
|
||||
|
||||
|
||||
|
||||
for (int i=0; i<qresults.length;i++)
|
||||
{
|
||||
assertEquals(queryResultModel[i],qresults[i].toString());
|
||||
}
|
||||
|
||||
|
||||
for (int i=0;i<eresults.length; i++)
|
||||
{
|
||||
assertEquals(entryResultModel[i],eresults[i].toString());
|
||||
|
@ -202,7 +209,7 @@ public class IndexManagerTests extends TestCase {
|
|||
|
||||
if (eresults.length != entryResultModel.length)
|
||||
fail("Entry Result length different from model");
|
||||
|
||||
|
||||
for (int i=0;i<eresults.length; i++)
|
||||
{
|
||||
assertEquals(entryResultModel[i],eresults[i].toString());
|
||||
|
@ -250,7 +257,7 @@ public class IndexManagerTests extends TestCase {
|
|||
String [] entryResultBeforeModel ={"EntryResult: word=typeDecl/C/CDocumentManager, refs={ 1 }", "EntryResult: word=typeDecl/C/Mail, refs={ 2 }", "EntryResult: word=typeDecl/C/Unknown, refs={ 2 }", "EntryResult: word=typeDecl/C/container, refs={ 2 }", "EntryResult: word=typeDecl/C/first_class, refs={ 2 }", "EntryResult: word=typeDecl/C/postcard, refs={ 2 }"};
|
||||
if (eresults.length != entryResultBeforeModel.length)
|
||||
fail("Entry Result length different from model");
|
||||
|
||||
|
||||
for (int i=0;i<eresults.length; i++)
|
||||
{
|
||||
assertEquals(entryResultBeforeModel[i],eresults[i].toString());
|
||||
|
@ -336,7 +343,7 @@ public class IndexManagerTests extends TestCase {
|
|||
|
||||
if (functionresults.length != functionResultModel.length)
|
||||
fail("Entry Result length different from model for functionDecl");
|
||||
|
||||
|
||||
for (int i=0;i<functionresults.length; i++)
|
||||
{
|
||||
assertEquals(functionResultModel[i],functionresults[i].toString());
|
||||
|
@ -423,6 +430,33 @@ public class IndexManagerTests extends TestCase {
|
|||
}
|
||||
}
|
||||
|
||||
public void testMacros() throws Exception
|
||||
{
|
||||
//Add a new file to the project, give it some time to index
|
||||
importFile("extramail.cpp","resources/indexer/extramail.cpp");
|
||||
//Enable indexing on the created project
|
||||
//By doing this, we force the Index Manager to indexAll()
|
||||
indexManager = CCorePlugin.getDefault().getCoreModel().getIndexManager();
|
||||
indexManager.setEnabled(testProject,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);
|
||||
|
||||
IEntryResult[] macroresults = ind.queryEntries(IIndexConstants.MACRO_DECL);
|
||||
|
||||
String [] macroResultModel = {"EntryResult: word=macroDecl/CASE, refs={ 1 }", "EntryResult: word=macroDecl/MAX, refs={ 1 }", "EntryResult: word=macroDecl/PRINT, refs={ 1 }"};
|
||||
|
||||
if (macroresults.length != macroResultModel.length)
|
||||
fail("Entry Result length different from model for macros");
|
||||
|
||||
for (int i=0;i<macroresults.length; i++)
|
||||
{
|
||||
assertEquals(macroResultModel[i],macroresults[i].toString());
|
||||
}
|
||||
}
|
||||
|
||||
public void testIndexShutdown() throws Exception{
|
||||
//Add a new file to the project, give it some time to index
|
||||
importFile("reftest.cpp","resources/indexer/reftest.cpp");
|
||||
|
@ -495,6 +529,9 @@ public class IndexManagerTests extends TestCase {
|
|||
if (depTestModelLocal.length != depTestIncludes.length)
|
||||
fail("Number of included files differsfrom model");
|
||||
|
||||
Arrays.sort(depTestModelLocal);
|
||||
Arrays.sort(depTestIncludes);
|
||||
|
||||
for (i=0;i<depTestIncludes.length; i++)
|
||||
{
|
||||
assertEquals(depTestModelLocal[i],depTestIncludes[i]);
|
||||
|
@ -515,6 +552,9 @@ public class IndexManagerTests extends TestCase {
|
|||
if (depTest2ModelLocal.length != depTest2Includes.length)
|
||||
fail("Number of included files differsfrom model");
|
||||
|
||||
Arrays.sort(depTest2ModelLocal);
|
||||
Arrays.sort(depTest2Includes);
|
||||
|
||||
for (i=0;i<depTest2Includes.length; i++)
|
||||
{
|
||||
assertEquals(depTest2ModelLocal[i],depTest2Includes[i]);
|
||||
|
|
|
@ -3,6 +3,10 @@
|
|||
#include <alloc.h>
|
||||
#include <iomanip.h>
|
||||
|
||||
#define PRINT(a,b) cout<<(a)<<(b)
|
||||
#define CASE break;case
|
||||
#define MAX(a,b) (((a)>(b))?(a):(b))
|
||||
|
||||
typedef int int32;
|
||||
|
||||
static void doSomething();
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
2003-08-11 Bogdan Gheorghe
|
||||
- Added macro declarations to the index
|
||||
|
||||
2003-08-07 Bogdan Gheorghe
|
||||
- Added shutdown cleanup routine in IndexManager
|
||||
|
||||
|
|
|
@ -20,6 +20,7 @@ import org.eclipse.cdt.core.parser.ast.IASTEnumerationSpecifier;
|
|||
import org.eclipse.cdt.core.parser.ast.IASTEnumerator;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTField;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTFunction;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTMacro;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTMethod;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTNamespaceDefinition;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTTypedefDeclaration;
|
||||
|
@ -78,6 +79,12 @@ public abstract class AbstractIndexer implements IIndexer, IIndexConstants, ICSe
|
|||
}
|
||||
}
|
||||
|
||||
public void addMacro(IASTMacro macro) {
|
||||
String[] macroName = new String[1];
|
||||
macroName[0] = macro.getName();
|
||||
this.output.addRef(encodeEntry(macroName,MACRO_DECL,MACRO_DECL_LENGTH));
|
||||
}
|
||||
|
||||
public void addEnumerationReference(IASTEnumerationSpecifier enumeration) {
|
||||
this.output.addRef(encodeTypeEntry(enumeration.getFullyQualifiedName(), ENUM, ICSearchConstants.REFERENCES));
|
||||
}
|
||||
|
|
|
@ -59,6 +59,9 @@ public interface IIndexConstants {
|
|||
|
||||
char[] TYPEDEF_DECL = "typedefDecl/".toCharArray(); //$NON-NLS-1$
|
||||
int TYPEDEF_DECL_LENGTH = 12;
|
||||
|
||||
char[] MACRO_DECL = "macroDecl/".toCharArray();
|
||||
int MACRO_DECL_LENGTH = 10;
|
||||
//a Var REF will be treated as a typeREF
|
||||
//char[] VAR_REF= "varRef/".toCharArray(); //$NON-NLS-1$
|
||||
|
||||
|
|
|
@ -80,7 +80,7 @@ public class SourceIndexerRequestor implements ISourceElementRequestor, IIndexCo
|
|||
*/
|
||||
public void acceptMacro(IASTMacro macro) {
|
||||
// TODO Auto-generated method stub
|
||||
//System.out.println("acceptMacro");
|
||||
indexer.addMacro(macro);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
|
Loading…
Add table
Reference in a new issue