Weird API

Aleix Pol aleixpol at kde.org
Mon Sep 1 01:21:46 UTC 2014


On Sun, Aug 31, 2014 at 6:33 PM, Milian Wolff <mail at milianw.de> wrote:

> On Sunday 31 August 2014 03:51:02 Aleix Pol wrote:
> > Hi,
> > I've just realized that there's some kind of omnipresent concept in the
> > DUChain called "ParseSession".
>
> Yes, and there was at one point even a ParseSession implementation in
> KDevplatform but it doesn't make any sense. The ParseSession is extremely
> language dependent. Think of it as a concept, vs. an interface with virtual
> functions.
>
> > All language implementations I've looked at implement it but then it's
> not
> > documented anywhere (AFAIK). I've been looking through the code further,
> > then I realized there's the AbstractUseBuilder header file. This one
> > instantiates some ParseSession as a template argument and does weird
> things
> > with it [1]. And by weird things, I mean Adding an attribute called
> > m_mapAst and then expecting the availability of an API such as:
> > LanguageSpecificUseBuilderBase::editor()->parseSession()->mapAstUse.
>
> Yes, it's a concept there is also afaik some more API like finding ranges
> which is essential.
>
> > I don't really think this is acceptable API. Or maybe it's just that I
> > don't feel like implementing a ParseSession concept in my plugin only
> > because of that, so I would like to have your feedback.
> >
> > As a naïve suggestion, alternatively this API should be added to the
> > UseBuilder, both the mapAst attribute and the mapAstUse could be
> specified
> > within the AbstractUseBuilder. If the implementation decides to call a
> > ParseSession indoors, then it stays as an implementation detail.
>
> Yes, that could work. But actually, from our (Olivier JG and my) POV, we
> should get rid of most of the Abstract*Builder and instead get a list of
> helper functions. Take a look at kdev-clang which already builds the whole
> cache without using the Abstract*Builder stuff _at all_. These builders are
> deceptively easy to use and you think "oh so much code that can be shared,
> cool". While actually, most of the code there is crap.
>
> You are working on the CMake language stuff, right? If possible, don't use
> the
> Abstract*Builders. Just iterate over your AST and create contexts,
> declarations and uses as you go, manually. It's not too hard actually.
>
> > Good night and happy hacking!
> > Aleix
>
> You too.
>
> > [1]
> >
> https://www.nerdist.com/wp-content/uploads/2014/05/shia-labeouf-magic-gif.gi
> > f
>
> Magic :)
>

Fair enough, it's what cmake used to do anyway. Will try to make a custom
UseBuilder directly.

Thanks!
Aleix

PS: What about deprecating the builders API then? :D
http://i0.kym-cdn.com/photos/images/original/000/165/945/444.gif
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kdevelop-devel/attachments/20140901/259a95ab/attachment.html>


More information about the KDevelop-devel mailing list