code completion help...

John R. Zedlewski zedlwski at Princeton.EDU
Sun Feb 4 03:34:12 GMT 2001


Hey folks,
  Every so often, this topic shows up again on the list.  I think it's because the completion problem
seems easy, but it's actually quite hard.
  About a year ago, I started doing a little Code Completion work, and it seemed to be going pretty well
at first.  For instance, you can do completion for static member accesses pretty trivially: just parse
"FooClass::", then grab the list of members for FooClass that has already been parsed for the class tree
view.
  But this simplicity doesn't hold at all for completing on object instances.  If I declare a local
"FooClass x;", then later type "x.", I want to see a list of all the non-static members of FooClass.
But, at the moment, I don't even know the type of "x", and no regular expression will figure that out.
Consider, for instance, that the "x" variable might actually be declared anywhere in the current method,
as a static or instance field of the enclosing class, or as a global object.  Currently, KDevelop uses a
simplified parser, because it doesn't need to handle individual statements or expressions within a
method or function.  That works great for the class tree, but it's not sufficient to handle completion.
  The only real solution is to use a full-fledged C++ parser.  In the past, g++'s parser was a total
mess.  But the experimental version 3 has really cleaned it up a lot, to the extent where it would be
possible to integrate it into KDevelop.  I'm not saying it would be easy, though.  .  .   Way back
around KDevelop 0.4, somebody posted a message to this list that had reviews of several different
C++ parsers.  Anybody working on Code Completion should definitely search the archives and try to find
it; I know he mentioned OpenC++ as a really good alternative.
  Good luck!
--JRZ

>
> > there are two things that would help me out a lot.
> > 1)  whats a regular expression definition that would match a c++ method
> > signature?  i.e.  match something like "QStringList*
> > CCodeCompletion::getMethods(const QString& aClassVar) {"
> > 2)  some algorithm to convert someone's method signature they type in a
> > .cpp file to match the string required by
> > CParsedContainer::getMethodByNameAndArg().  i think i'll work on this
> > today, but once thats done, the code completion class should recognize
> > method params as well as class vars.
>


-
to unsubscribe from this list send an email to kdevelop-request at kdevelop.org with the following body:
unsubscribe »your-email-address«



More information about the KDevelop mailing list