Example #1
0
 /** {@inheritDoc} */
 public void inherit(DocFinder.Input input, DocFinder.Output output) {
   Utils utils = input.utils;
   if (input.tagId == null) {
     input.isTypeVariableParamTag = ((ParamTree) input.docTreeInfo.docTree).isTypeParameter();
     ExecutableElement ee = (ExecutableElement) input.docTreeInfo.element;
     CommentHelper ch = utils.getCommentHelper(ee);
     List<? extends Element> parameters =
         input.isTypeVariableParamTag ? ee.getTypeParameters() : ee.getParameters();
     String target = ch.getParameterName(input.docTreeInfo.docTree);
     for (int i = 0; i < parameters.size(); i++) {
       Element e = parameters.get(i);
       String pname =
           input.isTypeVariableParamTag
               ? utils.getTypeName(e.asType(), false)
               : utils.getSimpleName(e);
       if (pname.equals(target)) {
         input.tagId = String.valueOf(i);
         break;
       }
     }
   }
   ExecutableElement md = (ExecutableElement) input.element;
   CommentHelper ch = utils.getCommentHelper(md);
   List<? extends DocTree> tags =
       input.isTypeVariableParamTag ? utils.getTypeParamTrees(md) : utils.getParamTrees(md);
   List<? extends Element> parameters =
       input.isTypeVariableParamTag ? md.getTypeParameters() : md.getParameters();
   Map<String, String> rankMap = getRankMap(utils, parameters);
   for (DocTree tag : tags) {
     String paramName = ch.getParameterName(tag);
     if (rankMap.containsKey(paramName) && rankMap.get(paramName).equals((input.tagId))) {
       output.holder = input.element;
       output.holderTag = tag;
       output.inlineTags = ch.getBody(utils.configuration, tag);
       return;
     }
   }
 }
Example #2
0
 /**
  * Loop through each individual parameter, despite not having a corresponding param tag, try to
  * inherit it.
  */
 private Content getInheritedTagletOutput(
     boolean isParameters,
     Element holder,
     TagletWriter writer,
     List<? extends Element> formalParameters,
     Set<String> alreadyDocumented) {
   Utils utils = writer.configuration().utils;
   Content result = writer.getOutputInstance();
   if ((!alreadyDocumented.contains(null)) && utils.isExecutableElement(holder)) {
     for (int i = 0; i < formalParameters.size(); i++) {
       if (alreadyDocumented.contains(String.valueOf(i))) {
         continue;
       }
       // This parameter does not have any @param documentation.
       // Try to inherit it.
       Input input =
           new DocFinder.Input(
               writer.configuration().utils, holder, this, Integer.toString(i), !isParameters);
       DocFinder.Output inheritedDoc = DocFinder.search(writer.configuration(), input);
       if (inheritedDoc.inlineTags != null && !inheritedDoc.inlineTags.isEmpty()) {
         Element e = formalParameters.get(i);
         String lname =
             isParameters ? utils.getSimpleName(e) : utils.getTypeName(e.asType(), false);
         CommentHelper ch = utils.getCommentHelper(holder);
         ch.setOverrideElement(inheritedDoc.holder);
         Content content =
             processParamTag(
                 holder,
                 isParameters,
                 writer,
                 inheritedDoc.holderTag,
                 lname,
                 alreadyDocumented.isEmpty());
         result.addContent(content);
       }
       alreadyDocumented.add(String.valueOf(i));
     }
   }
   return result;
 }