Weird API

Milian Wolff mail at
Sun Aug 31 16:33:55 UTC 2014

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 

> 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]
> f

Magic :)

Milian Wolff
mail at

More information about the KDevelop-devel mailing list