Search in sources :

Example 16 with ClassDoc

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

the class MethodsFilter 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.getClassMethods(classDoc).toList();
        }
    }
    return null;
}
Also used : ClassDoc(com.sun.javadoc.ClassDoc)

Example 17 with ClassDoc

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

the class FieldsFilter 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.getClassFields(classDoc).toList();
        }
    }
    return null;
}
Also used : ClassDoc(com.sun.javadoc.ClassDoc)

Example 18 with ClassDoc

use of com.sun.javadoc.ClassDoc in project geode by apache.

the class UnitTestDoclet method start.

/**
   * The entry point for the doclet
   */
public static boolean start(RootDoc root) {
    String[][] options = root.options();
    File outputFile = null;
    for (int i = 0; i < options.length; i++) {
        String[] option = options[i];
        if (option[0].equals("-output")) {
            outputFile = new File(option[1]);
        }
    }
    if (outputFile == null) {
        root.printError("Internal Error: No output file");
        return false;
    } else {
        root.printNotice("Generating " + outputFile);
    }
    try {
        PrintWriter pw = new PrintWriter(new FileWriter(outputFile));
        Formatter.center("GemFire Unit Test Summary", pw);
        Formatter.center(new Date().toString(), pw);
        pw.println("");
        ClassDoc[] classes = root.classes();
        Arrays.sort(classes, new Comparator() {

            public int compare(Object o1, Object o2) {
                ClassDoc c1 = (ClassDoc) o1;
                ClassDoc c2 = (ClassDoc) o2;
                return c1.qualifiedName().compareTo(c2.qualifiedName());
            }
        });
        for (int i = 0; i < classes.length; i++) {
            ClassDoc c = classes[i];
            if (!c.isAbstract() && isUnitTest(c)) {
                document(c, pw);
            }
        }
        pw.flush();
        pw.close();
    } catch (IOException ex) {
        StringWriter sw = new StringWriter();
        ex.printStackTrace(new PrintWriter(sw, true));
        root.printError(sw.toString());
        return false;
    }
    return true;
}
Also used : ClassDoc(com.sun.javadoc.ClassDoc)

Example 19 with ClassDoc

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

the class StubSkeletonWriter method writeStubMethod.

/**
     * Writes the stub method for the remote method with the given
     * operation number.
     **/
private void writeStubMethod(IndentingWriter p, int opnum) throws IOException {
    RemoteClass.Method method = remoteMethods[opnum];
    MethodDoc methodDoc = method.methodDoc();
    String methodName = methodDoc.name();
    Type[] paramTypes = method.parameterTypes();
    String[] paramNames = nameParameters(paramTypes);
    Type returnType = methodDoc.returnType();
    ClassDoc[] exceptions = method.exceptionTypes();
    /*
         * Declare stub method; throw exceptions declared in remote
         * interface(s).
         */
    p.pln("// implementation of " + Util.getFriendlyUnqualifiedSignature(methodDoc));
    p.p("public " + returnType.toString() + " " + methodName + "(");
    for (int i = 0; i < paramTypes.length; i++) {
        if (i > 0) {
            p.p(", ");
        }
        p.p(paramTypes[i].toString() + " " + paramNames[i]);
    }
    p.plnI(")");
    if (exceptions.length > 0) {
        p.p("throws ");
        for (int i = 0; i < exceptions.length; i++) {
            if (i > 0) {
                p.p(", ");
            }
            p.p(exceptions[i].qualifiedName());
        }
        p.pln();
    }
    p.pOlnI("{");
    /*
         * The RemoteRef.invoke methods throw Exception, but unless
         * this stub method throws Exception as well, we must catch
         * Exceptions thrown from the invocation.  So we must catch
         * Exception and rethrow something we can throw:
         * UnexpectedException, which is a subclass of
         * RemoteException.  But for any subclasses of Exception that
         * we can throw, like RemoteException, RuntimeException, and
         * any of the exceptions declared by this stub method, we want
         * them to pass through unmodified, so first we must catch any
         * such exceptions and rethrow them directly.
         *
         * We have to be careful generating the rethrowing catch
         * blocks here, because javac will flag an error if there are
         * any unreachable catch blocks, i.e. if the catch of an
         * exception class follows a previous catch of it or of one of
         * its superclasses.  The following method invocation takes
         * care of these details.
         */
    List<ClassDoc> catchList = computeUniqueCatchList(exceptions);
    /*
         * If we need to catch any particular exceptions (i.e. this method
         * does not declare java.lang.Exception), put the entire stub
         * method in a try block.
         */
    if (catchList.size() > 0) {
        p.plnI("try {");
    }
    if (version == StubVersion.VCOMPAT) {
        p.plnI("if (useNewInvoke) {");
    }
    if (version == StubVersion.VCOMPAT || version == StubVersion.V1_2) {
        if (!Util.isVoid(returnType)) {
            // REMIND: why $?
            p.p("Object $result = ");
        }
        p.p("ref.invoke(this, " + methodFieldNames[opnum] + ", ");
        if (paramTypes.length > 0) {
            p.p("new java.lang.Object[] {");
            for (int i = 0; i < paramTypes.length; i++) {
                if (i > 0)
                    p.p(", ");
                p.p(wrapArgumentCode(paramTypes[i], paramNames[i]));
            }
            p.p("}");
        } else {
            p.p("null");
        }
        p.pln(", " + method.methodHash() + "L);");
        if (!Util.isVoid(returnType)) {
            p.pln("return " + unwrapArgumentCode(returnType, "$result") + ";");
        }
    }
    if (version == StubVersion.VCOMPAT) {
        p.pOlnI("} else {");
    }
    if (version == StubVersion.V1_1 || version == StubVersion.VCOMPAT) {
        p.pln(REMOTE_CALL + " call = ref.newCall((" + REMOTE_OBJECT + ") this, operations, " + opnum + ", interfaceHash);");
        if (paramTypes.length > 0) {
            p.plnI("try {");
            p.pln("java.io.ObjectOutput out = call.getOutputStream();");
            writeMarshalArguments(p, "out", paramTypes, paramNames);
            p.pOlnI("} catch (java.io.IOException e) {");
            p.pln("throw new " + MARSHAL_EXCEPTION + "(\"error marshalling arguments\", e);");
            p.pOln("}");
        }
        p.pln("ref.invoke(call);");
        if (Util.isVoid(returnType)) {
            p.pln("ref.done(call);");
        } else {
            p.pln(returnType.toString() + " $result;");
            // REMIND: why $?
            p.plnI("try {");
            p.pln("java.io.ObjectInput in = call.getInputStream();");
            boolean objectRead = writeUnmarshalArgument(p, "in", returnType, "$result");
            p.pln(";");
            p.pOlnI("} catch (java.io.IOException e) {");
            p.pln("throw new " + UNMARSHAL_EXCEPTION + "(\"error unmarshalling return\", e);");
            /*
                 * If any only if readObject has been invoked, we must catch
                 * ClassNotFoundException as well as IOException.
                 */
            if (objectRead) {
                p.pOlnI("} catch (java.lang.ClassNotFoundException e) {");
                p.pln("throw new " + UNMARSHAL_EXCEPTION + "(\"error unmarshalling return\", e);");
            }
            p.pOlnI("} finally {");
            p.pln("ref.done(call);");
            p.pOln("}");
            p.pln("return $result;");
        }
    }
    if (version == StubVersion.VCOMPAT) {
        // end if/else (useNewInvoke) block
        p.pOln("}");
    }
    /*
         * If we need to catch any particular exceptions, finally write
         * the catch blocks for them, rethrow any other Exceptions with an
         * UnexpectedException, and end the try block.
         */
    if (catchList.size() > 0) {
        for (ClassDoc catchClass : catchList) {
            p.pOlnI("} catch (" + catchClass.qualifiedName() + " e) {");
            p.pln("throw e;");
        }
        p.pOlnI("} catch (java.lang.Exception e) {");
        p.pln("throw new " + UNEXPECTED_EXCEPTION + "(\"undeclared checked exception\", e);");
        // end try/catch block
        p.pOln("}");
    }
    // end stub method
    p.pOln("}");
}
Also used : Type(com.sun.javadoc.Type) MethodDoc(com.sun.javadoc.MethodDoc) ClassDoc(com.sun.javadoc.ClassDoc)

Example 20 with ClassDoc

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

the class Util method typeDescriptorOf.

/**
     * Returns the descriptor for the specified type, as appropriate
     * for either a parameter or return type in a method descriptor.
     **/
private static String typeDescriptorOf(Type type) {
    String desc;
    ClassDoc classDoc = type.asClassDoc();
    if (classDoc == null) {
        /*
             * Handle primitive types.
             */
        String name = type.typeName();
        if (name.equals("boolean")) {
            desc = "Z";
        } else if (name.equals("byte")) {
            desc = "B";
        } else if (name.equals("char")) {
            desc = "C";
        } else if (name.equals("short")) {
            desc = "S";
        } else if (name.equals("int")) {
            desc = "I";
        } else if (name.equals("long")) {
            desc = "J";
        } else if (name.equals("float")) {
            desc = "F";
        } else if (name.equals("double")) {
            desc = "D";
        } else if (name.equals("void")) {
            desc = "V";
        } else {
            throw new AssertionError("unrecognized primitive type: " + name);
        }
    } else {
        /*
             * Handle non-array reference types.
             */
        desc = "L" + binaryNameOf(classDoc).replace('.', '/') + ";";
    }
    /*
         * Handle array types.
         */
    int dimensions = type.dimension().length() / 2;
    for (int i = 0; i < dimensions; i++) {
        desc = "[" + desc;
    }
    return desc;
}
Also used : 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