Custom CodeModel like Repository

Niko Sams niko.sams at
Wed Feb 17 14:49:55 UTC 2010

On Wed, Feb 17, 2010 at 14:02, David Nolden <zwabel at> wrote:
> Am Dienstag 16 Februar 2010 18:32:23 schrieb Niko Sams:
>> Hi David,
>> For my Php problem we talked about yesterday I think I found a pretty
>> good solution.
>> I created a custom Repository where I store the needed information.
>> Basically I copied CodeModel, added additional needed members and
>> store class declarations
>> in there.
>> It's blazingly fast :D
>> But the problem I have with it: it's a almost exact copy of CodeModel.
>> Do you think it's a good idea?
>> Do you think it is a good idea to make a generic base class and add a
>> mechanism that allows
>> declarations updating multiple CodeModels?
> Not sure if such a base class really makes sense. Since it would have to deal
> with different data-types in each case, it would have to be a template class,
> and it would be ugly.
Yes, it would be more complex and ugly. But I'd prefer not to maintain
this class
in Php as I don't understand the code...
I'll try to come up with something.

> At some point maybe we can find a way to store additional information into the
> code-model, but we don't want it to replace the duchain, the better option
> would be making the duchain faster.
that would be the best way of course, but I doubt that this would be possible.
As an experiment I created a global top context that imports all top
contexts of a project,
and is imported into all top contexts of a project.
(that way findDeclarations etc. would return all needed declarations
and we wouldn't need
a CodeModel anymore)
But it turned out that this isn't efficient.

> A maybe better solution for you would be to create a separate repository where
> you only store the additional information that doesn't fit into the normal
> code-model, by mapping from IndexedDeclaration to that specific information
> (like duchain/defintiions.h and duchain/definitions.cpp).
and where should I search for declarations then?
Using CodeModel and then looking up the additonal thate in the other repo?
currently CodeModel doesn't have an IndexedDeclaration.
But i still prefer having an own custom repo containing only the
information I need.
that way it can be most performant.

> Just out of interest, what exact new members did you require in the code-
> model?
for now it's just a flag and the prettyName.


More information about the KDevelop-devel mailing list