CEDET 
 Libraries 
  EIEIO  
   Vis Bookmarks 
   LM Compile 
  Semantic  
   Intellisense 
  SRecode  
  Tools  
  Speedbar  
  EDE  
  COGRE  
  Download 
  1.0 Pre Releases 
   1.0pre4 
   1.0pre3 
  Other  
  Checkdoc 
 Project Information 
  Project 
  Releases 
  Mailing Lists 
   cedet-devel 
   cedet-semantic 
   cedet-eieio 
  Donate 
 
<< Files >>

Intellisense

"Using Semantic for Intellisense"

Intellisense is a term coined from (I think) Microsoft Visual Studio. It represents a set of behaviors that aids a developer write code by providing reminders of what possible classes and variables are available. Another way to describe this is simply "Smart Completion".

It is possible for Smart Completion to be provided via the tools made available in Semantic.

What is Intellisense? (For Emacs Lisp programmers)

In emacs-lisp-mode, if you press M-TAB, the window may split and show you completions. In addition, it even knows if you are completing a function or a variable, and adjusts the list accordingly. This is pretty close to what intellisense is, though the task is much more difficult in C++.

For C++, if you typed in

q = foo.a

the intellisense feature would realize that the "a" symbol must be a field or method of "foo", so first it looks up what "foo" is to determine the data type. It also knows that the result is assigned into "q", so it also looks up q's datatype. Lastly, it finds all fields/methods of the variable "foo" that start with a, and is/returns the datatype of q.

That is (presumably) the "intelli-" part.

While that would be really handy to have bound to M-TAB, the association users from other environments make is that it shows these features in popup interactive window, much like one of Emacs' tool tips.

The features of this window are that regular typing goes into the editor, and up/down keys modify the highlighting of a selected completion in the tooltip window.

A feature of the completion is that the tooltip window would just appear out of nowhere without you asking for it, presumably because the editor thinks you're stuck. It's not my term, but perhaps this is the "-sense" part where the editor thinks it knows you are stuck.

Basic Setup

Here is the quick-and-dirty setup for Semantic.

call-tree.jpg
Smart Completion

Start inline completion

   M-x semantic-complete-analyze-inline
This is a new command that does inline completion (underlining the target symbol) and allows TAB to be used for completion purposes. It uses the semantic analyzer to provide the list of completions.

Automatic starting for inline completion in idle time

   M-x global-semantic-idle-completions-mode

This is a minor mode which starts semantic-complete-analyze-inline during idle time. This has the additional effect of showing a list of completions in a tooltip if you leave Emacs alone for too long.

This is started automatically if you choose the excessive canned starup option for semantic.

Keypress automatic starting for inline completion

  (define-key your-mode-map-here "." 'semantic-complete-self-insert)

Binding semantic-complete-self-insert to a key will insert that key, as per self-insert-command, and then fire up the inline completion engine if there is appropriate context nearby.

You will need to bind this individually per-mode to keys of your choice.

Speedbar completion mode

   M-x semantic-speedbar-analysis

This will start speedbar in a special mode. In this mode it will analyze the cursor location, and provide intelligent references. Unlike inline completion, a raw list of options is provided and you just need to click on the one you want. Sometimes you need to press g to force an update.

Command based completion

  (require 'semantic-ia)
The commands available (for binding to a key) are:
  • semantic-ia-complete-symbol
  • semantic-ia-complete-symbol-menu
  • semantic-ia-complete-tip

Semantic Analyzer FAQ

Questions are for C/C++:
Q) When I type the name of a struct or class and press "." nothing
   happens:

A1) Nothing is supposed to happen when you press ".".  you need to
    explicitly bind semantic-complete-self-insert to a key.

A2) If you enable global-semantic-idle-completions-mode, then
    you need to wait for the timeout period before options appear.

Q) I've typed in a new function, and the analyzer does nothing or
   throws an error.

A) The new code must be parsed by Semantic at least once to identify
   that you are in a function.  You can force this to occur using
   the command "M-x bovinate RET".

   All syntax surrounding the types you are attempting to complete in
   must also be syntactically correct for the parse to work.

Q) How does semantic choose the available completions?

A) It first attempts to determine the type for the local context as
   an assignment, argument to a function, or other.

   Second, it parses the current reference, such as "c->f".

   It determines the type of "c", and collects a list of available
   members.  It then filters all those members starting with "f" in
   this case, and filters again to only those members of the desired
   datatype.


 
SourceForge Logo
Donate With Paypal
gnu Eric's homepage
Return to CEDET.
Send mail to zappo@gnu.org to contact me.
Visit Siege-engine.com to see what I do in analog land.
Copyright(C) 1997,98,99,2000,01,02,03,04,05,06,07 Eric M. Ludlam
Verbatim copying and distribution is permitted in any medium, provided this notice is preserved.