Tutorial: Navigating Code


Home » Support » Index of All Documentation » Introduction for New Users » Wing IDE Tutorial »

As already noted, the Source Assistant updates as you move your insertion caret around the editor, or when browsing through the auto-completer. For example, try moving between the invocation of PrintAsText and the variable news in the code you just typed. The blue links in the Source Assistant can be used to jump to the points of definition of each symbol listed there.

If you click on one of the links in the Source Assistant, use the green back arrow at the top left of the editor to return from the value or type definition:

/images/doc/en/intro/history-buttons.png

The link after Symbol: goes to the point of definition of that variable, while any links after Likely Type: go to the point of definition of that data type. These are the same if the symbol is a function, method, or class, but they differ for variables. For example, for news the point of definition is the line where it is first assigned a value and the type is a Python list.

Python Documentation

For built-ins and code in the Python standard library, Wing tries to add links into the Python documentation. For example, type open in the editor and try out the http://docs.python.org link. The documentation will be opened in your default web browser.

/images/doc/en/intro/python-docs.png

Now use Undo or press the delete key to remove open from your code.

Goto-Definition

A quicker way to visit the point of definition of a symbol is to click on it and press F4 or right click and use one of the Goto Definition context menu items. Again, you can use the history back/forward arrows at the top left of the editor to return from the point of definition.

Try this for ParseRDFNews in example1.py. Wing will open up the file path_example.py and show the point of definition of ParseRDFNews. Notice that the file is opened in non-sticky mode stickpin-unstuck and will auto-close unless you toggle the stick pin icon to stickpin-stuck or edit the file.

Source Index

Wing maintains a set of source index menus at the top of the editor area. The menus are updated as you move around code, and additional levels of menus are added as needed, based on context. Try these now to navigate to CHandler in path_example.py, and then use the second menu to navigate to endElement.

/images/doc/en/intro/source-index.png

Now use the history back arrow at top left of the editor area to return to the invocation of ParseRDFNews in example1.py. You will need to press the arrow several times to move back through your visit history.

Find Symbol

If you are looking for a symbol defined in the current scope, use Find Symbol in the Source menu. This displays a dialog where you can type a fragment matching the symbol name. Use the arrow keys to traverse the matches and press Enter to visit the symbol's point of definition.

/images/doc/en/intro/find-symbol.png

Find Points of Use

It is also possible to enumerate and visit all points of use of a symbol. Try this now by right clicking on news and selecting Find Points of Use. Wing will display the Uses tool with a list of all the points of use for that symbol. Click on the uses to visit them in the editor.

/images/doc/en/intro/find-uses.png

Note that Wing distinguishes between the news that is defined at the top level of example1.py (in the code that you typed) and the like-named but independent variables news inside the various functions here. For an example, use F4 to go to the definition of ReadPythonNews and run Find Uses on the variable news defined at the bottom of the function. The results are distinct from those returned for the top-level news.

There are many other editor features worth learning, but we'll get back to those later in this tutorial, after we try out the debugger.

« 1.6. Tutorial: Introduction to the EditorTable of Contents1.8. Tutorial: Debugging »