jQassistant plugin-add properties or links to existing nodes/links

94 Views Asked by At

I'm currently working on a project where I try to create a jQassistant-plugin that adds additional information(Javadoc) to existing nodes/links (created by the Java plugin) in the form of properties(like @author or @version) or new links(@see).

I'm now facing the problem that I need to somehow access an existing node or a link to add properties, but I can't seem to find a way to do that.

A little hint to get me in the right direction would be greatly appreciated :)

1

There are 1 best solutions below

0
Dirk Mahler On

the Java plugin (jqassistant.plugin.java) provides an interface TypeResolver which allows looking up existing type (class, interface, enum, annotation) nodes including their members. You can get an instance of the type resolver from the context provided to your scanner plugin:

TypeCache.CachedType<TypeDescriptor> resolver = context.peek(TypeResolver.class);
CachedType cachedType = resolver.resolve(typeName, context);
TypeDescriptor typeDescriptor = cachedType .getTypeDescriptor();
MethodDescriptor methodDescriptor = typeDescriptor .getMethod(methodSignature);
FieldDescriptor fieldDescriptor = typeDescriptor .getMethod(fieldSignature);

There are two issues with this:

  1. These interfaces might not be stable yet (i.e. there may be some changes in the future)
  2. It's likely that you won't get a TypeResolver instance - it's only availabe if a Java classpath is currently scanned (e.g. a classes directory or a JAR file). What are you actually scanning (e.g. JavaDoc) and how (command line interface or Maven plugin)?