类com.sun.javadoc.MethodDoc源码实例Demo

下面列出了怎么用com.sun.javadoc.MethodDoc的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: swagger-more   文件: SwaggerMoreDoclet.java
private static void parseAndAnnotate(RootDoc rootDoc) throws ClassNotFoundException, NotFoundException, CannotCompileException, IOException {
    for (ClassDoc classDoc : rootDoc.classes()) {
        if (StringUtils.isEmpty(classDoc.getRawCommentText())) {
            DocLogger.warn("No javadoc found in class " + classDoc.qualifiedName() + "." + classDoc.name());
        }
        Class clazz = Class.forName(classDoc.qualifiedName());
        ClassPool pool = ClassPool.getDefault();
        pool.insertClassPath(new ClassClassPath(clazz));
        CtClass ctClass = pool.get(clazz.getName());
        ApiInfo apiInfo = ApiInfo.fromClassDoc(clazz, classDoc);
        if (!apiInfo.hidden()) {
            annotateClassAnn(ctClass, apiInfo);
            for (MethodDoc methodDoc : classDoc.methods()) {
                ApiMethodInfo apiMethodInfo = ApiMethodInfo.fromMethodDoc(matchingMethod(clazz, methodDoc), methodDoc);
                if (StringUtils.isEmpty(methodDoc.getRawCommentText())) {
                    DocLogger.warn("No javadoc found in method " + classDoc.qualifiedName() + "." + methodDoc.name() + methodDoc.signature());
                }
                annotateMethodAnn(ctClass, apiMethodInfo);
            }
            DocLogger.info("Successfully annotated " + clazz.getTypeName());
        }
        ctClass.writeFile(classDir);
    }
}
 
源代码2 项目: kodkod   文件: SpecificationTaglet.java
/**
 * {@inheritDoc}
 */
@Override
public Content getTagletOutput(Doc doc, TagletWriter writer) throws IllegalArgumentException {
	Tag[] tags = doc.tags(getName());
	if (tags.length==0 && doc instanceof MethodDoc) { // inherit if necessary and possible
		final DocFinder.Output inheritedDoc = DocFinder.search(new DocFinder.Input((MethodDoc) doc, this));
		tags = inheritedDoc.holderTag == null ? tags : new Tag[] {inheritedDoc.holderTag};
	}
	if (tags.length==0)
		return null;
	final StringBuilder out = writeHeader(new StringBuilder());
	for(Tag tag : tags) { 
		writeTag(out, tag, writer);
	}
	return new RawHtml(out.toString());
}
 
源代码3 项目: TencentKona-8   文件: StubSkeletonWriter.java
/**
 * Writes code to initialize the static fields for each method
 * using the Java Reflection API.
 **/
private void writeMethodFieldInitializers(IndentingWriter p)
    throws IOException
{
    for (int i = 0; i < methodFieldNames.length; i++) {
        p.p(methodFieldNames[i] + " = ");
        /*
         * Look up the Method object in the somewhat arbitrary
         * interface that we find in the Method object.
         */
        RemoteClass.Method method = remoteMethods[i];
        MethodDoc methodDoc = method.methodDoc();
        String methodName = methodDoc.name();
        Type paramTypes[] = method.parameterTypes();

        p.p(methodDoc.containingClass().qualifiedName() + ".class.getMethod(\"" +
            methodName + "\", new java.lang.Class[] {");
        for (int j = 0; j < paramTypes.length; j++) {
            if (j > 0)
                p.p(", ");
            p.p(paramTypes[j].toString() + ".class");
        }
        p.pln("});");
    }
}
 
源代码4 项目: jdk8u60   文件: StubSkeletonWriter.java
/**
 * Writes code to initialize the static fields for each method
 * using the Java Reflection API.
 **/
private void writeMethodFieldInitializers(IndentingWriter p)
    throws IOException
{
    for (int i = 0; i < methodFieldNames.length; i++) {
        p.p(methodFieldNames[i] + " = ");
        /*
         * Look up the Method object in the somewhat arbitrary
         * interface that we find in the Method object.
         */
        RemoteClass.Method method = remoteMethods[i];
        MethodDoc methodDoc = method.methodDoc();
        String methodName = methodDoc.name();
        Type paramTypes[] = method.parameterTypes();

        p.p(methodDoc.containingClass().qualifiedName() + ".class.getMethod(\"" +
            methodName + "\", new java.lang.Class[] {");
        for (int j = 0; j < paramTypes.length; j++) {
            if (j > 0)
                p.p(", ");
            p.p(paramTypes[j].toString() + ".class");
        }
        p.pln("});");
    }
}
 
源代码5 项目: PrivacyStreams   文件: PSItemDoc.java
private PSItemDoc(ClassDoc classDoc) {
    this.classDoc = classDoc;
    this.name = classDoc.name();
    this.description = classDoc.commentText();
    this.itemFieldDocs = new ArrayList<>();
    this.providerDocs = new ArrayList<>();

    List<FieldDoc> allFields = new ArrayList<>();
    this.getAllFieldDocs(classDoc, allFields);

    for (FieldDoc fieldDoc : allFields) {
        PSItemFieldDoc itemFieldDoc = PSItemFieldDoc.build(this, fieldDoc);
        if (itemFieldDoc != null) this.itemFieldDocs.add(itemFieldDoc);
    }

    for (MethodDoc methodDoc : classDoc.methods()) {
        PSOperatorDoc providerDoc = PSOperatorDoc.build(classDoc, methodDoc);
        if (providerDoc != null) this.providerDocs.add(providerDoc);
    }
}
 
源代码6 项目: openjdk-jdk8u-backup   文件: StubSkeletonWriter.java
/**
 * Writes code to initialize the static fields for each method
 * using the Java Reflection API.
 **/
private void writeMethodFieldInitializers(IndentingWriter p)
    throws IOException
{
    for (int i = 0; i < methodFieldNames.length; i++) {
        p.p(methodFieldNames[i] + " = ");
        /*
         * Look up the Method object in the somewhat arbitrary
         * interface that we find in the Method object.
         */
        RemoteClass.Method method = remoteMethods[i];
        MethodDoc methodDoc = method.methodDoc();
        String methodName = methodDoc.name();
        Type paramTypes[] = method.parameterTypes();

        p.p(methodDoc.containingClass().qualifiedName() + ".class.getMethod(\"" +
            methodName + "\", new java.lang.Class[] {");
        for (int j = 0; j < paramTypes.length; j++) {
            if (j > 0)
                p.p(", ");
            p.p(paramTypes[j].toString() + ".class");
        }
        p.pln("});");
    }
}
 
源代码7 项目: jdk8u-jdk   文件: StubSkeletonWriter.java
/**
 * Writes code to initialize the static fields for each method
 * using the Java Reflection API.
 **/
private void writeMethodFieldInitializers(IndentingWriter p)
    throws IOException
{
    for (int i = 0; i < methodFieldNames.length; i++) {
        p.p(methodFieldNames[i] + " = ");
        /*
         * Look up the Method object in the somewhat arbitrary
         * interface that we find in the Method object.
         */
        RemoteClass.Method method = remoteMethods[i];
        MethodDoc methodDoc = method.methodDoc();
        String methodName = methodDoc.name();
        Type paramTypes[] = method.parameterTypes();

        p.p(methodDoc.containingClass().qualifiedName() + ".class.getMethod(\"" +
            methodName + "\", new java.lang.Class[] {");
        for (int j = 0; j < paramTypes.length; j++) {
            if (j > 0)
                p.p(", ");
            p.p(paramTypes[j].toString() + ".class");
        }
        p.pln("});");
    }
}
 
源代码8 项目: hottub   文件: StubSkeletonWriter.java
/**
 * Writes code to initialize the static fields for each method
 * using the Java Reflection API.
 **/
private void writeMethodFieldInitializers(IndentingWriter p)
    throws IOException
{
    for (int i = 0; i < methodFieldNames.length; i++) {
        p.p(methodFieldNames[i] + " = ");
        /*
         * Look up the Method object in the somewhat arbitrary
         * interface that we find in the Method object.
         */
        RemoteClass.Method method = remoteMethods[i];
        MethodDoc methodDoc = method.methodDoc();
        String methodName = methodDoc.name();
        Type paramTypes[] = method.parameterTypes();

        p.p(methodDoc.containingClass().qualifiedName() + ".class.getMethod(\"" +
            methodName + "\", new java.lang.Class[] {");
        for (int j = 0; j < paramTypes.length; j++) {
            if (j > 0)
                p.p(", ");
            p.p(paramTypes[j].toString() + ".class");
        }
        p.pln("});");
    }
}
 
源代码9 项目: openjdk-8-source   文件: StubSkeletonWriter.java
/**
 * Writes code to initialize the static fields for each method
 * using the Java Reflection API.
 **/
private void writeMethodFieldInitializers(IndentingWriter p)
    throws IOException
{
    for (int i = 0; i < methodFieldNames.length; i++) {
        p.p(methodFieldNames[i] + " = ");
        /*
         * Look up the Method object in the somewhat arbitrary
         * interface that we find in the Method object.
         */
        RemoteClass.Method method = remoteMethods[i];
        MethodDoc methodDoc = method.methodDoc();
        String methodName = methodDoc.name();
        Type paramTypes[] = method.parameterTypes();

        p.p(methodDoc.containingClass().qualifiedName() + ".class.getMethod(\"" +
            methodName + "\", new java.lang.Class[] {");
        for (int j = 0; j < paramTypes.length; j++) {
            if (j > 0)
                p.p(", ");
            p.p(paramTypes[j].toString() + ".class");
        }
        p.pln("});");
    }
}
 
源代码10 项目: openjdk-8   文件: StubSkeletonWriter.java
/**
 * Writes code to initialize the static fields for each method
 * using the Java Reflection API.
 **/
private void writeMethodFieldInitializers(IndentingWriter p)
    throws IOException
{
    for (int i = 0; i < methodFieldNames.length; i++) {
        p.p(methodFieldNames[i] + " = ");
        /*
         * Look up the Method object in the somewhat arbitrary
         * interface that we find in the Method object.
         */
        RemoteClass.Method method = remoteMethods[i];
        MethodDoc methodDoc = method.methodDoc();
        String methodName = methodDoc.name();
        Type paramTypes[] = method.parameterTypes();

        p.p(methodDoc.containingClass().qualifiedName() + ".class.getMethod(\"" +
            methodName + "\", new java.lang.Class[] {");
        for (int j = 0; j < paramTypes.length; j++) {
            if (j > 0)
                p.p(", ");
            p.p(paramTypes[j].toString() + ".class");
        }
        p.pln("});");
    }
}
 
源代码11 项目: jdk8u_jdk   文件: StubSkeletonWriter.java
/**
 * Writes code to initialize the static fields for each method
 * using the Java Reflection API.
 **/
private void writeMethodFieldInitializers(IndentingWriter p)
    throws IOException
{
    for (int i = 0; i < methodFieldNames.length; i++) {
        p.p(methodFieldNames[i] + " = ");
        /*
         * Look up the Method object in the somewhat arbitrary
         * interface that we find in the Method object.
         */
        RemoteClass.Method method = remoteMethods[i];
        MethodDoc methodDoc = method.methodDoc();
        String methodName = methodDoc.name();
        Type paramTypes[] = method.parameterTypes();

        p.p(methodDoc.containingClass().qualifiedName() + ".class.getMethod(\"" +
            methodName + "\", new java.lang.Class[] {");
        for (int j = 0; j < paramTypes.length; j++) {
            if (j > 0)
                p.p(", ");
            p.p(paramTypes[j].toString() + ".class");
        }
        p.pln("});");
    }
}
 
源代码12 项目: swagger-more   文件: ApiMethodInfo.java
private ApiMethodInfo(Method method, MethodDoc methodDoc) {
    this.method = method;
    this.methodDoc = methodDoc;
    value = "";
    returnDescription = method.getReturnType().getSimpleName();
    noteBuilder = new StringBuilder();
}
 
源代码13 项目: dragonwell8_jdk   文件: Util.java
/**
 * Returns a reader-friendly string representation of the
 * specified method's signature.  Names of reference types are not
 * package-qualified.
 **/
static String getFriendlyUnqualifiedSignature(MethodDoc method) {
    String sig = method.name() + "(";
    Parameter[] parameters = method.parameters();
    for (int i = 0; i < parameters.length; i++) {
        if (i > 0) {
            sig += ", ";
        }
        Type paramType = parameters[i].type();
        sig += paramType.typeName() + paramType.dimension();
    }
    sig += ")";
    return sig;
}
 
源代码14 项目: jdk8u-dev-jdk   文件: RemoteClass.java
/**
 * Creates a new Method instance for the specified method.
 **/
Method(MethodDoc methodDoc) {
    this.methodDoc = methodDoc;
    exceptionTypes = methodDoc.thrownExceptions();
    /*
     * Sort exception types to improve consistency with
     * previous implementations.
     */
    Arrays.sort(exceptionTypes, new ClassDocComparator());
    operationString = computeOperationString();
    nameAndDescriptor =
        methodDoc.name() + Util.methodDescriptorOf(methodDoc);
    methodHash = computeMethodHash();
}
 
源代码15 项目: dragonwell8_jdk   文件: RemoteClass.java
/**
 * Returns the MethodDoc for the method of this remote
 * implementation class that implements the specified remote
 * method of a remote interface.  Returns null if no matching
 * method was found in this remote implementation class.
 **/
private MethodDoc findImplMethod(MethodDoc interfaceMethod) {
    String name = interfaceMethod.name();
    String desc = Util.methodDescriptorOf(interfaceMethod);
    for (MethodDoc implMethod : implClass.methods()) {
        if (name.equals(implMethod.name()) &&
            desc.equals(Util.methodDescriptorOf(implMethod)))
        {
            return implMethod;
        }
    }
    return null;
}
 
源代码16 项目: dragonwell8_jdk   文件: RemoteClass.java
/**
 * Creates a new Method instance for the specified method.
 **/
Method(MethodDoc methodDoc) {
    this.methodDoc = methodDoc;
    exceptionTypes = methodDoc.thrownExceptions();
    /*
     * Sort exception types to improve consistency with
     * previous implementations.
     */
    Arrays.sort(exceptionTypes, new ClassDocComparator());
    operationString = computeOperationString();
    nameAndDescriptor =
        methodDoc.name() + Util.methodDescriptorOf(methodDoc);
    methodHash = computeMethodHash();
}
 
源代码17 项目: TencentKona-8   文件: Util.java
/**
 * Returns the method descriptor for the specified method.
 *
 * See section 4.3.3 of The Java Virtual Machine Specification
 * Second Edition for the definition of a "method descriptor".
 **/
static String methodDescriptorOf(MethodDoc method) {
    String desc = "(";
    Parameter[] parameters = method.parameters();
    for (int i = 0; i < parameters.length; i++) {
        desc += typeDescriptorOf(parameters[i].type());
    }
    desc += ")" + typeDescriptorOf(method.returnType());
    return desc;
}
 
源代码18 项目: TencentKona-8   文件: Util.java
/**
 * Returns a reader-friendly string representation of the
 * specified method's signature.  Names of reference types are not
 * package-qualified.
 **/
static String getFriendlyUnqualifiedSignature(MethodDoc method) {
    String sig = method.name() + "(";
    Parameter[] parameters = method.parameters();
    for (int i = 0; i < parameters.length; i++) {
        if (i > 0) {
            sig += ", ";
        }
        Type paramType = parameters[i].type();
        sig += paramType.typeName() + paramType.dimension();
    }
    sig += ")";
    return sig;
}
 
源代码19 项目: TencentKona-8   文件: RemoteClass.java
/**
 * Creates a new Method instance for the specified method.
 **/
Method(MethodDoc methodDoc) {
    this.methodDoc = methodDoc;
    exceptionTypes = methodDoc.thrownExceptions();
    /*
     * Sort exception types to improve consistency with
     * previous implementations.
     */
    Arrays.sort(exceptionTypes, new ClassDocComparator());
    operationString = computeOperationString();
    nameAndDescriptor =
        methodDoc.name() + Util.methodDescriptorOf(methodDoc);
    methodHash = computeMethodHash();
}
 
源代码20 项目: jdk8u60   文件: Util.java
/**
 * Returns the method descriptor for the specified method.
 *
 * See section 4.3.3 of The Java Virtual Machine Specification
 * Second Edition for the definition of a "method descriptor".
 **/
static String methodDescriptorOf(MethodDoc method) {
    String desc = "(";
    Parameter[] parameters = method.parameters();
    for (int i = 0; i < parameters.length; i++) {
        desc += typeDescriptorOf(parameters[i].type());
    }
    desc += ")" + typeDescriptorOf(method.returnType());
    return desc;
}
 
源代码21 项目: jdk8u60   文件: Util.java
/**
 * Returns a reader-friendly string representation of the
 * specified method's signature.  Names of reference types are not
 * package-qualified.
 **/
static String getFriendlyUnqualifiedSignature(MethodDoc method) {
    String sig = method.name() + "(";
    Parameter[] parameters = method.parameters();
    for (int i = 0; i < parameters.length; i++) {
        if (i > 0) {
            sig += ", ";
        }
        Type paramType = parameters[i].type();
        sig += paramType.typeName() + paramType.dimension();
    }
    sig += ")";
    return sig;
}
 
源代码22 项目: jdk8u60   文件: RemoteClass.java
/**
 * Returns the MethodDoc for the method of this remote
 * implementation class that implements the specified remote
 * method of a remote interface.  Returns null if no matching
 * method was found in this remote implementation class.
 **/
private MethodDoc findImplMethod(MethodDoc interfaceMethod) {
    String name = interfaceMethod.name();
    String desc = Util.methodDescriptorOf(interfaceMethod);
    for (MethodDoc implMethod : implClass.methods()) {
        if (name.equals(implMethod.name()) &&
            desc.equals(Util.methodDescriptorOf(implMethod)))
        {
            return implMethod;
        }
    }
    return null;
}
 
源代码23 项目: jdk8u60   文件: RemoteClass.java
/**
 * Creates a new Method instance for the specified method.
 **/
Method(MethodDoc methodDoc) {
    this.methodDoc = methodDoc;
    exceptionTypes = methodDoc.thrownExceptions();
    /*
     * Sort exception types to improve consistency with
     * previous implementations.
     */
    Arrays.sort(exceptionTypes, new ClassDocComparator());
    operationString = computeOperationString();
    nameAndDescriptor =
        methodDoc.name() + Util.methodDescriptorOf(methodDoc);
    methodHash = computeMethodHash();
}
 
源代码24 项目: openjdk-jdk8u   文件: Util.java
/**
 * Returns a reader-friendly string representation of the
 * specified method's signature.  Names of reference types are not
 * package-qualified.
 **/
static String getFriendlyUnqualifiedSignature(MethodDoc method) {
    String sig = method.name() + "(";
    Parameter[] parameters = method.parameters();
    for (int i = 0; i < parameters.length; i++) {
        if (i > 0) {
            sig += ", ";
        }
        Type paramType = parameters[i].type();
        sig += paramType.typeName() + paramType.dimension();
    }
    sig += ")";
    return sig;
}
 
源代码25 项目: jdk8u-dev-jdk   文件: Util.java
/**
 * Returns the method descriptor for the specified method.
 *
 * See section 4.3.3 of The Java Virtual Machine Specification
 * Second Edition for the definition of a "method descriptor".
 **/
static String methodDescriptorOf(MethodDoc method) {
    String desc = "(";
    Parameter[] parameters = method.parameters();
    for (int i = 0; i < parameters.length; i++) {
        desc += typeDescriptorOf(parameters[i].type());
    }
    desc += ")" + typeDescriptorOf(method.returnType());
    return desc;
}
 
源代码26 项目: PrivacyStreams   文件: PSOperatorDoc.java
private PSOperatorDoc(ClassDoc classDoc, MethodDoc methodDoc) {
        this.declaringClassDoc = classDoc;
        this.methodDoc = methodDoc;
        this.description = methodDoc.commentText().replace('\n', ' ');
        this.paramDesc = "";

        Tag[] paramTags = methodDoc.tags("param");
        for (Tag paramTag : paramTags) {
            String paraStr = paramTag.text();
            String paraName = paraStr.substring(0, paraStr.indexOf(' ')).replace('\n', ' ');;
            String paraDesc = paraStr.substring(paraStr.indexOf(' ') + 1).replace('\n', ' ');;
            this.paramDesc += "<br> - `" + paraName + "`: " + paraDesc;
        }

        this.returnType = methodDoc.returnType();
//        ParameterizedType returnType = methodDoc.returnType().asParameterizedType();
//        this.inputType = returnType.typeArguments()[0];
//        this.outputType = returnType.typeArguments()[1];
//        this.completeSignature = "Function<" + this.inputType + ", " + this.outputType + "> " + methodDoc.toString();

        String shortSignature = classDoc.name() + "." + methodDoc.name() + "(";
        boolean firstParameter = true;
        for (Parameter parameter : methodDoc.parameters()) {
            if (firstParameter) {
                shortSignature += Utils.getSimpleTypeName(parameter.type()) + " " + parameter.name();
                firstParameter = false;
            } else {
                shortSignature += ", " + Utils.getSimpleTypeName(parameter.type()) + " " + parameter.name();
            }
        }
        shortSignature += ")";
        this.shortSignature = shortSignature;
    }
 
源代码27 项目: PrivacyStreams   文件: PSOperatorDoc.java
public static PSOperatorDoc build(ClassDoc classDoc, MethodDoc methodDoc) {
    if (methodDoc.isStatic() && methodDoc.isPublic()
            && Utils.instanceOf(methodDoc.returnType().asClassDoc(), Consts.TYPE_FUNCTION)) {
        return new PSOperatorDoc(classDoc, methodDoc);
    }
    return null;
}
 
源代码28 项目: PrivacyStreams   文件: PSOperatorWrapperDoc.java
private PSOperatorWrapperDoc(ClassDoc classDoc) {
    this.classDoc = classDoc;
    this.name = classDoc.name();
    this.description = classDoc.commentText();
    this.operatorDocs = new ArrayList<>();

    for (MethodDoc methodDoc : classDoc.methods()) {
        PSOperatorDoc operatorDoc = PSOperatorDoc.build(classDoc, methodDoc);
        if (operatorDoc != null) this.operatorDocs.add(operatorDoc);
    }
}
 
源代码29 项目: PrivacyStreams   文件: PSPipelineDoc.java
public static PSPipelineDoc build(ClassDoc classDoc, MethodDoc methodDoc) {
    AnnotationDesc[] annotations = methodDoc.annotations();
    for (AnnotationDesc annotation : annotations) {
        AnnotationTypeDoc annotationType = annotation.annotationType();
        if (Consts.TRANSFORMATION_ANNOTATION.equals(annotationType.toString())) {
            return new PSPipelineDoc(classDoc, methodDoc, annotation, TYPE_TRANSFORMATION);
        }
        else if (Consts.ACTION_ANNOTATION.equals(annotationType.toString())) {
            return new PSPipelineDoc(classDoc, methodDoc, annotation, TYPE_ACTION);
        }
    }
    return null;
}
 
源代码30 项目: sarl   文件: ProgrammaticWrappingProxyInstaller.java
/** Wrap a method doc.
 *
 * @param source the source
 * @return the wrapper.
 */
public MethodDoc wrap(MethodDoc source) {
	if (source == null || source instanceof Proxy<?> || !(source instanceof MethodDocImpl)) {
		return source;
	}
	return new MethodDocWrapper((MethodDocImpl) source);
}