Ejemplo n.º 1
0
 /**
  * Given an array of <code>Parameter</code>s, return a name/rank number map. If the array is null,
  * then null is returned.
  *
  * @param params The array of parameters (from type or executable member) to check.
  * @return a name-rank number map.
  */
 private static Map<String, String> getRankMap(Utils utils, List<? extends Element> params) {
   if (params == null) {
     return null;
   }
   HashMap<String, String> result = new HashMap<>();
   int rank = 0;
   for (Element e : params) {
     String name =
         utils.isTypeParameterElement(e)
             ? utils.getTypeName(e.asType(), false)
             : utils.getSimpleName(e);
     result.put(name, String.valueOf(rank));
     rank++;
   }
   return result;
 }
Ejemplo n.º 2
0
 /**
  * Given an array of <code>ParamTag</code>s,return its string representation.
  *
  * @param holder the member that holds the param tags.
  * @param writer the TagletWriter that will write this tag.
  * @return the TagletOutput representation of these <code>ParamTag</code>s.
  */
 public Content getTagletOutput(Element holder, TagletWriter writer) {
   Utils utils = writer.configuration().utils;
   if (utils.isExecutableElement(holder)) {
     ExecutableElement member = (ExecutableElement) holder;
     Content output =
         getTagletOutput(
             false, member, writer, member.getTypeParameters(), utils.getTypeParamTrees(member));
     output.addContent(
         getTagletOutput(
             true, member, writer, member.getParameters(), utils.getParamTrees(member)));
     return output;
   } else {
     TypeElement typeElement = (TypeElement) holder;
     return getTagletOutput(
         false,
         typeElement,
         writer,
         typeElement.getTypeParameters(),
         utils.getTypeParamTrees(typeElement));
   }
 }
Ejemplo n.º 3
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;
 }
Ejemplo n.º 4
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;
     }
   }
 }