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

项目:incubator-netbeans    文件:JavadocUtilities.java   
private static MethodDoc searchInSuperclass(
        CompilationInfo javac, TypeElement class2query, TypeElement overriderClass,
        ExecutableElement overrider, Set<TypeElement> exclude) {

    // Step 3a
    TypeMirror superclassMirror = class2query.getSuperclass();
    if (superclassMirror.getKind() != TypeKind.DECLARED) {
        return null;
    }
    TypeElement superclass = (TypeElement) ((DeclaredType) superclassMirror).asElement();
    // check methods
    MethodDoc jdoc = searchInMethods(javac, superclass, overriderClass, overrider);
    if (jdoc != null) {
        return jdoc;
    }

    // Step 3b
    return searchInInterfaces(javac, superclass, overriderClass, overrider, exclude);
}
项目: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);
    }
}
项目:org.alloytools.alloy    文件:SpecificationTaglet.java   
/**
 * {@inheritDoc}
 * @see com.sun.tools.doclets.internal.toolkit.taglets.Taglet#getTagletOutput(com.sun.javadoc.Doc, com.sun.tools.doclets.internal.toolkit.taglets.TagletWriter)
 */
@Override
public TagletOutput 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 TagletOutputImpl(out.toString());
}
项目:wrdocletbase    文件:AbstractServiceDocBuilder.java   
@Override
protected void processOpenAPIClasses(ClassDoc[] classes,
        Configuration configuration) {
    for (int i = 0; i < classes.length; i++) {
        if (configuration.nodeprecated
                && (Util.isDeprecated(classes[i]) || Util
                        .isDeprecated(classes[i].containingPackage()))) {
            continue;
        }

        if (this.isServiceInterface(classes[i])) {
            this.processServiceClass(classes[i], configuration);
            MethodDoc[] methods = classes[i].methods();
            for (int l = 0; l < methods.length; l++) {
                if (configuration.nodeprecated
                        && Util.isDeprecated(methods[l])) {
                    continue;
                }
                this.processOpenAPIMethod(methods[l], configuration);
            }
        }
    }
}
项目:wrdocletbase    文件:AbstractServiceDocBuilder.java   
protected void processServiceClass(ClassDoc service,
        Configuration configuration) {
    Tag[] serviceTagArray = service.tags(WRTagTaglet.NAME);
    for (int i = 0; i < serviceTagArray.length; i++) {
        Set<String> serviceTags = WRTagTaglet.getTagSet(serviceTagArray[i]
                .text());
        for (Iterator<String> iter = serviceTags.iterator(); iter.hasNext();) {
            String tag = iter.next();
            if (!this.taggedOpenAPIMethods.containsKey(tag)) {
                this.taggedOpenAPIMethods
                        .put(tag, new HashSet<MethodDoc>());
            }
            // all method of this service should be processed later.
            for (int j = 0; j < service.methods().length; j++) {
                if (configuration.nodeprecated
                        && Util.isDeprecated(service.methods()[j])) {
                    continue;
                }
                this.taggedOpenAPIMethods.get(tag)
                        .add(service.methods()[j]);
            }
        }

        this.wrDoc.getWRTags().addAll(serviceTags);
    }
}
项目:wrdocletbase    文件:DubboDocBuilder.java   
protected LinkedList<String> processAnnotationDubboInterfaces(ClassDoc[] classes) {
    LinkedList<String> result = new LinkedList<String>();
    for (int i = 0; i < classes.length; i++) {
        // implementation class which used com.alibaba.dubbo.config.annotation.Service 
        if(isDubboService(classes[i])) {
            for(ClassDoc interfaceClassDoc : classes[i].interfaces()) {
                result.add(interfaceClassDoc.qualifiedName());
                // mapping the method in interface to the method in implementation class
                for(MethodDoc implMethodDoc : classes[i].methods()) {
                    MethodDoc overriddenMethod = implMethodDoc.overriddenMethod();
                    if(overriddenMethod != null) {
                        methodMap.put(overriddenMethod, implMethodDoc);
                    } else {
                        //It seems that MethodDoc.overriddenMethod() doesn't work, but MethodDoc.overrides() works fine.
                        for(MethodDoc interfaceMethodDoc : interfaceClassDoc.methods()) {
                            if(implMethodDoc.overrides(interfaceMethodDoc)) {
                                methodMap.put(interfaceMethodDoc, implMethodDoc);
                            }
                        }
                    }
                }
            }
        }
    }
    return result;
}
项目:wrdocletbase    文件:DubboDocBuilder.java   
@Override
protected APIParameter getOutputParam(MethodDoc methodDoc) {
    APIParameter apiParameter = null;
    if (methodDoc.returnType() != null) {
        apiParameter = new APIParameter();
        apiParameter.setParameterOccurs(ParameterOccurs.REQUIRED);
        apiParameter.setType(this.getTypeName(methodDoc.returnType(), false));
        for (Tag tag : methodDoc.tags("return")) {
            apiParameter.setDescription(tag.text());
        }
        HashSet<String> processingClasses = new HashSet<String>();
        apiParameter.setFields(this.getFields(methodDoc.returnType(),
                ParameterType.Response, processingClasses));
        apiParameter.setHistory(this.getModificationHistory(methodDoc
                .returnType()));
    }
    return apiParameter;
}
项目:wrdocletbase    文件:SOAPDocBuilder.java   
@Override
protected RequestMapping parseRequestMapping(MethodDoc method) {
    RequestMapping mapping = new RequestMapping();
    mapping.setContainerName(method.containingClass().simpleTypeName());
    AnnotationDesc[] annotations = method.annotations();
    String url = method.toString().replaceFirst(
            method.containingClass().qualifiedName() + ".", "");
    for (int i = 0; i < annotations.length; i++) {
        if (annotations[i].annotationType().name().equals("WebMethod")) {
            for (ElementValuePair p : annotations[i].elementValues()) {
                if (p.element().name().equals("operationName")) {
                    url = url.replace(method.name(), p.value().value()
                            .toString().replace("\"", ""));
                }
            }
        }
    }
    mapping.setUrl(url);
    mapping.setTooltip(method.containingClass().simpleTypeName());
    mapping.setContainerName(method.containingClass().simpleTypeName());
    return mapping;
}
项目:OpenJSharp    文件: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("});");
    }
}
项目:monarch    文件:UnitTestDoclet.java   
/**
 * Returns an array containing all of the "test" methods (including those that are inherited) for
 * the given class.
 */
private static MethodDoc[] getTestMethods(ClassDoc c) {
  Set set = new TreeSet();
  while (c != null) {
    MethodDoc[] methods = c.methods();
    for (int i = 0; i < methods.length; i++) {
      MethodDoc method = methods[i];
      if (method.isPublic() && method.parameters().length == 0
          && method.name().startsWith("test")) {
        set.add(method);
      }
    }

    c = c.superclass();
  }

  return (MethodDoc[]) set.toArray(new MethodDoc[0]);
}
项目: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("});");
    }
}
项目:openjdk-jdk10    文件: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("});");
    }
}
项目:openjdk9    文件: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("});");
    }
}
项目:ThriftyPaxos    文件:Doclet.java   
private boolean foundMethod(ClassDoc clazz, boolean include,
        String methodName, int parameterCount) {
    if (include) {
        for (MethodDoc m : clazz.methods()) {
            if (m.name().equals(methodName)
                    && m.parameters().length == parameterCount) {
                return true;
            }
        }
    }
    for (ClassDoc doc : clazz.interfaces()) {
        if (foundMethod(doc, true, methodName, parameterCount)) {
            return true;
        }
    }
    clazz = clazz.superclass();
    return clazz != null
            && foundMethod(clazz, true, methodName, parameterCount);
}
项目:openjfx-8u-dev-tests    文件:Template.java   
public static boolean start(RootDoc doc) throws FileNotFoundException, IOException {
    if(out == null) out = System.out;
    for (ClassDoc cls : doc.classes()) {
        Map<String, MethodDoc> allProps = getPropNames(cls);
        for (MethodDoc m : cls.methods()) {
            String propName = getPropName(m, true);
            if (propName != null) {
                MethodDoc mDeclaring = allProps.get(propName);
                if (mDeclaring != null) {
                    boolean supported = false;
                    if (m.name().startsWith("get") || m.name().startsWith("is")) {
                        supported = m.returnType().equals(mDeclaring.returnType());
                    } else if (m.name().startsWith("set")) {
                        supported = m.parameters()[0].type().equals(mDeclaring.returnType());
                    }
                    if (supported) {
                        out.println(cls.qualifiedName() + "." + propName);
                    }
                }
            }
        }
    }
    return true;
}
项目:openjfx-8u-dev-tests    文件:Template.java   
protected static String getPropName(MethodDoc m, boolean includeSetters) {
    if (m.parameters().length > 0) {
        return null;
    }
    if (m.name().startsWith("get") && m.name().length() > 3) {
        if (m.returnType().typeName().equals(Void.TYPE.getName())) {
            return null;
        }
        return m.name().substring(3, 4).toLowerCase() + m.name().substring(4);
    }
    if (m.name().startsWith("is") && m.name().length() > 2) {
        if (m.returnType().typeName().equals(Boolean.TYPE.getName())) {
            return null;
        }
        return m.name().substring(2, 3).toLowerCase() + m.name().substring(3);
    }
    if (includeSetters && m.name().startsWith("set") && m.name().length() > 3) {
        if (!m.returnType().typeName().equals(Void.TYPE.getName())
                || m.parameters().length != 1) {
            return null;
        }
        return m.name().substring(3, 4).toLowerCase() + m.name().substring(4);
    }
    return null;
}
项目: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("});");
    }
}
项目:lookaside_java-1.8.0-openjdk    文件: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("});");
    }
}
项目: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());
}
项目:infobip-open-jdk-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("});");
    }
}
项目:jdk8u-dev-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("});");
    }
}
项目:xml-doclet    文件:Parser.java   
private String parseIdentifier(Doc doc) {
  if (doc instanceof ClassDoc) {
    ClassDoc classDoc = (ClassDoc) doc;

    return parseIdentifier((Doc) classDoc.containingPackage()) + classDoc.name() + "/";
  } else if (doc instanceof AnnotationTypeElementDoc) {
    AnnotationTypeElementDoc annotationTypeElementDoc = (AnnotationTypeElementDoc) doc;
    return parseIdentifier((Doc) annotationTypeElementDoc.containingClass()) + "#" + annotationTypeElementDoc.name();
  } else if (doc instanceof FieldDoc) {
    FieldDoc fieldDoc = (FieldDoc) doc;
    return parseIdentifier((Doc) fieldDoc.containingClass()) + "#" + fieldDoc.name();
  } else if (doc instanceof ConstructorDoc) {
    ConstructorDoc constructorDoc = (ConstructorDoc) doc;
    return parseIdentifier((Doc) constructorDoc.containingClass()) + "#" + constructorDoc.name() + URLEncoder.encode(constructorDoc.flatSignature());
  } else if (doc instanceof MethodDoc) {
    MethodDoc methodDoc = (MethodDoc) doc;
    return parseIdentifier((Doc) methodDoc.containingClass()) + "#" + methodDoc.name() + URLEncoder.encode(methodDoc.flatSignature());
  } else {
    return "/" + doc.name() + "/";
  }
}
项目:api-resolver    文件:ApiDoclet.java   
private static String getApiMapping(ClassDoc classDoc, MethodDoc methodDoc) throws Exception {

    Class<?> classz = Class.forName(classDoc.qualifiedTypeName());
    Class<?>[] interfaces = classz.getInterfaces();
    for (Class<?> inf : interfaces) {
        if (inf.isAssignableFrom(ApiExportor.class)) {
            return new SimpleApiMapping().getMappingName(classz, DocletUtil.getMethodByDoc(classz, methodDoc));
        }
    }

    ApiMapping annotation = classz.getAnnotation(ApiMapping.class);
    if (annotation != null) {
        return new AnnotationApiMapping().getMappingName(classz, DocletUtil.getMethodByDoc(classz, methodDoc));
    }

    return "";
}
项目:api-resolver    文件:ApiDoclet.java   
public static void returnDoc(ApiDoc apiDoc, ClassDoc classDoc, MethodDoc methodDoc) throws Exception {

    Method method = DocletUtil.getMethodByDoc(Class.forName(classDoc.qualifiedTypeName()), methodDoc);

    Type returnType = method.getGenericReturnType();

    if (returnType.toString().equalsIgnoreCase("void")) {
        return;
    }

    ResultDoc resultDoc = new ResultDoc();
    Tag[] tags = methodDoc.tags("return");
    if (tags != null && tags.length == 1) {
        String[] returnTexts = tags[0].text().split("(e.g|eg|e.g.|example|exam|例如|如)(:|:)", 2);
        resultDoc.setDesc(returnTexts[0]);
        resultDoc.setExampleValue(returnTexts.length==2 ? returnTexts[1] : "");
        resultDoc.setName("");
        resultDoc.setType(methodDoc.returnType().typeName() + methodDoc.returnType().dimension());
    }

    addRefType(classDoc, returnType, resultDoc);

    apiDoc.setResultDoc(resultDoc);
}
项目:jdk7-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("});");
    }
}
项目:conqat    文件:InsufficientCommentAnalyzer.java   
/** {@inheritDoc} */
@Override
public void analyze(MethodDoc docElement, IJavaElement element)
        throws ConQATException {
    if (!isInsufficient(docElement.commentText())) {
        return;
    }

    if (isTagSufficient(docElement, "param")) {
        return;
    }

    if (isTagSufficient(docElement, "return")) {
        return;
    }

    if (isTagSufficient(docElement, "throws")) {
        return;
    }

    if (isSeeTagSufficient(docElement)) {
        return;
    }

    createFinding(docElement, element);
}
项目:conqat    文件:ConQATTaglet.java   
/**
 * Checks the type of the program element and determines comment
 * accordingly.
 */
@Override
public TagletOutput getTagletOutput(Tag tag, TagletWriter writer) {

    Doc doc = tag.holder();

    String text;
    if (doc instanceof MethodDoc) {
        text = methodDoc((MethodDoc) doc);
    } else if (doc instanceof ClassDoc) {
        text = classDoc((ClassDoc) doc);
    } else if (doc instanceof FieldDoc) {
        text = fieldDoc((FieldDoc) doc);
    } else {
        throw new IllegalStateException("Should not happen.");
    }

    if (isFirstSentence(writer)) {
        text = getFirstSentence(text);
    }

    TagletOutput result = writer.getOutputInstance();
    result.setOutput(text);
    return result;
}
项目:openjdk-source-code-learn    文件: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("});");
    }
}
项目:myrobotlab    文件:ListMethodsDoclet.java   
public static boolean start(RootDoc root) {
  ClassDoc[] classes = root.classes();
  for (int i = 0; i < classes.length; i++) {
    System.out.println(classes[i]);
    ClassDoc classdoc = classes[i];
    String x = classdoc.getRawCommentText();
    System.out.println(x);
    MethodDoc[] methods = classes[i].methods();
    for (int j = 0; j < methods.length; j++) {
      MethodDoc m = methods[j];
      System.out.println(m.getRawCommentText());
      if (m.isPublic()) {
        System.out.println("\t" + m.name());
        Parameter[] parameters = m.parameters();
        for (int k = 0; k < parameters.length; k++) {
          Parameter p = parameters[k];
          System.out.println("\t\t" + p.name() + ": " + p.type().qualifiedTypeName());
        }
      }
    }
  }
  return true;
}
项目:OLD-OpenJDK8    文件: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("});");
    }
}
项目:javadoc-json-doclet    文件:JsonDoclet.java   
/**
 * @return the full JSON for the given MethodDoc
 */
protected JSONObject processMethodDoc(MethodDoc methodDoc) {

    if (methodDoc == null) {
        return null;
    }

    JSONObject retMe = processExecutableMemberDoc(methodDoc);

    retMe.put("returnType", processType(methodDoc.returnType()));
    retMe.put("overriddenMethod", processMethodDocStub(methodDoc.overriddenMethod() ) );
    retMe.put("overriddenType", processTypeStub(methodDoc.overriddenType() ) );
    MethodDoc specifiedByMethodDoc = getSpecifiedByMethod(methodDoc);
    retMe.put("specifiedByMethod", processMethodDocStub( specifiedByMethodDoc ) );

    if (methodDoc.overriddenMethod() != null || specifiedByMethodDoc != null) {
        inheritDoc(retMe, methodDoc, specifiedByMethodDoc);
    }

    return retMe;
}
项目:javadoc-json-doclet    文件:JsonDoclet.java   
/**
 * @return retMe
 */
protected JSONObject inheritReturnTag(JSONObject retMe, MethodDoc methodDoc, MethodDoc specifiedByMethodDoc) {

    String returnTagText = getInheritedReturnTagText(methodDoc, specifiedByMethodDoc);

    if (! StringUtils.isEmpty( returnTagText ) ) {

        // TODO: Cawls.replaceFirst would be a nice method to have....
        JSONObject returnTag = (JSONObject) Cawls.findFirst( (List<Map>)retMe.get("tags"), new MapBuilder().append("name","@return") );

        if (returnTag != null) {
            returnTag.put("text", returnTagText);   // updates the list in place.
        } else {
            // Add a new tag to the list.
            ((JSONArray)retMe.get("tags")).add( new MapBuilder().append("name", "@return")
                                                                .append("kind", "@return")
                                                                .append("text", returnTagText ) );
        }
    }

    return retMe;
}
项目:javadoc-json-doclet    文件:JsonDoclet.java   
/**
 * Resolve inherited comment text by scanning up the methodDoc's inheritance chain,
 * resolving any {@inheritDoc} encountered along the way.
 *
 * This method returns as soon as it finds a non-empty commentText with all {@inheritDoc}
 * tags resolved.
 * 
 * @return the comment text for the given methodDoc, all inheritance resolved.
 */
protected String getInheritedCommentText(MethodDoc methodDoc, MethodDoc specifiedByMethodDoc) {

    String retMe = null;

    for ( ;
         methodDoc != null && (StringUtils.isEmpty(retMe) || retMe.contains(JsonDoclet.InheritDocTag) );
         methodDoc = methodDoc.overriddenMethod() ) {

        retMe = resolveInheritDoc(retMe, methodDoc.commentText() );
    }

    // Inherit from the interface
    retMe = resolveInheritDoc(retMe, (specifiedByMethodDoc != null) ? specifiedByMethodDoc.commentText() : null);

    return retMe;
}
项目:javadoc-json-doclet    文件:JsonDoclet.java   
/**
 * Resolve inherited @return tag text by scanning up the methodDoc's inheritance chain,
 * resolving any {@inheritDoc} encountered along the way.
 *
 * This method returns as soon as it finds a non-empty @return tag text with all {@inheritDoc}
 * tags resolved.
 *
 * Note: the logic of this method is exactly the same as getInheritedCommentText.
 *       The only difference is the value we're retrieving from the methodDoc (@return tag
 *       text vs commentText).
 * 
 * @return the @return tag text for the given methodDoc, all inheritance resolved.
 */
protected String getInheritedReturnTagText(MethodDoc methodDoc, MethodDoc specifiedByMethodDoc) {

    String retMe = null;

    for ( ;
         methodDoc != null && (StringUtils.isEmpty(retMe) || retMe.contains(JsonDoclet.InheritDocTag) );
         methodDoc = methodDoc.overriddenMethod() ) {

        retMe = resolveInheritDoc(retMe, getReturnTagText( methodDoc ) );
    }

    // Inherit from the interface
    retMe = resolveInheritDoc(retMe, getReturnTagText( specifiedByMethodDoc) );

    return retMe;
}
项目:javadoc-json-doclet    文件:JsonDoclet.java   
/**
 * Resolve inherited @param tag text by scanning up the methodDoc's inheritance chain,
 * resolving any {@inheritDoc} encountered along the way.
 *
 * This method returns as soon as it finds a non-empty @param tag text with all {@inheritDoc}
 * tags resolved.
 *
 * Note: the logic of this method is exactly the same as getInheritedCommentText.
 *       The only difference is the value we're retrieving from the methodDoc (@param tag
 *       text vs commentText).
 * 
 * @return the @param tag text for the given methodDoc, all inheritance resolved.
 */
protected String getInheritedParamTagComment(MethodDoc methodDoc, String parameterName, MethodDoc specifiedByMethodDoc) {

    String retMe = null;

    for ( ;
         methodDoc != null && (StringUtils.isEmpty(retMe) || retMe.contains(JsonDoclet.InheritDocTag) );
         methodDoc = methodDoc.overriddenMethod() ) {

        retMe = resolveInheritDoc(retMe, getParamTagComment( methodDoc, parameterName ));
    }

    // Inherit from the interface
    retMe = resolveInheritDoc(retMe, getParamTagComment( specifiedByMethodDoc, parameterName) );

    return retMe;
}
项目:javadoc-json-doclet    文件:JsonDoclet.java   
/**
 * @return the first non-null ParamTag with the given parameterName in the inheritance tree
 *         for the given methodDoc.
 */
protected ParamTag getInheritedParamTag(MethodDoc methodDoc, String parameterName, MethodDoc specifiedByMethodDoc)  {

    for ( ;
         methodDoc != null;
         methodDoc = methodDoc.overriddenMethod() ) {

        ParamTag retMe = getParamTag( methodDoc.paramTags(), parameterName );
        if (retMe != null) {
            return retMe;
        }
    }

    // Couldn't find it in the superclass hierarchy. Check the interface method
    return (specifiedByMethodDoc != null) ? getParamTag( specifiedByMethodDoc.paramTags(), parameterName ) : null;
}
项目:javadoc-json-doclet    文件:JsonDoclet.java   
/**
 * @return the method from the given intf (or its superclasses) that is overridden
 *         (or implemented by) the given methodDoc.
 */
protected MethodDoc getSpecifiedByMethod(MethodDoc methodDoc, ClassDoc intf) {

    MethodDoc retMe = null;

    if (intf != null) {
        retMe = getOverriddenMethod( methodDoc, intf.methods() ); 

        if (retMe == null) {
            // Try the super interface.
            retMe = getSpecifiedByMethod( methodDoc, intf.superclass() );
        }
    }

    return retMe;
}
项目:rest4j    文件:Rest4JDoclet.java   
/**
 * 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);
    }
  }

  _docInfo.put(_id, docInfo);

  return true;
}
项目:rest4j    文件:DocletDocsProvider.java   
@Override
public String getParamDoc(Method method, String name)
{
  final MethodDoc methodDoc = Rest4JDoclet.getMethodDoc(_docletId, method);
  if (methodDoc != null)
  {
    for (ParamTag tag: methodDoc.paramTags())
    {
      if (name.equals(tag.parameterName()))
      {
        return buildDoc(tag.parameterComment());
      }
    }
  }

  return null;
}
项目:openjdk-jdk7u-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("});");
    }
}