Search in sources :

Example 6 with ClassDoc

use of com.sun.javadoc.ClassDoc in project RESTdoclet by IG-Group.

the class MethodBuilder method initResponseParams.

private void initResponseParams(Method method, final MethodDoc methodDoc) {
    ArrayList<ResponseParameter> responseParams = new ArrayList<ResponseParameter>();
    // Add return type
    if (methodDoc.returnType() != null) {
        responseParams.add(new ResponseParameter(DocTypeUtils.getTypeName(methodDoc.returnType()), DocTypeUtils.getTypeName(methodDoc.returnType()), DocletUtils.preserveJavadocFormatting(DocTypeUtils.getReturnDoc(methodDoc))));
    }
    // Add any checked exceptions
    for (ClassDoc exceptionDoc : methodDoc.thrownExceptions()) {
        responseParams.add(new ResponseParameter(DocTypeUtils.getTypeName(exceptionDoc), DocTypeUtils.getTypeName(exceptionDoc), DocletUtils.preserveJavadocFormatting(DocTypeUtils.getTypeDoc(exceptionDoc))));
    }
    method.setResponseParams(responseParams);
}
Also used : ResponseParameter(com.iggroup.oss.restdoclet.doclet.type.ResponseParameter) ArrayList(java.util.ArrayList) ClassDoc(com.sun.javadoc.ClassDoc)

Example 7 with ClassDoc

use of com.sun.javadoc.ClassDoc in project RESTdoclet by IG-Group.

the class DocletUtils method findMethodDocumentation.

public static MethodDoc findMethodDocumentation(final MethodDoc methodDoc) {
    // Look in parent class for javadoc
    if (methodDoc.commentText().contains("@inheritDoc")) {
        ClassDoc containingClass = methodDoc.containingClass();
        ClassDoc superClass = containingClass.superclass().asClassDoc();
        for (MethodDoc md : superClass.methods()) {
            if (md.name().equalsIgnoreCase(methodDoc.name()) && md.signature().equalsIgnoreCase(methodDoc.signature())) {
                return md;
            }
        }
        // Look in interfaces for javadoc
        for (ClassDoc cd : containingClass.interfaces()) {
            for (MethodDoc md : cd.methods()) {
                if (md.name().equalsIgnoreCase(methodDoc.name()) && md.signature().equalsIgnoreCase(methodDoc.signature())) {
                    return md;
                }
            }
        }
    }
    return methodDoc;
}
Also used : MethodDoc(com.sun.javadoc.MethodDoc) ClassDoc(com.sun.javadoc.ClassDoc)

Example 8 with ClassDoc

use of com.sun.javadoc.ClassDoc in project Orchid by JavaEden.

the class ConstructorsFilter method execute.

@Override
public Object execute(FunctionRequest request) {
    List<Object> fnParams = request.minimumNumberOfArguments(1).maximumNumberOfArguments(1).getArguments();
    if (rootDoc == null) {
        rootDoc = OrchidJavadoc.rootDoc;
    }
    if (fnParams.size() == 1 && fnParams.get(0) != null) {
        String classDocName = fnParams.get(0).toString();
        ClassDoc classDoc = rootDoc.classNamed(classDocName);
        if (classDoc != null) {
            return parser.getClassConstructors(classDoc).toList();
        }
    }
    return null;
}
Also used : ClassDoc(com.sun.javadoc.ClassDoc)

Example 9 with ClassDoc

use of com.sun.javadoc.ClassDoc in project Orchid by JavaEden.

the class DirectSubclassesFilter method execute.

@Override
public Object execute(FunctionRequest request) {
    List<Object> fnParams = request.minimumNumberOfArguments(1).maximumNumberOfArguments(1).getArguments();
    if (rootDoc == null) {
        rootDoc = OrchidJavadoc.rootDoc;
    }
    if (fnParams.size() == 1 && fnParams.get(0) != null) {
        String classDocName = fnParams.get(0).toString();
        ClassDoc classDoc = rootDoc.classNamed(classDocName);
        if (classDoc != null) {
            return parser.getDirectSubclasses(classDoc).toList();
        }
    }
    return null;
}
Also used : ClassDoc(com.sun.javadoc.ClassDoc)

Example 10 with ClassDoc

use of com.sun.javadoc.ClassDoc in project jdk8u_jdk by JetBrains.

the class RemoteClass method init.

/**
     * Validates this remote implementation class and computes the
     * RMI-specific information.  Returns true if successful, or false
     * if an error occurred.
     **/
private boolean init() {
    /*
         * Verify that it is really a class, not an interface.
         */
    if (implClass.isInterface()) {
        env.error("rmic.cant.make.stubs.for.interface", implClass.qualifiedName());
        return false;
    }
    /*
         * Find all of the remote interfaces of our remote
         * implementation class-- for each class up the superclass
         * chain, add each directly-implemented interface that somehow
         * extends Remote to a list.
         */
    List<ClassDoc> remotesImplemented = new ArrayList<ClassDoc>();
    for (ClassDoc cl = implClass; cl != null; cl = cl.superclass()) {
        for (ClassDoc intf : cl.interfaces()) {
            /*
                 * Add interface to the list if it extends Remote and
                 * it is not already there.
                 */
            if (!remotesImplemented.contains(intf) && intf.subclassOf(env.docRemote())) {
                remotesImplemented.add(intf);
                if (env.verbose()) {
                    env.output("[found remote interface: " + intf.qualifiedName() + "]");
                }
            }
        }
        /*
             * Verify that the candidate remote implementation class
             * implements at least one remote interface directly.
             */
        if (cl == implClass && remotesImplemented.isEmpty()) {
            if (implClass.subclassOf(env.docRemote())) {
                /*
                     * This error message is used if the class does
                     * implement a remote interface through one of its
                     * superclasses, but not directly.
                     */
                env.error("rmic.must.implement.remote.directly", implClass.qualifiedName());
            } else {
                /*
                     * This error message is used if the class does
                     * not implement a remote interface at all.
                     */
                env.error("rmic.must.implement.remote", implClass.qualifiedName());
            }
            return false;
        }
    }
    /*
         * Convert list of remote interfaces to an array
         * (order is not important for this array).
         */
    remoteInterfaces = remotesImplemented.toArray(new ClassDoc[remotesImplemented.size()]);
    /*
         * Collect the methods from all of the remote interfaces into
         * a table, which maps from method name-and-descriptor string
         * to Method object.
         */
    Map<String, Method> methods = new HashMap<String, Method>();
    boolean errors = false;
    for (ClassDoc intf : remotesImplemented) {
        if (!collectRemoteMethods(intf, methods)) {
            /*
                 * Continue iterating despite errors in order to
                 * generate more complete error report.
                 */
            errors = true;
        }
    }
    if (errors) {
        return false;
    }
    /*
         * Sort table of remote methods into an array.  The elements
         * are sorted in ascending order of the string of the method's
         * name and descriptor, so that each elements index is equal
         * to its operation number in the JDK 1.1 version of the JRMP
         * stub/skeleton protocol.
         */
    String[] orderedKeys = methods.keySet().toArray(new String[methods.size()]);
    Arrays.sort(orderedKeys);
    remoteMethods = new Method[methods.size()];
    for (int i = 0; i < remoteMethods.length; i++) {
        remoteMethods[i] = methods.get(orderedKeys[i]);
        if (env.verbose()) {
            String msg = "[found remote method <" + i + ">: " + remoteMethods[i].operationString();
            ClassDoc[] exceptions = remoteMethods[i].exceptionTypes();
            if (exceptions.length > 0) {
                msg += " throws ";
                for (int j = 0; j < exceptions.length; j++) {
                    if (j > 0) {
                        msg += ", ";
                    }
                    msg += exceptions[j].qualifiedName();
                }
            }
            msg += "\n\tname and descriptor = \"" + remoteMethods[i].nameAndDescriptor();
            msg += "\n\tmethod hash = " + remoteMethods[i].methodHash() + "]";
            env.output(msg);
        }
    }
    /*
         * Finally, pre-compute the interface hash to be used by
         * stubs/skeletons for this remote class in the JDK 1.1
         * version of the JRMP stub/skeleton protocol.
         */
    interfaceHash = computeInterfaceHash();
    return true;
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) ClassDoc(com.sun.javadoc.ClassDoc)

Aggregations

ClassDoc (com.sun.javadoc.ClassDoc)23 MethodDoc (com.sun.javadoc.MethodDoc)10 FileOutputStream (java.io.FileOutputStream)3 ParamTag (com.sun.javadoc.ParamTag)2 Parameter (com.sun.javadoc.Parameter)2 Tag (com.sun.javadoc.Tag)2 Type (com.sun.javadoc.Type)2 OutputStream (java.io.OutputStream)2 MalformedURLException (java.net.MalformedURLException)2 ArrayList (java.util.ArrayList)2 JAXBContext (javax.xml.bind.JAXBContext)2 Marshaller (javax.xml.bind.Marshaller)2 Controller (com.iggroup.oss.restdoclet.doclet.type.Controller)1 ResponseParameter (com.iggroup.oss.restdoclet.doclet.type.ResponseParameter)1 ControllerBuilder (com.iggroup.oss.restdoclet.doclet.type.builder.ControllerBuilder)1 JiBXUtils.marshallController (com.iggroup.oss.restdoclet.doclet.util.JiBXUtils.marshallController)1 FieldDoc (com.sun.javadoc.FieldDoc)1 MemberDoc (com.sun.javadoc.MemberDoc)1 ParameterizedType (com.sun.javadoc.ParameterizedType)1 BufferedOutputStream (java.io.BufferedOutputStream)1