| <html><head> | |
| <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> | |
| <title>Navigating Program Structure</title><meta name="generator" content="DocBook XSL Stylesheets V1.44"><link rel="home" href="index.html" title="The AspectJtm Development Environment Guide"><link rel="up" href="ajbrowser.html" title="Chapter 1. AspectJ Browser"><link rel="previous" href="ch01s02.html" title="Building Programs"><link rel="next" href="ch01s04.html" title="Running Programs"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Navigating Program Structure</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="ch01s02.html">Prev</a> </td><th width="60%" align="center">Chapter 1. AspectJ Browser</th><td width="20%" align="right"> <a accesskey="n" href="ch01s04.html">Next</a></td></tr></table><hr></div><div class="sect1"><a name="d0e944"></a><div class="titlepage"><div><h2 class="title" style="clear: both"><a name="d0e944"></a>Navigating Program Structure</h2></div></div><p> | |
| Select nodes in the program structure by clicking them (see label 2). | |
| If one node is related to one or more other nodes by an association the | |
| name of the association will appear below that node and will be | |
| displayed in italics. Links to other structure nodes appear in blue | |
| below the association. If there is no corresponding source for the | |
| link it will appear light-blue. | |
| </p><img src="ajbrowser-building.gif"><div class="sect2"><a name="d0e951"></a><div class="titlepage"><div><h3 class="title"><a name="d0e951"></a>Example: Exploring the "Spacewar" sample code </h3></div></div><p> | |
| <div class="itemizedlist"><ul><li><p><a name="d0e957"></a>Launch <tt>ajbrowser</tt></p></li><li><a name="d0e962"></a> Choose "File -> Open" or click the "Open Build | |
| Configuration" button | |
| (<span class="inlinemediaobject"><img src="openConfig.gif"></span>) and select the configuration file for debugging | |
| the spacewar example, in | |
| <tt>examples/spacewar/debug.lst</tt>. | |
| </li><li><p><a name="d0e971"></a>Click the "Build" button (<span class="inlinemediaobject"><img src="build.gif"></span>) to | |
| compile. The left pane should fill with a spacewar declaration | |
| tree. If there is a compiler error, the clickable error message | |
| shows up as in label 4. | |
| </p><p>Note: If you did not set up your classpath, the | |
| compile will fail with a message that you need to install | |
| aspectjrt.jar on your compile classpath. To do that, select "Tools | |
| -> Options" or click the "Options" button | |
| (<span class="inlinemediaobject"><img src="browseroptions.gif"></span>). Click the <tt>Build Options</tt> tab | |
| to view the Build Paths pane. Edit the classpath entry to use your | |
| install location. For example, if you ran from the base Aspectj | |
| directory, the classpath need only include | |
| <tt>lib/aspectjrt.jar</tt> (though the browser may populate | |
| the classpath with the bootclasspath and classpath initially.) | |
| Be sure to use the | |
| <tt>lib/aspectjrt.jar</tt> that came with the browser. | |
| </p><p> | |
| <img src="ajbrowser-options.gif"> | |
| </p></li><li><p><a name="d0e998"></a>Different structure views: The structure tree at the | |
| left can display different orderings and granularity for structure: | |
| <div class="itemizedlist"><ul><li><a name="d0e1002"></a> The package hierarchy view shows the traditional hierarchy | |
| of package, class, and members. </li><li><a name="d0e1004"></a> The inheritance view shows the hierarchy from topmost | |
| parent classes through subclasses to members. </li><li><a name="d0e1006"></a> The crosscutting view shows the aspect members | |
| and the code they affect. </li><li><a name="d0e1008"></a> Additional buttons in the pane can be used to change the | |
| granularity and filter out items. | |
| </li></ul></div> | |
| </p><p>Whenever you select an item in the tree view, the | |
| source pane scrolls to that item. If you select a leaf item | |
| representing another program element, then the tree | |
| selection will go to the corresponding node. (See below for | |
| how to use two panes to maintain your place.) | |
| </p></li><li><p><a name="d0e1013"></a>When working with aspects, it helps to be able to navigate | |
| between different program elements: | |
| </p><div class="itemizedlist"><ul><li><p><a name="d0e1017"></a>When looking at a method, find the advice that | |
| affects it. </p></li><li><p><a name="d0e1020"></a>When looking at a pointcut, find the advice that | |
| uses it. </p></li><li><p><a name="d0e1023"></a>When looking at advice, find what it advises - | |
| e.g., method calls or executions, initializers, etc. | |
| </p></li><li><p><a name="d0e1026"></a>When looking at a type, find any aspects that | |
| declare members or supertypes of the type, or | |
| vice-versa. | |
| </p></li></ul></div><p>You can view the advice on a particular method using the | |
| default, hierarchical view. Navigate to the tree item for | |
| <tt>spacewar.Registry.register(SpaceObject)</tt> | |
| in the <tt>debug.lst</tt> config file. Now, in | |
| the lower, file view, you can see and navigate to the advice | |
| using the subtree whose parent is the <tt>method | |
| affected by</tt> relation. | |
| </p><p>You can also use crosscutting view to see the | |
| advice using a pointcut or the methods affected by advice. | |
| For example, to see what advice uses a particular pointcut, | |
| navigate to the tree item for the pointcut | |
| <tt>spacewar.Debug.allConstructorsCut()</tt> in | |
| the <tt>debug.lst</tt> config file. You can see | |
| and navigate to the advice that uses the pointcut using the | |
| <tt>pointcut used by</tt> relation. | |
| </p><p>As an example of seeing the methods affected by advice, | |
| while still in the same view, select the first | |
| <tt>before</tt> advice in | |
| <tt>spacewar.Debug</tt>. It has relation | |
| sub-trees for both <tt>uses pointcut</tt> and | |
| <tt>affects constructions</tt>. The | |
| <tt>affects</tt> relations will list different | |
| kinds of join points - constructor or method calls, etc. | |
| </p><p>Note that the AspectJ browser can only display | |
| static structure (whether hierarchical or crosscutting). | |
| That means that dynamicly-determined pointcuts (like | |
| <tt>cflow(pointcut)</tt>) | |
| will not be shown as picking out static points in | |
| source code. Displayable pointcuts roughly correspond | |
| to those that can be used in a | |
| <tt>declare error</tt> statement. | |
| </p></li></ul></div> | |
| </p></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="ch01s02.html">Prev</a> </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right"> <a accesskey="n" href="ch01s04.html">Next</a></td></tr><tr><td width="40%" align="left">Building Programs </td><td width="20%" align="center"><a accesskey="u" href="ajbrowser.html">Up</a></td><td width="40%" align="right"> Running Programs</td></tr></table></div></body></html> |