Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
RE: [cdt-dev] CDT API hover help and completion

> -----Original Message-----
> From: Chris Moller [mailto:cmoller@xxxxxxxxxx]
> Sent: July 3, 2003 2:19 PM
> To: cdt-dev@xxxxxxxxxxx
> Subject: [cdt-dev] CDT API hover help and completion
> 
> 
> To the world at large:
> 
> We here at Le Chapeau Rouge have started a project to supply 
> API "hover help" and completion mechanisms for CDT.

That is great news that you guys want to look at this.
The even better news is that the basic framework is already done
and is being used today so you aren't going to likely have to do 
nearly as much work as you likely thought:

To see it in action try this:
- Create a C project
- Turn on indexing (this will require that CTags is installed)
- Write a bit of code ...

int afunction(int x, int y) {
	return x + y;
}

int anotherfunction() {
	return 0;
}

int main(int argc, char **argv) {
}

- Save the code 
- In main type in
  a[CTRL+SPACE]
- Hover on top of the function and you will see the
  additional information about location etc.

You will see that the information is propagated.  This is what
the collection of patches I've been fixing up for the past few
weeks have been doing (see the Big CEditor patch from a couple
of weeks ago).

Obviously there is lots of work to be done, but now that work is
forging ahead on the indexer so that the ctags dependancy can be
dropped this will likely become accessible to many more people.
There is lots of work to be done in this area since we don't do
any work to show structure members, variables etc ... just the
function completion currently.

The function completion and information actually comes from two
sources today.  The first source is from the indexer.  The second
source is from the extension point which is declared by the 
CCompletionContributor ... more on that below:

> The basis for both of these is the construction of a collection of 
> indexable databases containing the necessary information.  What's at 
> least a first pass at creating one such db has already been done by 
> writing a custom parser that extracts info from the GNU glibc manual 
> .texi sources.  As time goes on, we plan to add dbs for libs like X, 
> GTK, and whatever else looks useful.
>
> Our next step will be to tinker the CDT plugin to make use of 
> the dbs, using the mechanisms already in place for JDT.
> 
> Any input -- suggestions, wish-lists, whatever -- is welcome.

Using the CCompletionContributor extension point is where you can 
put this "database" of information.  The class you define will extend
the ICCompletionContributor which gives you an initialization mechanism
(it is a singleton) so you can load whatever database you want and
then two additional methods:
IFunctionSummary getFunctionInfo(String name)
IFunctionSummary [] getMatchingFunctions(String prefix)

If you fulfill this requirement then you will have a working function
completion with help and with argument hovering ... all for free!  In 
fact it takes about 5 minutes to build a test plugin to do this. This 
is exactly how QNX integrates its documentation and online help to 
the C/C++ Editor.

Obviously there are some issues which need to be resolved (ie what
happens if you have QNX and RedHat/Linux information installed, how
do you choose which database(s) to use?), but this mechanism works 
very well for integrating "static" help like information into the CDT.

The more interesting part of course is what Doug has raised and what
I like to think of as Dynamic Hover Help and Code Completion.  In
theory it could use the same extension point, but then you will have
entries effectively being "double indexed" so I think that a different
mechanism will have to be used to provide this dynamic type of 
information.  If you guys could do some work in this area, that would
be awesome ... especially when done in conjunction with the Indexer
work!

Thomas


Back to the top