Code Intelligence

Komodo's Code Intelligence system is a set of tools that makes browsing, searching, and programming complex code easier and more accessible. Use the Code Browser to view the hierarchical code structure within a program file or project, the Object Browser to search for language-specific code constructs (for example, variables, methods, imports), and easily preview and open associated source files in the editor. The Code Intelligence system includes support for Python, Perl, Tcl, PHP, Ruby, and JavaScript. Code Intelligence is comprised of the following tools:

  • Code Browser: A tab that displays a hierarchical view of all code constructs (for example, variables, methods, imports) in all open files. In the Code Browser, symbols can be sorted and filtered; the current scope of a symbol can be located. The lower part of the Code Browser provides additional documentation (when available) on various program components. To access the Code Browser, click View|Tabs|Code Browser. The Code Browser is displayed on the Code tab beside the Projects tab.

  • Object Browser: A graphical browser that searches the Code Intelligence database for specified code symbols and modules. Use the Preview Pane to view code snippets containing the search criteria. To open the Object Browser, select Tools|Object Browser.

  • Perl, Python and Ruby AutoComplete and CallTips: The Code Intelligence system is used to drive AutoComplete and CallTip functionality for Perl, Python and Ruby.
The Python Tutorial demonstrates the Code Browser and other Code Intelligence tools. See the Python Tutorial to explore a Python program in Komodo.

Feature Showcases

Building the Code Intelligence Database

Komodo maintains a database of information on code files to support the various Code Intelligence features. Komodo automatically builds this database in the background while you work with files in Komodo. However, building the Code Intelligence Database beforehand can help improve the performance of Perl, Python and Ruby AutoComplete and CallTips, and makes more information available for queries in the Object Browser.

To build the Code Intelligence Database, use the following wizards: Scan language installations and Scan custom directories (located under Edit|Preferences|Code Intelligence).

Code Browser

Use the Code Browser to view the general program structure of all source files open in the Editor Pane. For each source file, the Code Browser displays a tree of symbol nodes, including modules, classes, functions, interfaces, namespaces, imports and variables. In Python, instance attributes are also displayed. Each node in the tree hierarchy can be expanded to display further detail, acting as an index to your source code. Symbols can be sorted, filtered, and the current scope of a symbol can be located. The lower part of the Code Browser displays code descriptions (when available) on various program components. The Code Browser supports the following languages: Python, Perl, PHP, Ruby, Tcl, and JavaScript.

Use the Code Browser to:

  • View program structure.
  • Browse from a listed namespace, command, or variable definition and jump to the actual source code where it is declared.
  • Locate all variables used within a file.
  • View a symbol definition signature.
  • Find all defined symbols matching a pattern.

Context Menu

Right-click in the Code Browser Pane to access code searching options. The following options are available:

  • Go to Definition: Jumps to the definition of the associated symbol in the editor. Alternatively, double-click the symbol name in the Code Browser tree.
  • Find Symbol: Right-click on a symbol name to search for matching symbols in the Object Browser.
  • Copy: Copies the symbol name to the clipboard.
  • Sort By File Order: Sorts all symbols in the tree by file order.
  • Sort Alphabetically: Sorts all symbols in the tree alphabetically.

Sorting

Use the Sort By button to organize all Code Browser symbols by file order or alphabetically. To sort all symbols by file order, click Sort By, and then select Sort By File Order from the drop-down list. To sort all symbols alphabetically, click Sort By, and then select Sort Alphabetically from the drop-down list. Alternatively, use the context menu (right-click in the Code Brower) to access sorting options.

Locating Current Scope

Use the Locate Current Scope button to find the scope of a symbol (for example, namespace, command, or variable definition). To view the scope of a symbol, place the cursor on the desired symbol in the source code and then click the Locate Current Scope button. The Code Browser tree opens to the associated scope. Alternatively, click Code|Locate Current Scope in Code Browser to open the Code Browser tree to the associated scope.

Using the Scope Indicator

The Komodo status bar displays a Scope Indicator when a file written in a supported language is open in the Editor Pane. Place the cursor over the Scope Indicator to display the current scope name and type (class, function, etc). Double-click the Scope Indicator to open the Code Browser and locate the current scope within the tree hierarchy.

Filtering Symbols

The Filter Symbols text box limits the Code Browser display to matching symbols. To filter symbols in the Code Browser, enter the desired symbol name, or partial name, in the text box. Press 'Tab' to switch focus between the Filter text box and the Code Browser tree. Press 'Esc' to clear the current filter pattern.

Viewing Code Descriptions

Use the Code Description pane to view additional information on a method, class, variable, etc. Code documentation is only displayed when the documentation itself is included within the source file. To open the Code Description pane, click the Show/Hide Description button, located at the bottom of the Code Browser. To view code descriptions, select the desired symbol in the Code Browser tree hierarchy.

The Code Description pane displays the following information, when available:

  • Filename where the symbol exists.
  • Line number where the symbol is declared.
  • Name of the symbol.
  • Internal documentation, if available (for example, Python docstrings).
  • Symbol declaration signature.

Code Description limitations:

There are limitations in how the Code Intelligence system matches internal documentation to declared symbols. These limitations only affect whether associated documentation is shown in the Code Browser's Description pane. Specifically, nearby comments are typically not associated with declarations (function, variable, class, etc). Further, POD documentation in Perl files is not mapped to associated modules and subs. However, the following can be viewed in the Code Description pane: PHP block comments immediately preceding classes and functions, and Python modules, classes, and def docstrings.

Object Browser

The Object Browser is a graphical browsing tool that searches the Code Intelligence database for specified code symbols and modules. To open the Object Browser, select Tools|Object Browser. Alternatively, invoke the Object Browser from the Code Browser context menu.

When searching source files by symbol, module, or a combination of both, the Matches pane displays a tree of symbol nodes that outline the general program structure of found search criteria. Each node in the tree hierarchy can be expanded to display further detail. Select a node to view the symbol code in the Preview pane. Double-clicking a symbol opens the file in the editor at the position where that symbol is declared.

Searching

Search by symbol, module or a combination of both to locate all instances where a component is used.

To search:

  1. In the Symbol text box, enter the desired name to search. Leave blank to just search for modules.
  2. In the Module text box, enter the desired name to search. Leave blank to search all modules.
  3. Select Exact match to find the literal symbol and/or module name in the Code Intelligence database.
  4. Select Show imports to include import, use, and include statements in the results.
  5. In the Search drop-down list, select the desired language type. Note that only those language installations scanned into the Code Intelligence database can be selected. To scan a language installation in the Code Intelligence database, see Building the Code Intelligence Database for more information.
  6. Click Go.

Alternatively, select the desired symbol or module in the Editor Pane, and then click Code|Find Symbol in Object Browser. The Object Browser is invoked (if not already launched) and displays the search results for the selected symbol or module.

Use the Matches pane to sort the symbols that match the search criteria. Sorting options are:

  • Name
  • Type
  • Module
  • File Path
  • Line