diff --git a/core/org.eclipse.cdt.core.tests/indexer/org/eclipse/cdt/core/indexer/tests/SourceIndexerTests.java b/core/org.eclipse.cdt.core.tests/indexer/org/eclipse/cdt/core/indexer/tests/SourceIndexerTests.java index 56bb417036f..4b48aaebd19 100644 --- a/core/org.eclipse.cdt.core.tests/indexer/org/eclipse/cdt/core/indexer/tests/SourceIndexerTests.java +++ b/core/org.eclipse.cdt.core.tests/indexer/org/eclipse/cdt/core/indexer/tests/SourceIndexerTests.java @@ -153,11 +153,11 @@ public class SourceIndexerTests extends TestCase implements IIndexChangeListener suite.addTest(new SourceIndexerTests("testAddNewFileToIndex")); //$NON-NLS-1$ suite.addTest(new SourceIndexerTests("testForwardDeclarations")); //$NON-NLS-1$ suite.addTest(new SourceIndexerTests("testIndexAll")); //$NON-NLS-1$ - //suite.addTest(new SourceIndexerTests("testIndexContents")); //$NON-NLS-1$ - //suite.addTest(new SourceIndexerTests("testMacros")); //$NON-NLS-1$ - //suite.addTest(new SourceIndexerTests("testRefs")); //$NON-NLS-1$ + suite.addTest(new SourceIndexerTests("testIndexContents")); //$NON-NLS-1$ + suite.addTest(new SourceIndexerTests("testMacros")); //$NON-NLS-1$ + suite.addTest(new SourceIndexerTests("testRefs")); //$NON-NLS-1$ suite.addTest(new SourceIndexerTests("testExactDeclarations")); //$NON-NLS-1$ - //suite.addTest(new SourceIndexerTests("testRemoveFileFromIndex")); //$NON-NLS-1$ + suite.addTest(new SourceIndexerTests("testRemoveFileFromIndex")); //$NON-NLS-1$ suite.addTest(new SourceIndexerTests("testRemoveProjectFromIndex")); //$NON-NLS-1$ suite.addTest(new SourceIndexerTests("testIndexShutdown")); //$NON-NLS-1$ @@ -326,15 +326,22 @@ public class SourceIndexerTests extends TestCase implements IIndexChangeListener IEntryResult[] eresults = ind.queryEntries(prefix); assertTrue("Entry result found for typdeDecl/", eresults != null); //$NON-NLS-1$ - String [] entryResultBeforeModel ={"EntryResult: word=typeDecl/C/CDocumentManager, refs={ 2 }", //$NON-NLS-1$ - "EntryResult: word=typeDecl/C/Mail, refs={ 3 }", "EntryResult: word=typeDecl/C/Unknown, refs={ 3 }", //$NON-NLS-1$ //$NON-NLS-2$ - "EntryResult: word=typeDecl/C/container, refs={ 3 }", "EntryResult: word=typeDecl/C/first_class, refs={ 3 }", //$NON-NLS-1$ //$NON-NLS-2$ - "EntryResult: word=typeDecl/C/postcard, refs={ 3 }", "EntryResult: word=typeDecl/D/Mail, refs={ 3 }", //$NON-NLS-1$ //$NON-NLS-2$ - "EntryResult: word=typeDecl/D/first_class, refs={ 3 }", "EntryResult: word=typeDecl/D/postcard, refs={ 3 }", //$NON-NLS-1$ //$NON-NLS-2$ - "EntryResult: word=typeDecl/V/, refs={ 1, 2 }", "EntryResult: word=typeDecl/V/PO_Box, refs={ 3 }", //$NON-NLS-1$ //$NON-NLS-2$ - "EntryResult: word=typeDecl/V/index, refs={ 3 }", "EntryResult: word=typeDecl/V/mail, refs={ 3 }", //$NON-NLS-1$ //$NON-NLS-2$ - "EntryResult: word=typeDecl/V/size, refs={ 3 }", "EntryResult: word=typeDecl/V/temp, refs={ 3 }", //$NON-NLS-1$ //$NON-NLS-2$ - "EntryResult: word=typeDecl/V/x, refs={ 3 }"}; //$NON-NLS-1$ //$NON-NLS-2$ + String [] entryResultBeforeModel ={"EntryResult: word=typeDecl/C/CDocumentManager, refs={ 2 }, offsets={ [ 2127] }", + "EntryResult: word=typeDecl/C/Mail, refs={ 3 }, offsets={ [ 294] }", + "EntryResult: word=typeDecl/C/Unknown, refs={ 3 }, offsets={ [ 2738] }", + "EntryResult: word=typeDecl/C/container, refs={ 3 }, offsets={ [ 21084] }", + "EntryResult: word=typeDecl/C/first_class, refs={ 3 }, offsets={ [ 2506] }", + "EntryResult: word=typeDecl/C/postcard, refs={ 3 }, offsets={ [ 2298] }", + "EntryResult: word=typeDecl/D/Mail, refs={ 3 }, offsets={ [ 294] }", + "EntryResult: word=typeDecl/D/first_class, refs={ 3 }, offsets={ [ 2506] }", + "EntryResult: word=typeDecl/D/postcard, refs={ 3 }, offsets={ [ 2298] }", + "EntryResult: word=typeDecl/V/PO_Box, refs={ 3 }, offsets={ [ 21371] }", + "EntryResult: word=typeDecl/V/index, refs={ 3 }, offsets={ [ 21303, 21846] }", + "EntryResult: word=typeDecl/V/mail, refs={ 3 }, offsets={ [ 21336, 21912] }", + "EntryResult: word=typeDecl/V/size, refs={ 3 }, offsets={ [ 21927] }", + "EntryResult: word=typeDecl/V/temp, refs={ 3 }, offsets={ [ 21964] }", + "EntryResult: word=typeDecl/V/x, refs={ 3 }, offsets={ [ 21201, 21526] }"}; + if (eresults.length != entryResultBeforeModel.length) fail("Entry Result length different from model"); //$NON-NLS-1$ @@ -356,7 +363,7 @@ public class SourceIndexerTests extends TestCase implements IIndexChangeListener eresults = ind.queryEntries(prefix); assertTrue("Entry exists", eresults != null); //$NON-NLS-1$ - String [] entryResultAfterModel ={"EntryResult: word=typeDecl/C/CDocumentManager, refs={ 2 }", "EntryResult: word=typeDecl/V/, refs={ 1, 2 }"}; //$NON-NLS-1$ //$NON-NLS-2$ + String [] entryResultAfterModel ={"EntryResult: word=typeDecl/C/CDocumentManager, refs={ 2 }, offsets={ [ 2127] }"}; //$NON-NLS-1$ //$NON-NLS-2$ if (eresults.length != entryResultAfterModel.length) fail("Entry Result length different from model"); //$NON-NLS-1$ @@ -379,15 +386,15 @@ public class SourceIndexerTests extends TestCase implements IIndexChangeListener IEntryResult[] typerefreesults = ind.queryEntries(IIndexConstants.TYPE_REF); assertTrue("Type Ref Results exist", typerefreesults != null); //$NON-NLS-1$ - String [] typeDeclEntryResultModel ={"EntryResult: word=typeDecl/C/Mail/Y/X/Z, refs={ 1 }, offsets={ [ 2329] }","EntryResult: word=typeDecl/C/Unknown/Y/X/Z, refs={ 1 }, offsets={ [ 21057] }", //$NON-NLS-1$ //$NON-NLS-2$ - "EntryResult: word=typeDecl/C/container/Y/X/Z, refs={ 1 }, offsets={ [ 21439] }","EntryResult: word=typeDecl/C/first_class/Y/X/Z, refs={ 1 }, offsets={ [ 2798] }", //$NON-NLS-1$ //$NON-NLS-2$ - "EntryResult: word=typeDecl/C/postcard/Y/X/Z, refs={ 1 }, offsets={ [ 2566] }","EntryResult: word=typeDecl/D/Mail/Y/X/Z, refs={ 1 }, offsets={ [ 2329] }", //$NON-NLS-1$ //$NON-NLS-2$ - "EntryResult: word=typeDecl/D/first_class/Y/X/Z, refs={ 1 }, offsets={ [ 2798] }", "EntryResult: word=typeDecl/D/postcard/Y/X/Z, refs={ 1 }, offsets={ [ 2566] }", //$NON-NLS-1$ //$NON-NLS-2$ - "EntryResult: word=typeDecl/E/test/Y/X/Z, refs={ 1 }, offsets={ [ 2297] }","EntryResult: word=typeDecl/T/int32, refs={ 1 }, offsets={ [ 2188] }", //$NON-NLS-1$ //$NON-NLS-2$ - "EntryResult: word=typeDecl/V/PO_Box, refs={ 1 }, offsets={ [ 21782] }","EntryResult: word=typeDecl/V/index, refs={ 1 }, offsets={ [ 21702, 22329] }", //$NON-NLS-1$ //$NON-NLS-2$ - "EntryResult: word=typeDecl/V/mail, refs={ 1 }, offsets={ [ 21736, 22396] }", "EntryResult: word=typeDecl/V/size, refs={ 1 }, offsets={ [ 22419] }", //$NON-NLS-1$ //$NON-NLS-2$ - "EntryResult: word=typeDecl/V/temp, refs={ 1 }, offsets={ [ 22459] }", "EntryResult: word=typeDecl/V/x, refs={ 1 }, offsets={ [ 21585, 21961] }", //$NON-NLS-1$ //$NON-NLS-2$ - "EntryResult: word=typeDecl/V/x/Z, refs={ 1 }, offsets={ [ 2255] }"}; //$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$ IEntryResult[] typedeclresults =ind.queryEntries(IIndexConstants.TYPE_DECL); assertTrue("Type Decl Results exist", typedeclresults != null); //$NON-NLS-1$ @@ -400,7 +407,7 @@ public class SourceIndexerTests extends TestCase implements IIndexChangeListener assertEquals(typeDeclEntryResultModel[i],typedeclresults[i].toString()); } - String [] typeDefEntryResultModel ={"EntryResult: word=typeDecl/T/int32, refs={ 1 }, offsets={ [ 2188] }"}; //$NON-NLS-1$ + String [] typeDefEntryResultModel ={"EntryResult: word=typeDecl/T/int32, refs={ 1 }, offsets={ [ 2200] }"}; //$NON-NLS-1$ IEntryResult[] typedefresults =ind.queryEntries(IIndexConstants.TYPEDEF_DECL); assertTrue("Type Def Results exist", typedefresults != null); //$NON-NLS-1$ @@ -412,8 +419,8 @@ public class SourceIndexerTests extends TestCase implements IIndexChangeListener assertEquals(typeDefEntryResultModel[i],typedefresults[i].toString()); } - String [] namespaceResultModel = {"EntryResult: word=namespaceDecl/X/Z, refs={ 1 }, offsets={ [ 2264] }", "EntryResult: word=namespaceDecl/Y/X/Z, refs={ 1 }, offsets={ [ 2280] }", //$NON-NLS-1$ //$NON-NLS-2$ - "EntryResult: word=namespaceDecl/Z, refs={ 1 }, offsets={ [ 2240] }"}; //$NON-NLS-1$ + 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$ IEntryResult[] namespaceresults =ind.queryEntries(IIndexConstants.NAMESPACE_DECL); assertTrue("Namespace Results exist", namespaceresults != null); //$NON-NLS-1$ @@ -426,9 +433,9 @@ public class SourceIndexerTests extends TestCase implements IIndexChangeListener assertEquals(namespaceResultModel[i],namespaceresults[i].toString()); } - String [] fieldResultModel = {"EntryResult: word=fieldDecl/array/container/Y/X/Z, refs={ 1 }, offsets={ [ 21478] }", "EntryResult: word=fieldDecl/index/container/Y/X/Z, refs={ 1 }, offsets={ [ 21478] }, EntryResult: word=fieldDecl/index/container/Y/X/Z, refs={ 1 }, offsets={ [ 21496] }", //$NON-NLS-1$ //$NON-NLS-2$ - "EntryResult: word=fieldDecl/postage/Mail/Y/X/Z, refs={ 1 }, offsets={ [ 2463] }", "EntryResult: word=fieldDecl/sz/container/Y/X/Z, refs={ 1 }, offsets={ [ 21511] }", //$NON-NLS-1$ //$NON-NLS-2$ - "EntryResult: word=fieldDecl/type/Mail/Y/X/Z, refs={ 1 }, offsets={ [ 2482] }"}; //$NON-NLS-1$ //$NON-NLS-2$ + 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$ IEntryResult[] fieldresults =ind.queryEntries(IIndexConstants.FIELD_DECL); assertTrue("Field Results exist", fieldresults != null); //$NON-NLS-1$ @@ -440,8 +447,8 @@ public class SourceIndexerTests extends TestCase implements IIndexChangeListener assertEquals(fieldResultModel[i],fieldresults[i].toString()); } - String [] enumeratorResultModel = {"EntryResult: word=enumtorDecl/bye/Y/X/Z, refs={ 1 }", "EntryResult: word=enumtorDecl/cool/Y/X/Z, refs={ 1 }", //$NON-NLS-1$ //$NON-NLS-2$ - "EntryResult: word=enumtorDecl/hi/Y/X/Z, refs={ 1 }", "EntryResult: word=enumtorDecl/why/Y/X/Z, refs={ 1 }"}; //$NON-NLS-1$ //$NON-NLS-2$ + 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] }"}; IEntryResult[] enumeratorresults =ind.queryEntries(IIndexConstants.ENUMTOR_DECL); assertTrue("Enumerator Results exist", enumeratorresults != null); //$NON-NLS-1$ @@ -454,7 +461,7 @@ public class SourceIndexerTests extends TestCase implements IIndexChangeListener assertEquals(enumeratorResultModel[i],enumeratorresults[i].toString()); } - String [] functionResultModel = {"EntryResult: word=functionDecl/doSomething, refs={ 1 }", "EntryResult: word=functionDecl/main/Y/X/Z, refs={ 1 }"}; //$NON-NLS-1$ //$NON-NLS-2$ + 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$ IEntryResult[] functionresults =ind.queryEntries(IIndexConstants.FUNCTION_DECL); if (functionresults.length != functionResultModel.length) @@ -465,13 +472,19 @@ public class SourceIndexerTests extends TestCase implements IIndexChangeListener assertEquals(functionResultModel[i],functionresults[i].toString()); } - String [] methodResultModel = {"EntryResult: word=methodDecl/Mail/Mail/Y/X/Z, refs={ 1 }", "EntryResult: word=methodDecl/Unknown/Unknown/Y/X/Z, refs={ 1 }", //$NON-NLS-1$ //$NON-NLS-2$ - "EntryResult: word=methodDecl/container/container/Y/X/Z, refs={ 1 }", "EntryResult: word=methodDecl/first_class/first_class/Y/X/Z, refs={ 1 }", //$NON-NLS-1$ //$NON-NLS-2$ - "EntryResult: word=methodDecl/operator =/container/Y/X/Z, refs={ 1 }","EntryResult: word=methodDecl/operator []/container/Y/X/Z, refs={ 1 }", //$NON-NLS-1$ //$NON-NLS-2$ - "EntryResult: word=methodDecl/postcard/postcard/Y/X/Z, refs={ 1 }", "EntryResult: word=methodDecl/print/Mail/Y/X/Z, refs={ 1 }", //$NON-NLS-1$ //$NON-NLS-2$ - "EntryResult: word=methodDecl/print/Unknown/Y/X/Z, refs={ 1 }", "EntryResult: word=methodDecl/print/first_class/Y/X/Z, refs={ 1 }", //$NON-NLS-1$ //$NON-NLS-2$ - "EntryResult: word=methodDecl/print/postcard/Y/X/Z, refs={ 1 }", "EntryResult: word=methodDecl/size/container/Y/X/Z, refs={ 1 }", //$NON-NLS-1$ //$NON-NLS-2$ - "EntryResult: word=methodDecl/~container/container/Y/X/Z, refs={ 1 }"}; //$NON-NLS-1$ + 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] }"}; @@ -497,8 +510,10 @@ public class SourceIndexerTests extends TestCase implements IIndexChangeListener 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 }", "EntryResult: word=typeRef/E/e1/B/A, refs={ 1 }", //$NON-NLS-1$ //$NON-NLS-2$ - "EntryResult: word=typeRef/G/ForwardA/A, refs={ 1 }", "EntryResult: word=typeRef/V/x/B/A, refs={ 1 }"}; //$NON-NLS-1$ //$NON-NLS-2$ + String [] typeRefEntryResultModel ={"EntryResult: word=typeRef/C/C/B/A, refs={ 1 }, offsets={ [ 2142] }", + "EntryResult: word=typeRef/E/e1/B/A, refs={ 1 }, offsets={ [ 2104] }", + "EntryResult: word=typeRef/G/ForwardA/A, refs={ 1 }, offsets={ [ 225] }", + "EntryResult: word=typeRef/V/x/B/A, refs={ 1 }, offsets={ [ 2128] }"}; IEntryResult[] typerefresults = ind.queryEntries(IIndexConstants.TYPE_REF); assertTrue("Entry exists",typerefresults != null); //$NON-NLS-1$ @@ -511,7 +526,7 @@ public class SourceIndexerTests extends TestCase implements IIndexChangeListener assertEquals(typeRefEntryResultModel[i],typerefresults[i].toString()); } - String [] funRefEntryResultModel ={"EntryResult: word=functionRef/something/A, refs={ 1 }"};//$NON-NLS-1$ + String [] funRefEntryResultModel ={"EntryResult: word=functionRef/something/A, refs={ 1 }, offsets={ [ 259] }"};//$NON-NLS-1$ IEntryResult[] funRefresults = ind.queryEntries(IIndexConstants.FUNCTION_REF); assertTrue("Entry exists",funRefresults != null); //$NON-NLS-1$ @@ -523,7 +538,7 @@ public class SourceIndexerTests extends TestCase implements IIndexChangeListener assertEquals(funRefEntryResultModel[i],funRefresults[i].toString()); } - String [] namespaceRefResultModel = {"EntryResult: word=namespaceRef/A, refs={ 1 }", "EntryResult: word=namespaceRef/B/A, refs={ 1 }"}; //$NON-NLS-1$ //$NON-NLS-2$ + String [] namespaceRefResultModel = {"EntryResult: word=namespaceRef/A, refs={ 1 }, offsets={ [ 210] }", "EntryResult: word=namespaceRef/B/A, refs={ 1 }, offsets={ [ 288] }"}; //$NON-NLS-1$ //$NON-NLS-2$ IEntryResult[] namespacerefresults = ind.queryEntries(IIndexConstants.NAMESPACE_REF); assertTrue("Entry exists",namespacerefresults!=null); //$NON-NLS-1$ @@ -535,7 +550,7 @@ public class SourceIndexerTests extends TestCase implements IIndexChangeListener assertEquals(namespaceRefResultModel[i],namespacerefresults[i].toString()); } - String [] fieldRefResultModel = {"EntryResult: word=fieldRef/y/C/B/A, refs={ 1 }"}; //$NON-NLS-1$ + String [] fieldRefResultModel = {"EntryResult: word=fieldRef/y/C/B/A, refs={ 1 }, offsets={ [ 2161] }"}; //$NON-NLS-1$ IEntryResult[] fieldrefresults = ind.queryEntries(IIndexConstants.FIELD_REF); assertTrue("Entry exists",fieldrefresults!=null); //$NON-NLS-1$ @@ -547,7 +562,7 @@ public class SourceIndexerTests extends TestCase implements IIndexChangeListener assertEquals(fieldRefResultModel[i],fieldrefresults[i].toString()); } - String [] methodRefResultModel = {"EntryResult: word=methodRef/bar/C/B/A, refs={ 1 }"}; //$NON-NLS-1$ + String [] methodRefResultModel = {"EntryResult: word=methodRef/bar/C/B/A, refs={ 1 }, offsets={ [ 2184] }"}; //$NON-NLS-1$ IEntryResult[] methodrefresults = ind.queryEntries(IIndexConstants.METHOD_REF); assertTrue("Entry exists", methodrefresults != null); //$NON-NLS-1$ @@ -643,9 +658,10 @@ public class SourceIndexerTests extends TestCase implements IIndexChangeListener IEntryResult[] macroresults = ind.queryEntries(IIndexConstants.MACRO_DECL); assertTrue("Entry exists", macroresults != null); //$NON-NLS-1$ - String [] macroResultModel = {"EntryResult: word=macroDecl/CASE, refs={ 1 }", "EntryResult: word=macroDecl/MAX, refs={ 1 }", //$NON-NLS-1$ //$NON-NLS-2$ - "EntryResult: word=macroDecl/PRINT, refs={ 1 }"}; //$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) fail("Entry Result length different from model for macros"); //$NON-NLS-1$ diff --git a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/core/index/ICDTIndexer.java b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/core/index/ICDTIndexer.java index 866edb192d5..2f176df3be3 100644 --- a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/core/index/ICDTIndexer.java +++ b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/core/index/ICDTIndexer.java @@ -128,4 +128,11 @@ public interface ICDTIndexer extends IIndexer { */ public IIndex getIndex(IPath path, boolean reuseExistingFile, boolean createIfMissing); + /** + * Called the index manager when a project changes its indexer to a new indexer. This can be + * used to clean up specific indexer properties. + * @param project + */ + public void indexerChangeNotification(IProject project); + } diff --git a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/ctagsindexer/CTagsFileReader.java b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/ctagsindexer/CTagsFileReader.java index b6a2ecd36a4..059026e4aa1 100644 --- a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/ctagsindexer/CTagsFileReader.java +++ b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/ctagsindexer/CTagsFileReader.java @@ -12,10 +12,12 @@ package org.eclipse.cdt.internal.core.index.ctagsindexer; import java.io.BufferedReader; +import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; import java.util.List; +import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.search.ICSearchConstants; import org.eclipse.cdt.internal.core.index.IIndex; import org.eclipse.cdt.internal.core.index.IIndexer; @@ -30,21 +32,37 @@ import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IProject; public class CTagsFileReader { + String filename = null; List list = null; IProject project; IIndex index; + CTagsIndexer indexer; - public CTagsFileReader(IProject project,String filename) { + public CTagsFileReader(IProject project,String filename, CTagsIndexer indexer) { this.filename = filename; this.project = project; + this.indexer = indexer; } - public void parse() throws IOException { - BufferedReader reader = new BufferedReader(new FileReader(filename)); + public void parse() { + BufferedReader reader = null; + try{ + reader = new BufferedReader(new FileReader(filename)); + } catch (FileNotFoundException ex){ + indexer.createProblemMarker(CCorePlugin.getResourceString("CTagsIndexMarker.fileMissing") + " - " + filename, project); //$NON-NLS-1$ //$NON-NLS-2$ + return; + } + CTagsHeader header = new CTagsHeader(); // Skip the header. - header.parse(reader); + + try { + header.parse(reader); + } catch (IOException e) { + indexer.createProblemMarker(e.getMessage(), project); + return; + } String s; String currentFileName = null; @@ -56,27 +74,29 @@ public class CTagsFileReader { if (index == null) return; - while ((s = reader.readLine()) != null) { - CTagEntry tagEntry = parser.processLineReturnTag(s); - - String fileName = tagEntry.fileName; - - if (currentFileName == null || - (!currentFileName.equals(fileName))){ - currentFileName = fileName; - currentFile = (IFile) project.findMember(fileName); - 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)); - } + try { + while ((s = reader.readLine()) != null) { + CTagEntry tagEntry = parser.processLineReturnTag(s); + + String fileName = tagEntry.fileName; + + if (currentFileName == null || + (!currentFileName.equals(fileName))){ + currentFileName = fileName; + currentFile = (IFile) project.findMember(fileName); + 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)); + } + } catch (IOException e){} } - + class MiniIndexer implements IIndexer, IIndexConstants { IIndexerOutput output; diff --git a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/ctagsindexer/CTagsHeader.java b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/ctagsindexer/CTagsHeader.java index ae57d8ce46e..5253d579b6b 100644 --- a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/ctagsindexer/CTagsHeader.java +++ b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/ctagsindexer/CTagsHeader.java @@ -20,7 +20,7 @@ public class CTagsHeader { final static String TAG_FILE_FORMAT = "!_TAG_FILE_FORMAT\t2\t/extended format; --format=1 will not append ;\" to lines/"; //$NON-NLS-1$ final static String TAG_FILE_SORTED = - "!_TAG_FILE_SORTED\t0\t/0=unsorted, 1=sorted/"; //$NON-NLS-1$ + "!_TAG_FILE_SORTED\t0\t/0=unsorted, 1=sorted, 2=foldcase/"; //$NON-NLS-1$ final static String TAG_PROGRAM_AUTHOR = "!_TAG_PROGRAM_AUTHOR\tDarren Hiebert\t/dhiebert@users.sourceforge.net/"; //$NON-NLS-1$ final static String TAG_PROGRAM_NAME = @@ -57,16 +57,15 @@ public class CTagsHeader { void parse (BufferedReader in) throws IOException { // !_TAG_FILE_FORMAT 2 /extended format; --format=1 will not append ;" to lines/ format = in.readLine(); - //If we care about verifying header info we can put this back in - /*if (format == null || !format.equals(TAG_FILE_FORMAT)) { - throw new IOException("Wrong Tag Format Header"); - }*/ + if (format == null || !format.equals(TAG_FILE_FORMAT)) { + throw new IOException("Wrong Tag Format Header: Needs to be --format=2"); //$NON-NLS-1$ + } // !_TAG_FILE_SORTED 0 /0=unsorted, 1=sorted/ sorted = in.readLine(); - /*if (sorted == null || !sorted.equals(TAG_FILE_SORTED)) { - throw new IOException("Wrong Tag Format Header"); - }*/ + if (sorted == null || !sorted.equals(TAG_FILE_SORTED)) { + throw new IOException("Wrong Tag Format Header: Sort needs to be --sort=no"); //$NON-NLS-1$ + } // !_TAG_PROGRAM_AUTHOR Darren Hiebert /dhiebert@users.sourceforge.net/ author = in.readLine(); @@ -76,20 +75,20 @@ public class CTagsHeader { // !_TAG_PROGRAM_NAME Exuberant Ctags // name = in.readLine(); - /*if (name == null || !name.equals(TAG_PROGRAM_NAME)) { - throw new IOException("Wrong Tag Format Header"); - }*/ + if (name == null || !name.equals(TAG_PROGRAM_NAME)) { + throw new IOException("Wrong Tag Format Header: Must use Exuberant Ctags"); //$NON-NLS-1$ + } // !_TAG_PROGRAM_URL http://ctags.sourceforge.net /official site/ url = in.readLine(); /*if (url == null || !url.equals(TAG_PROGRAM_URL)) { - throw new IOException("Wrong Tag Format Header"); + throw new IOException("Wrong Tag Format Header"); //$NON-NLS-1$ }*/ - // !_TAG_PROGRAM_VERSION 5.2.3 // + // !_TAG_PROGRAM_VERSION 5.5.4 // version = in.readLine(); /*if (version == null || !version.equals(TAG_PROGRAM_VERSION)) { - throw new IOException("Wrong Tag Format Header"); + throw new IOException("Wrong Tag Format Header: Need Exuberant CTags 5.5.4"); //$NON-NLS-1$ }*/ } diff --git a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/ctagsindexer/CTagsIndexAll.java b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/ctagsindexer/CTagsIndexAll.java index 1e00563f517..175175f7938 100644 --- a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/ctagsindexer/CTagsIndexAll.java +++ b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/ctagsindexer/CTagsIndexAll.java @@ -15,6 +15,7 @@ import java.io.IOException; import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.CommandLauncher; +import org.eclipse.cdt.core.model.ICModelMarker; import org.eclipse.cdt.internal.core.index.IIndex; import org.eclipse.cdt.internal.core.index.sourceindexer.AbstractIndexer; import org.eclipse.cdt.internal.core.index.sourceindexer.CIndexStorage; @@ -22,6 +23,8 @@ import org.eclipse.cdt.internal.core.search.indexing.IndexManager; import org.eclipse.cdt.internal.core.search.indexing.ReadWriteMonitor; import org.eclipse.cdt.internal.core.search.processing.JobManager; import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.Path; @@ -31,7 +34,7 @@ import org.eclipse.core.runtime.Path; */ class CTagsIndexAll extends CTagsIndexRequest { IProject project; - static String ctagsFile = CCorePlugin.getDefault().getStateLocation().toOSString() + "\\tempctags"; //$NON-NLS-1$ + static String ctagsFile = CCorePlugin.getDefault().getStateLocation().append("tempctags").toOSString(); //$NON-NLS-1$ public CTagsIndexAll(IProject project, CTagsIndexer indexer) { super(project.getFullPath(), indexer); @@ -67,6 +70,11 @@ class CTagsIndexAll extends CTagsIndexRequest { //Timing support long startTime=0, cTagsEndTime=0, endTime=0; + //Remove any existing problem markers + try { + project.deleteMarkers(ICModelMarker.INDEXER_MARKER, true,IResource.DEPTH_ZERO); + } catch (CoreException e) {} + if (AbstractIndexer.TIMING) startTime = System.currentTimeMillis(); @@ -81,7 +89,7 @@ class CTagsIndexAll extends CTagsIndexRequest { if (success) { //Parse the CTag File - CTagsFileReader reader = new CTagsFileReader(project,ctagsFile); + CTagsFileReader reader = new CTagsFileReader(project,ctagsFile,indexer); reader.setIndex(index); reader.parse(); @@ -113,8 +121,7 @@ class CTagsIndexAll extends CTagsIndexRequest { * @return */ private boolean runCTags() { - String[] args = {"ctags", //$NON-NLS-1$ - "--excmd=number", //$NON-NLS-1$ + String[] args = {"--excmd=number", //$NON-NLS-1$ "--format=2", //$NON-NLS-1$ "--sort=no", //$NON-NLS-1$ "--fields=aiKlmnsz", //$NON-NLS-1$ @@ -136,12 +143,17 @@ class CTagsIndexAll extends CTagsIndexRequest { IPath fileDirectory = project.getLocation(); //Process p = launcher.execute(fCompileCommand, args, setEnvironment(launcher), fWorkingDirectory); - Process p = launcher.execute(new Path(""), args, null, fileDirectory); //$NON-NLS-1$ + Process p = launcher.execute(new Path("ctags"), args, null, fileDirectory); //$NON-NLS-1$ p.waitFor(); } catch (InterruptedException e) { return false; } + catch (NullPointerException e){ + //CTags not installed + indexer.createProblemMarker(CCorePlugin.getResourceString("CTagsIndexMarker.CTagsMissing"), project); //$NON-NLS-1$ + return false; + } return true; } @@ -157,5 +169,5 @@ class CTagsIndexAll extends CTagsIndexRequest { public String toString() { return "indexing project " + this.project.getFullPath(); //$NON-NLS-1$ } - + } diff --git a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/ctagsindexer/CTagsIndexer.java b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/ctagsindexer/CTagsIndexer.java index 9348e184864..83704fe1bc8 100644 --- a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/ctagsindexer/CTagsIndexer.java +++ b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/ctagsindexer/CTagsIndexer.java @@ -18,6 +18,7 @@ import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.ICLogConstants; import org.eclipse.cdt.core.index.ICDTIndexer; import org.eclipse.cdt.core.index.IIndexStorage; +import org.eclipse.cdt.core.model.ICModelMarker; import org.eclipse.cdt.internal.core.index.IIndex; import org.eclipse.cdt.internal.core.index.IIndexerOutput; import org.eclipse.cdt.internal.core.index.sourceindexer.CIndexStorage; @@ -25,8 +26,11 @@ import org.eclipse.cdt.internal.core.search.indexing.IndexManager; import org.eclipse.cdt.internal.core.search.indexing.ReadWriteMonitor; import org.eclipse.cdt.internal.core.search.processing.IIndexJob; import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IMarker; import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.IResourceDelta; +import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IPath; /** @@ -324,6 +328,46 @@ public class CTagsIndexer extends AbstractCExtension implements ICDTIndexer { this.indexAll(project); } + protected void createProblemMarker(String message, IProject project){ + + try { + IMarker[] markers = project.findMarkers(ICModelMarker.INDEXER_MARKER, true,IResource.DEPTH_ZERO); + + boolean newProblem = true; + + if (markers.length > 0) { + IMarker tempMarker = null; + String tempMsgString = null; + + for (int i=0; i 0) { - //initializeIndexerId(); - for (int i = 0; i < cext.length; i++) { - String id = cext[i].getID(); - //if (cext[i].getID().equals(parserID)) { - String orig = cext[i].getExtensionData("indexenabled"); //$NON-NLS-1$ - String indexEnabled = getIndexerEnabledString(); - if (orig == null || !orig.equals(indexEnabled)) { - cext[i].setExtensionData("indexenabled", indexEnabled); //$NON-NLS-1$ - } - //} - } - } - } /*else { - Preferences store = null; - if (container != null){ - store = container.getPreferences(); - } - - if (store != null) { - String indexEnabled = getIndexerEnabledString(); - String indexMarkers = getIndexerProblemsValuesString(); - store.setValue(PREF_INDEX_ENABLED, indexEnabled); - store.setValue(PREF_INDEX_MARKERS, indexMarkers); - } - } - - boolean indexProject = getIndexerValue(); - - if ((indexProject != oldIndexerValue) - && (currentProject != null) - && indexProject) { - ICDTIndexer indexer = CCorePlugin.getDefault().getCoreModel().getIndexManager().getIndexerForProject(currentProject); - if (indexer instanceof SourceIndexer) - ((SourceIndexer) indexer).indexAll(currentProject); - }*/ + } - /* (non-Javadoc) * @see org.eclipse.cdt.ui.dialogs.ICOptionPage#performDefaults() */ public void performDefaults() { - // TODO Auto-generated method stub - } - /* (non-Javadoc) * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite) */ public void createControl(Composite parent) { - Composite page = ControlFactory.createComposite(parent, 1); - - Group group = ControlFactory.createGroup(page,"CTags Indexer",1); //$NON-NLS-1$ - - GridData gd = (GridData) group.getLayoutData(); - gd.grabExcessHorizontalSpace = true; - gd.horizontalAlignment = GridData.FILL; - - indexerEnabled = ControlFactory.createCheckBox(group, "Enable Indexing" ); //$NON-NLS-1$ - + Composite page = ControlFactory.createComposite(parent, 1); setControl(page); } - public void loadPersistedValues(IProject project) throws CoreException { - - ICDescriptor cdesc = CCorePlugin.getDefault().getCProjectDescription(project, false); - ICExtensionReference[] cext = cdesc.get(CCorePlugin.INDEXER_UNIQ_ID); - if (cext.length > 0) { - for (int i = 0; i < cext.length; i++) { - String id = cext[i].getID(); - String orig = cext[i].getExtensionData("indexenabled"); //$NON-NLS-1$ - if (orig != null){ - Boolean tempBool = new Boolean(orig); - oldIndexerValue = tempBool.booleanValue(); - } - } - } - } - - private String getIndexerEnabledString(){ - if (indexerEnabled.getSelection()) - return "true"; //$NON-NLS-1$ - - return "false"; //$NON-NLS-1$ - } - + }