src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/InheritDocTaglet.java

changeset 1724
d918b63a5509
parent 1410
bfec2a1cc869
child 1743
6a5288a298fd
     1.1 --- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/InheritDocTaglet.java	Fri May 03 15:08:47 2013 -0700
     1.2 +++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/InheritDocTaglet.java	Fri May 03 17:44:38 2013 -0700
     1.3 @@ -1,5 +1,5 @@
     1.4  /*
     1.5 - * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved.
     1.6 + * Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved.
     1.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1.8   *
     1.9   * This code is free software; you can redistribute it and/or modify it
    1.10 @@ -60,8 +60,8 @@
    1.11  
    1.12      /**
    1.13       * Will return false because this inline tag may
    1.14 -     * only appear in Methods.
    1.15 -     * @return false since this is not a method.
    1.16 +     * not appear in Fields.
    1.17 +     * @return false
    1.18       */
    1.19      public boolean inField() {
    1.20          return false;
    1.21 @@ -69,8 +69,8 @@
    1.22  
    1.23      /**
    1.24       * Will return false because this inline tag may
    1.25 -     * only appear in Methods.
    1.26 -     * @return false since this is not a method.
    1.27 +     * not appear in Constructors.
    1.28 +     * @return false
    1.29       */
    1.30      public boolean inConstructor() {
    1.31          return false;
    1.32 @@ -78,8 +78,8 @@
    1.33  
    1.34      /**
    1.35       * Will return false because this inline tag may
    1.36 -     * only appear in Methods.
    1.37 -     * @return false since this is not a method.
    1.38 +     * not appear in Overview.
    1.39 +     * @return false
    1.40       */
    1.41      public boolean inOverview() {
    1.42          return false;
    1.43 @@ -87,20 +87,20 @@
    1.44  
    1.45      /**
    1.46       * Will return false because this inline tag may
    1.47 -     * only appear in Methods.
    1.48 -     * @return false since this is not a method.
    1.49 +     * not appear in Packages.
    1.50 +     * @return false
    1.51       */
    1.52      public boolean inPackage() {
    1.53          return false;
    1.54      }
    1.55  
    1.56      /**
    1.57 -     * Will return false because this inline tag may
    1.58 -     * only appear in Methods.
    1.59 -     * @return false since this is not a method.
    1.60 +     * Will return true because this inline tag may
    1.61 +     * appear in Type (Class).
    1.62 +     * @return true
    1.63       */
    1.64      public boolean inType() {
    1.65 -        return false;
    1.66 +        return true;
    1.67      }
    1.68  
    1.69      /**
    1.70 @@ -109,12 +109,13 @@
    1.71       * of @inheritDoc with documentation from it's superclass or superinterface.
    1.72       *
    1.73       * @param writer the writer that is writing the output.
    1.74 -     * @param md the {@link MethodDoc} that we are documenting.
    1.75 -     * @param holderTag the tag that holds the inheritDoc tag.
    1.76 +     * @param ped the {@link ProgramElementDoc} that we are documenting.
    1.77 +     * @param holderTag the tag that holds the inheritDoc tag or null for type
    1.78 +     * (class) docs.
    1.79       * @param isFirstSentence true if we only want to inherit the first sentence.
    1.80       */
    1.81      private TagletOutput retrieveInheritedDocumentation(TagletWriter writer,
    1.82 -            MethodDoc md, Tag holderTag, boolean isFirstSentence) {
    1.83 +            ProgramElementDoc ped, Tag holderTag, boolean isFirstSentence) {
    1.84          TagletOutput replacement = writer.getTagletOutputInstance();
    1.85  
    1.86          Configuration configuration = writer.configuration();
    1.87 @@ -122,20 +123,30 @@
    1.88              null : configuration.tagletManager.getTaglet(holderTag.name());
    1.89          if (inheritableTaglet != null &&
    1.90              !(inheritableTaglet instanceof InheritableTaglet)) {
    1.91 +                String message = ped.name() +
    1.92 +                    ((ped instanceof ExecutableMemberDoc)
    1.93 +                        ? ((ExecutableMemberDoc)ped).flatSignature()
    1.94 +                        : "");
    1.95                  //This tag does not support inheritence.
    1.96 -                configuration.message.warning(md.position(),
    1.97 -                "doclet.noInheritedDoc", md.name() + md.flatSignature());
    1.98 +                configuration.message.warning(ped.position(),
    1.99 +                "doclet.noInheritedDoc", message);
   1.100           }
   1.101          DocFinder.Output inheritedDoc =
   1.102 -            DocFinder.search(new DocFinder.Input(md,
   1.103 +            DocFinder.search(new DocFinder.Input(ped,
   1.104                  (InheritableTaglet) inheritableTaglet, holderTag,
   1.105                  isFirstSentence, true));
   1.106 -        if (inheritedDoc.isValidInheritDocTag == false) {
   1.107 -            configuration.message.warning(md.position(),
   1.108 -                "doclet.noInheritedDoc", md.name() + md.flatSignature());
   1.109 -        } else if (inheritedDoc.inlineTags.length > 0) {
   1.110 -            replacement = writer.commentTagsToOutput(inheritedDoc.holderTag,
   1.111 -                inheritedDoc.holder, inheritedDoc.inlineTags, isFirstSentence);
   1.112 +        if (inheritedDoc.isValidInheritDocTag) {
   1.113 +            if (inheritedDoc.inlineTags.length > 0) {
   1.114 +                replacement = writer.commentTagsToOutput(inheritedDoc.holderTag,
   1.115 +                    inheritedDoc.holder, inheritedDoc.inlineTags, isFirstSentence);
   1.116 +            }
   1.117 +        } else {
   1.118 +            String message = ped.name() +
   1.119 +                    ((ped instanceof ExecutableMemberDoc)
   1.120 +                        ? ((ExecutableMemberDoc)ped).flatSignature()
   1.121 +                        : "");
   1.122 +            configuration.message.warning(ped.position(),
   1.123 +                "doclet.noInheritedDoc", message);
   1.124          }
   1.125          return replacement;
   1.126      }
   1.127 @@ -149,11 +160,11 @@
   1.128       * @return the TagletOutput representation of this <code>Tag</code>.
   1.129       */
   1.130      public TagletOutput getTagletOutput(Tag tag, TagletWriter tagletWriter) {
   1.131 -        if (! (tag.holder() instanceof MethodDoc)) {
   1.132 +        if (! (tag.holder() instanceof ProgramElementDoc)) {
   1.133              return tagletWriter.getOutputInstance();
   1.134          }
   1.135          return tag.name().equals("@inheritDoc") ?
   1.136 -                retrieveInheritedDocumentation(tagletWriter, (MethodDoc) tag.holder(), null, tagletWriter.isFirstSentence) :
   1.137 -                retrieveInheritedDocumentation(tagletWriter, (MethodDoc) tag.holder(), tag, tagletWriter.isFirstSentence);
   1.138 +                retrieveInheritedDocumentation(tagletWriter, (ProgramElementDoc) tag.holder(), null, tagletWriter.isFirstSentence) :
   1.139 +                retrieveInheritedDocumentation(tagletWriter, (ProgramElementDoc) tag.holder(), tag, tagletWriter.isFirstSentence);
   1.140      }
   1.141  }

mercurial