Semantic analyser - ecb-org/ecb GitHub Wiki

Displaying the current semantic context via analyser

The CEDET-suite contains the semantic analyzer [1] which is a library tool that performs context analysis and can derive useful information.

Please see the related node in the info-manual of cedet/semantic for more detailed informations about this tool and how to setup it for best performance for your project needs.

The semantic-analyzer output can be used through a special ECB-window. This interface lists details about the analysis, such as the current function, local arguments and variables, details on the prefix (the symbol the cursor is on), and a list of all possible completions (see semantic-analyze-possible-completions for more details about completions available via the semantic-analyser).

The analyser-ECB-window is of type tree-buffer. See Tree-buffer basics for basic informations how to use such a tree-buffer.

Usage of the analyser-ECB-window

  • When a node-name in the “Context”-bucket is selected with the primary mouse button (see Using the mouse) or RETURN (see Using the keyboard) the buffer in the edit-window (which one depends on the setting in ecb-mouse-click-destination) will jump to the related entry. For strongly typed languages, this means you will jump to the definition of the variable, slot, or type definition.
  • Clicking on a node-name in the “Context”-bucket with the secondary mouse button or C-RETURN (see Usage of ECB) will jump to the related entry in another edit window - which one depends on the setting in ecb-mouse-click-destination.
  • If you click on a node-name in the "Completions"-bucket, then the text that was recently analyzed will be replaced with the name of the tag that was clicked on in the analyser-ECB-window.
  • Right clicking with the mouse (or with the keyboard, see Using popup-menus) onto a tree-node opens a popup-menu which allows to display additional (if available) informations to the current node.

Synchronizing the analyse-window

Per default the content of the analyser-ECB-window is automatically synchronized and updated with current point of the current source-buffer in the edit-area (see ecb-analyse-buffer-sync and most notably ecb-analyse-buffer-sync-delay) and ECB-window synchronizing).

In contrary to the sync-options of the basic ECB-windows [2] the default synchronisation delay of the ECB-analyse-window is quite high: 2 seconds (see ecb-analyse-buffer-sync).

What is the reason for this: a small value like 0.25 as for the basic windows would make the analyse-window quite unusable because then more or less after each type (depends on how fast you are typing) the analyse window would be synchronized with current point, which can be really annoying when there would be hundreds of completions for the current point.

Imagine the following scenario: programming in emacs-lisp, typing

(e

and then you make a short break, just a moment, but immediately ECB would call the semantic-analyzer to analyse the current context for possible completions (a.o.). You can imagine that there are even thousands of possible function completions in emacs-lisp which beginns with “e”. Getting all these and displaying them in the analyse-window can take some time! Of course the whole stuff is interruptable by any key-press so ECB will not be blocked but nevertheless the will be a noticeable break in your typing.

Therefore it is strongly recommended to choose one of the following possibilities:

  • Automatic synchronizing with long delay

    Set ecb-analyse-buffer-sync-delay to a value which is suitable for your programing and typing style, default is already to seconds.

  • Manually synchronizing on demand

    • Switch off the automatic synchronizing for the ECB-analyse-window by setting the option ecb-analyse-buffer-sync to nil. Use always customize for this, never setq!
    • Bind the command ecb-analyse-buffer-sync to a conveniant shortcut
    • Synchronize the analyse-window exactly then when you need the context informations for current point (e.g. possible local variables or completions).

But note that semantic already offers some intellisense commands which can help you on demand too! See the documentation of the semantic analyzer.

Interactive commands of the analyser-ECB-window

ECB offers the following commands for the analyser-ECB-window:

  • ecb-analyse-buffer-sync
  • ecb-goto-window-analyse
  • ecb-maximize-window-analyse

See Interactive ECB commands for details about these commands.

Activating/Displaying the analyser-ECB-window

Either use one of the predefined layouts "left-analyse" or “leftright-analyse” (e.g. via C-c . l c) or create a new ecb-layout via the command eco-create-new-layout and add a buffer of type “other” and name “analyse” into this new layout (see Creating a new ECB-layout).

Customizing the analyser ECB-window

See ecb-analyse for a list of all options currently available for customizing this ECB-window to your needs.

Footnotes

[1] Note that ECB uses analyser (with s) whereas semantic uses analyzer (with z).

[2] see Basic ECB-windows and the options eco-basic-buffer-sync and ecb-basic-buffer-sync-delay.