<type>documentation</type>
<domain>intro</domain>
<id>tutorial-navigating-code</id>
<title>Tutorial: Navigating Code</title>
<date>$Date: 2013-07-02 15:16:25 -0400 (Tue, 02 Jul 2013) $</date>
<product>per+</product>

As already noted, the ``Source Assistant`` updates as you move your insertion caret around
the editor, or when browsing through the auto-completer. This includes links to the point
of definition of symbols. 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.

After visiting the point of definition with one of these links, use the green back arrow
at the top left of the editor to return from the value or type definition:

.. image:: history-buttons.png
  :width: 56
  :height: 29

The link after ``Symbol:`` goes to the point of definition of that variable, while any
links after ``Type:`` or ``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 and attributes. For example, for ``news`` the point of definition is the line
where ``news`` 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
``https://docs.python.org`` link. The documentation will be opened in your default web
browser.

.. image:: python-docs.png
  :width: 520
  :height: 253

Now use ``Undo`` or 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``.

**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.

.. image:: source-index.png
  :width: 549
  :height: 26

Try these now to navigate to ``CHandler`` in ``path_example.py``, and then use the second
menu to navigate to ``endElement``.

Then 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.

.. image:: find-symbol.png
  :width: 442
  :height: 353

~~~if WINGPRO:
``Find Symbol in Project`` in Wing Pro functions in the same way but searches all files 
in the project for a symbol.

**Find Points of Use**

In Wing Pro 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.

.. image:: find-uses.png
  :width: 481
  :height: 87

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.

