use of com.sun.javadoc.ClassDoc in project checkstyle by checkstyle.
the class TokenTypesDoclet method start.
/**
* The doclet's starter method.
* @param root {@code RootDoc} given to the doclet
* @return true if the given {@code RootDoc} is processed.
* @exception FileNotFoundException will be thrown if the doclet
* will be unable to write to the specified file.
*/
public static boolean start(RootDoc root) throws FileNotFoundException {
final String fileName = getDestFileName(root.options());
final FileOutputStream fos = new FileOutputStream(fileName);
final Writer osw = new OutputStreamWriter(fos, StandardCharsets.UTF_8);
final PrintWriter writer = new PrintWriter(osw, false);
try {
final ClassDoc[] classes = root.classes();
final FieldDoc[] fields = classes[0].fields();
for (final FieldDoc field : fields) {
if (field.isStatic() && field.isPublic() && field.isFinal() && "int".equals(field.type().qualifiedTypeName())) {
if (field.firstSentenceTags().length != 1) {
final String message = "Should be only one tag.";
throw new IllegalArgumentException(message);
}
writer.println(field.name() + "=" + field.firstSentenceTags()[0].text());
}
}
} finally {
writer.close();
}
return true;
}
use of com.sun.javadoc.ClassDoc in project jersey by jersey.
the class ResourceDoclet method getSerializedLinkFromTag.
private static String getSerializedLinkFromTag(final SeeTag linkTag) {
final MemberDoc referencedMember = linkTag.referencedMember();
if (referencedMember == null) {
throw new NullPointerException("Referenced member of @link " + print(linkTag) + " cannot be resolved.");
}
if (!referencedMember.isStatic()) {
LOG.warning("Referenced member of @link " + print(linkTag) + " is not static." + " Right now only references to static members are supported.");
return null;
}
/* Get referenced example bean
*/
final ClassDoc containingClass = referencedMember.containingClass();
final Object object;
try {
final Field declaredField = Class.forName(containingClass.qualifiedName(), false, Thread.currentThread().getContextClassLoader()).getDeclaredField(referencedMember.name());
if (referencedMember.isFinal()) {
declaredField.setAccessible(true);
}
object = declaredField.get(null);
LOG.log(Level.FINE, "Got object " + object);
} catch (final Exception e) {
LOG.info("Have classloader: " + ResourceDoclet.class.getClassLoader().getClass());
LOG.info("Have thread classloader " + Thread.currentThread().getContextClassLoader().getClass());
LOG.info("Have system classloader " + ClassLoader.getSystemClassLoader().getClass());
LOG.log(Level.SEVERE, "Could not get field " + referencedMember.qualifiedName(), e);
return null;
}
/* marshal the bean to xml
*/
try {
final JAXBContext jaxbContext = JAXBContext.newInstance(object.getClass());
final StringWriter stringWriter = new StringWriter();
final Marshaller marshaller = jaxbContext.createMarshaller();
marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
marshaller.marshal(object, stringWriter);
final String result = stringWriter.getBuffer().toString();
LOG.log(Level.FINE, "Got marshalled output:\n" + result);
return result;
} catch (final Exception e) {
LOG.log(Level.SEVERE, "Could serialize bean to xml: " + object, e);
return null;
}
}
use of com.sun.javadoc.ClassDoc in project rest.li by linkedin.
the class RestLiDoclet method start.
/**
* Entry point for Javadoc Doclet.
*
* @param root {@link RootDoc} passed in by Javadoc
* @return is successful or not
*/
public static boolean start(RootDoc root) {
final DocInfo docInfo = new DocInfo();
for (ClassDoc classDoc : root.classes()) {
docInfo.setClassDoc(classDoc.qualifiedName(), classDoc);
for (MethodDoc methodDoc : classDoc.methods()) {
docInfo.setMethodDoc(MethodIdentity.create(methodDoc), methodDoc);
}
}
_currentDocLet = new RestLiDoclet(docInfo);
return true;
}
use of com.sun.javadoc.ClassDoc in project jangaroo-tools by CoreMedia.
the class MethodDocImpl method overriddenMethod.
public MethodDoc overriddenMethod() {
ClassDoc superClass = containingClass().superclass();
while (superClass != null) {
MethodDoc superMethodDoc = getSuperMethodDoc(superClass);
if (superMethodDoc != null)
return superMethodDoc;
superClass = superClass.superclass();
}
return null;
}
use of com.sun.javadoc.ClassDoc in project RESTdoclet by IG-Group.
the class XmlDoclet method controllerDocs.
/**
* Generates Java documentation for controllers.
*
* @param rootDoc the root Java documentation object.
* @throws IoException
* @throws JiBXException
*/
public static void controllerDocs(final RootDoc rootDoc) throws IOException, JiBXException {
LOG.info("Finding controllers.....");
Boolean found = false;
for (ClassDoc classDoc : rootDoc.classes()) {
LOG.debug("Controller? " + classDoc.qualifiedName() + ".java");
if (isAnnotated(classDoc, org.springframework.stereotype.Controller.class)) {
LOG.info("Found controller. Generating javadoc xml for " + classDoc.qualifiedName() + ".java");
marshallController(new ControllerBuilder().build(new Controller(), classDoc), DocletUtils.documentationFile(classDoc));
found = true;
}
}
if (!found) {
throw new IllegalArgumentException("No controllers with Spring @Controller annotation found");
}
LOG.info("Done finding controllers.");
}
Aggregations