Community
Participate
Working Groups
Namespaces were implemented as ITypes 5 years ago by Michael Spector. None remember why. Maybe problem with old DLTK api? In theory this should be implemented by IElementRequestor.acceptPackage instead of IElementRequestor.acceptType. Advantages: 1. Performance: we don’t have to filter namespaces while search (for ex. group by namespaces in PHPExplorer or any findType call) 2. Performance: less IType in H2 database, so faster SQL search. 3. No more ugly green icon :P 4. Cleaner PHP outliner, more JDT like Disadvantages: 1. Migration ;) 2. Problem with sorting if file have more than one namespace, probably easy to fix.
I started to look at this problem and I think I know why it was implemented with IType and not with IPackageDeclaration. IPackageDeclaration api doesn't have any type of "getChildren" method, so there is not place for fields, methods, types. Probably we can implement custom member type to fill this gap, but I just started to review it. In general I agree that we need separate types from namespaces in DB. It should give big performance improvement for some queries e.g. where element name is not specified. With some projects I noticed that overall number of types can be even around 30K+ and almost half of it were namespaces.
I think we can start on index level, without changing models: Index everything as packages, but while search resolve as types (PhpElementResolver). PHPModelAccess will need additional method : findNamespaces or findPackages.
Sounds good from performance perspective:)
New Gerrit change created: https://git.eclipse.org/r/44958
Gerrit patch is in general ready to review, but I think this change should be accepted only when bug #462138 will be fixed.
Gerrit change https://git.eclipse.org/r/44958 was merged to [master]. Commit: http://git.eclipse.org/c/pdt/org.eclipse.pdt.git/commit/?id=e12b5d6b72d454f435508932622e80a07a3538e0
Conversation from Gerrit: @Dawid I also thought to split this bug into 3 smaller pieces: Index (this patch), INamespace usage (IType.getNamespace), PackageDeclaration. @Michal I agree that implementing working IType.getNamespace can be useful, but what is your plan for IPackageDeclaration? @Dawid IType.getChildren() isn't important, because namespace and type declarations should be reported on same level (IType.getNamespace() and you can forget about namespace declaration, also see what happens in IType.getParent()). Like in JDT for one type per file pattern. Import declarations use only package names (bug 455754). In general, IPackageDeclaration is lighter than IType. Problems with two namespaces in file may be easy resolved by outliner / explorer contentproviders or sorters. Besides I personally hate current icon, it's too similar to class icon. First part of changes was merged (Namespaces are indexed as IPackageDeclaration now).
New Gerrit change created: https://git.eclipse.org/r/102761