Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-dev] ajdoc lite

Good!  Probably the way to start is to look at Mik's code for walking
the model and to manually write an HTML file that has the kinds of
links you want for a particular crosscutting association.  Walking
the model will tell you what's in the model, and writing the file
will tell you what you want to produce.

Below is Mik's code.

(Mik: fyi, I'm going to move the one in the tree.)

Wes

-------- org/aspectj/samples/JoinPointCollector.java

package org.aspectj.samples;

import java.util.*;
import org.aspectj.tools.ajc.Main;


import org.aspectj.asm.*;

/**
 * Collects join point information for all advised methods and constructors.  Prints results
 * to
 *
 * @author Mik Kersten
 */
public class JoinPointCollector extends Main {

	/**
	 *
	 * @param args
	 */
	public static void main(String[] args) {
		String[] newArgs = new String[args.length +1];
		newArgs[0] = "-emacssym";
		for (int i = 0; i < args.length; i++) {
			newArgs[i+1] = args[i];
		}
		new JoinPointCollector().runMain(newArgs, false);
	}

	public void runMain(String[] args, boolean useSystemExit) {
		super.runMain(args, useSystemExit);
		
		ModelWalker walker = new ModelWalker() {
			public void preProcess(StructureNode node) {
				ProgramElementNode p = (ProgramElementNode)node;
				
				// first check if it is a method or constructor
				if (p.getProgramElementKind().equals(ProgramElementNode.Kind.METHOD)) {

					// now check if it is advsied
					for (Iterator it = p.getRelations().iterator(); it.hasNext(); ) {
					
						RelationNode relationNode = (RelationNode)it.next();
						Relation relation = relationNode.getRelation();
						if (relation == AdviceAssociation.METHOD_RELATION) {
							System.out.println("method: " + p.toString() + ", advised by: " + relationNode.getChildren());
						}
					}
				}
					
				// code around the fact that constructor advice relationship is on the type
				if (p.getProgramElementKind().equals(ProgramElementNode.Kind.CONSTRUCTOR)) {
					for (Iterator it = ((ProgramElementNode)p.getParent()).getRelations().iterator(); it.hasNext(); ) {
						RelationNode relationNode = (RelationNode)it.next();
						Relation relation = relationNode.getRelation();
						if (relation == AdviceAssociation.CONSTRUCTOR_RELATION) {
							System.out.println("constructor: " + p.toString() + ", advised by: " + relationNode.getChildren());
						}
					}
				}
			}
		};

		StructureModelManager.getDefault().getStructureModel().getRoot().walk(walker);
	}
}



Russell Miles wrote:
Hi Wes and everyone,

Sounds like an exciting task to me. Plus this would solve in the interim my problems with convincing teams in my company to look at AspectJ (one of their big gripes are the issues with ajdoc, because they have little else to moan about if truth be told;o) also it just doesn't convince them that AspectJ is a robust and reliable solution when I have to ask them to play around with Java versions to get something working ;).

So, yes, I think the task would be very useful and, yes, I would be very interested in contributing.

Cheers

Russ Miles

On Thursday, July 31, 2003, at 06:24  pm, Wes Isberg wrote:

I wonder if some of the demand now for ajdoc would be satisfied in
part by aspect indexes into javadoc HTML.  The indexes would be
HTML files generated into an existing set of javadoc HTML files
and would have links for crosscutting structure:

- a list of aspects and classes containing pointcuts
  - a list of their pointcuts, advice, and inter-type declarations
    - for pointcuts and advice,
      links to the javadoc for static shadow of the pointcuts
      (i.e., the methods advised by call or execution, etc.)
    - for inter-type declarations,
      links to the types that the members or supertypes
      are declared on

- a reverse list, in package/type/member order of affected
  types and members, with links back to aspects advising them
  (i.e., for now back to the first list)

- perhaps update the javadoc files for the affected types with
  a link back to their entry in the aspect index.  A single link
  for each affected type would be great, and a link for
  each affected member might not be too difficult.

It might be worth building a partial and interim solution because
there is a lot of interest in something like ajdoc, but efforts
are stymied in the short term by the desire to (and difficulty
of) doing it right.

This is a good project for a contributor interested in learning
to build tools on AJDE.  This index could be generated from data
obtained by walking the structure model after a compile completes.
The tool would generate the appropriate lists or tables with
predicted links into corresponding javadoc.  Mik has already
provided some model-walking code that I will include in the
samples I post later, and we can answer questions on
aspectj-dev@xxxxxxxxxxx.  I believe a good Java programmer could
write the code to gather the data in 4-16 hours and build the
indexes in 3-6 times that initial effort.

This proposal does not render javadoc for AspectJ source files
and relies on javadoc to document the non-aspect sources,
so it is not intended as a final solution for ajdoc.
(However, the code might form the basis for
something more than these simple indexes, depending on how
it's built.)  To avoid confusing people, we should call it
something else -- mostly likely whatever name is proposed by
the contributor who builds it.

So:

- For those people for whom the lack of a documentation tool
  is a hindrance to adoption, does this partial solution help
  enough that it is worth doing?

- Who is interested in contributing to this effort?

Thanks -
Wes


_______________________________________________
aspectj-dev mailing list
aspectj-dev@xxxxxxxxxxx
http://dev.eclipse.org/mailman/listinfo/aspectj-dev


_______________________________________________
aspectj-dev mailing list
aspectj-dev@xxxxxxxxxxx
http://dev.eclipse.org/mailman/listinfo/aspectj-dev




Back to the top