1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

Refactored CTags Indexer to allow individual tags to add themslves to an Indexer Output (consolidated CTagsIndexAll and CTagsAddCompilationUnit)

CTagFileReader logic change to read in all tags in ctags file
Patch from Dave with fix for TempVA merge problem (Indexer View was opening BlocksInput without close) + other UI improvements
Renamed generated CTags file
Refactored indexer tests to not depend on EntryResult toString()
This commit is contained in:
Bogdan Gheorghe 2005-05-05 04:25:16 +00:00
parent 641fbeb7a6
commit ea15dddbc9
20 changed files with 563 additions and 354 deletions

View file

@ -221,6 +221,11 @@ public class SourceIndexerTests extends TestCase implements IIndexChangeListener
"EntryResult: word=typeDecl/V/x, refs={ 1 }, offsets={ [ 21201, 21526] }"}; //$NON-NLS-1$
String[] entryResultNameModel = {"Mail","Unknown","container","first_class","postcard","Mail","first_class","postcard","PO_Box","index","mail","size","temp","x"};
int[] entryResultMetaModel = {IIndex.TYPE};
int[] entryResultTypeModel = {IIndex.TYPE_CLASS,IIndex.TYPE_CLASS,IIndex.TYPE_CLASS,IIndex.TYPE_CLASS,IIndex.TYPE_CLASS,IIndex.TYPE_DERIVED,IIndex.TYPE_DERIVED,IIndex.TYPE_DERIVED, IIndex.TYPE_VAR, IIndex.TYPE_VAR, IIndex.TYPE_VAR, IIndex.TYPE_VAR, IIndex.TYPE_VAR, IIndex.TYPE_VAR};
int[] entryResultRefModel = {IIndex.DECLARATION};
if (qresults.length != queryResultModel.length)
fail("Query Result length different from model"); //$NON-NLS-1$
@ -234,7 +239,10 @@ public class SourceIndexerTests extends TestCase implements IIndexChangeListener
for (int i=0;i<eresults.length; i++)
{
assertEquals(entryResultModel[i],eresults[i].toString());
assertEquals(entryResultNameModel[i],eresults[i].getName());
assertEquals(entryResultMetaModel[0],eresults[i].getMetaKind());
assertEquals(entryResultTypeModel[i],eresults[i].getKind());
assertEquals(entryResultRefModel[0],eresults[i].getRefKind());
}
}
@ -257,17 +265,25 @@ public class SourceIndexerTests extends TestCase implements IIndexChangeListener
ind = sourceIndexer.getIndex(testProjectPath,true,true);
String name = "CDocumentManager"; //$NON-NLS-1$
String [] entryResultModel ={"EntryResult: word=typeDecl/C/CDocumentManager, refs={ 2 }, offsets={ [ 2127] }"}; //$NON-NLS-1$
String[] entryResultNameModel = {"CDocumentManager"};
int[] entryResultMetaModel = {IIndex.TYPE};
int[] entryResultTypeModel = {IIndex.TYPE_CLASS};
int[] entryResultRefModel = {IIndex.DECLARATION};
IEntryResult[] eresults =ind.getEntries(IIndex.TYPE, IIndex.TYPE_CLASS, IIndex.DECLARATION, name);
IEntryResult[] bogRe = ind.getEntries(IIndex.TYPE, IIndex.ANY, IIndex.DECLARATION);
assertTrue("Entry Result exists", eresults != null); //$NON-NLS-1$
if (eresults.length != entryResultModel.length)
if (eresults.length != entryResultNameModel.length)
fail("Entry Result length different from model"); //$NON-NLS-1$
for (int i=0;i<eresults.length; i++)
{
assertEquals(entryResultModel[i],eresults[i].toString());
assertEquals(entryResultNameModel[i],eresults[i].getName());
assertEquals(entryResultMetaModel[i],eresults[i].getMetaKind());
assertEquals(entryResultTypeModel[i],eresults[i].getKind());
assertEquals(entryResultRefModel[i],eresults[i].getRefKind());
}
}
@ -339,12 +355,20 @@ public class SourceIndexerTests extends TestCase implements IIndexChangeListener
"EntryResult: word=typeDecl/V/temp, refs={ 3 }, offsets={ [ 21964] }",
"EntryResult: word=typeDecl/V/x, refs={ 3 }, offsets={ [ 21201, 21526] }"};
if (eresults.length != entryResultBeforeModel.length)
String[] entryResultNameModel = {"CDocumentManager","Mail","Unknown","container","first_class","postcard","Mail","first_class","postcard","PO_Box","index","mail","size","temp","x"};
int[] entryResultMetaModel = {IIndex.TYPE};
int[] entryResultTypeModel = {IIndex.TYPE_CLASS, IIndex.TYPE_CLASS,IIndex.TYPE_CLASS,IIndex.TYPE_CLASS,IIndex.TYPE_CLASS,IIndex.TYPE_CLASS,IIndex.TYPE_DERIVED,IIndex.TYPE_DERIVED,IIndex.TYPE_DERIVED, IIndex.TYPE_VAR, IIndex.TYPE_VAR, IIndex.TYPE_VAR, IIndex.TYPE_VAR, IIndex.TYPE_VAR, IIndex.TYPE_VAR};
int[] entryResultRefModel = {IIndex.DECLARATION};
if (eresults.length != entryResultNameModel.length)
fail("Entry Result length different from model"); //$NON-NLS-1$
for (int i=0;i<eresults.length; i++)
{
assertEquals(entryResultBeforeModel[i],eresults[i].toString());
assertEquals(entryResultNameModel[i],eresults[i].getName());
assertEquals(entryResultMetaModel[0],eresults[i].getMetaKind());
assertEquals(entryResultTypeModel[i],eresults[i].getKind());
assertEquals(entryResultRefModel[0],eresults[i].getRefKind());
}
//Delete mail.cpp from the project, give some time to remove index
IResource resourceHdl = testProject.findMember("mail.cpp") ; //$NON-NLS-1$
@ -361,12 +385,21 @@ public class SourceIndexerTests extends TestCase implements IIndexChangeListener
assertTrue("Entry exists", eresults != null); //$NON-NLS-1$
String [] entryResultAfterModel ={"EntryResult: word=typeDecl/C/CDocumentManager, refs={ 2 }, offsets={ [ 2127] }"}; //$NON-NLS-1$ //$NON-NLS-2$
if (eresults.length != entryResultAfterModel.length)
String[] entryResultANameModel = {"CDocumentManager"};
int[] entryResultAMetaModel = {IIndex.TYPE};
int[] entryResultATypeModel = {IIndex.TYPE_CLASS};
int[] entryResultARefModel = {IIndex.DECLARATION};
if (eresults.length != entryResultANameModel.length)
fail("Entry Result length different from model"); //$NON-NLS-1$
for (int i=0;i<eresults.length; i++)
{
assertEquals(entryResultAfterModel[i],eresults[i].toString());
assertEquals(entryResultANameModel[i],eresults[i].getName());
assertEquals(entryResultAMetaModel[0],eresults[i].getMetaKind());
assertEquals(entryResultATypeModel[0],eresults[i].getKind());
assertEquals(entryResultARefModel[0],eresults[i].getRefKind());
}
}
@ -383,118 +416,134 @@ public class SourceIndexerTests extends TestCase implements IIndexChangeListener
IEntryResult[] typerefreesults = ind.getEntries(IIndex.TYPE, IIndex.ANY, IIndex.REFERENCE);
assertTrue("Type Ref Results exist", typerefreesults != null); //$NON-NLS-1$
String [] typeDeclEntryResultModel ={"EntryResult: word=typeDecl/C/Mail/Y/X/Z, refs={ 1 }, offsets={ [ 2335] }","EntryResult: word=typeDecl/C/Unknown/Y/X/Z, refs={ 1 }, offsets={ [ 21063] }", //$NON-NLS-1$ //$NON-NLS-2$
"EntryResult: word=typeDecl/C/container/Y/X/Z, refs={ 1 }, offsets={ [ 21445] }","EntryResult: word=typeDecl/C/first_class/Y/X/Z, refs={ 1 }, offsets={ [ 2804] }", //$NON-NLS-1$ //$NON-NLS-2$
"EntryResult: word=typeDecl/C/postcard/Y/X/Z, refs={ 1 }, offsets={ [ 2572] }","EntryResult: word=typeDecl/D/Mail/Y/X/Z, refs={ 1 }, offsets={ [ 2335] }", //$NON-NLS-1$ //$NON-NLS-2$
"EntryResult: word=typeDecl/D/first_class/Y/X/Z, refs={ 1 }, offsets={ [ 2804] }", "EntryResult: word=typeDecl/D/postcard/Y/X/Z, refs={ 1 }, offsets={ [ 2572] }", //$NON-NLS-1$ //$NON-NLS-2$
"EntryResult: word=typeDecl/E/test/Y/X/Z, refs={ 1 }, offsets={ [ 2302] }","EntryResult: word=typeDecl/T/int32, refs={ 1 }, offsets={ [ 2200] }", //$NON-NLS-1$ //$NON-NLS-2$
"EntryResult: word=typeDecl/V/PO_Box, refs={ 1 }, offsets={ [ 21792] }","EntryResult: word=typeDecl/V/index, refs={ 1 }, offsets={ [ 21706, 22333] }", //$NON-NLS-1$ //$NON-NLS-2$
"EntryResult: word=typeDecl/V/mail, refs={ 1 }, offsets={ [ 21742, 22402] }", "EntryResult: word=typeDecl/V/size, refs={ 1 }, offsets={ [ 22423] }", //$NON-NLS-1$ //$NON-NLS-2$
"EntryResult: word=typeDecl/V/temp, refs={ 1 }, offsets={ [ 22463] }", "EntryResult: word=typeDecl/V/x, refs={ 1 }, offsets={ [ 21589, 21965] }", //$NON-NLS-1$ //$NON-NLS-2$
"EntryResult: word=typeDecl/V/x/Z, refs={ 1 }, offsets={ [ 2259] }"}; //$NON-NLS-1$
String[] entryResultNameModel = {"Mail/Y/X/Z", "Unknown/Y/X/Z", "container/Y/X/Z", "first_class/Y/X/Z", "postcard/Y/X/Z", "Mail/Y/X/Z",
"first_class/Y/X/Z", "postcard/Y/X/Z", "test/Y/X/Z", "int32", "PO_Box", "index", "mail", "size", "temp", "x", "x/Z" };
int[] entryResultMetaModel = {IIndex.TYPE};
int[] entryResultTypeModel = {IIndex.TYPE_CLASS, IIndex.TYPE_CLASS, IIndex.TYPE_CLASS, IIndex.TYPE_CLASS, IIndex.TYPE_CLASS,
IIndex.TYPE_DERIVED, IIndex.TYPE_DERIVED, IIndex.TYPE_DERIVED, IIndex.TYPE_ENUM, IIndex.TYPE_TYPEDEF, IIndex.TYPE_VAR,
IIndex.TYPE_VAR,IIndex.TYPE_VAR,IIndex.TYPE_VAR,IIndex.TYPE_VAR,IIndex.TYPE_VAR,IIndex.TYPE_VAR};
int[] entryResultRefModel = {IIndex.DECLARATION};
IEntryResult[] typedeclresults =ind.getEntries(IIndex.TYPE, IIndex.ANY, IIndex.DECLARATION);
assertTrue("Type Decl Results exist", typedeclresults != null); //$NON-NLS-1$
if (typedeclresults.length != typeDeclEntryResultModel.length)
if (typedeclresults.length != entryResultNameModel.length)
fail("Entry Result length different from model for typeDecl"); //$NON-NLS-1$
for (int i=0;i<typedeclresults.length; i++)
{
assertEquals(typeDeclEntryResultModel[i],typedeclresults[i].toString());
assertEquals(entryResultNameModel[i],typedeclresults[i].getName());
assertEquals(entryResultMetaModel[0],typedeclresults[i].getMetaKind());
assertEquals(entryResultTypeModel[i],typedeclresults[i].getKind());
assertEquals(entryResultRefModel[0],typedeclresults[i].getRefKind());
}
String [] typeDefEntryResultModel ={"EntryResult: word=typeDecl/T/int32, refs={ 1 }, offsets={ [ 2200] }"}; //$NON-NLS-1$
String[] entryResultTNameModel = {"int32" };
int[] entryResultTMetaModel = {IIndex.TYPE};
int[] entryResultTTypeModel = {IIndex.TYPE_TYPEDEF};
int[] entryResultTRefModel = {IIndex.DECLARATION};
IEntryResult[] typedefresults =ind.getEntries(IIndex.TYPE, IIndex.TYPE_TYPEDEF, IIndex.DECLARATION);
assertTrue("Type Def Results exist", typedefresults != null); //$NON-NLS-1$
if (typedefresults.length != typeDefEntryResultModel.length)
if (typedefresults.length != entryResultTNameModel.length)
fail("Entry Result length different from model for typeDef"); //$NON-NLS-1$
for (int i=0;i<typedefresults.length; i++)
{
assertEquals(typeDefEntryResultModel[i],typedefresults[i].toString());
assertEquals(entryResultNameModel[i],typedeclresults[i].getName());
assertEquals(entryResultMetaModel[i],typedeclresults[i].getMetaKind());
assertEquals(entryResultTypeModel[i],typedeclresults[i].getKind());
assertEquals(entryResultRefModel[i],typedeclresults[i].getRefKind());
}
String [] namespaceResultModel = {"EntryResult: word=namespaceDecl/X/Z, refs={ 1 }, offsets={ [ 2274] }", "EntryResult: word=namespaceDecl/Y/X/Z, refs={ 1 }, offsets={ [ 2290] }", //$NON-NLS-1$ //$NON-NLS-2$
"EntryResult: word=namespaceDecl/Z, refs={ 1 }, offsets={ [ 2250] }"}; //$NON-NLS-1$
String[] entryResultNNameModel = {"X/Z", "Y/X/Z" , "Z" };
int[] entryResultNMetaModel = {IIndex.NAMESPACE};
int[] entryResultNRefModel = {IIndex.DECLARATION};
IEntryResult[] namespaceresults =ind.getEntries(IIndex.NAMESPACE, IIndex.ANY, IIndex.DECLARATION);
assertTrue("Namespace Results exist", namespaceresults != null); //$NON-NLS-1$
if (namespaceresults.length != namespaceResultModel.length)
if (namespaceresults.length != entryResultNNameModel.length)
fail("Entry Result length different from model for namespace"); //$NON-NLS-1$
for (int i=0;i<namespaceresults.length; i++)
{
assertEquals(namespaceResultModel[i],namespaceresults[i].toString());
assertEquals(entryResultNNameModel[i],namespaceresults[i].getName());
assertEquals(entryResultNMetaModel[0],namespaceresults[i].getMetaKind());
assertEquals(entryResultNRefModel[0],namespaceresults[i].getRefKind());
}
String [] fieldResultModel = {"EntryResult: word=fieldDecl/array/container/Y/X/Z, refs={ 1 }, offsets={ [ 21485] }", "EntryResult: word=fieldDecl/index/container/Y/X/Z, refs={ 1 }, offsets={ [ 21500] }",
"EntryResult: word=fieldDecl/postage/Mail/Y/X/Z, refs={ 1 }, offsets={ [ 2469] }", "EntryResult: word=fieldDecl/sz/container/Y/X/Z, refs={ 1 }, offsets={ [ 21515] }",
"EntryResult: word=fieldDecl/type/Mail/Y/X/Z, refs={ 1 }, offsets={ [ 2488] }"}; //$NON-NLS-1$ //$NON-NLS-2$
String[] entryResultFNameModel = {"array/container/Y/X/Z", "index/container/Y/X/Z" , "postage/Mail/Y/X/Z","sz/container/Y/X/Z", "type/Mail/Y/X/Z"};
int[] entryResultFMetaModel = {IIndex.FIELD};
int[] entryResultFRefModel = {IIndex.DECLARATION};
IEntryResult[] fieldresults =ind.getEntries(IIndex.FIELD, IIndex.ANY, IIndex.DECLARATION);
assertTrue("Field Results exist", fieldresults != null); //$NON-NLS-1$
if (fieldresults.length != fieldResultModel.length)
if (fieldresults.length != entryResultFNameModel.length)
fail("Entry Result length different from model for fieldDecl"); //$NON-NLS-1$
for (int i=0;i<fieldresults.length; i++)
{
assertEquals(fieldResultModel[i],fieldresults[i].toString());
assertEquals(entryResultFNameModel[i],fieldresults[i].getName());
assertEquals(entryResultFMetaModel[0],fieldresults[i].getMetaKind());
assertEquals(entryResultFRefModel[0],fieldresults[i].getRefKind());
}
String [] enumeratorResultModel = {"EntryResult: word=enumtorDecl/bye/Y/X/Z, refs={ 1 }, offsets={ [ 2315] }", "EntryResult: word=enumtorDecl/cool/Y/X/Z, refs={ 1 }, offsets={ [ 2307] }",
"EntryResult: word=enumtorDecl/hi/Y/X/Z, refs={ 1 }, offsets={ [ 2312] }", "EntryResult: word=enumtorDecl/why/Y/X/Z, refs={ 1 }, offsets={ [ 2319] }"};
String[] entryResultENameModel = {"bye/Y/X/Z", "cool/Y/X/Z" , "hi/Y/X/Z", "why/Y/X/Z"};
int[] entryResultEMetaModel = {IIndex.ENUMTOR};
int[] entryResultERefModel = {IIndex.DECLARATION};
IEntryResult[] enumeratorresults =ind.getEntries(IIndex.ENUMTOR, IIndex.ANY, IIndex.DECLARATION);
assertTrue("Enumerator Results exist", enumeratorresults != null); //$NON-NLS-1$
if (enumeratorresults.length != enumeratorResultModel.length)
if (enumeratorresults.length != entryResultENameModel.length)
fail("Entry Result length different from model for enumtorDecl"); //$NON-NLS-1$
for (int i=0;i<enumeratorresults.length; i++)
{
assertEquals(enumeratorResultModel[i],enumeratorresults[i].toString());
assertEquals(entryResultENameModel[i],enumeratorresults[i].getName());
assertEquals(entryResultEMetaModel[0],enumeratorresults[i].getMetaKind());
assertEquals(entryResultERefModel[0],enumeratorresults[i].getRefKind());
}
String [] functionResultModel = {"EntryResult: word=functionDecl/doSomething, refs={ 1 }, offsets={ [ 2222] }", "EntryResult: word=functionDecl/main/Y/X/Z, refs={ 1 }, offsets={ [ 21765] }"}; //$NON-NLS-1$ //$NON-NLS-2$
String[] entryResultFNNameModel = {"doSomething", "main/Y/X/Z"};
int[] entryResultFNMetaModel = {IIndex.FUNCTION};
int[] entryResultFNRefModel = {IIndex.DECLARATION};
IEntryResult[] functionresults =ind.getEntries(IIndex.FUNCTION, IIndex.ANY, IIndex.DECLARATION);
if (functionresults.length != functionResultModel.length)
if (functionresults.length != entryResultFNNameModel.length)
fail("Entry Result length different from model for functionDecl"); //$NON-NLS-1$
for (int i=0;i<functionresults.length; i++)
{
assertEquals(functionResultModel[i],functionresults[i].toString());
assertEquals(entryResultFNNameModel[i],functionresults[i].getName());
assertEquals(entryResultFNMetaModel[0],functionresults[i].getMetaKind());
assertEquals(entryResultFNRefModel[0],functionresults[i].getRefKind());
}
String [] methodResultModel = {"EntryResult: word=methodDecl/Mail/Mail/Y/X/Z, refs={ 1 }, offsets={ [ 2362] }",
"EntryResult: word=methodDecl/Unknown/Unknown/Y/X/Z, refs={ 1 }, offsets={ [ 21152] }",
"EntryResult: word=methodDecl/container/container/Y/X/Z, refs={ 1 }, offsets={ [ 21535] }",
"EntryResult: word=methodDecl/first_class/first_class/Y/X/Z, refs={ 1 }, offsets={ [ 2852] }",
"EntryResult: word=methodDecl/operator =/container/Y/X/Z, refs={ 1 }, offsets={ [ 21724, 22384] }",
"EntryResult: word=methodDecl/operator []/container/Y/X/Z, refs={ 1 }, offsets={ [ 21691, 22318] }",
"EntryResult: word=methodDecl/postcard/postcard/Y/X/Z, refs={ 1 }, offsets={ [ 2617] }",
"EntryResult: word=methodDecl/print/Mail/Y/X/Z, refs={ 1 }, offsets={ [ 2388] }",
"EntryResult: word=methodDecl/print/Unknown/Y/X/Z, refs={ 1 }, offsets={ [ 21293] }",
"EntryResult: word=methodDecl/print/first_class/Y/X/Z, refs={ 1 }, offsets={ [ 2923] }",
"EntryResult: word=methodDecl/print/postcard/Y/X/Z, refs={ 1 }, offsets={ [ 2681] }",
"EntryResult: word=methodDecl/size/container/Y/X/Z, refs={ 1 }, offsets={ [ 21661] }",
"EntryResult: word=methodDecl/~container/container/Y/X/Z, refs={ 1 }, offsets={ [ 21563] }"};
String[] entryResultMNameModel = {"Mail/Mail/Y/X/Z", "Unknown/Unknown/Y/X/Z" , "container/container/Y/X/Z", "first_class/first_class/Y/X/Z",
"operator =/container/Y/X/Z", "operator []/container/Y/X/Z","postcard/postcard/Y/X/Z","print/Mail/Y/X/Z", "print/Unknown/Y/X/Z",
"print/first_class/Y/X/Z", "print/postcard/Y/X/Z", "size/container/Y/X/Z", "~container/container/Y/X/Z"};
int[] entryResultMMetaModel = {IIndex.METHOD};
int[] entryResultMRefModel = {IIndex.DECLARATION};
IEntryResult[] methodresults =ind.getEntries(IIndex.METHOD, IIndex.ANY, IIndex.DECLARATION);
assertTrue("Entry exists", methodresults != null); //$NON-NLS-1$
if (methodresults.length != methodResultModel.length)
if (methodresults.length != entryResultMNameModel.length)
fail("Entry Result length different from model for functionDecl"); //$NON-NLS-1$
for (int i=0;i<methodresults.length; i++)
{
assertEquals("Index is " +i , methodResultModel[i],methodresults[i].toString()); //$NON-NLS-1$
assertEquals(entryResultMNameModel[i],methodresults[i].getName());
assertEquals(entryResultMMetaModel[0],methodresults[i].getMetaKind());
assertEquals(entryResultMRefModel[0],methodresults[i].getRefKind());
}
}
@ -506,69 +555,99 @@ public class SourceIndexerTests extends TestCase implements IIndexChangeListener
IPath testProjectPath = testProject.getFullPath();
IIndex ind = sourceIndexer.getIndex(testProjectPath,true,true);
assertTrue("Index exists for project",ind != null); //$NON-NLS-1$
String [] typeRefEntryResultModel ={"EntryResult: word=typeRef/C/C/B/A, refs={ 1 }, offsets={ [ 2263, 2279, 2298] }",
"EntryResult: word=typeRef/E/e1/B/A, refs={ 1 }, offsets={ [ 2340] }",
"EntryResult: word=typeRef/G/ForwardA/A, refs={ 1 }, offsets={ [ 237] }",
"EntryResult: word=typeRef/V/x/B/A, refs={ 1 }, offsets={ [ 2247] }"};
String[] entryResultNameModel = {"C/B/A", "e1/B/A", "ForwardA/A", "x/B/A"};
int[] entryResultMetaModel = {IIndex.TYPE};
int[] entryResultTypeModel = {IIndex.TYPE_CLASS, IIndex.TYPE_ENUM, IIndex.TYPE_FWD_CLASS, IIndex.TYPE_VAR};
int[] entryResultRefModel = {IIndex.REFERENCE};
IEntryResult[] typerefresults = ind.getEntries(IIndex.TYPE,IIndex.ANY,IIndex.REFERENCE);
assertTrue("Entry exists",typerefresults != null); //$NON-NLS-1$
if (typerefresults.length != typeRefEntryResultModel.length)
if (typerefresults.length != entryResultNameModel.length)
fail("Entry Result length different from model for typeRef"); //$NON-NLS-1$
for (int i=0;i<typerefresults.length; i++)
{
assertEquals(typeRefEntryResultModel[i],typerefresults[i].toString());
assertEquals(entryResultNameModel[i],typerefresults[i].getName());
assertEquals(entryResultMetaModel[0],typerefresults[i].getMetaKind());
assertEquals(entryResultTypeModel[i],typerefresults[i].getKind());
assertEquals(entryResultRefModel[0],typerefresults[i].getRefKind());
}
String [] funRefEntryResultModel ={"EntryResult: word=functionRef/something/A, refs={ 1 }, offsets={ [ 2316] }"};//$NON-NLS-1$
String[] entryResultFNameModel = {"something/A"};
int[] entryResultFMetaModel = {IIndex.FUNCTION};
int[] entryResultFRefModel = {IIndex.REFERENCE};
IEntryResult[] funRefresults = ind.getEntries(IIndex.FUNCTION,IIndex.ANY, IIndex.REFERENCE);
assertTrue("Entry exists",funRefresults != null); //$NON-NLS-1$
if (funRefresults.length != funRefEntryResultModel.length)
if (funRefresults.length != entryResultFNameModel.length)
fail("Entry Result length different from model for funcRef"); //$NON-NLS-1$
for (int i=0;i<funRefresults.length; i++)
{
assertEquals(funRefEntryResultModel[i],funRefresults[i].toString());
assertEquals(entryResultFNameModel[i],funRefresults[i].getName());
assertEquals(entryResultFMetaModel[0],funRefresults[i].getMetaKind());
assertEquals(entryResultFRefModel[0],funRefresults[i].getRefKind());
}
String [] namespaceRefResultModel = {"EntryResult: word=namespaceRef/A, refs={ 1 }, offsets={ [ 2228, 2241, 2257, 2273, 2292, 2313, 2334] }", "EntryResult: word=namespaceRef/B/A, refs={ 1 }, offsets={ [ 2231, 2244, 2260, 2276, 2295, 2337] }"}; //$NON-NLS-1$ //$NON-NLS-2$
String [] namespaceRefResultModel = {"EntryResult: word=namespaceRef/A, refs={ 1 }, offsets={ [ 2228, 2241, 2257, 2273, 2292, 2313, 2334] }",
"EntryResult: word=namespaceRef/B/A, refs={ 1 }, offsets={ [ 2231, 2244, 2260, 2276, 2295, 2337] }"}; //$NON-NLS-1$ //$NON-NLS-2$
String[] entryResultNNameModel = {"A", "B/A"};
int[] entryResultNMetaModel = {IIndex.NAMESPACE};
int[] entryResultNRefModel = {IIndex.REFERENCE};
IEntryResult[] namespacerefresults = ind.getEntries(IIndex.NAMESPACE, IIndex.ANY, IIndex.REFERENCE);
assertTrue("Entry exists",namespacerefresults!=null); //$NON-NLS-1$
if (namespacerefresults.length != namespaceRefResultModel.length)
if (namespacerefresults.length != entryResultNNameModel.length)
fail("Entry Result length different from model for namespaceRef"); //$NON-NLS-1$
for (int i=0;i<namespacerefresults.length; i++)
{
assertEquals(namespaceRefResultModel[i],namespacerefresults[i].toString());
assertEquals(entryResultNNameModel[i],namespacerefresults[i].getName());
assertEquals(entryResultNMetaModel[0],namespacerefresults[i].getMetaKind());
assertEquals(entryResultNRefModel[0],namespacerefresults[i].getRefKind());
}
String [] fieldRefResultModel = {"EntryResult: word=fieldRef/y/C/B/A, refs={ 1 }, offsets={ [ 2282] }"}; //$NON-NLS-1$
String[] entryResultFDNameModel = {"y/C/B/A"};
int[] entryResultFDMetaModel = {IIndex.FIELD};
int[] entryResultFDRefModel = {IIndex.REFERENCE};
IEntryResult[] fieldrefresults = ind.getEntries(IIndex.FIELD, IIndex.ANY, IIndex.REFERENCE);
assertTrue("Entry exists",fieldrefresults!=null); //$NON-NLS-1$
if (fieldrefresults.length != fieldRefResultModel.length)
if (fieldrefresults.length != entryResultFDNameModel.length)
fail("Entry Result length different from model for fieldRef"); //$NON-NLS-1$
for (int i=0;i<fieldrefresults.length; i++)
{
assertEquals(fieldRefResultModel[i],fieldrefresults[i].toString());
assertEquals(entryResultFDNameModel[i],fieldrefresults[i].getName());
assertEquals(entryResultFDMetaModel[0],fieldrefresults[i].getMetaKind());
assertEquals(entryResultFDRefModel[0],fieldrefresults[i].getRefKind());
}
String [] methodRefResultModel = {"EntryResult: word=methodRef/bar/C/B/A, refs={ 1 }, offsets={ [ 2301] }"}; //$NON-NLS-1$
String[] entryResultMNameModel = {"bar/C/B/A"};
int[] entryResultMMetaModel = {IIndex.METHOD};
int[] entryResultMRefModel = {IIndex.REFERENCE};
IEntryResult[] methodrefresults = ind.getEntries(IIndex.METHOD, IIndex.ANY, IIndex.REFERENCE);
assertTrue("Entry exists", methodrefresults != null); //$NON-NLS-1$
if (methodrefresults.length != methodRefResultModel.length)
if (methodrefresults.length != entryResultMNameModel.length)
fail("Entry Result length different from model for methodRef");//$NON-NLS-1$
for (int i=0;i<methodrefresults.length; i++)
{
assertEquals(methodRefResultModel[i],methodrefresults[i].toString());
assertEquals(entryResultMNameModel[i],methodrefresults[i].getName());
assertEquals(entryResultMMetaModel[0],methodrefresults[i].getMetaKind());
assertEquals(entryResultMRefModel[0],methodrefresults[i].getRefKind());
}
}
@ -654,17 +733,19 @@ public class SourceIndexerTests extends TestCase implements IIndexChangeListener
IEntryResult[] macroresults = ind.getEntries(IIndex.MACRO, IIndex.ANY, IIndex.DECLARATION);
assertTrue("Entry exists", macroresults != null); //$NON-NLS-1$
String [] macroResultModel = {"EntryResult: word=macroDecl/CASE, refs={ 1 }, offsets={ [ 2131] }",
"EntryResult: word=macroDecl/MAX, refs={ 1 }, offsets={ [ 2156] }",
"EntryResult: word=macroDecl/PRINT, refs={ 1 }, offsets={ [ 296] }"};
if (macroresults.length != macroResultModel.length)
String[] entryResultNameModel = {"CASE", "MAX", "PRINT"};
int[] entryResultMetaModel = {IIndex.MACRO};
int[] entryResultRefModel = {IIndex.DECLARATION};
if (macroresults.length != entryResultNameModel.length)
fail("Entry Result length different from model for macros"); //$NON-NLS-1$
for (int i=0;i<macroresults.length; i++)
{
assertEquals(macroResultModel[i],macroresults[i].toString());
assertEquals(entryResultNameModel[i],macroresults[i].getName());
assertEquals(entryResultMetaModel[0],macroresults[i].getMetaKind());
assertEquals(entryResultRefModel[0],macroresults[i].getRefKind());
}
}
@ -715,26 +796,40 @@ public class SourceIndexerTests extends TestCase implements IIndexChangeListener
assertTrue("Entry exists",fwdDclResults != null); //$NON-NLS-1$
String [] fwdDclModel = {"EntryResult: word=typeDecl/G/ForwardA/A, refs={ 1 }, offsets={ [ 225] }"}; //$NON-NLS-1$
String[] entryResultNameModel = {"ForwardA/A"};
int[] entryResultMetaModel = {IIndex.TYPE};
int[] entryResultTypeModel = {IIndex.TYPE_FWD_CLASS};
int[] entryResultRefModel = {IIndex.DECLARATION};
if (fwdDclResults.length != fwdDclModel.length)
fail("Entry Result length different from model for forward declarations"); //$NON-NLS-1$
for (int i=0;i<fwdDclResults.length; i++)
{
assertEquals(fwdDclModel[i],fwdDclResults[i].toString());
assertEquals(entryResultNameModel[i],fwdDclResults[i].getName());
assertEquals(entryResultMetaModel[i],fwdDclResults[i].getMetaKind());
assertEquals(entryResultTypeModel[i],fwdDclResults[i].getKind());
assertEquals(entryResultRefModel[i],fwdDclResults[i].getRefKind());
}
IEntryResult[] fwdDclRefResults = ind.getEntries(IIndex.TYPE, IIndex.TYPE_FWD_CLASS, IIndex.REFERENCE, "ForwardA/A"); //$NON-NLS-1$
assertTrue("Entry exists", fwdDclRefResults!= null); //$NON-NLS-1$
String [] fwdDclRefModel = {"EntryResult: word=typeRef/G/ForwardA/A, refs={ 1 }, offsets={ [ 237] }"}; //$NON-NLS-1$
String[] entryResultName2Model = {"ForwardA/A"};
int[] entryResultMeta2Model = {IIndex.TYPE};
int[] entryResultType2Model = {IIndex.TYPE_FWD_CLASS};
int[] entryResultRef2Model = {IIndex.REFERENCE};
if (fwdDclRefResults.length != fwdDclRefModel.length)
fail("Entry Result length different from model for forward declarations refs"); //$NON-NLS-1$
for (int i=0;i<fwdDclRefResults.length; i++)
{
assertEquals(fwdDclRefModel[i],fwdDclRefResults[i].toString());
assertEquals(entryResultName2Model[i],fwdDclRefResults[i].getName());
assertEquals(entryResultMeta2Model[i],fwdDclRefResults[i].getMetaKind());
assertEquals(entryResultType2Model[i],fwdDclRefResults[i].getKind());
assertEquals(entryResultRef2Model[i],fwdDclRefResults[i].getRefKind());
}
}

View file

@ -28,6 +28,10 @@ public interface IEntryResult {
public int getRefKind();
public String getName();
public String getStringMetaKind();
public String getStringKind();
public String getStringRefKind();
/**
* Returns the offsets for this entry - offsets are in the same position
* as the file references (ex. the first offset array belongs to the first

View file

@ -0,0 +1,15 @@
package org.eclipse.cdt.internal.core.index;
public interface IFunctionEntry extends IIndexEntry {
public void setSignature();
public void getSignature();
public void setReturnType();
public void getReturnType();
public void setStatic(boolean staticVar);
public boolean isStatic();
}

View file

@ -75,6 +75,9 @@ public interface IIndex {
/**
* Returns the number of documents indexed.
*/
String [] getDocumentList() throws IOException;
int getNumDocuments() throws IOException;
/**
* Returns the number of unique words indexed.

View file

@ -0,0 +1,11 @@
package org.eclipse.cdt.internal.core.index;
public interface IIndexEntry {
//DECLARATION, DEFINITION, or REFERENCE as defined in IIndex
public void setEntryType(int type);
public int getEntryType();
public void serialize(IIndexerOutput output);
}

View file

@ -0,0 +1,14 @@
package org.eclipse.cdt.internal.core.index;
public interface ITypeEntry extends IIndexEntry {
public void setKind(int meta_kind);
public int getKind();
public void setReturnType();
public void getReturnType();
public void isStatic();
public void setName(String name);
}

View file

@ -67,10 +67,16 @@ public int hashCode(){
return CharOperation.hashCode(getWord());
}
public String toString(){
char [] word = getWord();
StringBuffer buffer = new StringBuffer(word.length * 2);
buffer.append("EntryResult: word="); //$NON-NLS-1$
buffer.append(word);
StringBuffer buffer = new StringBuffer();
buffer.append("EntryResult: " + getName() + "\n\tmeta="); //$NON-NLS-1$
buffer.append(ICIndexStorageConstants.encodings[meta_type]);
if(meta_type == IIndex.TYPE) {
buffer.append(" type=");
buffer.append(ICIndexStorageConstants.typeConstantNames[kind]);
}
buffer.append(" Reference=");
buffer.append(ICIndexStorageConstants.encodingTypes[reftype]);
buffer.append(", refs={"); //$NON-NLS-1$
for (int i = 0; i < fileRefs.length; i++){
if (i > 0) buffer.append(',');
@ -89,7 +95,7 @@ public String toString(){
}
buffer.append(']');
}
buffer.append(" }"); //$NON-NLS-1$
buffer.append(" }\n"); //$NON-NLS-1$
return buffer.toString();
}
/* (non-Javadoc)
@ -116,19 +122,18 @@ public String extractSimpleName() {
}
private void decode(char [] word) {
String aWord = new String(word);
int pos = 0;
meta_type = 0;
for (int i = 1; i < ICIndexStorageConstants.encodings.length; i ++){
if (aWord.indexOf(new String(ICIndexStorageConstants.encodings[i]), pos) == 0) {
if (CharOperation.prefixEquals(ICIndexStorageConstants.encodings[i], word)) {
meta_type = i;
pos += ICIndexStorageConstants.encodings[i].length;
break;
}
}
for ( int i = 1; i < ICIndexStorageConstants.encodingTypes.length; i++) {
if (aWord.indexOf(new String(ICIndexStorageConstants.encodingTypes[i]), pos) == pos) {
for ( int i = 1; i < ICIndexStorageConstants.encodingTypes.length; i++) {
if (CharOperation.fragmentEquals(ICIndexStorageConstants.encodingTypes[i], word, pos, true)) {
reftype = i;
pos += ICIndexStorageConstants.encodingTypes[i].length;
break;
@ -181,6 +186,15 @@ public int getRefKind() {
public String getName() {
return longname;
}
public String getStringMetaKind() {
return String.valueOf(ICIndexStorageConstants.encodings[meta_type]);
}
public String getStringKind() {
return ICIndexStorageConstants.typeConstantNames[kind];
}
public String getStringRefKind() {
return String.valueOf(ICIndexStorageConstants.encodingTypes[reftype]);
}
}

View file

@ -72,6 +72,19 @@ public interface ICIndexStorageConstants {
'I' // FWD_UNION
};
final static String[] typeConstantNames = { "", // not used
"Class",
"Struct",
"Union",
"Enum",
"Variable",
"Typedef",
"Derived",
"Friend",
"FWD Class",
"FWD Struct",
"FWD Union"
};
final static char [][] accessSpecifiers = {
"".toCharArray(), // not used //$NON-NLS-1$
"private".toCharArray(), // private //$NON-NLS-1$

View file

@ -201,6 +201,30 @@ public class Index implements IIndex, ICIndexStorageConstants, ICSearchConstants
input.close();
}
}
/**
* Returns the path list
*/
public String [] getDocumentList() throws IOException {
IndexInput input= new BlocksIndexInput(indexFile);
try {
input.open();
int num = input.getNumFiles();
String [] result = new String[num+1];
for(int i = 1; i < num+1; i++) {
//i+1 since reference encoding starts at 1
IndexedFileEntry file = input.getIndexedFile(i);
if (file != null)
result[i] = file.getPath();
else
result[i] = null;
}
return result;
} finally {
input.close();
}
}
/**
* see IIndex.hasChanged
*/
@ -265,7 +289,18 @@ public class Index implements IIndex, ICIndexStorageConstants, ICSearchConstants
//rename the file created to become the main index
File mainIndexFile= (File) mainIndexInput.getSource();
File tempIndexFile= (File) tempIndexOutput.getDestination();
mainIndexFile.delete();
boolean deleted = mainIndexFile.delete();
int counter=0;
while (!deleted && counter<5){
System.out.println("Not deleted");
try {
Thread.sleep(50);
} catch (InterruptedException e) {}
counter++;
deleted=mainIndexFile.delete();
}
tempIndexFile.renameTo(mainIndexFile);
} finally {
//initialise remove vectors and addsindex, and change the state

View file

@ -13,6 +13,9 @@ package org.eclipse.cdt.internal.core.index.ctagsindexer;
import java.util.HashMap;
import java.util.StringTokenizer;
import org.eclipse.cdt.internal.core.index.IIndex;
import org.eclipse.cdt.internal.core.index.IIndexerOutput;
class CTagEntry{
private final CTagsConsoleParser parser;
@ -53,8 +56,10 @@ class CTagEntry{
case 2: // LINE NUMBER;
try {
String sub = token.trim();
if (Character.isDigit(sub.charAt(0))) {
lineNumber = Integer.parseInt(sub);
int i = sub.indexOf(';');
String num = sub.substring(0, i);
if (Character.isDigit(num.charAt(0))) {
lineNumber = Integer.parseInt(num);
}
} catch (NumberFormatException e) {
} catch (IndexOutOfBoundsException e) {
@ -72,4 +77,75 @@ class CTagEntry{
}
}
}
/**
* @param tempTag
* @return
*/
public char[][] getQualifiedName() {
char[][] fullName = null;
String name = null;
String[] types = {CTagsConsoleParser.NAMESPACE, CTagsConsoleParser.CLASS, CTagsConsoleParser.STRUCT, CTagsConsoleParser.UNION, CTagsConsoleParser.FUNCTION, CTagsConsoleParser.ENUM};
for (int i=0; i<types.length; i++){
//look for name
name = (String) tagExtensionField.get(types[i]);
if (name != null)
break;
}
if (name != null){
StringTokenizer st = new StringTokenizer(name, CTagsConsoleParser.COLONCOLON);
fullName = new char[st.countTokens() + 1][];
int i=0;
while (st.hasMoreTokens()){
fullName[i] = st.nextToken().toCharArray();
i++;
}
fullName[i] = elementName.toCharArray();
} else {
fullName = new char[1][];
fullName[0] = elementName.toCharArray();
}
return fullName;
}
public void addTagToIndexOutput(int fileNum, IIndexerOutput output){
String kind = (String) tagExtensionField.get(CTagsConsoleParser.KIND);
if (kind == null)
return;
char[][] fullName = getQualifiedName();
if (kind.equals(CTagsConsoleParser.CLASS)){
output.addClassDecl(fileNum, fullName, lineNumber, 1, IIndex.LINE);
} else if (kind.equals(CTagsConsoleParser.MACRO)){
output.addMacroDecl(fileNum, fullName, lineNumber, 1, IIndex.LINE);
} else if (kind.equals(CTagsConsoleParser.ENUMERATOR)){
output.addEnumtorDecl(fileNum, fullName, lineNumber, 1, IIndex.LINE);
} else if (kind.equals(CTagsConsoleParser.FUNCTION)){
output.addFunctionDefn(fileNum, fullName, lineNumber, 1, IIndex.LINE);
} else if (kind.equals(CTagsConsoleParser.ENUM)){
output.addEnumDecl(fileNum, fullName, lineNumber, 1, IIndex.LINE);
} else if (kind.equals(CTagsConsoleParser.MEMBER)){
output.addFieldDecl(fileNum, fullName, lineNumber, 1, IIndex.LINE);
} else if (kind.equals(CTagsConsoleParser.NAMESPACE)){
output.addNamespaceDecl(fileNum, fullName, lineNumber, 1, IIndex.LINE);
} else if (kind.equals(CTagsConsoleParser.PROTOTYPE)){
output.addFunctionDecl(fileNum, fullName, lineNumber, 1, IIndex.LINE);
} else if (kind.equals(CTagsConsoleParser.STRUCT)){
output.addStructDecl(fileNum, fullName, lineNumber, 1, IIndex.LINE);
} else if (kind.equals(CTagsConsoleParser.TYPEDEF)){
output.addTypedefDecl(fileNum, fullName, lineNumber, 1, IIndex.LINE);
} else if (kind.equals(CTagsConsoleParser.UNION)){
output.addUnionDecl(fileNum, fullName, lineNumber, 1, IIndex.LINE);
} else if (kind.equals(CTagsConsoleParser.VARIABLE)){
output.addVariableDecl(fileNum, fullName, lineNumber, 1, IIndex.LINE);
} else if (kind.equals(CTagsConsoleParser.EXTERNALVAR)){
}
}
}

View file

@ -54,6 +54,7 @@ public abstract class CTagsAddFileToIndex extends CTagsIndexRequest {
return false;
} finally {
monitor.exitWrite(); // free write lock
indexer.request(new CTagsSaveIndex(this.indexPath, indexer));
}
return true;
}

View file

@ -10,11 +10,7 @@
**********************************************************************/
package org.eclipse.cdt.internal.core.index.ctagsindexer;
import java.util.StringTokenizer;
import org.eclipse.cdt.core.IConsoleParser;
import org.eclipse.cdt.core.search.ICSearchConstants;
import org.eclipse.cdt.internal.core.index.IIndex;
import org.eclipse.cdt.internal.core.index.cindexstorage.IndexedFileEntry;
/**
@ -58,7 +54,7 @@ public class CTagsConsoleParser implements IConsoleParser {
public boolean processLine(String line) {
CTagEntry tempTag = new CTagEntry(this, line);
if (indexer != null)
encodeTag(tempTag);
tempTag.addTagToIndexOutput(getFileNumber(), indexer.getOutput());
return false;
}
@ -68,49 +64,6 @@ public class CTagsConsoleParser implements IConsoleParser {
return tempTag;
}
/**
* @param tempTag
*/
private void encodeTag(CTagEntry tempTag) {
String kind = (String)tempTag.tagExtensionField.get(KIND);
if (kind == null)
return;
char[][] fullName = getQualifiedName(tempTag);
ICSearchConstants.LimitTo type = ICSearchConstants.DECLARATIONS;
int lineNumber = Integer.parseInt( (String)tempTag.tagExtensionField.get(LINE) );
if (kind.equals(CLASS)){
indexer.getOutput().addClassDecl(getFileNumber(), fullName, lineNumber, 1, IIndex.LINE);
} else if (kind.equals(MACRO)){
indexer.getOutput().addMacroDecl(getFileNumber(), fullName, lineNumber, 1, IIndex.LINE);
} else if (kind.equals(ENUMERATOR)){
indexer.getOutput().addEnumtorDecl(getFileNumber(), fullName, lineNumber, 1, IIndex.LINE);
} else if (kind.equals(FUNCTION)){
indexer.getOutput().addFunctionDefn(getFileNumber(), fullName, lineNumber, 1, IIndex.LINE);
} else if (kind.equals(ENUM)){
indexer.getOutput().addEnumDecl(getFileNumber(), fullName, lineNumber, 1, IIndex.LINE);
} else if (kind.equals(MEMBER)){
indexer.getOutput().addFieldDecl(getFileNumber(), fullName, lineNumber, 1, IIndex.LINE);
} else if (kind.equals(NAMESPACE)){
indexer.getOutput().addNamespaceDecl(getFileNumber(), fullName, lineNumber, 1, IIndex.LINE);
} else if (kind.equals(PROTOTYPE)){
indexer.getOutput().addFunctionDecl(getFileNumber(), fullName, lineNumber, 1, IIndex.LINE);
} else if (kind.equals(STRUCT)){
indexer.getOutput().addStructDecl(getFileNumber(), fullName, lineNumber, 1, IIndex.LINE);
} else if (kind.equals(TYPEDEF)){
indexer.getOutput().addTypedefDecl(getFileNumber(), fullName, lineNumber, 1, IIndex.LINE);
} else if (kind.equals(UNION)){
indexer.getOutput().addUnionDecl(getFileNumber(), fullName, lineNumber, 1, IIndex.LINE);
} else if (kind.equals(VARIABLE)){
indexer.getOutput().addVariableDecl(getFileNumber(), fullName, lineNumber, 1, IIndex.LINE);
} else if (kind.equals(EXTERNALVAR)){
}
}
/**
* @return
*/
@ -123,38 +76,7 @@ public class CTagsConsoleParser implements IConsoleParser {
return fileNum;
}
/**
* @param tempTag
* @return
*/
public char[][] getQualifiedName(CTagEntry tempTag) {
char[][] fullName = null;
String name = null;
String[] types = {NAMESPACE, CLASS, STRUCT, UNION, FUNCTION, ENUM};
for (int i=0; i<types.length; i++){
//look for name
name = (String) tempTag.tagExtensionField.get(types[i]);
if (name != null)
break;
}
if (name != null){
StringTokenizer st = new StringTokenizer(name, COLONCOLON);
fullName = new char[st.countTokens() + 1][];
int i=0;
while (st.hasMoreTokens()){
fullName[i] = st.nextToken().toCharArray();
i++;
}
fullName[i] = tempTag.elementName.toCharArray();
} else {
fullName = new char[1][];
fullName[0] = tempTag.elementName.toCharArray();
}
return fullName;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.index.ctagsindexer.IConsoleParser#shutdown()

View file

@ -76,7 +76,7 @@ public class CTagsFileReader {
String fileName = tagEntry.fileName;
if (currentFileName == null ||
if (currentFileName == null ||
(!currentFileName.equals(fileName))){
currentFileName = fileName;
currentFile = (IFile) project.findMember(fileName);
@ -93,14 +93,10 @@ public class CTagsFileReader {
if (currentFile != null){
indexer = new MiniIndexer(currentFile);
index.add(currentFile,indexer);
//encode new tag in current file
char[][] fullName = parser.getQualifiedName(tagEntry);
//encode name
String lineNumber = (String) tagEntry.tagExtensionField.get(CTagsConsoleParser.LINE);
indexer.addToOutput(fullName,(String)tagEntry.tagExtensionField.get(CTagsConsoleParser.KIND), Integer.parseInt(lineNumber));
}
}
}
indexer.addToOutput(tagEntry);
}
} catch (IOException e){}
@ -116,44 +112,14 @@ public class CTagsFileReader {
public MiniIndexer(IFile currentFile) {
this.currentFile = currentFile;
}
public void addToOutput(char[][]fullName, String kind, int lineNumber){
if (kind == null)
return;
public void addToOutput(CTagEntry tagEntry){
IndexedFileEntry mainIndexFile = this.output.getIndexedFile(currentFile.getFullPath().toString());
int fileNum = 0;
if (mainIndexFile != null)
fileNum = mainIndexFile.getFileID();
if (kind.equals(CTagsConsoleParser.CLASS)){
output.addClassDecl(fileNum, fullName, lineNumber, 1, IIndex.LINE);
} else if (kind.equals(CTagsConsoleParser.MACRO)){
output.addMacroDecl(fileNum, fullName, lineNumber, 1, IIndex.LINE);
} else if (kind.equals(CTagsConsoleParser.ENUMERATOR)){
output.addEnumtorDecl(fileNum, fullName, lineNumber, 1, IIndex.LINE);
} else if (kind.equals(CTagsConsoleParser.FUNCTION)){
output.addFunctionDecl(fileNum, fullName, lineNumber, 1, IIndex.LINE);
} else if (kind.equals(CTagsConsoleParser.ENUM)){
output.addEnumDecl(fileNum, fullName, lineNumber, 1, IIndex.LINE);
} else if (kind.equals(CTagsConsoleParser.MEMBER)){
output.addFieldDecl(fileNum, fullName, lineNumber, 1, IIndex.LINE);
} else if (kind.equals(CTagsConsoleParser.NAMESPACE)){
output.addNamespaceDecl(fileNum, fullName, lineNumber, 1, IIndex.LINE);
} else if (kind.equals(CTagsConsoleParser.PROTOTYPE)){
output.addFunctionDecl(fileNum, fullName, lineNumber, 1, IIndex.LINE);
//type = ICSearchConstants.DEFINITIONS;
} else if (kind.equals(CTagsConsoleParser.STRUCT)){
output.addStructDecl(fileNum, fullName, lineNumber, 1, IIndex.LINE);
} else if (kind.equals(CTagsConsoleParser.TYPEDEF)){
output.addTypedefDecl(fileNum, fullName, lineNumber, 1, IIndex.LINE);
} else if (kind.equals(CTagsConsoleParser.UNION)){
output.addUnionDecl(fileNum, fullName, lineNumber, 1, IIndex.LINE);
} else if (kind.equals(CTagsConsoleParser.VARIABLE)){
output.addVariableDecl(fileNum, fullName, lineNumber, 1, IIndex.LINE);
} else if (kind.equals(CTagsConsoleParser.EXTERNALVAR)){
}
tagEntry.addTagToIndexOutput(fileNum, this.output);
}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.index.IIndexer#index(org.eclipse.cdt.internal.core.index.IDocument, org.eclipse.cdt.internal.core.index.IIndexerOutput)

View file

@ -36,12 +36,13 @@ import org.eclipse.core.runtime.Path;
*/
class CTagsIndexAll extends CTagsIndexRequest {
IProject project;
static String ctagsFile = CCorePlugin.getDefault().getStateLocation().append("tempctags").toOSString(); //$NON-NLS-1$
private String ctagsFile;
private String ctagsFileToUse;
public CTagsIndexAll(IProject project, CTagsIndexer indexer) {
super(project.getFullPath(), indexer);
this.project = project;
this.ctagsFile = CCorePlugin.getDefault().getStateLocation().append(project.getName() + ".ctags").toOSString(); //$NON-NLS-1$
}
public boolean equals(Object o) {

View file

@ -95,15 +95,13 @@ public class CTagsIndexerRunner extends AbstractIndexer {
OutputStream consoleErr = (sniffer == null ? cos : sniffer.getErrorStream());
IPath fileDirectory = resourceFile.getRawLocation().removeLastSegments(1);
//Process p = launcher.execute(fCompileCommand, args, setEnvironment(launcher), fWorkingDirectory);
Process p = launcher.execute(new Path("ctags"), args, null, fileDirectory); //$NON-NLS-1$
if (p != null) {
try {
// Close the input of the Process explicitely.
// We will never write to it.
p.getOutputStream().close();
} catch (IOException e) {
}
} catch (IOException e) {}
if (launcher.waitAndRead(consoleOut, consoleErr, new NullProgressMonitor()) != CommandLauncher.OK) {
errMsg = launcher.getErrorMessage();
}
@ -123,13 +121,7 @@ public class CTagsIndexerRunner extends AbstractIndexer {
}
}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.index.sourceindexer.AbstractIndexer#addMarkers(org.eclipse.core.resources.IFile, org.eclipse.core.resources.IFile, java.lang.Object, java.lang.Object)
*/
protected void addMarkers(IFile tempFile, IFile originator, Object problem, Object location) {
// TODO Auto-generated method stub
}
protected void addMarkers(IFile tempFile, IFile originator, Object problem, Object location) {}

View file

@ -9,11 +9,9 @@
* IBM Rational Software - Initial API and implementation
**********************************************************************/
package org.eclipse.cdt.ui.tests.IndexerView;
import org.eclipse.cdt.core.parser.util.ArrayUtil;
import org.eclipse.cdt.internal.core.index.IIndex;
import org.eclipse.cdt.internal.core.index.cindexstorage.Index;
//import org.eclipse.cdt.internal.core.index.cindexstorage.Index;
import org.eclipse.cdt.ui.CUIPlugin;
import org.eclipse.cdt.ui.browser.typeinfo.TypeInfoMessages;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.dialogs.IDialogSettings;
@ -38,8 +36,14 @@ import org.eclipse.swt.widgets.Text;
*/
public class FilterIndexerViewDialog extends Dialog {
private static String getStringDescription(int meta, int kind, int ref) {
return Index.getDescriptionOf(meta, kind, ref);
private static String getStringDescription(int index) {
return buttonNames[index];
}
private static String getUniqueStringDescription(int index) {
//return Index.getDescriptionOf(meta, kind, ref);
//return buttonNames[index] + new String(ICIndexStorageConstants.encodingTypes[iAllTypes[index][2]]);
return String.valueOf(index);
}
private static final int DECL_BUTTON_ID = 3;
private static final int REF_BUTTON_ID = 2;
@ -52,13 +56,15 @@ public class FilterIndexerViewDialog extends Dialog {
private static final String REF_BUTTON = "Ref"; //$NON-NLS-1$
private static final String BLANK_STRING = ""; //$NON-NLS-1$
private static final String PAGE_SIZE_ = "Page Size:"; //$NON-NLS-1$
private static final String TYPESELECTIONDIALOG_FILTERLABEL = "TypeSelectionDialog.filterLabel"; //$NON-NLS-1$
private static final String TYPESELECTIONDIALOG_DeclLABEL = "Declarations:"; //$NON-NLS-1$
private static final String TYPESELECTIONDIALOG_RefLABEL = "References:"; //$NON-NLS-1$
private static final String FILTER_INDEXER_RESULTS = "Filter Indexer Results"; //$NON-NLS-1$
private static final String SETTINGS = "Settings"; //$NON-NLS-1$
private static final String PAGE_SIZE = "PAGE_SIZE"; //$NON-NLS-1$
private static final String FILTER_TEXT = "Filter"; //$NON-NLS-1$
private String fFilter = BLANK_STRING; //$NON-NLS-1$
Text filterText = null;
private String pageSize = BLANK_STRING; //$NON-NLS-1$
private int pageSize = IndexerNodeParent.PAGE_SIZE;
Text pageSizeText = null;
protected boolean [] fFilterMatcher = new boolean [iAllTypes.length];
protected boolean[] groupedButtonSelections;
@ -125,7 +131,7 @@ public class FilterIndexerViewDialog extends Dialog {
{IIndex.TYPE, IIndex.TYPE_STRUCT, IIndex.DECLARATION},
{IIndex.TYPE, IIndex.TYPE_ENUM, IIndex.DECLARATION},
{IIndex.TYPE, IIndex.TYPE_UNION, IIndex.DECLARATION},
{IIndex.TYPE, IIndex.TYPE_DERIVED, Index.DECLARATION},
{IIndex.TYPE, IIndex.TYPE_DERIVED, IIndex.DECLARATION},
{IIndex.TYPE, IIndex.TYPE_FRIEND, IIndex.DECLARATION},
{IIndex.TYPE, IIndex.TYPE_FWD_CLASS, IIndex.DECLARATION},
{IIndex.TYPE, IIndex.TYPE_FWD_STRUCT, IIndex.DECLARATION},
@ -133,6 +139,32 @@ public class FilterIndexerViewDialog extends Dialog {
{IIndex.INCLUDE, IIndex.ANY, IIndex.REFERENCE}
};
private static String [] buttonNames = {
"Macro",
"Function",
"Namepace",
"Function",
"Namespace",
"Field",
"Enumtor",
"Method",
"Field",
"Enumtor",
"Method",
"Type",
"Typedef",
"Class",
"Variable",
"Struct",
"Enum",
"Union",
"Derived",
"Friend",
"Fwd Class",
"Fwd Struct",
"Fwd Union",
"Include"
};
// keep track of the buttons to programmatically change their state
protected Button[] buttons = new Button[iAllTypes.length];
protected Button allButton = null;
@ -225,7 +257,7 @@ public class FilterIndexerViewDialog extends Dialog {
* Creates a type filter checkbox.
*/
private void createTypeCheckbox(Composite parent, int type) {
String name = getStringDescription(iAllTypes[type][0], iAllTypes[type][1], iAllTypes[type][2]);
String name = getStringDescription(type);
Image icon = IndexerViewPluginImages.get(type);
Composite composite = new Composite(parent, SWT.NONE);
@ -243,10 +275,7 @@ public class FilterIndexerViewDialog extends Dialog {
public void widgetSelected(SelectionEvent e) {
if (e.widget instanceof Button) {
Button aCheckbox = (Button) e.widget;
if (aCheckbox.getSelection())
fFilterMatcher[type1] = true;
else
fFilterMatcher[type1] = false;
fFilterMatcher[type1] = aCheckbox.getSelection();
}
}
});
@ -255,7 +284,7 @@ public class FilterIndexerViewDialog extends Dialog {
label.setFont(composite.getFont());
label.setText(name);
buttons = (Button[])ArrayUtil.append(Button.class, buttons, checkbox);
buttons[type] = checkbox;
}
@ -266,8 +295,7 @@ public class FilterIndexerViewDialog extends Dialog {
* area to create controls in
*/
private void createTypeFilterArea(Composite parent) {
createLabel(parent, TypeInfoMessages
.getString(TYPESELECTIONDIALOG_FILTERLABEL));
createLabel(parent,TYPESELECTIONDIALOG_DeclLABEL);
Composite upperRow = new Composite(parent, SWT.NONE);
GridLayout upperLayout = new GridLayout(3, true);
@ -279,7 +307,20 @@ public class FilterIndexerViewDialog extends Dialog {
// the for loop is here to guarantee we always
// create the checkboxes in the same order
for (int i = 0; i < iAllTypes.length; ++i) {
createTypeCheckbox(upperRow, i);
if(iAllTypes[i][2] == IIndex.DECLARATION)
createTypeCheckbox(upperRow, i);
}
createLabel(parent,TYPESELECTIONDIALOG_RefLABEL);
Composite lowerRow = new Composite(parent, SWT.NONE);
lowerRow.setLayout(upperLayout);
// the for loop is here to guarantee we always
// create the checkboxes in the same order
for (int i = 0; i < iAllTypes.length; ++i) {
if(iAllTypes[i][2] == IIndex.REFERENCE)
createTypeCheckbox(lowerRow, i);
}
}
@ -309,8 +350,7 @@ public class FilterIndexerViewDialog extends Dialog {
// select/deselect all of the buttons in the buttons array
for(int i=0; i<buttons.length; i++) {
if (buttons[i]!=null) {
if (isChecked) buttons[i].setSelection(true);
else buttons[i].setSelection(false);
buttons[i].setSelection(isChecked);
event.widget = buttons[i];
buttons[i].notifyListeners(SWT.Selection, event);
}
@ -349,9 +389,8 @@ public class FilterIndexerViewDialog extends Dialog {
// select/deselect all of the buttons in the buttons array
for(int i=0; i<buttons.length; i++) {
if (buttons[i] != null) {
if (buttons[i].getText().indexOf(TYPE_BUTTON) >= 0) {
if (isChecked) buttons[i].setSelection(true);
else buttons[i].setSelection(false);
if (iAllTypes[i][0] == IIndex.TYPE) {
buttons[i].setSelection(isChecked);
event.widget = buttons[i];
buttons[i].notifyListeners(SWT.Selection, event);
}
@ -384,9 +423,8 @@ public class FilterIndexerViewDialog extends Dialog {
// select/deselect all of the buttons in the buttons array
for(int i=0; i<buttons.length; i++) {
if (buttons[i] != null) {
if (buttons[i].getText().indexOf(DECL_BUTTON) >= 0) {
if (isChecked) buttons[i].setSelection(true);
else buttons[i].setSelection(false);
if (iAllTypes[i][2] == IIndex.DECLARATION) {
buttons[i].setSelection(isChecked);
event.widget = buttons[i];
buttons[i].notifyListeners(SWT.Selection, event);
}
@ -419,9 +457,8 @@ public class FilterIndexerViewDialog extends Dialog {
// select/deselect all of the buttons in the buttons array
for(int i=0; i<buttons.length; i++) {
if (buttons[i] != null) {
if (buttons[i].getText().toUpperCase().indexOf(REF_BUTTON.toUpperCase()) >= 0) {
if (isChecked) buttons[i].setSelection(true);
else buttons[i].setSelection(false);
if (iAllTypes[i][2] == IIndex.REFERENCE) {
buttons[i].setSelection(isChecked);
event.widget = buttons[i];
buttons[i].notifyListeners(SWT.Selection, event);
}
@ -472,7 +509,7 @@ public class FilterIndexerViewDialog extends Dialog {
pageSizeText.setLayoutData(data);
pageSizeText.setFont(parent.getFont());
pageSizeText.setText((pageSize == null ? BLANK_STRING : pageSize));
pageSizeText.setText(String.valueOf(pageSize));
}
/**
@ -549,7 +586,7 @@ public class FilterIndexerViewDialog extends Dialog {
for(int i = 0; i < iAllTypes.length; i++) {
section.put(
getStringDescription(iAllTypes[i][0], iAllTypes[i][1], iAllTypes[i][2]),
getUniqueStringDescription(i),
fFilterMatcher[i] );
}
@ -559,6 +596,7 @@ public class FilterIndexerViewDialog extends Dialog {
section.put(DECL_BUTTON, groupedButtonSelections[DECL_BUTTON_ID]);
section.put(PAGE_SIZE, pageSize);
section.put(FILTER_TEXT, fFilter);
}
/**
@ -566,10 +604,11 @@ public class FilterIndexerViewDialog extends Dialog {
*/
protected void writeDefaultSettings(IDialogSettings section) {
for(int i = 0; i < iAllTypes.length; i++) {
String description = getStringDescription(iAllTypes[i][0], iAllTypes[i][1], iAllTypes[i][2]);
String description = getUniqueStringDescription(i);
section.put(description, true);
}
section.put(FILTER_TEXT, fFilter);
section.put(PAGE_SIZE, IndexerNodeParent.PAGE_SIZE);
}
@ -616,14 +655,14 @@ public class FilterIndexerViewDialog extends Dialog {
int height = section.getInt(SETTINGS_HEIGHT);
fSize = new Point(width, height);
pageSize = String.valueOf(section.getInt(PAGE_SIZE));
pageSize = section.getInt(PAGE_SIZE);
} catch (NumberFormatException e) {
fLocation = null;
fSize = null;
}
for(int i = 0; i < iAllTypes.length; i++) {
fFilterMatcher[i] = section.getBoolean(getStringDescription(iAllTypes[i][0], iAllTypes[i][1], iAllTypes[i][2]));
fFilterMatcher[i] = section.getBoolean(getUniqueStringDescription(i));
}
// get the grouped button selection status
@ -631,6 +670,9 @@ public class FilterIndexerViewDialog extends Dialog {
groupedButtonSelections[TYPE_BUTTON_ID] = section.getBoolean(TYPE_BUTTON);
groupedButtonSelections[REF_BUTTON_ID] = section.getBoolean(REF_BUTTON);
groupedButtonSelections[DECL_BUTTON_ID] = section.getBoolean(DECL_BUTTON);
fFilter = section.get(FILTER_TEXT);
if (fFilter == null)
fFilter = BLANK_STRING;
}
public IndexerFilterManager createFilterManager() {
@ -639,21 +681,20 @@ public class FilterIndexerViewDialog extends Dialog {
private void apply() {
fFilter = filterText.getText();
pageSize = pageSizeText.getText();
writeSettings(getDialogSettings());
root.setFilterManager(fFilterMatcher, fFilter);
int size=IndexerNodeParent.PAGE_SIZE;
pageSize=IndexerNodeParent.PAGE_SIZE;
try {
size = Integer.valueOf(pageSize).intValue();
if (size<=0) size=IndexerNodeParent.PAGE_SIZE;
pageSize = Integer.valueOf(pageSizeText.getText()).intValue();
if (pageSize<=0)
pageSize=IndexerNodeParent.PAGE_SIZE;
} catch (NumberFormatException e) {}
root.setPageSize(size);
root.setFilterManager(fFilterMatcher, fFilter);
root.setPageSize(pageSize);
root.reset();
writeSettings(getDialogSettings());
}
public String getPageSize() {
public int getPageSize() {
return pageSize;
}

View file

@ -10,15 +10,10 @@
**********************************************************************/
package org.eclipse.cdt.ui.tests.IndexerView;
import java.io.File;
import java.io.IOException;
import org.eclipse.cdt.core.browser.PathUtil;
import org.eclipse.cdt.core.parser.util.ArrayUtil;
import org.eclipse.cdt.internal.core.index.IEntryResult;
import org.eclipse.cdt.internal.core.index.cindexstorage.IndexedFileEntry;
import org.eclipse.cdt.internal.core.index.cindexstorage.io.BlocksIndexInput;
import org.eclipse.cdt.internal.core.index.cindexstorage.io.IndexInput;
import org.eclipse.cdt.internal.core.index.IIndex;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.ui.views.properties.IPropertyDescriptor;
import org.eclipse.ui.views.properties.IPropertySource;
@ -31,14 +26,18 @@ public class IndexerNodeLeaf implements IAdaptable {
private static final char EMPTY_SPACE = ' ';
private int filtersType=0;
IEntryResult result = null;
File indexFile = null;
private IEntryResult result = null;
private String [] fileMap = null;
public String[] getFileMap() {
return fileMap;
}
private IndexerNodeParent parent = null;
public IndexerNodeLeaf(IEntryResult result, File indexFile) {
public IndexerNodeLeaf(IEntryResult result, String[] fileMap) {
this.result = result;
this.indexFile = indexFile;
this.fileMap = fileMap;
if (result != null)
this.filtersType = IndexerView.getKey(result.getMetaKind(), result.getKind(), result.getRefKind());
}
@ -84,18 +83,14 @@ public class IndexerNodeLeaf implements IAdaptable {
TextPropertyDescriptor text = null;
IndexInput input = new BlocksIndexInput(indexFile);
try {
input.open();
// get the reference descriptors
int[] references = entryResult.getFileReferences();
if (references != null) {
for (int j = 0; j < references.length; ++j) {
IndexedFileEntry file = input.getIndexedFile(references[j]);
if (file != null && file.getPath() != null) {
String file = fileMap[references[j]];
if (file != null) {
String id = REFERENCE_NUMBER_ + String.valueOf(j);
text = new TextPropertyDescriptor(new TextDescriptorId(id, PathUtil.getWorkspaceRelativePath(file.getPath()).toOSString()), id);
text = new TextPropertyDescriptor(new TextDescriptorId(id, PathUtil.getWorkspaceRelativePath(file).toOSString()), id);
text.setCategory(REFERENCES);
descriptors = (IPropertyDescriptor[])ArrayUtil.append(IPropertyDescriptor.class, descriptors, text);
}
@ -127,15 +122,24 @@ public class IndexerNodeLeaf implements IAdaptable {
descriptors = (IPropertyDescriptor[])ArrayUtil.append(IPropertyDescriptor.class, descriptors, text);
}
}
// add a word descriptor
text = new TextPropertyDescriptor(new TextDescriptorId(IENTRYRESULT_GETWORD__, String.valueOf(entryResult.toString())), IENTRYRESULT_GETWORD__);
text = new TextPropertyDescriptor(new TextDescriptorId("MetaKind", entryResult.getStringMetaKind()), "MetaKind");
text.setCategory(IENTRYRESULT);
descriptors = (IPropertyDescriptor[])ArrayUtil.append(IPropertyDescriptor.class, descriptors, text);
} catch (IOException e) {
}
// add a word descriptor
if (entryResult.getMetaKind() == IIndex.TYPE) {
text = new TextPropertyDescriptor(new TextDescriptorId("TypeKind", entryResult.getStringKind()), "TypeKind");
text.setCategory(IENTRYRESULT);
descriptors = (IPropertyDescriptor[])ArrayUtil.append(IPropertyDescriptor.class, descriptors, text);
}
// add a word descriptor
text = new TextPropertyDescriptor(new TextDescriptorId("ReferenceKind", entryResult.getStringRefKind()), "ReferenceKind");
text.setCategory(IENTRYRESULT);
descriptors = (IPropertyDescriptor[])ArrayUtil.append(IPropertyDescriptor.class, descriptors, text);
return (IPropertyDescriptor[])ArrayUtil.trim(IPropertyDescriptor.class, descriptors);
}

View file

@ -10,7 +10,6 @@
**********************************************************************/
package org.eclipse.cdt.ui.tests.IndexerView;
import java.io.File;
import org.eclipse.cdt.core.parser.util.ArrayUtil;
import org.eclipse.cdt.internal.core.index.IEntryResult;
import org.eclipse.cdt.ui.testplugin.CTestPlugin;
@ -34,18 +33,15 @@ public class IndexerNodeParent extends IndexerNodeLeaf {
private boolean displayFullName=true;
private boolean navigate=false;
public IndexerNodeParent(IEntryResult result, File indexerFile, IndexerView.ViewContentProvider view) {
super(result, indexerFile);
public IndexerNodeParent(IEntryResult result, String [] fileMap, IndexerView.ViewContentProvider view) {
super(result, fileMap);
// create an IndexerFilterManager using the FilterIndexerViewDialog (since all of the work is done there anyways)
FilterIndexerViewDialog dialog = new FilterIndexerViewDialog(CTestPlugin.getStandardDisplay().getActiveShell(), this, view.getProjectName());
dialog.readSettings(dialog.getDialogSettings());
filterManager = dialog.createFilterManager();
try {
pageSize = Integer.valueOf(dialog.getPageSize()).intValue();
} catch (NumberFormatException e) {}
pageSize = dialog.getPageSize();
this.view = view;
}

View file

@ -10,17 +10,12 @@
**********************************************************************/
package org.eclipse.cdt.ui.tests.IndexerView;
import java.io.IOException;
import org.eclipse.cdt.core.browser.PathUtil;
import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.core.parser.util.ArrayUtil;
import org.eclipse.cdt.core.search.BasicSearchMatch;
import org.eclipse.cdt.core.search.IMatch;
import org.eclipse.cdt.internal.core.index.IEntryResult;
import org.eclipse.cdt.internal.core.index.cindexstorage.IndexedFileEntry;
import org.eclipse.cdt.internal.core.index.cindexstorage.io.BlocksIndexInput;
import org.eclipse.cdt.internal.core.index.cindexstorage.io.IndexInput;
import org.eclipse.cdt.internal.ui.search.CSearchQuery;
import org.eclipse.cdt.internal.ui.search.CSearchResult;
import org.eclipse.cdt.internal.ui.search.NewSearchResultCollector;
@ -84,7 +79,7 @@ public class IndexerQuery extends CSearchQuery implements ISearchQuery {
fileResource =tempResource;
else
fileResource = tempPath;
collector.acceptMatch( createMatch(fileResource, matches[i].getStart(),
collector.acceptMatch( createMatch(fileResource, matches[i].getOffsetType(), matches[i].getStart(),
matches[i].getEnd(), matches[i].getName(), matches[i].getPath()) );
}
} catch (CoreException ce) {}
@ -97,52 +92,50 @@ public class IndexerQuery extends CSearchQuery implements ISearchQuery {
}
private MatchInfo[] generateMatchInfo() {
IndexInput input = new BlocksIndexInput(leaf.indexFile);
String [] fileMap = leaf.getFileMap();
IEntryResult entryResult = leaf.getResult();
MatchInfo[] matches = new MatchInfo[DEFAULT_MATCH_INFO_SIZE];
try {
input.open();
int[] references = entryResult.getFileReferences();
int[][]offsets = entryResult.getOffsets();
int[][]offsetLengths = entryResult.getOffsetLengths();
if (offsets != null){
for (int j=0; j<offsets.length; j++){
for (int k=0; k<offsets[j].length; k++){
MatchInfo match = new MatchInfo();
if (references.length > j-1) {
IndexedFileEntry file = input.getIndexedFile(references[j]);
if (file != null){
IPath filePath = new Path(file.getPath());
//If we can verify that the file exists within the workspace, we'll use it
//to open the appropriate editor - if not we can just set the path and we'll
//use the external editor mechanism
IFile tempFile = ResourcesPlugin.getWorkspace().getRoot().getFile(filePath);
if (tempFile != null && tempFile.exists())
match.setResource(tempFile);
else {
match.setPath(PathUtil.getWorkspaceRelativePath(file.getPath()));
}
}
int[] references = entryResult.getFileReferences();
int[][]offsets = entryResult.getOffsets();
int[][]offsetLengths = entryResult.getOffsetLengths();
if (offsets != null){
for (int j=0; j<offsets.length; j++){
for (int k=0; k<offsets[j].length; k++){
MatchInfo match = new MatchInfo();
if (references.length > j-1) {
String file = fileMap[references[j]];
if (file != null){
IPath filePath = new Path(file);
//If we can verify that the file exists within the workspace, we'll use it
//to open the appropriate editor - if not we can just set the path and we'll
//use the external editor mechanism
IFile tempFile = ResourcesPlugin.getWorkspace().getRoot().getFile(filePath);
if (tempFile != null && tempFile.exists())
match.setResource(tempFile);
else {
match.setPath(PathUtil.getWorkspaceRelativePath(file));
}
}
int start=0;
int end=0;
try {
start=Integer.valueOf(String.valueOf(offsets[j][k]).substring(1)).intValue();
end=start+offsetLengths[j][k];
} catch (NumberFormatException nfe) {}
match.setStart(start) ;
match.setEnd(end);
match.setName(leaf.getName());
matches = (MatchInfo[])ArrayUtil.append(MatchInfo.class, matches, match);
}
int offsetType=0;
int start=0;
int end=0;
try {
offsetType=Integer.valueOf(String.valueOf(offsets[j][k]).substring(0,1)).intValue();
start=Integer.valueOf(String.valueOf(offsets[j][k]).substring(1)).intValue();
end=start+offsetLengths[j][k];
} catch (NumberFormatException nfe) {}
match.setOffsetType(offsetType);
match.setStart(start) ;
match.setEnd(end);
match.setName(leaf.getName());
matches = (MatchInfo[])ArrayUtil.append(MatchInfo.class, matches, match);
}
}
} catch (IOException e) {
}
return matches;
@ -150,6 +143,7 @@ public class IndexerQuery extends CSearchQuery implements ISearchQuery {
private class MatchInfo {
private IPath path=null;
private int offsetType=0;
private int start=0;
private int end=0;
private String name=null;
@ -158,7 +152,13 @@ public class IndexerQuery extends CSearchQuery implements ISearchQuery {
public IPath getPath() {
return path;
}
public void setPath(IPath path) {
public void setOffsetType(int offsetType){
this.offsetType=offsetType;
}
public int getOffsetType() {
return offsetType;
}
public void setPath(IPath path) {
this.path = path;
}
public int getEnd() {
@ -187,7 +187,7 @@ public class IndexerQuery extends CSearchQuery implements ISearchQuery {
}
}
public IMatch createMatch( Object fileResource, int start, int end, String name, IPath referringElement ) {
public IMatch createMatch( Object fileResource,int offsetType, int start, int end, String name, IPath referringElement ) {
BasicSearchMatch result = new BasicSearchMatch();
if( fileResource instanceof IResource )
result.resource = (IResource) fileResource;
@ -201,6 +201,8 @@ public class IndexerQuery extends CSearchQuery implements ISearchQuery {
result.name = name;
result.offsetType = offsetType;
result.type = ICElement.C_FIELD; // TODO Devin static for now, want something like BasicSearchResultCollector#setElementInfo
result.visibility = ICElement.CPP_PUBLIC; // TODO Devin static for now, want something like BasicSearchResultCollector#setElementInfo
result.returnType = BLANK_STRING;

View file

@ -127,12 +127,15 @@ public class IndexerView extends ViewPart {
try {
IEntryResult[] results = index.getEntries(IIndex.ANY, IIndex.ANY, IIndex.ANY );
if (results == null) return Status.CANCEL_STATUS;
String [] fileMap = index.getDocumentList();
int size = results.length;
IndexerNodeLeaf[] children = new IndexerNodeLeaf[size];
for(int j=0; j<size; j++) {
children[j] = new IndexerNodeLeaf(results[j], index.getIndexFile());
children[j] = new IndexerNodeLeaf(results[j], fileMap);
children[j].setParent(invisibleRoot);
}
@ -583,6 +586,7 @@ public class IndexerView extends ViewPart {
case IIndex.INCLUDE : return FilterIndexerViewDialog.ENTRY_INCLUDE_REF;
}
break;
case IIndex.DEFINITION :
case IIndex.DECLARATION :
switch (meta) {
case IIndex.TYPE :