Updating Methods-window - ECB - the Emacs Code Browser
Description: ECB - the Emacs Code Browser

Next: Updating for ind. buffers, Previous: Customizing the display, Up: The Methods window

#### 6.6.4 Updating the Methods-window with contents of current source-buffer

First a preliminary remark: Do not confuse this chapter with that synchronizing described in ECB-window synchronizing. The latter one describes the mechanism for synchronizing the ECB-windows when the current-buffer in the edit-area has been changed. This chapter describes how to update the ECB-methods-window with the contents of the current-buffer if the buffer has been modified!

##### 6.6.4.1 The short version

In almost all cases there is NO need to manually rebuild the method-buffer, because it is always done automatically if necessary; the mechanism depends on the sources:

- semantic-sources: The command `global-semantic-idle-scheduler-mode` switches on autom. reparsing of semantic-sources. All the rest will be done by semantic and ECB automatically. ECB and semantic always try to reparse and update as less as possible of the sourcecode-buffer.
- non-semantic-sources (imenu supported): You can switch on autom. rescanning/reparsing with the option `imenu-auto-rescan`. But nevertheless you have to manually rebuild the Method-buffer (with the autom. updated imenu-tags) via the command `ecb-rebuild-methods-buffer` (bound to `C-c . r`).
- non-semantic-sources (etags supported): For these sources there is no built-in auto-rescan mechanism, because etags is an external tool it can only operate on the saved file-contents. So rescanning the buffer contents would need to save the buffer before. Therefore there is no built-in auto-rescan mechanism because this would always result in saving the buffer and running an external tool. But of course you can program such a an etags-auto-rescan mechanism for yourself!

##### 6.6.4.2 The full and long story

Generally ECB calls semantic to get the list of tags for current source-file of current edit-window. Per default ECB does never automatically force a reparse of the source-file after this has been changed - this is only done on demand by calling the command `ecb-rebuild-methods-buffer`. So per default the idle-scheduler of semantic is responsible for reparsing the source-file when this is necessary (see `semantic-idle-scheduler-mode' for further details). So this scheduler is also responsible when updating/sychronizing the methods-window with current buffer-contents. This is the most user-resonsible and therefore the recommended approach.

ECB is responsible to update the methods-window after the idle scheduler of semantic has triggered either a full or partial reparse of the source-buffer. Semantic always tries to reparse as less tags of the buffer as possible, often just the edited section (if it has no sideeffect to tags outside the edited parts). ECB handles this partial reparse output smoothly and updates only these nodes which are releated to the reparsed tags.

The main effect a user will notice is that edit actions which trigger just a partial reparse will just update the related node in the methods-window and not the whole methods-window. One of the main advantages is that this preserves the expand/collapse state of the methods-window.

Editing examples which trigger only a partial reparse:

- editing a function- or method-body
- changing the name of a variable or function/method
- modifying the return-type of a function/method
- and some other...

In these cases only the related node in the methods-window will change nothing else, ie. the expand/collapse-states of all other nodes in the methods-window will not be changed.

Summary: It's strongly recommended to enable `semantic-idle-scheduler-mode` or `global-semantic-idle-scheduler-mode` (see Setting up CEDET/semantic) because then reparsing is always done during idle-time of Emacs and - maybe even more important - it is also interruptable.

But if this idle-scheduler is switched off then ECB offers now two possibilities (via `ecb-force-reparse-when-semantic-idle-scheduler-off`):

- Not forcing itself a reparse when tags are needed by ECB: then a user declines knowingly Emacs/semantic-driven parsing of code when he/she switches off the idle-mode of semantic. This is the default behavior of ECB and the default value of this option. But this has also the consequence that the methods-buffer is only filed on demand via `ecb-rebuild-methods-buffer` (bound to <C-c . r>)!

  This means also in consequence that the methods-buffer is not automatically filled when a source-file is opened but first on demand after calling the command `ecb-rebuild-methods-buffer`!

- Forcing a reparse when tags are needed: Then ECB forces semantic to parse the source-file when ECB needs tags to display. For this behavior this option has to be set to not nil.

The term “forcing a reparse by semantic” is a simplification: ECB uses then the function `semantic-fetch-tags` which can decide that the cached tags are up-to-date so no real reparsing is necessary - but it can also run a full reparse and this reparse is not being done when Emacs is idle but immediatelly and not interruptable (as with the idle-scheduler of semantic), which can be quite annoying with big source-files.

To make a long story short: It is strongly recommended to enable the `semantic-idle-scheduler-mode` or `global-semantic-idle-scheduler-mode`! See Setting up CEDET/semantic. This will give you in all cases the behavior you would expect of an IDE like ECB/semantic.