c++ code completion status report

Richard Dale Richard_Dale at tipitina.demon.co.uk
Mon Jan 7 15:46:01 UTC 2002


On Monday 07 January 2002 8:05 am, Daniel.Engelschalt at gmx.net wrote:
> just a quick note from my side - because these are things i added.
>
> when i did my first steps in kdevelop i looked in the file BUGS and fixed 2
> of them in the classstore. after that i thought that it should be possible
> to use that mechanism of parsing (flex) for getting a variable's type in a
> cpp-file. so i just extended what was there (without going very deep in
> flex- grammer) and mailed it to victor roeder who, in that time, started
> the cc stuff. since then we are searching for "the right way" to make cc
> work and so we "found" thomas schilling who seems to be very good,
> interested and fast in learning grammer things. so all cc related stuff in
> parts/cppsupport is subject to change (or you can convince us that using
> the current approach of parsing a cpp-file could lead to success ;)
> victor's and my intention was to provide a cc for basic types (like
> QString, ...) so that people who are new to qt / kde have an easy start and
> do not only see tons of classes and methods.
  
Hi Daniel

Ok - I understand what's going on now, and I agree it doesn't make sense to 
combine the two tokenizers, as that work was part of the cc prototyping 
effort.

Below is a 'quick and dirty' way of implementing code completion used by KDE 
Studio. If you type something like 'foobar->' and invoke code completion, it 
pastes "WAIT_STUDIO_WAIT", to give 'foobar->WAIT_STUDIO_WAIT' at the current 
cursor position and temporarily saves the source file. The temp file is 
compiled with gcc, and the error message containing 'WAIT_STUDIO_WAIT' is 
parsed. It extracts the type of foobar from the error text and uses that to 
display matching methods for that type. The temp change is undone and the 
source file saved again.

With two C++ support directories, cppsupport and advancedcpp we could do 
simple hacks in cppsupport like this, and use it to get the UI and widgets 
prototyped and working. Then in advancedcpp, we could have the code 
completion C++ parser stuff, which would do a better job in the long term, 
even if it didn't work so well in the short term..

-- Richard

#define STUDIO_PREFIX "WAIT_STUDIO_WAIT"
...
QString notMember = STUDIO_PREFIX;
  notMember += ";//";

  if ( column == 0 || !(tl->getChar(column-1) == '.' || tl->getChar(column-1) 
== '>') )
  {
    notMember.prepend( " this->" );
  }
  editor->pasteStr( notMember );
  editor->save();

  out = QString::null;
  runMake();

  editor->undo();
  editor->save();
  editor->doc()->setUpdatesEnabled( true );
  int i = out.find( STUDIO_PREFIX );




More information about the KDevelop-devel mailing list