Wing IDE Reference Manual
   
Wing IDE Reference Manual

Version 1.1b7-2


next up previous contents
Next: 6. Debugger Up: Wing IDE Reference Manual Previous: 4. Source Code Editor


Subsections


5. Source Code Browser

This chapter describes the source code browser. The browser is intended to act as an index to your source code, supporting inspection of bodies of Python source code from either a module-oriented or class hierarchy-oriented standpoint.

The source code browser is divided into three panels: (1) a hierarchical list view, (2) a panel of display filter options, and (3) an embedded information display area. These panels can be resized by dragging on the seperator handles between them.


   Wing IDE's source code browser, autocompletion, and other source navigation capabilities all make use of a central source code analyzer.

Because Python does not (yet) support data type definitions, source code analysis currently does not identify the type of all constructs found in your code. This will affect how often Wing manages to present the correct autocompletion list or correctly determines the point of definition of a construct.

For more information, read section 5.7 below.


5.1 Display Choices

The source code browser offers three ways in which to look at your body of source code. These are selected using the radio buttons along the top edge of the class browser window.

5.1.1 Viewing by Module

Viewing by module shows all files that you have placed into your project file within the top major panel of the source code browser window. This module list is a hierarchical expandable tree view that shows all modules, directories, and packages at the top level in alphabetical order. These major units are defined as follows:

Within each top-level package, directory, or module, the browser will display all sub-modules, sub-directories, modules, and any Python constructs. These are all labeled by generic type, including the following types:

5.1.2 Class Hierarchy

When viewing by class hierachy, the browser replaces the hierarchical tree view with a list of all top-level classes found in analyzed code, in alphabetical order.

In this display mode, the structure on disk of your packages, directories, and modules is completely hidden from view. Instead, the hierarchy of your classes is displayed, starting at base classes and working downward to derived classes.

Within each class, in addition to a list of derived classes, the methods and attributes for the class are shown.

5.1.3 All Classes

In order to find classes by name more easily, the browser can be asked to display a list that includes all found Python classes. In this case, all classes (and not just base classes) are displayed at the top-level of the hierarchical viewer.

This view is otherwise identical to the Class Hierarchy view.


  

The source code analyzer will run in the background from the time that you open a project until all files have been analyzed. You may notice this overhead during the first 5 to 30 seconds after you have opened your project, depending on the size of your source base. Until analysis is complete, the class-oriented view within the browser window will only include those classes that have been analyzed. This list is updated as more code is analyzed.


5.2 Display Filters

A number of options are available for filtering the constructs that are presented by the source code browser. These filters are organized into two major groups: (1) construct scope and source, and (2) construct type.

5.2.1 Construct Scope and Source

The following distinctions are made. Constructs in each category can be shown or hidden as a group:

5.2.2 Construct Type

Constructs in the source code browser window can also be shown or hidden on the basis of their basic type within the language:

5.3 Sorting

In all the display views, the ordering of constructs within a module or class can be controlled by the radio buttons labeled 'Sort'.

Sorting doesn't affect the top-level of the hierarchical list view, which is alphabetic in all cases.

5.4 Embedded Information Display

The tabbed area at the bottom of the source code browser can be used to view information about items selected in the hierarchical list view above.

5.4.1 Documentation

When the Documentation tab is selected, the source code browser will display any available Python 'doc string' information for the construct selected in the hierarchical list view above.

This only contains information when a doc string is defined and only works for packages, modules, classes, functions, and methods (and never for variables or attributes).

5.4.2 Source Display

When the Source tab is selected, the source code browser will display the source at point of definition of the selected construct.

The source view is a fully functional source code editor. If you make changes here, any additional view of that source will be updated.


  

You may be asked to save changes if you navigate to another source file after making an edit, since the source files are closed if there isn't another view to them open in another window.


You can disable tracking of your selection in the hierarchical list area by unchecking the 'Follow Selection' check box that is displayed under this tab. Otherwise, the source code view will scroll to position as you change your selection above.

5.5 Navigating to Source

A number of options are available for navigating around source from the browser window:


5.6 Python versions


   In analysing your source, Wing will use the Python interpreter and PYTHONPATH that you have specified in your debug properties. If you have indicated a main debug file for your project, the values from that file's per-file debug properties are used; otherwise the project-wide values are used. Whenever any of these values changes, Wing will completely re-analyze your source code from scratch.

You can view the Python interpreter and PYTHONPATH that are being used by the source code analysis engine, by selecting the Show Analysis Stats item in the Source menu. The values shown in the resulting dialog window are read-only but may be changed by pushing the Settings button. See section 6.2 for details on changing these values.

Be aware that if you use multiple versions of the Python interpreter or different PYTHONPATH values for different source files in your project, Wing will analyse all files in the project using the one interpreter version and PYTHONPATH it finds through the main debug file or project-wide debug properties settings. This may lead to incorrect or incomplete analysis of some source, so it is best to use only one version of Python with each Wing IDE project file.



5.7 Limitations

The following are known bugs affecting source browsing generically (within the source code browser window, or using the editor's popup menu or auto-completion facility):


  

One way to inform the code analysis facility of the type of a variable is to add an isinstance call in your code. An example is assert isinstance(obj, CMyClass). The code analyzer will pick up on these and present more complete information for the asserted values. This assertion may have the side-effect of catching type errors at the time isinstance is called rather then when an invalid operation is attempted.


5.8 Disk Cache

The source code analyzer writes information about files it has recently examined under ~/.wingide/cache (on Linux) or WINGHOME\profiles\[username]\cache (on Windows).

Cache size may be controlled with the pysource.max-disk-cache-size preference. However, Wing does not perform well if the space available for the cache is smaller than the space needed for a single project's source analysis information. If you see excessive slowdowns, either increase the size of the cache or disable it entirely by setting its size to 0.

If the cache will be used by more than one computer, make sure the clocks of the two computers are synchronized. The caching mechanism uses time stamps, and may become confused if this is not done.

The analysis cache may be removed in its entirety with no ill effects (for example 'rm -rf ~/.wingide/cache' on Linux or remove WINGHOME\profiles\[username]\cache on Windows). It will be rebuilt as needed subsequently unless it has been disabled.

5.9 Preferences

The following preferences are available for control source code analysis and the source browser:

You need to quit and restart Wing before any changes in these preferences take effect.


next up previous contents
Next: 6. Debugger Up: Wing IDE Reference Manual Previous: 4. Source Code Editor   Contents


Stephan R.A. Deibel
2001-09-17