Code completion in KDEStudio

Bernd Gehrmann bernd at physik.hu-berlin.de
Thu Apr 12 08:45:31 UTC 2001


On Wed, 11 Apr 2001, Roland Krause wrote:
> Somebody on this list pointed out that the problem is not the class
> parser but to parse the file the user is working on and then again
> someone else claimed that this was not the problem at all but the
> problem was to parse the class tree of the project fast enough. 

The problem is to find out the type of the object you are trying to
complete. When you have that, everything else is pretty straightforward.

Finding out the type of an object while editing can basically
be done in two ways: parse backwards from the cursor position 
until you have found out the scope you're in, or parsing forward
from the beginning of the file. 

IIRC parsing backwards is what the abandoned wxStudio code did. 
Obviously, you can't reuse any other parser code for this :-)
But it could be feasible. One problem is that it can't handle
namespaces reliably. If the code contains a 'using namespace'
at the top, then you can only guess the class scope you're
in by looking in which namespace such a class is declared.
In practice, this should be no problem though. Few people have
classes with the same name in different namespaces.

Parsing forwards is the alternative. For this, you _could_ reuse
existing parsers. But it is not clear that any valid C++ parser
is also usable for getting the type information about some
variable which is currently edited, because you want the feature
to work in most cases even if the source code is not 100%
syntactically correct. For example, g++ currently has very
bad error recovery. The C++ parser in KDevelop is not suitable at
all because it doesn't parse the _implementation_ of methods -
all it does it extract type information from the _declaration_.

Bernd.


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



More information about the KDevelop-devel mailing list