![]() |
|
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. |
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.
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:
__init__.py
. This
file contains a special variable __all__
that lists the file-level
modules Python should automatically import when the package as a whole is
imported. See the Python documentation for additional information
on creating packages, or look at the Wing source code for examples.
__init__.py
file are listed as 'directory' rather than 'package'
in the source browser window.
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:
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.
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.
|
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.
The following distinctions are made. Constructs in each category can be shown or hidden as a group:
Print()
or kMaxListLength
.__ConstructNameList()
or __id_seed
. Python
enforces local-only access to these constructs in class methods
(see the Python documentation for details)._NotifyError()
or
_gMaxCount
. Python doesn't enforce usage of these constructs,
but they are helpful in writing clean, well-structured code and are
recommended in the Python language style guide.
Constructs in the source code browser window can also be shown or hidden on the basis of their basic type within the language:
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.
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.
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).
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.
A number of options are available for navigating around source from the browser window:
![]() |
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
Be aware that if you use multiple versions of the Python interpreter or
different |
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):
isinstance
to inform the
analyzer, as described below.http://wingide.com/support/issuetrak
![]() |
One way to inform the code analysis facility of the type of a variable is to
add an
|
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.
The following preferences are available for control source code analysis and the source browser:
WINGHOME
.
Default='src/pysource/builtin-pi-files'
true
__init__
method
or all methods in each class. Valid values are 'init-only'
and
'all-methods'
. Default='all-methods'
.50
. 10
.You need to quit and restart Wing before any changes in these preferences take effect.