Custom CodeModel like Repository

Milian Wolff mail at milianw.de
Wed Feb 17 13:20:23 UTC 2010


David Nolden, 17.02.2010:
> 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.

But a template/abstract class could at least be used to share code and remove 
duplication. Adding the data members can be done by inheritance or 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.

The duchain is fast afaik, last time I profiled the slow part was the disk-
access. And since in PHP you don't have #include's you can follow, you have to 
load every single file of the probably hundreds of files in your project (esp. 
with frameworks that have one class per file).

> 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).
> 
> Just out of interest, what exact new members did you require in the code-
> model?

- "is class with static members" (since in PHP, Classes don't act as 
namespaces you don't have to show them during global code completion, when 
they don't have static functions/constants etc. pp.)

- "is exception class" - there are a few special cases where you only require 
a list of classes that inherit from the Exception class, otherwise you'd have 
to iterate over every class and check that yourself

- "pretty identifier" (see case insensitivity etc.)

Maybe more, niko is out to get something to eat :)

-- 
Milian Wolff
mail at milianw.de
http://milianw.de
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 197 bytes
Desc: This is a digitally signed message part.
URL: <http://mail.kde.org/pipermail/kdevelop-devel/attachments/20100217/caae0471/attachment.sig>


More information about the KDevelop-devel mailing list