How does C++ support create class declarations?

Andreas Pakulat apaku at gmx.de
Mon Feb 18 20:26:44 UTC 2008


On 18.02.08 20:57:52, David Nolden wrote:
> On Monday 18 February 2008 19:47:16 Andreas Pakulat wrote:
> > I've got the following DUChain:
> > kdevelop(14055)/kdevelop (python support) Python::DumpChain::dump: "" New
> > Context  "" [ (0, 0)  ->  (23, 0) ]   top-context kdevelop(14055)/kdevelop
> > (python support) Python::DumpChain::dump: "  " New Context  "Bar" [ (0, 0) 
> > ->  (2, 1) ] kdevelop(14055)/kdevelop (python support)
> > Python::DumpChain::dump: "    " Declaration:  "<notype> "  [ "Bar::" ]  
> > 0x844ef20 (internal ctx 0x0 ) [ (0, 6)  ->  (0, 9) ] ,  defined,  0 use(s)
> >
> > i.e. there's a Context with localScopeIdentifier "Bar" and inside that
> > the class declaration and following that would be the body statements.
> >
> > Or should the Declaration be in the top context and there should be a
> > context just for the body with the localScopeIdentifier "Bar"?
> >
> > Andreas
> 
> I think it should be like this:
> 
> Context  "" [ (0, 0)  ->  (23, 0) ]   top-context 
>  Context  "Bar" id 0x1 [ (0, 0)  ->  (2, 1) ] 
>  Declaration "Bar" (internal ctx 0x1)
> 
> So the context "Bar" and declaration "Bar" are connected through 
> the "Context::owner()" and "Declaration::internalContext()" relationship, and 
> they both have the top-context as parent context.

Yeah, that makes more sense. However what I'm really stumbling about is
that in C++ apparently such code:

class Foo {};

doesn't get "Foo" highlighted as GlobalVariable but as a Class and I
don't understand how this happens. 

I mean the highlighting code checks
declaration->context()->scopeIdentifier().isEmpty() and if its empty it
uses GlobalVariable. And for my example obviously that condition is
always true as the context of that class is the top-level context.

So I think somehow I'm still missing a piece somewhere. Note: I've
mostly copied the context and declaration builders functions like
openContext/openDeclaration and such things...

Andreas

-- 
You will be run over by a bus.




More information about the KDevelop-devel mailing list