From f20ffd5b51ae738513d531dd22fd8fda77343010 Mon Sep 17 00:00:00 2001 From: Bogdan Gheorghe Date: Tue, 7 Jun 2005 17:48:18 +0000 Subject: [PATCH] Fix for 92296 (Source Indexer doesn't encode definitions) Fix fo 92628 (Definitions missing in new Search Engine) Got rid of FWD_CLASS, FWD_STRUCT and FWD_UNION encodings (updated all 3 indexers) Updated Indexer View (got rid of FWD declarations) --- .../core/indexer/tests/DependencyTests.java | 2 +- .../indexer/tests/SourceIndexerTests.java | 139 ++++++++++-------- .../tests/ast2/CodeReaderCacheTest.java | 1 + .../cdt/core/tests/SearchRegressionTests.java | 73 +++++---- .../tests/ClassDeclarationPatternTests.java | 36 +++-- .../core/search/tests/OtherPatternTests.java | 18 +-- .../eclipse/cdt/core/index/ICDTIndexer.java | 17 +++ .../cdt/internal/core/index/IIndex.java | 4 +- .../ICIndexStorageConstants.java | 8 +- .../core/index/cindexstorage/Index.java | 19 ++- .../core/index/ctagsindexer/CTagEntry.java | 4 +- .../core/index/ctagsindexer/CTagsIndexer.java | 67 ++++++++- .../CGenerateIndexVisitor.java | 4 +- .../CPPGenerateIndexVisitor.java | 6 +- .../IndexerOutputWrapper.java | 21 --- .../core/index/nullindexer/NullIndexer.java | 16 ++ .../index/sourceindexer/SourceIndexer.java | 25 ++++ .../sourceindexer/SourceIndexerRequestor.java | 4 +- .../sourceindexer/SourceIndexerRunner.java | 97 ++++++++++-- .../core/search/indexing/IndexManager.java | 35 +++++ .../cdt/core/search/ICSearchConstants.java | 5 - .../core/search/matching/CSearchPattern.java | 11 +- .../matching/ClassDeclarationPattern.java | 25 +--- .../search/matching/DerivedTypesPattern.java | 2 +- .../core/search/matching/FriendPattern.java | 2 +- .../IndexerView/FilterIndexerViewDialog.java | 11 +- .../cdt/ui/tests/IndexerView/IndexerView.java | 3 - .../cdt/internal/ui/search/CSearchPage.java | 9 +- 28 files changed, 411 insertions(+), 253 deletions(-) diff --git a/core/org.eclipse.cdt.core.tests/indexer/org/eclipse/cdt/core/indexer/tests/DependencyTests.java b/core/org.eclipse.cdt.core.tests/indexer/org/eclipse/cdt/core/indexer/tests/DependencyTests.java index 621fac82895..182ae4c511e 100644 --- a/core/org.eclipse.cdt.core.tests/indexer/org/eclipse/cdt/core/indexer/tests/DependencyTests.java +++ b/core/org.eclipse.cdt.core.tests/indexer/org/eclipse/cdt/core/indexer/tests/DependencyTests.java @@ -592,7 +592,7 @@ import org.eclipse.core.runtime.Platform; testProject.setSessionProperty(SourceIndexer.activationKey,new Boolean(true)); - ICSearchPattern pattern = SearchEngine.createSearchPattern( "Z", ICSearchConstants.TYPE, ICSearchConstants.DECLARATIONS, true ); + ICSearchPattern pattern = SearchEngine.createSearchPattern( "Z", ICSearchConstants.TYPE, ICSearchConstants.DEFINITIONS, true ); search(workspace,pattern,scope,resultCollector); 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 66e273c9476..8ea1ed495e4 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 @@ -198,33 +198,35 @@ public class SourceIndexerTests extends TestCase implements IIndexChangeListener IIndex ind = sourceIndexer.getIndex(testProject.getFullPath(),true,true); assertTrue("Index exists for project",ind != null); //$NON-NLS-1$ - IQueryResult[] qresults = ind.getPrefix(IIndex.TYPE, IIndex.ANY, IIndex.DECLARATION); - IEntryResult[] eresults = ind.getEntries(IIndex.TYPE, IIndex.ANY, IIndex.DECLARATION); + IQueryResult[] qresults = ind.getPrefix(IIndex.TYPE, IIndex.ANY, IIndex.DEFINITION); + IEntryResult[] eresults = ind.getEntries(IIndex.TYPE, IIndex.ANY, IIndex.DEFINITION); + IEntryResult[] eresultsDecls = ind.getEntries(IIndex.TYPE, IIndex.ANY, IIndex.DECLARATION); assertTrue("Query Results exist", qresults != null); //$NON-NLS-1$ 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$ - "EntryResult: word=typeDecl/C/Unknown, refs={ 1 }, offsets={ [ 2738] }", //$NON-NLS-1$ - "EntryResult: word=typeDecl/C/container, refs={ 1 }, offsets={ [ 21084] }", //$NON-NLS-1$ - "EntryResult: word=typeDecl/C/first_class, refs={ 1 }, offsets={ [ 2506] }", //$NON-NLS-1$ - "EntryResult: word=typeDecl/C/postcard, refs={ 1 }, offsets={ [ 2298] }", //$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/PO_Box, refs={ 1 }, offsets={ [ 21371] }", //$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$ - "EntryResult: word=typeDecl/V/size, refs={ 1 }, offsets={ [ 21927] }", //$NON-NLS-1$ - "EntryResult: word=typeDecl/V/temp, refs={ 1 }, offsets={ [ 21964] }", //$NON-NLS-1$ - "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"}; + }; + String[] entryResultNameModel = {"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_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}; + 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[] entryResultRefModel = {IIndex.DEFINITION}; if (qresults.length != queryResultModel.length) fail("Query Result length different from model"); //$NON-NLS-1$ @@ -232,6 +234,9 @@ public class SourceIndexerTests extends TestCase implements IIndexChangeListener if (eresults.length != entryResultModel.length) fail("Entry Result length different from model"); //$NON-NLS-1$ + if (eresultsDecls.length != entryResultDeclsModel.length) + fail("Entry Result length different from model"); //$NON-NLS-1$ + for (int i=0; iIndexManager will send out a jobFinishedEvent to the indexer that * had scheduled the previous runnign job to give that indexer a chance to update its @@ -141,4 +157,5 @@ public interface ICDTIndexer extends IIndexer { */ public void indexerRemoved(IProject project); + } 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 75a1f034596..2379013c38e 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 @@ -51,9 +51,7 @@ public interface IIndex { final static int TYPE_TYPEDEF = 6; final static int TYPE_DERIVED = 7; final static int TYPE_FRIEND = 8; - final static int TYPE_FWD_CLASS = 9; - final static int TYPE_FWD_STRUCT = 10; - final static int TYPE_FWD_UNION = 11; + // type final static int UNKNOWN = 0; 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 7fbed8938c9..aee97a998b7 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 @@ -66,10 +66,7 @@ public interface ICIndexStorageConstants { 'V', // VAR 'T', // TYPEDEF 'D', // DERIVED - 'F', // FRIEND - 'G', // FWD_CLASS - 'H', // FWD_STRUCT - 'I' // FWD_UNION + 'F' // FRIEND }; final static String[] typeConstantNames = { "", // not used //$NON-NLS-1$ @@ -81,9 +78,6 @@ public interface ICIndexStorageConstants { "Typedef", //$NON-NLS-1$ "Derived", //$NON-NLS-1$ "Friend", //$NON-NLS-1$ - "FWD Class", //$NON-NLS-1$ - "FWD Struct", //$NON-NLS-1$ - "FWD Union" //$NON-NLS-1$ }; final static String[] allSpecifiers = {"", //not used //$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 400a6c716cd..eb8ec9ab86f 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 @@ -477,6 +477,8 @@ public class Index implements IIndex, ICIndexStorageConstants, ICSearchConstants char [] prefix = null; if( limitTo == DECLARATIONS ){ prefix = encodeEntry(IIndex.TYPE, ANY, DECLARATION); + } else if (limitTo == DEFINITIONS){ + prefix = encodeEntry(IIndex.TYPE, ANY, DEFINITION); } else if( limitTo == REFERENCES ){ prefix = encodeEntry(IIndex.TYPE, ANY, REFERENCE); } else { @@ -499,12 +501,6 @@ public class Index implements IIndex, ICIndexStorageConstants, ICSearchConstants classType = DERIVED_SUFFIX; } else if ( searchFor == ICSearchConstants.FRIEND){ classType = FRIEND_SUFFIX; - } else if ( searchFor == ICSearchConstants.FWD_CLASS) { - classType = FWD_CLASS_SUFFIX; - } else if ( searchFor == ICSearchConstants.FWD_STRUCT) { - classType = FWD_STRUCT_SUFFIX; - } else if ( searchFor == ICSearchConstants.FWD_UNION) { - classType = FWD_UNION_SUFFIX; } else { //could be TYPE or CLASS_STRUCT, best we can do for these is the prefix return prefix; @@ -517,8 +513,8 @@ public class Index implements IIndex, ICIndexStorageConstants, ICSearchConstants char [] prefix = null; if( limitTo == REFERENCES ){ prefix = encodeEntry(IIndex.NAMESPACE, ANY, REFERENCE); - } else if ( limitTo == DECLARATIONS ) { - prefix = encodeEntry(IIndex.NAMESPACE, ANY, DECLARATION); + } else if ( limitTo == DEFINITIONS ) { + prefix = encodeEntry(IIndex.NAMESPACE, ANY, DEFINITION); } else { return encodeEntry(IIndex.NAMESPACE, ANY, ANY); } @@ -532,6 +528,8 @@ public class Index implements IIndex, ICIndexStorageConstants, ICSearchConstants prefix = encodeEntry(IIndex.TYPE, ANY, REFERENCE); } else if( limitTo == DECLARATIONS ){ prefix = encodeEntry(IIndex.TYPE, ANY, DECLARATION); + } else if( limitTo == DEFINITIONS ){ + prefix = encodeEntry(IIndex.TYPE, ANY, DEFINITION); } else { return encodeEntry(IIndex.TYPE, ANY, ANY); } @@ -545,6 +543,8 @@ public class Index implements IIndex, ICIndexStorageConstants, ICSearchConstants prefix = encodeEntry(IIndex.FIELD, ANY, REFERENCE); } else if( limitTo == DECLARATIONS ){ prefix = encodeEntry(IIndex.FIELD, ANY, DECLARATION); + } else if( limitTo == DEFINITIONS ){ + prefix = encodeEntry(IIndex.FIELD, ANY, DEFINITION); } else { return encodeEntry(IIndex.FIELD, ANY, ANY); } @@ -576,8 +576,7 @@ public class Index implements IIndex, ICIndexStorageConstants, ICSearchConstants } else if( limitTo == DECLARATIONS ){ prefix = encodeEntry(IIndex.METHOD, ANY, DECLARATION); } else if( limitTo == DEFINITIONS ){ - //TODO prefix = METHOD_DEF; - return encodeEntry(IIndex.METHOD, ANY, ANY); + return encodeEntry(IIndex.METHOD, ANY, DEFINITION); } else { return encodeEntry(IIndex.METHOD, ANY, ANY); } diff --git a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/ctagsindexer/CTagEntry.java b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/ctagsindexer/CTagEntry.java index 4352e922346..8093d757cc9 100644 --- a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/ctagsindexer/CTagEntry.java +++ b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/ctagsindexer/CTagEntry.java @@ -162,11 +162,11 @@ class CTagEntry{ typeEntry.setNameOffset(lineNumber, 1, IIndex.LINE); typeEntry.serialize(output); } else if (kind.equals(CTagsConsoleParser.MEMBER)){ - NamedEntry namedEntry = new NamedEntry(IIndex.FIELD, IIndex.DECLARATION,fullName,getModifiers(),fileNum); + NamedEntry namedEntry = new NamedEntry(IIndex.FIELD, IIndex.DEFINITION,fullName,getModifiers(),fileNum); namedEntry.setNameOffset(lineNumber, 1, IIndex.LINE); namedEntry.serialize(output); } else if (kind.equals(CTagsConsoleParser.NAMESPACE)){ - NamedEntry namedEntry = new NamedEntry(IIndex.NAMESPACE, IIndex.DECLARATION,fullName,getModifiers(),fileNum); + NamedEntry namedEntry = new NamedEntry(IIndex.NAMESPACE, IIndex.DEFINITION,fullName,getModifiers(),fileNum); namedEntry.setNameOffset(lineNumber, 1, IIndex.LINE); namedEntry.serialize(output); } else if (kind.equals(CTagsConsoleParser.PROTOTYPE)){ 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 41452fcf2c2..36ba4b95658 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 @@ -15,6 +15,7 @@ import java.io.OutputStream; import java.util.ArrayList; import java.util.Collections; import java.util.HashSet; +import java.util.Iterator; import java.util.List; import org.eclipse.cdt.core.AbstractCExtension; @@ -37,10 +38,12 @@ 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.IFolder; 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.resources.IResourceVisitor; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IProgressMonitor; @@ -97,9 +100,10 @@ public class CTagsIndexer extends AbstractCExtension implements ICDTIndexer { this.indexAll(project); break; - /*case ICDTIndexer.FOLDER: - this.indexSourceFolder(element.getCProject().getProject(),element.getPath(),null); - break;*/ + case ICDTIndexer.FOLDER: + IFolder folder = (IFolder) delta.getResource(); + this.indexSourceFolder(project,folder); + break; case ICDTIndexer.COMPILATION_UNIT: @@ -115,6 +119,26 @@ public class CTagsIndexer extends AbstractCExtension implements ICDTIndexer { } + public void indexSourceFolder(IProject project, IFolder folder) { + + final HashSet indexables = new HashSet(); + try { + folder.accept(new IResourceVisitor(){ + public boolean visit(IResource resource) throws CoreException { + if (resource instanceof IFile) + indexables.add(resource); + + return true; + } + }); + } catch (CoreException e) {} + + Iterator i = indexables.iterator(); + while (i.hasNext()){ + this.addSource((IFile) i.next(), project.getFullPath()); + } + } + /** * @param project */ @@ -149,7 +173,7 @@ public class CTagsIndexer extends AbstractCExtension implements ICDTIndexer { IFile file = (IFile) delta.getResource(); this.remove(file.getFullPath().toString(), file.getProject().getFullPath()); break; - } + } } /* (non-Javadoc) @@ -509,4 +533,39 @@ public class CTagsIndexer extends AbstractCExtension implements ICDTIndexer { public void shutdown() {} } + public void addResource(IProject project, IResource resource) { + + if (resource instanceof IProject){ + this.indexAll(project); + } + else if (resource instanceof IFolder){ + IFolder folder = (IFolder) resource; + this.indexSourceFolder(project,folder); + } + else if (resource instanceof IFile){ + IFile file = (IFile) resource; + this.addSource(file, project.getFullPath()); + } + else { + this.indexAll(project); + } + + } + + public void removeResource(IProject project, IResource resource) { + if (resource instanceof IProject){ + IPath fullPath = project.getFullPath(); + indexManager.discardJobs(fullPath.segment(0)); + indexStorage.removeIndexFamily(fullPath); + } + else if (resource instanceof IFile){ + IFile file = (IFile) resource; + this.remove(file.getFullPath().toString(), file.getProject().getFullPath()); + } + } + + public void addResourceByPath(IProject project, IPath path, int resourceType) { + //Nothing yet + } + } diff --git a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/domsourceindexer/CGenerateIndexVisitor.java b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/domsourceindexer/CGenerateIndexVisitor.java index 218d91a26db..8b2de166e34 100644 --- a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/domsourceindexer/CGenerateIndexVisitor.java +++ b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/domsourceindexer/CGenerateIndexVisitor.java @@ -162,12 +162,12 @@ public class CGenerateIndexVisitor extends CASTVisitor { case ICompositeType.k_struct: iEntryType = IIndex.TYPE_STRUCT; if (name.isDeclaration() && prop == IASTElaboratedTypeSpecifier.TYPE_NAME) - iEntryType = IIndex.TYPE_FWD_STRUCT; + iEntryType = IIndex.TYPE_STRUCT; break; case ICompositeType.k_union: iEntryType = IIndex.TYPE_UNION; if (name.isDeclaration() && prop == IASTElaboratedTypeSpecifier.TYPE_NAME) - iEntryType = IIndex.TYPE_FWD_UNION; + iEntryType = IIndex.TYPE_UNION; break; } int modifiers = 0; diff --git a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/domsourceindexer/CPPGenerateIndexVisitor.java b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/domsourceindexer/CPPGenerateIndexVisitor.java index 7d346ac40af..efb2b3efcbe 100644 --- a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/domsourceindexer/CPPGenerateIndexVisitor.java +++ b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/domsourceindexer/CPPGenerateIndexVisitor.java @@ -188,19 +188,19 @@ public class CPPGenerateIndexVisitor extends CPPASTVisitor { case ICPPClassType.k_class: iEntryType = IIndex.TYPE_CLASS; if (name.isDeclaration() && prop == IASTElaboratedTypeSpecifier.TYPE_NAME) { - iEntryType = IIndex.TYPE_FWD_CLASS; + iEntryType = IIndex.TYPE_CLASS; } break; case ICompositeType.k_struct: iEntryType = IIndex.TYPE_STRUCT; if (name.isDeclaration() && prop == IASTElaboratedTypeSpecifier.TYPE_NAME) { - iEntryType = IIndex.TYPE_FWD_STRUCT; + iEntryType = IIndex.TYPE_STRUCT; } break; case ICompositeType.k_union: iEntryType = IIndex.TYPE_UNION; if (name.isDeclaration() && prop == IASTElaboratedTypeSpecifier.TYPE_NAME) { - iEntryType = IIndex.TYPE_FWD_UNION; + iEntryType = IIndex.TYPE_UNION; } break; } diff --git a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/domsourceindexer/IndexerOutputWrapper.java b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/domsourceindexer/IndexerOutputWrapper.java index bb56aa5f9aa..ed1b7451588 100644 --- a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/domsourceindexer/IndexerOutputWrapper.java +++ b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/domsourceindexer/IndexerOutputWrapper.java @@ -43,9 +43,6 @@ class IndexerOutputWrapper { private final static int TYPEDEF_CONST = 6; private final static int DERIVED_CONST = 7; private final static int FRIEND_CONST = 8; - private final static int FWD_CLASS_CONST = 9; - private final static int FWD_STRUCT_CONST = 10; - private final static int FWD_UNION_CONST = 11; private final static int NAMESPACE_CONST = 12; private final static int ENUMERATOR_CONST = 13; private final static int FIELD_CONST = 14; @@ -64,9 +61,6 @@ class IndexerOutputWrapper { final static EntryType TYPEDEF = new EntryType(TYPEDEF_CONST); final static EntryType DERIVED = new EntryType(DERIVED_CONST); final static EntryType FRIEND = new EntryType(FRIEND_CONST); - final static EntryType FWD_CLASS = new EntryType(FWD_CLASS_CONST); - final static EntryType FWD_STRUCT = new EntryType(FWD_STRUCT_CONST); - final static EntryType FWD_UNION = new EntryType(FWD_UNION_CONST); final static EntryType NAMESPACE = new EntryType(NAMESPACE_CONST); final static EntryType ENUMERATOR = new EntryType(ENUMERATOR_CONST); final static EntryType FIELD = new EntryType(FIELD_CONST); @@ -139,21 +133,6 @@ class IndexerOutputWrapper { typeEntry.setNameOffset(offset, length, offsetType); typeEntry.serialize(indexerOutput); break; - case FWD_CLASS_CONST: - typeEntry = new TypeEntry(IIndex.TYPE_FWD_CLASS ,entryKind, name, 0 /*getModifiers()*/, fileNumber); - typeEntry.setNameOffset(offset, length, offsetType); - typeEntry.serialize(indexerOutput); - break; - case FWD_STRUCT_CONST: - typeEntry = new TypeEntry(IIndex.TYPE_FWD_STRUCT ,entryKind, name, 0 /*getModifiers()*/, fileNumber); - typeEntry.setNameOffset(offset, length, offsetType); - typeEntry.serialize(indexerOutput); - break; - case FWD_UNION_CONST: - typeEntry = new TypeEntry(IIndex.TYPE_FWD_UNION ,entryKind, name, 0 /*getModifiers()*/, fileNumber); - typeEntry.setNameOffset(offset, length, offsetType); - typeEntry.serialize(indexerOutput); - break; case NAMESPACE_CONST: namedEntry = new NamedEntry(IIndex.NAMESPACE, entryKind, name, 0 /*getModifiers()*/, fileNumber); namedEntry.setNameOffset(offset, length, offsetType); diff --git a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/nullindexer/NullIndexer.java b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/nullindexer/NullIndexer.java index e2e1cd53f37..9b9ae260d64 100644 --- a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/nullindexer/NullIndexer.java +++ b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/nullindexer/NullIndexer.java @@ -12,6 +12,7 @@ import org.eclipse.cdt.internal.core.index.impl.IndexDelta; import org.eclipse.cdt.internal.core.search.processing.IIndexJob; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.IResourceDelta; import org.eclipse.core.runtime.IPath; @@ -87,4 +88,19 @@ public class NullIndexer extends AbstractCExtension implements ICDTIndexer { } + public void addResource(IProject project, IResource resource) { + // TODO Auto-generated method stub + + } + + public void removeResource(IProject project, IResource resource) { + // TODO Auto-generated method stub + + } + + public void addResourceByPath(IProject project, IPath path, int resourceType) { + // TODO Auto-generated method stub + + } + } diff --git a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/sourceindexer/SourceIndexer.java b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/sourceindexer/SourceIndexer.java index e685009c7c0..aa5bdd13609 100644 --- a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/sourceindexer/SourceIndexer.java +++ b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/sourceindexer/SourceIndexer.java @@ -36,6 +36,7 @@ import org.eclipse.cdt.internal.core.search.indexing.ReadWriteMonitor; import org.eclipse.cdt.internal.core.search.processing.IIndexJob; import org.eclipse.cdt.internal.core.sourcedependency.UpdateDependency; import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IFolder; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.IResourceDelta; @@ -628,5 +629,29 @@ public class SourceIndexer extends AbstractCExtension implements ICDTIndexer { public void indexerRemoved(IProject project) { removeIndexerProblems(project); } + + public void addResource(IProject project, IResource resource) { + + if (resource instanceof IProject){ + this.indexAll(project); + } + else if (resource instanceof IFolder){ + this.indexSourceFolder(project,resource.getFullPath(),null); + } + else if (resource instanceof IFile){ + IFile file = (IFile) resource; + this.addSource(file, project.getFullPath()); + } + } + + public void removeResource(IProject project, IResource resource) { + // TODO Auto-generated method stub + + } + + public void addResourceByPath(IProject project, IPath path, int resourceType) { + // TODO Auto-generated method stub + + } } diff --git a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/sourceindexer/SourceIndexerRequestor.java b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/sourceindexer/SourceIndexerRequestor.java index f95562c85ab..ef1e5f32295 100644 --- a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/sourceindexer/SourceIndexerRequestor.java +++ b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/sourceindexer/SourceIndexerRequestor.java @@ -172,7 +172,7 @@ public class SourceIndexerRequestor implements ISourceElementRequestor { //or if it occurs in another file int indexFlag = calculateIndexFlags(); - indexer.addFunctionDeclaration(function,indexFlag); + indexer.addFunctionDefinition(function,indexFlag); } @@ -235,7 +235,7 @@ public class SourceIndexerRequestor implements ISourceElementRequestor { //or if it occurs in another file int indexFlag = calculateIndexFlags(); - indexer.addMethodDeclaration(method, indexFlag); + indexer.addMethodDefinition(method, indexFlag); } public void exitMethodBody(IASTMethod method) {} diff --git a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/sourceindexer/SourceIndexerRunner.java b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/sourceindexer/SourceIndexerRunner.java index a5af376a943..3d58f185335 100644 --- a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/sourceindexer/SourceIndexerRunner.java +++ b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/sourceindexer/SourceIndexerRunner.java @@ -21,6 +21,8 @@ import java.util.ArrayList; import java.util.Iterator; import java.util.List; +import javax.naming.Name; + import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.ICLogConstants; import org.eclipse.cdt.core.index.IIndexDelta; @@ -52,6 +54,7 @@ import org.eclipse.cdt.core.parser.ast.IASTFieldReference; import org.eclipse.cdt.core.parser.ast.IASTFunction; import org.eclipse.cdt.core.parser.ast.IASTFunctionReference; import org.eclipse.cdt.core.parser.ast.IASTInclusion; +import org.eclipse.cdt.core.parser.ast.IASTInitializerClause; import org.eclipse.cdt.core.parser.ast.IASTMacro; import org.eclipse.cdt.core.parser.ast.IASTMethod; import org.eclipse.cdt.core.parser.ast.IASTMethodReference; @@ -313,7 +316,7 @@ public class SourceIndexerRunner extends AbstractIndexer { int offset = classSpecification.getNameOffset(); int offsetLength = classSpecification.getNameEndOffset() - offset; - TypeEntry typeEntry = new TypeEntry(IIndex.TYPE_CLASS,IIndex.DECLARATION, classSpecification.getFullyQualifiedNameCharArrays(), 0 /*getModifiers()*/, fileNumber); + TypeEntry typeEntry = new TypeEntry(IIndex.TYPE_CLASS,IIndex.DEFINITION, classSpecification.getFullyQualifiedNameCharArrays(), 0 /*getModifiers()*/, fileNumber); typeEntry.setNameOffset(offset, offsetLength, IIndex.OFFSET); //typeEntry.setBaseTypes(getInherits()); typeEntry.serialize(output); @@ -374,7 +377,7 @@ public class SourceIndexerRunner extends AbstractIndexer { int offset = classSpecification.getNameOffset(); int offsetLength = classSpecification.getNameEndOffset() - offset; - TypeEntry typeEntry = new TypeEntry(IIndex.TYPE_STRUCT,IIndex.DECLARATION, classSpecification.getFullyQualifiedNameCharArrays(), 0 /*getModifiers()*/, fileNumber); + TypeEntry typeEntry = new TypeEntry(IIndex.TYPE_STRUCT,IIndex.DEFINITION, classSpecification.getFullyQualifiedNameCharArrays(), 0 /*getModifiers()*/, fileNumber); typeEntry.setNameOffset(offset, offsetLength, IIndex.OFFSET); //typeEntry.setBaseTypes(getInherits()); typeEntry.serialize(output); @@ -384,7 +387,7 @@ public class SourceIndexerRunner extends AbstractIndexer { int offset = classSpecification.getNameOffset(); int offsetLength = classSpecification.getNameEndOffset() - offset; - TypeEntry typeEntry = new TypeEntry(IIndex.TYPE_UNION,IIndex.DECLARATION, classSpecification.getFullyQualifiedNameCharArrays(), 0 /*getModifiers()*/, fileNumber); + TypeEntry typeEntry = new TypeEntry(IIndex.TYPE_UNION,IIndex.DEFINITION, classSpecification.getFullyQualifiedNameCharArrays(), 0 /*getModifiers()*/, fileNumber); typeEntry.setNameOffset(offset,offsetLength, IIndex.OFFSET); //typeEntry.setBaseTypes(getInherits()); typeEntry.serialize(output); @@ -461,9 +464,17 @@ public class SourceIndexerRunner extends AbstractIndexer { public void addVariable(IASTVariable variable, int fileNumber) { int offset = variable.getNameOffset(); int offsetLength = variable.getNameEndOffset() - offset; - - TypeEntry typeEntry = new TypeEntry(IIndex.TYPE_VAR ,IIndex.DECLARATION, variable.getFullyQualifiedNameCharArrays(), 0 /*getModifiers()*/, fileNumber); - typeEntry.setNameOffset(offset, offsetLength, IIndex.OFFSET); + + IASTInitializerClause initClause = variable.getInitializerClause(); + TypeEntry typeEntry; + if ((variable.isExtern() && initClause == null )|| + variable.isStatic()){ + typeEntry = new TypeEntry(IIndex.TYPE_VAR ,IIndex.DECLARATION, variable.getFullyQualifiedNameCharArrays(), 0 /*getModifiers()*/, fileNumber); + } else { + typeEntry = new TypeEntry(IIndex.TYPE_VAR ,IIndex.DEFINITION, variable.getFullyQualifiedNameCharArrays(), 0 /*getModifiers()*/, fileNumber); + } + + typeEntry.setNameOffset(offset, offsetLength, IIndex.OFFSET); typeEntry.serialize(output); } @@ -500,9 +511,15 @@ public class SourceIndexerRunner extends AbstractIndexer { int offset = field.getNameOffset(); int offsetLength = field.getNameEndOffset() - offset; - NamedEntry namedEntry = new NamedEntry(IIndex.FIELD, IIndex.DECLARATION, field.getFullyQualifiedNameCharArrays(), 0 /*getModifiers()*/, fileNumber); - namedEntry.setNameOffset(offset, offsetLength, IIndex.OFFSET); - namedEntry.serialize(output); + if (field.isStatic()){ + NamedEntry namedEntry = new NamedEntry(IIndex.FIELD, IIndex.DECLARATION, field.getFullyQualifiedNameCharArrays(), 0 /*getModifiers()*/, fileNumber); + namedEntry.setNameOffset(offset, offsetLength, IIndex.OFFSET); + namedEntry.serialize(output); + } else { + NamedEntry namedEntry = new NamedEntry(IIndex.FIELD, IIndex.DEFINITION, field.getFullyQualifiedNameCharArrays(), 0 /*getModifiers()*/, fileNumber); + namedEntry.setNameOffset(offset, offsetLength, IIndex.OFFSET); + namedEntry.serialize(output); + } } public void addFieldReference(IASTFieldReference reference, int fileNumber) { @@ -540,6 +557,30 @@ public class SourceIndexerRunner extends AbstractIndexer { } } + public void addMethodDefinition(IASTMethod method, int fileNumber) { + int offset = method.getNameOffset(); + int offsetLength = method.getNameEndOffset() - offset; + + FunctionEntry functionEntry = new FunctionEntry(IIndex.METHOD, IIndex.DEFINITION, method.getFullyQualifiedNameCharArrays(),0 /*getModifiers()*/, fileNumber); + //funEntry.setSignature(getFunctionSignature()); + functionEntry.setNameOffset(offset, offsetLength, IIndex.OFFSET); + functionEntry.serialize(output); + + Iterator i=method.getParameters(); + while (i.hasNext()){ + Object parm = i.next(); + if (parm instanceof IASTParameterDeclaration){ + IASTParameterDeclaration parmDecl = (IASTParameterDeclaration) parm; + offset = parmDecl.getNameOffset(); + offsetLength = parmDecl.getNameEndOffset() - offset; + + TypeEntry typeEntry = new TypeEntry(IIndex.TYPE_VAR ,IIndex.DECLARATION, new char[][]{parmDecl.getNameCharArray()}, 0 /*getModifiers()*/, fileNumber); + typeEntry.setNameOffset(offset, offsetLength, IIndex.OFFSET); + typeEntry.serialize(output); + } + } + } + public void addMethodReference(IASTMethodReference reference, int fileNumber) { IASTMethod method = (IASTMethod) reference.getReferencedElement(); int offset = reference.getOffset(); @@ -557,19 +598,19 @@ public class SourceIndexerRunner extends AbstractIndexer { if (elaboratedType.getClassKind().equals(ASTClassKind.CLASS)) { - TypeEntry typeEntry = new TypeEntry(IIndex.TYPE_FWD_CLASS ,IIndex.DECLARATION, elaboratedType.getFullyQualifiedNameCharArrays(), 0 /*getModifiers()*/, fileNumber); + TypeEntry typeEntry = new TypeEntry(IIndex.TYPE_CLASS ,IIndex.DECLARATION, elaboratedType.getFullyQualifiedNameCharArrays(), 0 /*getModifiers()*/, fileNumber); typeEntry.setNameOffset(offset, offsetLength, IIndex.OFFSET); typeEntry.serialize(output); } else if (elaboratedType.getClassKind().equals(ASTClassKind.STRUCT)) { - TypeEntry typeEntry = new TypeEntry(IIndex.TYPE_FWD_STRUCT ,IIndex.DECLARATION, elaboratedType.getFullyQualifiedNameCharArrays(), 0 /*getModifiers()*/, fileNumber); + TypeEntry typeEntry = new TypeEntry(IIndex.TYPE_STRUCT ,IIndex.DECLARATION, elaboratedType.getFullyQualifiedNameCharArrays(), 0 /*getModifiers()*/, fileNumber); typeEntry.setNameOffset(offset, offsetLength, IIndex.OFFSET); typeEntry.serialize(output); } else if (elaboratedType.getClassKind().equals(ASTClassKind.UNION)) { - TypeEntry typeEntry = new TypeEntry(IIndex.TYPE_FWD_UNION,IIndex.DECLARATION, elaboratedType.getFullyQualifiedNameCharArrays(), 0 /*getModifiers()*/, fileNumber); + TypeEntry typeEntry = new TypeEntry(IIndex.TYPE_UNION,IIndex.DECLARATION, elaboratedType.getFullyQualifiedNameCharArrays(), 0 /*getModifiers()*/, fileNumber); typeEntry.setNameOffset(offset, offsetLength, IIndex.OFFSET); typeEntry.serialize(output); } @@ -613,6 +654,30 @@ public class SourceIndexerRunner extends AbstractIndexer { } } + public void addFunctionDefinition(IASTFunction function, int fileNumber){ + int offset = function.getNameOffset(); + int offsetLength = function.getNameEndOffset() - offset; + + FunctionEntry functionEntry = new FunctionEntry(IIndex.FUNCTION, IIndex.DEFINITION, function.getFullyQualifiedNameCharArrays(),0 /*getModifiers()*/, fileNumber); + //funEntry.setSignature(getFunctionSignature()); + functionEntry.setNameOffset(offset, offsetLength, IIndex.OFFSET); + functionEntry.serialize(output); + + /*Iterator i=function.getParameters(); + while (i.hasNext()){ + Object parm = i.next(); + if (parm instanceof IASTParameterDeclaration){ + IASTParameterDeclaration parmDecl = (IASTParameterDeclaration) parm; + offset = parmDecl.getNameOffset(); + offsetLength = parmDecl.getNameEndOffset() - offset; + + TypeEntry typeEntry = new TypeEntry(IIndex.TYPE_VAR ,IIndex.DECLARATION, new char[][]{parmDecl.getNameCharArray()}, 0 getModifiers(), fileNumber); + typeEntry.setNameOffset(offset, offsetLength, IIndex.OFFSET); + typeEntry.serialize(output); + } + }*/ + } + public void addFunctionReference(IASTFunctionReference reference, int fileNumber){ IASTFunction function=(IASTFunction) reference.getReferencedElement(); int offset = reference.getOffset(); @@ -632,7 +697,7 @@ public class SourceIndexerRunner extends AbstractIndexer { int offset = namespace.getNameOffset(); int offsetLength = namespace.getNameEndOffset() - offset; - NamedEntry namedEntry = new NamedEntry(IIndex.NAMESPACE, IIndex.DECLARATION, namespace.getFullyQualifiedNameCharArrays(), 0 /*getModifiers()*/, fileNumber); + NamedEntry namedEntry = new NamedEntry(IIndex.NAMESPACE, IIndex.DEFINITION, namespace.getFullyQualifiedNameCharArrays(), 0 /*getModifiers()*/, fileNumber); namedEntry.setNameOffset(offset, offsetLength, IIndex.OFFSET); namedEntry.serialize(output); } @@ -720,19 +785,19 @@ public class SourceIndexerRunner extends AbstractIndexer { if (classKind.equals(ASTClassKind.CLASS)) { - TypeEntry typeEntry = new TypeEntry(IIndex.TYPE_FWD_CLASS ,IIndex.REFERENCE, fullyQualifiedName, 0 /*getModifiers()*/, fileNumber); + TypeEntry typeEntry = new TypeEntry(IIndex.TYPE_CLASS ,IIndex.REFERENCE, fullyQualifiedName, 0 /*getModifiers()*/, fileNumber); typeEntry.setNameOffset(offset, offsetLength, IIndex.OFFSET); typeEntry.serialize(output); } else if (classKind.equals(ASTClassKind.STRUCT)) { - TypeEntry typeEntry = new TypeEntry(IIndex.TYPE_FWD_STRUCT ,IIndex.REFERENCE, fullyQualifiedName, 0 /*getModifiers()*/, fileNumber); + TypeEntry typeEntry = new TypeEntry(IIndex.TYPE_STRUCT ,IIndex.REFERENCE, fullyQualifiedName, 0 /*getModifiers()*/, fileNumber); typeEntry.setNameOffset(offset, offsetLength, IIndex.OFFSET); typeEntry.serialize(output); } else if (classKind.equals(ASTClassKind.UNION)) { - TypeEntry typeEntry = new TypeEntry(IIndex.TYPE_FWD_UNION ,IIndex.REFERENCE, fullyQualifiedName, 0 /*getModifiers()*/, fileNumber); + TypeEntry typeEntry = new TypeEntry(IIndex.TYPE_UNION ,IIndex.REFERENCE, fullyQualifiedName, 0 /*getModifiers()*/, fileNumber); typeEntry.setNameOffset(offset, offsetLength, IIndex.OFFSET); typeEntry.serialize(output); } diff --git a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/search/indexing/IndexManager.java b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/search/indexing/IndexManager.java index 789eeaca5e4..850db326479 100644 --- a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/search/indexing/IndexManager.java +++ b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/search/indexing/IndexManager.java @@ -132,6 +132,40 @@ public class IndexManager extends JobManager{ indexer.removeRequest(project, delta, kind); } + /** + * @param project + * @param element + * @param delta + */ + public void addResource(IProject project, IResource resource) { + //Get indexer for this project + ICDTIndexer indexer = getIndexerForProject(project); + + if (indexer != null) + indexer.addResource(project, resource); + } + + public void addResourceByPath(IProject project, IPath path, int resourceType) { + //Get indexer for this project + ICDTIndexer indexer = getIndexerForProject(project); + + if (indexer != null) + indexer.addResourceByPath(project, path,resourceType); + + } + /** + * @param project + * @param element + * @param delta + */ + public void removeResource(IProject project, IResource resource) { + //Get the indexer for this project + ICDTIndexer indexer = null; + indexer = (ICDTIndexer) indexerMap.get(project); + + if (indexer != null) + indexer.removeResource(project, resource); + } /** * Name of the background process @@ -401,5 +435,6 @@ public class IndexManager extends JobManager{ job.setPriority( Job.DECORATE ); job.schedule(); } + } diff --git a/core/org.eclipse.cdt.core/search/org/eclipse/cdt/core/search/ICSearchConstants.java b/core/org.eclipse.cdt.core/search/org/eclipse/cdt/core/search/ICSearchConstants.java index 0e21a5419dc..c98efdc5214 100644 --- a/core/org.eclipse.cdt.core/search/org/eclipse/cdt/core/search/ICSearchConstants.java +++ b/core/org.eclipse.cdt.core/search/org/eclipse/cdt/core/search/ICSearchConstants.java @@ -107,11 +107,6 @@ public interface ICSearchConstants { public static final SearchFor FRIEND = new SearchFor( 16 ); - public static final SearchFor FWD_CLASS = new SearchFor ( 17 ); - - public static final SearchFor FWD_STRUCT = new SearchFor ( 18 ); - - public static final SearchFor FWD_UNION = new SearchFor ( 19 ); /* Nature of match */ diff --git a/core/org.eclipse.cdt.core/search/org/eclipse/cdt/internal/core/search/matching/CSearchPattern.java b/core/org.eclipse.cdt.core/search/org/eclipse/cdt/internal/core/search/matching/CSearchPattern.java index fd0721dd5f0..e0263d039c3 100644 --- a/core/org.eclipse.cdt.core/search/org/eclipse/cdt/internal/core/search/matching/CSearchPattern.java +++ b/core/org.eclipse.cdt.core/search/org/eclipse/cdt/internal/core/search/matching/CSearchPattern.java @@ -108,7 +108,6 @@ public abstract class CSearchPattern implements ICSearchConstants, ICSearchPatte CSearchPattern pattern = null; if( searchFor == TYPE || searchFor == CLASS || searchFor == STRUCT || - searchFor == FWD_CLASS || searchFor == FWD_STRUCT || searchFor == FWD_UNION || searchFor == ENUM || searchFor == UNION || searchFor == CLASS_STRUCT || searchFor == TYPEDEF ) { @@ -171,7 +170,6 @@ public abstract class CSearchPattern implements ICSearchConstants, ICSearchPatte private static CSearchPattern createNamespacePattern(String patternString, LimitTo limitTo, int matchMode, boolean caseSensitive) { if( limitTo == ALL_OCCURRENCES ){ OrPattern orPattern = new OrPattern(); - orPattern.addPattern( createNamespacePattern( patternString, DECLARATIONS, matchMode, caseSensitive ) ); orPattern.addPattern( createNamespacePattern( patternString, DEFINITIONS, matchMode, caseSensitive ) ); orPattern.addPattern( createNamespacePattern( patternString, REFERENCES, matchMode, caseSensitive ) ); return orPattern; @@ -332,6 +330,7 @@ public abstract class CSearchPattern implements ICSearchConstants, ICSearchPatte if( limitTo == ALL_OCCURRENCES ){ OrPattern orPattern = new OrPattern(); orPattern.addPattern( createClassPattern( patternString, searchFor, DECLARATIONS, matchMode, caseSensitive ) ); + orPattern.addPattern( createClassPattern( patternString, searchFor, DEFINITIONS, matchMode, caseSensitive ) ); orPattern.addPattern( createClassPattern( patternString, searchFor, REFERENCES, matchMode, caseSensitive ) ); return orPattern; } @@ -343,11 +342,6 @@ public abstract class CSearchPattern implements ICSearchConstants, ICSearchPatte return orPattern; } - boolean isForward = false; - if (searchFor == FWD_CLASS || searchFor == FWD_STRUCT || searchFor == FWD_UNION){ - isForward = true; - } - char [] patternArray = patternString.toCharArray(); IScanner scanner =null; @@ -396,10 +390,9 @@ public abstract class CSearchPattern implements ICSearchConstants, ICSearchPatte char[] name = (char [])list.removeLast(); char [][] qualifications = new char[0][]; - return new ClassDeclarationPattern( name, (char[][])list.toArray( qualifications ), searchFor, limitTo, matchMode, caseSensitive, isForward ); + return new ClassDeclarationPattern( name, (char[][])list.toArray( qualifications ), searchFor, limitTo, matchMode, caseSensitive); } - private static CSearchPattern createDerivedPattern(String patternString, SearchFor searchFor, LimitTo limitTo, int matchMode, boolean caseSensitive) { char [] patternArray = patternString.toCharArray(); diff --git a/core/org.eclipse.cdt.core/search/org/eclipse/cdt/internal/core/search/matching/ClassDeclarationPattern.java b/core/org.eclipse.cdt.core/search/org/eclipse/cdt/internal/core/search/matching/ClassDeclarationPattern.java index 27673767537..82a28d3613f 100644 --- a/core/org.eclipse.cdt.core/search/org/eclipse/cdt/internal/core/search/matching/ClassDeclarationPattern.java +++ b/core/org.eclipse.cdt.core/search/org/eclipse/cdt/internal/core/search/matching/ClassDeclarationPattern.java @@ -52,10 +52,9 @@ public class ClassDeclarationPattern extends CSearchPattern { // super( matchMode, caseSensitive, DECLARATIONS ); // } - public ClassDeclarationPattern( char[] name, char[][] containers, SearchFor searchFor, LimitTo limit, int mode, boolean caseSensitive, boolean isForward ){ + public ClassDeclarationPattern( char[] name, char[][] containers, SearchFor searchFor, LimitTo limit, int mode, boolean caseSensitive ){ super( mode, caseSensitive, limit ); - this.isForward = isForward; simpleName = caseSensitive ? name : CharOperation.toLowerCase( name ); if( caseSensitive || containers == null ){ qualifications = containers; @@ -69,13 +68,13 @@ public class ClassDeclarationPattern extends CSearchPattern { this.searchFor = searchFor; - if( searchFor == CLASS || searchFor == FWD_CLASS ){ + if( searchFor == CLASS ){ classKind = ASTClassKind.CLASS; - } else if( searchFor == STRUCT || searchFor == FWD_STRUCT) { + } else if( searchFor == STRUCT ) { classKind = ASTClassKind.STRUCT; } else if ( searchFor == ENUM ) { classKind = ASTClassKind.ENUM; - } else if ( searchFor == UNION || searchFor == FWD_UNION ) { + } else if ( searchFor == UNION ) { classKind = ASTClassKind.UNION; } else { classKind = null; @@ -97,11 +96,6 @@ public class ClassDeclarationPattern extends CSearchPattern { if( ! canAccept( limit ) ) return IMPOSSIBLE_MATCH; - if ((node instanceof IASTElaboratedTypeSpecifier &&!isForward)|| - (node instanceof IASTClassSpecifier && isForward)){ - return IMPOSSIBLE_MATCH; - } - char[] nodeName = null; if (node instanceof IASTElaboratedTypeSpecifier) { @@ -161,9 +155,7 @@ public class ClassDeclarationPattern extends CSearchPattern { protected char[] decodedSimpleName; private char[][] decodedContainingTypes; protected int decodedType; - protected boolean isForward; - public void feedIndexRequestor(IIndexSearchRequestor requestor, int detailLevel, int[] fileRefs, int[][] offsets, int[][] offsetLengths,IndexInput input, ICSearchScope scope) throws IOException { boolean isClass = decodedType == IIndex.TYPE_CLASS; @@ -265,18 +257,15 @@ public class ClassDeclarationPattern extends CSearchPattern { return false; } } else if( classKind == ASTClassKind.CLASS ) { - if( decodedType != IIndex.TYPE_CLASS && - decodedType != IIndex.TYPE_FWD_CLASS){ + if( decodedType != IIndex.TYPE_CLASS ){ return false; } } else if ( classKind == ASTClassKind.STRUCT ) { - if( decodedType != IIndex.TYPE_STRUCT && - decodedType != IIndex.TYPE_FWD_STRUCT){ + if( decodedType != IIndex.TYPE_STRUCT){ return false; } } else if ( classKind == ASTClassKind.UNION ) { - if( decodedType != IIndex.TYPE_UNION && - decodedType != IIndex.TYPE_FWD_UNION){ + if( decodedType != IIndex.TYPE_UNION){ return false; } } else if ( classKind == ASTClassKind.ENUM ) { diff --git a/core/org.eclipse.cdt.core/search/org/eclipse/cdt/internal/core/search/matching/DerivedTypesPattern.java b/core/org.eclipse.cdt.core/search/org/eclipse/cdt/internal/core/search/matching/DerivedTypesPattern.java index e99be747f89..94c3c24f9e4 100644 --- a/core/org.eclipse.cdt.core/search/org/eclipse/cdt/internal/core/search/matching/DerivedTypesPattern.java +++ b/core/org.eclipse.cdt.core/search/org/eclipse/cdt/internal/core/search/matching/DerivedTypesPattern.java @@ -43,7 +43,7 @@ public class DerivedTypesPattern extends ClassDeclarationPattern { * @param caseSensitive */ public DerivedTypesPattern(char[] name, char[][] containers, SearchFor searchFor, LimitTo limit, int mode, boolean caseSensitive) { - super(name, containers, searchFor, limit, mode, caseSensitive, false); + super(name, containers, searchFor, limit, mode, caseSensitive); } public char[] indexEntryPrefix() { diff --git a/core/org.eclipse.cdt.core/search/org/eclipse/cdt/internal/core/search/matching/FriendPattern.java b/core/org.eclipse.cdt.core/search/org/eclipse/cdt/internal/core/search/matching/FriendPattern.java index 80f5eb0e289..249f728552e 100644 --- a/core/org.eclipse.cdt.core/search/org/eclipse/cdt/internal/core/search/matching/FriendPattern.java +++ b/core/org.eclipse.cdt.core/search/org/eclipse/cdt/internal/core/search/matching/FriendPattern.java @@ -42,7 +42,7 @@ public class FriendPattern extends ClassDeclarationPattern { * @param caseSensitive */ public FriendPattern(char[] name, char[][] containers, SearchFor searchFor, LimitTo limit, int mode, boolean caseSensitive) { - super(name, containers, searchFor, limit, mode, caseSensitive, false); + super(name, containers, searchFor, limit, mode, caseSensitive); } public char[] indexEntryPrefix() { diff --git a/core/org.eclipse.cdt.ui.tests/src/org/eclipse/cdt/ui/tests/IndexerView/FilterIndexerViewDialog.java b/core/org.eclipse.cdt.ui.tests/src/org/eclipse/cdt/ui/tests/IndexerView/FilterIndexerViewDialog.java index a6a3f398ac3..46a7ef1f8ec 100644 --- a/core/org.eclipse.cdt.ui.tests/src/org/eclipse/cdt/ui/tests/IndexerView/FilterIndexerViewDialog.java +++ b/core/org.eclipse.cdt.ui.tests/src/org/eclipse/cdt/ui/tests/IndexerView/FilterIndexerViewDialog.java @@ -91,10 +91,7 @@ public class FilterIndexerViewDialog extends Dialog { public static final int ENTRY_TYPE_DECL_UNION = 17; public static final int ENTRY_TYPE_DECL_DERIVED = 18; public static final int ENTRY_TYPE_DECL_FRIEND = 19; - public static final int ENTRY_TYPE_DECL_FWD_CLASS = 20; - public static final int ENTRY_TYPE_DECL_FWD_STRUCT = 21; - public static final int ENTRY_TYPE_DECL_FWD_UNION = 22; - public static final int ENTRY_INCLUDE_REF = 23; + public static final int ENTRY_INCLUDE_REF = 20; private String fDialogSection; @@ -133,9 +130,6 @@ public class FilterIndexerViewDialog extends Dialog { {IIndex.TYPE, IIndex.TYPE_UNION, IIndex.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}, - {IIndex.TYPE, IIndex.TYPE_FWD_UNION, IIndex.DECLARATION}, {IIndex.INCLUDE, IIndex.ANY, IIndex.REFERENCE} }; @@ -160,9 +154,6 @@ public class FilterIndexerViewDialog extends Dialog { "Union", "Derived", "Friend", - "Fwd Class", - "Fwd Struct", - "Fwd Union", "Include" }; // keep track of the buttons to programmatically change their state diff --git a/core/org.eclipse.cdt.ui.tests/src/org/eclipse/cdt/ui/tests/IndexerView/IndexerView.java b/core/org.eclipse.cdt.ui.tests/src/org/eclipse/cdt/ui/tests/IndexerView/IndexerView.java index 9d30049e941..2029a0a2749 100644 --- a/core/org.eclipse.cdt.ui.tests/src/org/eclipse/cdt/ui/tests/IndexerView/IndexerView.java +++ b/core/org.eclipse.cdt.ui.tests/src/org/eclipse/cdt/ui/tests/IndexerView/IndexerView.java @@ -599,9 +599,6 @@ public class IndexerView extends ViewPart { case IIndex.TYPE_TYPEDEF : return FilterIndexerViewDialog.ENTRY_TYPE_DECL_TYPEDEF; case IIndex.TYPE_DERIVED : return FilterIndexerViewDialog.ENTRY_TYPE_DECL_DERIVED; case IIndex.TYPE_FRIEND : return FilterIndexerViewDialog.ENTRY_TYPE_DECL_FRIEND; - case IIndex.TYPE_FWD_CLASS : return FilterIndexerViewDialog.ENTRY_TYPE_DECL_FWD_CLASS; - case IIndex.TYPE_FWD_STRUCT : return FilterIndexerViewDialog.ENTRY_TYPE_DECL_FWD_STRUCT; - case IIndex.TYPE_FWD_UNION : return FilterIndexerViewDialog.ENTRY_TYPE_DECL_FWD_UNION; } case IIndex.FUNCTION : return FilterIndexerViewDialog.ENTRY_FUNCTION_DECL; case IIndex.METHOD : return FilterIndexerViewDialog.ENTRY_METHOD_DECL; diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchPage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchPage.java index 890ad5c885d..95458412f6b 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchPage.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchPage.java @@ -121,11 +121,7 @@ public class CSearchPage extends DialogPage implements ISearchPage, ICSearchCons //include those items not represented in the UI searching.add( MACRO ); - searching.add( TYPEDEF ); - searching.add( FWD_CLASS ); - searching.add( FWD_STRUCT ); - searching.add( FWD_UNION ); - + searching.add( TYPEDEF ); } else { searching = data.searchFor; } @@ -345,7 +341,8 @@ public class CSearchPage extends DialogPage implements ISearchPage, ICSearchCons for (Iterator iter = searchFor.iterator(); iter.hasNext();) { SearchFor element = (SearchFor) iter.next(); if( element == FUNCTION || element == METHOD || element == VAR || - element == FIELD || element == NAMESPACE || element == UNKNOWN_SEARCH_FOR ){ + element == FIELD || element == NAMESPACE || element == CLASS_STRUCT || + element == UNION || element == UNKNOWN_SEARCH_FOR ){ set.add( DEFINITIONS ); break; }