diff --git a/core/org.eclipse.cdt.core.tests/indexer/org/eclipse/cdt/core/indexer/tests/DOMSourceIndexerTests.java b/core/org.eclipse.cdt.core.tests/indexer/org/eclipse/cdt/core/indexer/tests/DOMSourceIndexerTests.java index f7fccbd9949..5aa8e0607f9 100644 --- a/core/org.eclipse.cdt.core.tests/indexer/org/eclipse/cdt/core/indexer/tests/DOMSourceIndexerTests.java +++ b/core/org.eclipse.cdt.core.tests/indexer/org/eclipse/cdt/core/indexer/tests/DOMSourceIndexerTests.java @@ -172,7 +172,7 @@ public class DOMSourceIndexerTests extends TestCase implements IIndexChangeListe suite.addTest(new DOMSourceIndexerTests("testAddNewFileToIndex")); //$NON-NLS-1$ suite.addTest(new DOMSourceIndexerTests("testForwardDeclarations")); //$NON-NLS-1$ - suite.addTest(new FailingTest(new DOMSourceIndexerTests("testIndexAll"))); //$NON-NLS-1$ + suite.addTest(new DOMSourceIndexerTests("testIndexAll")); //$NON-NLS-1$ suite.addTest(new FailingTest(new DOMSourceIndexerTests("testIndexContents"))); //$NON-NLS-1$ suite.addTest(new DOMSourceIndexerTests("testMacros")); //$NON-NLS-1$ suite.addTest(new FailingTest(new DOMSourceIndexerTests("testRefs"))); //$NON-NLS-1$ @@ -228,26 +228,21 @@ public class DOMSourceIndexerTests extends TestCase implements IIndexChangeListe assertTrue("Entry Results exist", eresults != null); //$NON-NLS-1$ String [] queryResultModel = {"IndexedFile(1: /IndexerTestProject/mail.cpp)"}; //$NON-NLS-1$ - String [] entryResultModel ={"EntryResult: word=typeDecl/C/Mail, refs={ 1 }, offsets={ [ 294] }", //$NON-NLS-1$ + String [] entryResultModel ={"EntryResult: word=typeDefn/C/Mail, refs={ 1 }, offsets={ [ 294] }", //$NON-NLS-1$ "EntryResult: word=typeDefn/C/Unknown, refs={ 1 }, offsets={ [ 2738] }", //$NON-NLS-1$ "EntryResult: word=typeDefn/C/container, refs={ 1 }, offsets={ [ 21084] }", //$NON-NLS-1$ "EntryResult: word=typeDefn/C/first_class, refs={ 1 }, offsets={ [ 2506] }", //$NON-NLS-1$ "EntryResult: word=typeDefn/C/postcard, refs={ 1 }, offsets={ [ 2298] }", //$NON-NLS-1$ - "EntryResult: word=typeDefn/V/PO_Box, refs={ 1 }, offsets={ [ 21371] }", //$NON-NLS-1$ - "EntryResult: word=typeDefn/V/size, refs={ 1 }, offsets={ [ 21927] }", //$NON-NLS-1$ - "EntryResult: word=typeDefn/V/temp, refs={ 1 }, offsets={ [ 21964] }", //$NON-NLS-1$ - "EntryResult: word=typeDefn/V/x, refs={ 1 }, offsets={ [ 21201, 21526] }"}; //$NON-NLS-1$ + }; String [] entryResultDeclsModel = { "EntryResult: word=typeDecl/D/Mail, refs={ 1 }, offsets={ [ 294] }", //$NON-NLS-1$ "EntryResult: word=typeDecl/D/first_class, refs={ 1 }, offsets={ [ 2506] }", //$NON-NLS-1$ "EntryResult: word=typeDecl/D/postcard, refs={ 1 }, offsets={ [ 2298] }", //$NON-NLS-1$ - "EntryResult: word=typeDecl/V/index, refs={ 1 }, offsets={ [ 21303, 21846] }", //$NON-NLS-1$ - "EntryResult: word=typeDecl/V/mail, refs={ 1 }, offsets={ [ 21336, 21912] }", //$NON-NLS-1$ }; - String[] entryResultNameModel = {"Mail","Unknown","container","first_class","postcard","PO_Box","size","temp","x"}; + String[] entryResultNameModel = {"Mail","Unknown","container","first_class","postcard"}; int[] entryResultMetaModel = {IIndex.TYPE}; - int[] entryResultTypeModel = {IIndex.TYPE_CLASS,IIndex.TYPE_CLASS,IIndex.TYPE_CLASS,IIndex.TYPE_CLASS,IIndex.TYPE_CLASS, IIndex.TYPE_VAR, IIndex.TYPE_VAR, IIndex.TYPE_VAR, IIndex.TYPE_VAR}; + int[] entryResultTypeModel = {IIndex.TYPE_CLASS,IIndex.TYPE_CLASS,IIndex.TYPE_CLASS,IIndex.TYPE_CLASS,IIndex.TYPE_CLASS}; int[] entryResultRefModel = {IIndex.DEFINITION}; if (qresults.length != queryResultModel.length) @@ -386,7 +381,7 @@ public class DOMSourceIndexerTests extends TestCase implements IIndexChangeListe String[] entryResultNameModel = {"CDocumentManager","Mail","Unknown","container","first_class","postcard","PO_Box", "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_VAR, IIndex.TYPE_VAR, IIndex.TYPE_VAR, IIndex.TYPE_VAR}; + int[] entryResultTypeModel = {IIndex.TYPE_CLASS, IIndex.TYPE_CLASS,IIndex.TYPE_CLASS,IIndex.TYPE_CLASS,IIndex.TYPE_CLASS,IIndex.TYPE_CLASS, IIndex.TYPE, IIndex.TYPE, IIndex.VAR, IIndex.VAR}; int[] entryResultRefModel = {IIndex.DEFINITION}; if (eresults.length != entryResultNameModel.length) @@ -449,8 +444,8 @@ public class DOMSourceIndexerTests extends TestCase implements IIndexChangeListe String[] entryResultDefnNameModel = {"Mail/Y/X/Z", "Unknown/Y/X/Z", "container/Y/X/Z", "first_class/Y/X/Z", "postcard/Y/X/Z", "PO_Box", "size", "temp", "x", "x/Z" }; int[] entryResultMetaModel = {IIndex.TYPE}; int[] entryResultDefnTypeModel = {IIndex.TYPE_CLASS, IIndex.TYPE_CLASS, IIndex.TYPE_CLASS, IIndex.TYPE_CLASS, IIndex.TYPE_CLASS, - IIndex.TYPE_VAR,IIndex.TYPE_VAR,IIndex.TYPE_VAR,IIndex.TYPE_VAR,IIndex.TYPE_VAR}; - int[] entryResultDeclTypeModel = {IIndex.TYPE_DERIVED, IIndex.TYPE_DERIVED, IIndex.TYPE_DERIVED, IIndex.TYPE_ENUM, IIndex.TYPE_TYPEDEF,IIndex.TYPE_VAR,IIndex.TYPE_VAR}; + IIndex.VAR,IIndex.VAR,IIndex.VAR,IIndex.VAR,IIndex.VAR}; + int[] entryResultDeclTypeModel = {IIndex.TYPE_DERIVED, IIndex.TYPE_DERIVED, IIndex.TYPE_DERIVED, IIndex.TYPE_ENUM, IIndex.TYPE_TYPEDEF,IIndex.VAR,IIndex.VAR}; IEntryResult[] typedeclresults =ind.getEntries(IIndex.TYPE, IIndex.ANY, IIndex.DECLARATION); @@ -593,7 +588,7 @@ public class DOMSourceIndexerTests extends TestCase implements IIndexChangeListe String[] entryResultNameModel = {"C/B/A","ForwardA/A", "e1/B/A", "x/B/A"}; int[] entryResultMetaModel = {IIndex.TYPE}; - int[] entryResultTypeModel = {IIndex.TYPE_CLASS, IIndex.TYPE_CLASS, IIndex.TYPE_ENUM, IIndex.TYPE_VAR}; + int[] entryResultTypeModel = {IIndex.TYPE_CLASS, IIndex.TYPE_CLASS, IIndex.TYPE_ENUM, IIndex.VAR}; int[] entryResultRefModel = {IIndex.REFERENCE}; diff --git a/core/org.eclipse.cdt.core.tests/search/org/eclipse/cdt/core/search/tests/OtherPatternTests.java b/core/org.eclipse.cdt.core.tests/search/org/eclipse/cdt/core/search/tests/OtherPatternTests.java index 96222c559fe..fe700fd7830 100644 --- a/core/org.eclipse.cdt.core.tests/search/org/eclipse/cdt/core/search/tests/OtherPatternTests.java +++ b/core/org.eclipse.cdt.core.tests/search/org/eclipse/cdt/core/search/tests/OtherPatternTests.java @@ -65,16 +65,16 @@ public class OtherPatternTests extends BaseSearchTest { assertTrue( pattern instanceof FieldDeclarationPattern ); FieldDeclarationPattern variablePattern = (FieldDeclarationPattern)pattern; - assertEquals( getSearchPattern(IIndex.TYPE, IIndex.TYPE_VAR, IIndex.DECLARATION, "c"), variablePattern.indexEntryPrefix() ); //$NON-NLS-1$ + assertEquals( getSearchPattern(IIndex.VAR, IIndex.ANY, IIndex.DECLARATION, "c"), variablePattern.indexEntryPrefix() ); //$NON-NLS-1$ variablePattern = (FieldDeclarationPattern) SearchEngine.createSearchPattern( "rt*", VAR, DECLARATIONS, true ); //$NON-NLS-1$ - assertEquals( getSearchPattern(IIndex.TYPE, IIndex.TYPE_VAR, IIndex.DECLARATION, "rt"), variablePattern.indexEntryPrefix() ); //$NON-NLS-1$ + assertEquals( getSearchPattern(IIndex.VAR, IIndex.ANY, IIndex.DECLARATION, "rt"), variablePattern.indexEntryPrefix() ); //$NON-NLS-1$ variablePattern = (FieldDeclarationPattern) SearchEngine.createSearchPattern( "Ac", VAR, REFERENCES, false ); //$NON-NLS-1$ - assertEquals( getSearchPattern(IIndex.TYPE, IIndex.TYPE_VAR, IIndex.REFERENCE, ""), variablePattern.indexEntryPrefix() ); //$NON-NLS-1$ + assertEquals( getSearchPattern(IIndex.VAR, IIndex.ANY, IIndex.REFERENCE, ""), variablePattern.indexEntryPrefix() ); //$NON-NLS-1$ variablePattern = (FieldDeclarationPattern) SearchEngine.createSearchPattern( "A?c", VAR, REFERENCES, true ); //$NON-NLS-1$ - assertEquals( getSearchPattern(IIndex.TYPE, IIndex.TYPE_VAR, IIndex.REFERENCE, "A"), variablePattern.indexEntryPrefix() ); //$NON-NLS-1$ + assertEquals( getSearchPattern(IIndex.VAR, IIndex.ANY, IIndex.REFERENCE, "A"), variablePattern.indexEntryPrefix() ); //$NON-NLS-1$ } public void testFieldIndexPrefix(){ diff --git a/core/org.eclipse.cdt.core/browser/org/eclipse/cdt/internal/core/browser/cache/IndexerTypesJob2.java b/core/org.eclipse.cdt.core/browser/org/eclipse/cdt/internal/core/browser/cache/IndexerTypesJob2.java index 99c47798be8..974618cb9d6 100644 --- a/core/org.eclipse.cdt.core/browser/org/eclipse/cdt/internal/core/browser/cache/IndexerTypesJob2.java +++ b/core/org.eclipse.cdt.core/browser/org/eclipse/cdt/internal/core/browser/cache/IndexerTypesJob2.java @@ -107,23 +107,25 @@ public class IndexerTypesJob2 extends IndexerJob2 { } IEntryResult[] typeEntries = fProjectIndex.getEntries( IIndex.TYPE, IIndex.TYPE_DERIVED, IIndex.ANY ); - for( int j = 0; j < typeEntries.length; ++j ) - { - if (monitor.isCanceled()) - throw new InterruptedException(); - - IEntryResult entry = typeEntries[j]; - String name = entry.extractSimpleName(); - switch( entry.getKind() ) - { - case IIndex.TYPE_DERIVED : - if (name.length() != 0) { // skip anonymous structs - addSuperTypeReference(entry, name, entry.getEnclosingNames(), monitor); - } - break; - default: - break; - } + if (typeEntries != null){ + for( int j = 0; j < typeEntries.length; ++j ) + { + if (monitor.isCanceled()) + throw new InterruptedException(); + + IEntryResult entry = typeEntries[j]; + String name = entry.extractSimpleName(); + switch( entry.getKind() ) + { + case IIndex.TYPE_DERIVED : + if (name.length() != 0) { // skip anonymous structs + addSuperTypeReference(entry, name, entry.getEnclosingNames(), monitor); + } + break; + default: + break; + } + } } } diff --git a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/IIndex.java b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/IIndex.java index f26b1b63b9b..41ebb68a390 100644 --- a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/IIndex.java +++ b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/IIndex.java @@ -41,16 +41,16 @@ public interface IIndex { final static int NAMESPACE = 6; final static int ENUMTOR = 7; final static int INCLUDE = 8; + final static int VAR = 9; // kind final static int TYPE_CLASS = 1; final static int TYPE_STRUCT = 2; final static int TYPE_UNION = 3; final static int TYPE_ENUM = 4; - final static int TYPE_VAR = 5; - final static int TYPE_TYPEDEF = 6; - final static int TYPE_DERIVED = 7; - final static int TYPE_FRIEND = 8; + final static int TYPE_TYPEDEF = 5; + final static int TYPE_DERIVED = 6; + final static int TYPE_FRIEND = 7; // type diff --git a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/cindexstorage/ICIndexStorageConstants.java b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/cindexstorage/ICIndexStorageConstants.java index aee97a998b7..22fed60c0db 100644 --- a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/cindexstorage/ICIndexStorageConstants.java +++ b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/cindexstorage/ICIndexStorageConstants.java @@ -26,19 +26,6 @@ public interface ICIndexStorageConstants { final public static char SEPARATOR= '/'; - // TODO: Remove these constants. - static final public char CLASS_SUFFIX = 'C'; // CLASS - static final public char DERIVED_SUFFIX = 'D'; // DERIVED - static final public char ENUM_SUFFIX = 'E'; // ENUM - static final public char FRIEND_SUFFIX = 'F'; // FRIEND - static final public char FWD_CLASS_SUFFIX = 'G'; // FWD_CLASS - static final public char FWD_STRUCT_SUFFIX = 'H'; // FWD_STRUCT - static final public char FWD_UNION_SUFFIX = 'I'; // FWD_UNION - static final public char STRUCT_SUFFIX = 'S'; // STRUCT - static final public char TYPEDEF_SUFFIX = 'T'; // TYPEDEF - static final public char UNION_SUFFIX = 'U'; // UNION - static final public char VAR_SUFFIX = 'V'; // VAR - final static char [][] encodings = { "".toCharArray(), // not used //$NON-NLS-1$ "type".toCharArray(), // TYPES //$NON-NLS-1$ @@ -48,7 +35,8 @@ public interface ICIndexStorageConstants { "macro".toCharArray(), // MACROS //$NON-NLS-1$ "namespace".toCharArray(), // NAMESPACES //$NON-NLS-1$ "enumtor".toCharArray(), // ENUMERATORS //$NON-NLS-1$ - "include" .toCharArray() // INCLUDES //$NON-NLS-1$ + "include" .toCharArray(), // INCLUDES //$NON-NLS-1$ + "variable" .toCharArray() // VARIABLE //$NON-NLS-1$ }; final static char [][] encodingTypes = { @@ -62,8 +50,7 @@ public interface ICIndexStorageConstants { 'C', // CLASS 'S', // STRUCT 'U', // UNION - 'E', // ENUM - 'V', // VAR + 'E', // ENUM 'T', // TYPEDEF 'D', // DERIVED 'F' // FRIEND @@ -74,7 +61,6 @@ public interface ICIndexStorageConstants { "Struct", //$NON-NLS-1$ "Union", //$NON-NLS-1$ "Enum", //$NON-NLS-1$ - "Variable", //$NON-NLS-1$ "Typedef", //$NON-NLS-1$ "Derived", //$NON-NLS-1$ "Friend", //$NON-NLS-1$ diff --git a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/cindexstorage/Index.java b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/cindexstorage/Index.java index 5fa010168a0..f4fa5480456 100644 --- a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/cindexstorage/Index.java +++ b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/cindexstorage/Index.java @@ -488,19 +488,19 @@ public class Index implements IIndex, ICIndexStorageConstants, ICSearchConstants char classType = 0; if( searchFor == ICSearchConstants.CLASS ){ - classType = CLASS_SUFFIX; + classType = typeConstants[IIndex.TYPE_CLASS]; } else if ( searchFor == ICSearchConstants.STRUCT ){ - classType = STRUCT_SUFFIX; + classType = typeConstants[IIndex.TYPE_STRUCT]; } else if ( searchFor == ICSearchConstants.UNION ){ - classType = UNION_SUFFIX; + classType = typeConstants[IIndex.TYPE_UNION]; } else if ( searchFor == ICSearchConstants.ENUM ){ - classType = ENUM_SUFFIX; + classType = typeConstants[IIndex.TYPE_ENUM]; } else if ( searchFor == ICSearchConstants.TYPEDEF ){ - classType = TYPEDEF_SUFFIX; + classType = typeConstants[IIndex.TYPE_TYPEDEF]; } else if ( searchFor == ICSearchConstants.DERIVED){ - classType = DERIVED_SUFFIX; + classType = typeConstants[IIndex.TYPE_DERIVED]; } else if ( searchFor == ICSearchConstants.FRIEND){ - classType = FRIEND_SUFFIX; + classType = typeConstants[IIndex.TYPE_FRIEND]; } else { //could be TYPE or CLASS_STRUCT, best we can do for these is the prefix return prefix; @@ -525,16 +525,16 @@ public class Index implements IIndex, ICIndexStorageConstants, ICSearchConstants public static final char[] bestVariablePrefix( LimitTo limitTo, char[] varName, char[][] containingTypes, int matchMode, boolean isCaseSenstive ){ char [] prefix = null; if( limitTo == REFERENCES ){ - prefix = encodeEntry(IIndex.TYPE, ANY, REFERENCE); + prefix = encodeEntry(IIndex.VAR, ANY, REFERENCE); } else if( limitTo == DECLARATIONS ){ - prefix = encodeEntry(IIndex.TYPE, ANY, DECLARATION); + prefix = encodeEntry(IIndex.VAR, ANY, DECLARATION); } else if( limitTo == DEFINITIONS ){ - prefix = encodeEntry(IIndex.TYPE, ANY, DEFINITION); + prefix = encodeEntry(IIndex.VAR, ANY, DEFINITION); } else { - return encodeEntry(IIndex.TYPE, ANY, ANY); + return encodeEntry(IIndex.VAR, ANY, ANY); } - return bestPrefix( prefix, VAR_SUFFIX, varName, containingTypes, matchMode, isCaseSenstive ); + return bestPrefix( prefix, (char)0, varName, containingTypes, matchMode, isCaseSenstive ); } public static final char[] bestFieldPrefix( LimitTo limitTo, char[] fieldName,char[][] containingTypes, int matchMode, boolean isCaseSensitive) { diff --git a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/cindexstorage/IndexerOutput.java b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/cindexstorage/IndexerOutput.java index 488df1efc15..46678b03b6d 100644 --- a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/cindexstorage/IndexerOutput.java +++ b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/cindexstorage/IndexerOutput.java @@ -167,7 +167,12 @@ public class IndexerOutput implements ICIndexStorageConstants, IIndexerOutput { } //char[] has to be of size - [type length + length of the name (including qualifiers) + //separators (need one less than fully qualified name length) + try { pos = encodings[meta_kind].length + encodingTypes[ref].length; + } + catch (ArrayIndexOutOfBoundsException x) { + throw x; + } char[] result = new char[pos + nameLength + elementName.length - 1 ]; System.arraycopy(encodings[meta_kind], 0, result, 0, encodings[meta_kind].length); System.arraycopy(encodingTypes[ref], 0, result, encodings[meta_kind].length, encodingTypes[ref].length); @@ -226,7 +231,7 @@ public class IndexerOutput implements ICIndexStorageConstants, IIndexerOutput { baseClasses.length > 0){ for (int i=0; i