Custom CodeModel like Repository

Niko Sams niko.sams at
Wed Feb 17 20:38:32 UTC 2010

On Wed, Feb 17, 2010 at 21:20, David Nolden <zwabel at> wrote:
> Am Mittwoch 17 Februar 2010 15:49:55 schrieb Niko Sams:
>> 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.
> Well, there is not much to maintain, as this class hasn't seen any
> modifications for a long time. It's stable.
> If it would be a template-class, it would be even more complex than it already
> is. I don't see any benefit in creating new code-models all over the place, so
> we also don't need a template code-model class. In most languages, the duchain
> is supposed to hold the information that you're trying to gather.
> That the copied code-model helps you is fine, but we should strive for a
> better solution.
> I guess what you do using the code-model is something like:
> for(file in project) {
>  for(declaration in file) {
>    if(isVisible(declaration))
>      completionList.add(declaration)
>  }
> }
> You probably use the code-model now to iterate over the declarations for each
> file, but why don't you simply load the top-context for each file and iterate
> over its declarations directly?
We did that, and it worked - but it was just slow.
For lager projects code completion took about 15+ sec to appear. In debug
output one could see hundreds of top-context loaded messages.

To make using the declarations an option again things have to be much faster.
Is this realistic to change?


More information about the KDevelop-devel mailing list