langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/taglets/ValueTaglet.java
author ksrini
Mon, 05 Jun 2017 13:45:34 -0700
changeset 45417 f7479ee8de69
parent 40303 96a1226aca18
permissions -rw-r--r--
8177848: Rename Configuration(Impl) classes Reviewed-by: jjg
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
10
06bc494ca11e Initial load
duke
parents:
diff changeset
     1
/*
45417
f7479ee8de69 8177848: Rename Configuration(Impl) classes
ksrini
parents: 40303
diff changeset
     2
 * Copyright (c) 2001, 2017, Oracle and/or its affiliates. All rights reserved.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
06bc494ca11e Initial load
duke
parents:
diff changeset
     4
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
06bc494ca11e Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5520
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 10
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
10
06bc494ca11e Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5520
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 10
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    10
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
06bc494ca11e Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
06bc494ca11e Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
06bc494ca11e Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
06bc494ca11e Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
06bc494ca11e Initial load
duke
parents:
diff changeset
    16
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
06bc494ca11e Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
06bc494ca11e Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
06bc494ca11e Initial load
duke
parents:
diff changeset
    20
 *
5520
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 10
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 10
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 10
diff changeset
    23
 * questions.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    24
 */
06bc494ca11e Initial load
duke
parents:
diff changeset
    25
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 25874
diff changeset
    26
package jdk.javadoc.internal.doclets.toolkit.taglets;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 25874
diff changeset
    27
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    28
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 25874
diff changeset
    29
import javax.lang.model.element.Element;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 25874
diff changeset
    30
import javax.lang.model.element.TypeElement;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 25874
diff changeset
    31
import javax.lang.model.element.VariableElement;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 25874
diff changeset
    32
import javax.lang.model.util.Elements;
14258
8d2148961366 8000663: clean up langtools imports
jjg
parents: 5520
diff changeset
    33
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 25874
diff changeset
    34
import com.sun.source.doctree.DocTree;
45417
f7479ee8de69 8177848: Rename Configuration(Impl) classes
ksrini
parents: 40303
diff changeset
    35
import jdk.javadoc.internal.doclets.toolkit.BaseConfiguration;
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 25874
diff changeset
    36
import jdk.javadoc.internal.doclets.toolkit.Content;
40303
96a1226aca18 8160697: HTMLWriter needs perf cleanup
jjg
parents: 39364
diff changeset
    37
import jdk.javadoc.internal.doclets.toolkit.Messages;
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 25874
diff changeset
    38
import jdk.javadoc.internal.doclets.toolkit.util.CommentHelper;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 25874
diff changeset
    39
import jdk.javadoc.internal.doclets.toolkit.util.Utils;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 25874
diff changeset
    40
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 25874
diff changeset
    41
import static com.sun.source.doctree.DocTree.Kind.*;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    42
06bc494ca11e Initial load
duke
parents:
diff changeset
    43
/**
06bc494ca11e Initial load
duke
parents:
diff changeset
    44
 * An inline Taglet representing the value tag. This tag should only be used with
06bc494ca11e Initial load
duke
parents:
diff changeset
    45
 * constant fields that have a value.  It is used to access the value of constant
06bc494ca11e Initial load
duke
parents:
diff changeset
    46
 * fields.  This inline tag has an optional field name parameter.  If the name is
06bc494ca11e Initial load
duke
parents:
diff changeset
    47
 * specified, the constant value is retrieved from the specified field.  A link
06bc494ca11e Initial load
duke
parents:
diff changeset
    48
 * is also created to the specified field.  If a name is not specified, the value
06bc494ca11e Initial load
duke
parents:
diff changeset
    49
 * is retrieved for the field that the inline tag appears on.  The name is specifed
06bc494ca11e Initial load
duke
parents:
diff changeset
    50
 * in the following format:  [fully qualified class name]#[constant field name].
06bc494ca11e Initial load
duke
parents:
diff changeset
    51
 *
14260
727a84636f12 8000665: fix "internal API" comments on javadoc files
jjg
parents: 14259
diff changeset
    52
 *  <p><b>This is NOT part of any supported API.
727a84636f12 8000665: fix "internal API" comments on javadoc files
jjg
parents: 14259
diff changeset
    53
 *  If you write code that depends on this, you do so at your own risk.
727a84636f12 8000665: fix "internal API" comments on javadoc files
jjg
parents: 14259
diff changeset
    54
 *  This code and its internal interfaces are subject to change or
727a84636f12 8000665: fix "internal API" comments on javadoc files
jjg
parents: 14259
diff changeset
    55
 *  deletion without notice.</b>
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    56
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    57
 * @author Jamie Ho
06bc494ca11e Initial load
duke
parents:
diff changeset
    58
 */
06bc494ca11e Initial load
duke
parents:
diff changeset
    59
06bc494ca11e Initial load
duke
parents:
diff changeset
    60
public class ValueTaglet extends BaseInlineTaglet {
06bc494ca11e Initial load
duke
parents:
diff changeset
    61
06bc494ca11e Initial load
duke
parents:
diff changeset
    62
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    63
     * Construct a new ValueTaglet.
06bc494ca11e Initial load
duke
parents:
diff changeset
    64
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    65
    public ValueTaglet() {
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 25874
diff changeset
    66
        name = VALUE.tagName;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    67
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
    68
06bc494ca11e Initial load
duke
parents:
diff changeset
    69
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    70
     * Will return false because this inline tag may
06bc494ca11e Initial load
duke
parents:
diff changeset
    71
     * only appear in Fields.
06bc494ca11e Initial load
duke
parents:
diff changeset
    72
     * @return false since this is not a method.
06bc494ca11e Initial load
duke
parents:
diff changeset
    73
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    74
    public boolean inMethod() {
06bc494ca11e Initial load
duke
parents:
diff changeset
    75
        return true;
06bc494ca11e Initial load
duke
parents:
diff changeset
    76
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
    77
06bc494ca11e Initial load
duke
parents:
diff changeset
    78
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    79
     * Will return false because this inline tag may
06bc494ca11e Initial load
duke
parents:
diff changeset
    80
     * only appear in Fields.
06bc494ca11e Initial load
duke
parents:
diff changeset
    81
     * @return false since this is not a method.
06bc494ca11e Initial load
duke
parents:
diff changeset
    82
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    83
    public boolean inConstructor() {
06bc494ca11e Initial load
duke
parents:
diff changeset
    84
        return true;
06bc494ca11e Initial load
duke
parents:
diff changeset
    85
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
    86
06bc494ca11e Initial load
duke
parents:
diff changeset
    87
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    88
     * Will return false because this inline tag may
06bc494ca11e Initial load
duke
parents:
diff changeset
    89
     * only appear in Fields.
06bc494ca11e Initial load
duke
parents:
diff changeset
    90
     * @return false since this is not a method.
06bc494ca11e Initial load
duke
parents:
diff changeset
    91
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    92
    public boolean inOverview() {
06bc494ca11e Initial load
duke
parents:
diff changeset
    93
        return true;
06bc494ca11e Initial load
duke
parents:
diff changeset
    94
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
    95
06bc494ca11e Initial load
duke
parents:
diff changeset
    96
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    97
     * Will return false because this inline tag may
06bc494ca11e Initial load
duke
parents:
diff changeset
    98
     * only appear in Fields.
38911
48a00b5ee366 8156077: Support javadoc tags in module documentation
bpatel
parents: 35426
diff changeset
    99
     * @return false since this is not a field.
48a00b5ee366 8156077: Support javadoc tags in module documentation
bpatel
parents: 35426
diff changeset
   100
     */
48a00b5ee366 8156077: Support javadoc tags in module documentation
bpatel
parents: 35426
diff changeset
   101
    public boolean inModule() {
48a00b5ee366 8156077: Support javadoc tags in module documentation
bpatel
parents: 35426
diff changeset
   102
        return false;
48a00b5ee366 8156077: Support javadoc tags in module documentation
bpatel
parents: 35426
diff changeset
   103
    }
48a00b5ee366 8156077: Support javadoc tags in module documentation
bpatel
parents: 35426
diff changeset
   104
48a00b5ee366 8156077: Support javadoc tags in module documentation
bpatel
parents: 35426
diff changeset
   105
    /**
48a00b5ee366 8156077: Support javadoc tags in module documentation
bpatel
parents: 35426
diff changeset
   106
     * Will return false because this inline tag may
48a00b5ee366 8156077: Support javadoc tags in module documentation
bpatel
parents: 35426
diff changeset
   107
     * only appear in Fields.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   108
     * @return false since this is not a method.
06bc494ca11e Initial load
duke
parents:
diff changeset
   109
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   110
    public boolean inPackage() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   111
        return true;
06bc494ca11e Initial load
duke
parents:
diff changeset
   112
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   113
06bc494ca11e Initial load
duke
parents:
diff changeset
   114
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   115
     * Will return false because this inline tag may
06bc494ca11e Initial load
duke
parents:
diff changeset
   116
     * only appear in Fields.
06bc494ca11e Initial load
duke
parents:
diff changeset
   117
     * @return false since this is not a method.
06bc494ca11e Initial load
duke
parents:
diff changeset
   118
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   119
    public boolean inType() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   120
        return true;
06bc494ca11e Initial load
duke
parents:
diff changeset
   121
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   122
06bc494ca11e Initial load
duke
parents:
diff changeset
   123
    /**
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 25874
diff changeset
   124
     * Given the name of the field, return the corresponding VariableElement. Return null
20264
f7527e6828bb 8004825: javadoc crash DocletAbortException
bpatel
parents: 19667
diff changeset
   125
     * due to invalid use of value tag if the name is null or empty string and if
f7527e6828bb 8004825: javadoc crash DocletAbortException
bpatel
parents: 19667
diff changeset
   126
     * the value tag is not used on a field.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   127
     *
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 25874
diff changeset
   128
     * @param holder the element holding the tag
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   129
     * @param config the current configuration of the doclet.
06bc494ca11e Initial load
duke
parents:
diff changeset
   130
     * @param tag the value tag.
06bc494ca11e Initial load
duke
parents:
diff changeset
   131
     *
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 25874
diff changeset
   132
     * @return the corresponding VariableElement. If the name is null or empty string,
20264
f7527e6828bb 8004825: javadoc crash DocletAbortException
bpatel
parents: 19667
diff changeset
   133
     * return field that the value tag was used in. Return null if the name is null
f7527e6828bb 8004825: javadoc crash DocletAbortException
bpatel
parents: 19667
diff changeset
   134
     * or empty string and if the value tag is not used on a field.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   135
     */
45417
f7479ee8de69 8177848: Rename Configuration(Impl) classes
ksrini
parents: 40303
diff changeset
   136
    private VariableElement getVariableElement(Element holder, BaseConfiguration config, DocTree tag) {
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 25874
diff changeset
   137
        Utils utils = config.utils;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 25874
diff changeset
   138
        CommentHelper ch = utils.getCommentHelper(holder);
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 25874
diff changeset
   139
        String signature = ch.getReferencedSignature(tag);
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 25874
diff changeset
   140
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 25874
diff changeset
   141
        if (signature == null) { // no reference
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   142
            //Base case: no label.
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 25874
diff changeset
   143
            if (utils.isVariableElement(holder)) {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 25874
diff changeset
   144
                return (VariableElement)(holder);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   145
            } else {
20264
f7527e6828bb 8004825: javadoc crash DocletAbortException
bpatel
parents: 19667
diff changeset
   146
                // If the value tag does not specify a parameter which is a valid field and
f7527e6828bb 8004825: javadoc crash DocletAbortException
bpatel
parents: 19667
diff changeset
   147
                // it is not used within the comments of a valid field, return null.
f7527e6828bb 8004825: javadoc crash DocletAbortException
bpatel
parents: 19667
diff changeset
   148
                 return null;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   149
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   150
        }
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 25874
diff changeset
   151
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 25874
diff changeset
   152
        String[] sigValues = signature.split("#");
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   153
        String memberName = null;
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 25874
diff changeset
   154
        TypeElement te = null;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 25874
diff changeset
   155
        if (sigValues.length == 1) {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   156
            //Case 2:  @value in same class.
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 25874
diff changeset
   157
            if (utils.isExecutableElement(holder) || utils.isVariableElement(holder)) {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 25874
diff changeset
   158
                te = utils.getEnclosingTypeElement(holder);
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 25874
diff changeset
   159
            } else if (utils.isTypeElement(holder)) {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 25874
diff changeset
   160
                te = utils.getTopMostContainingTypeElement(holder);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   161
            }
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 25874
diff changeset
   162
            memberName = sigValues[0];
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   163
        } else {
06bc494ca11e Initial load
duke
parents:
diff changeset
   164
            //Case 3: @value in different class.
39364
bd6d4a7936b4 8160301: javadoc RootDoclmpl and DocEnv needs to be renamed
ksrini
parents: 38911
diff changeset
   165
            Elements elements = config.docEnv.getElementUtils();
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 25874
diff changeset
   166
            te = elements.getTypeElement(sigValues[0]);
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 25874
diff changeset
   167
            memberName = sigValues[1];
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   168
        }
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 25874
diff changeset
   169
        if (te == null) {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   170
            return null;
06bc494ca11e Initial load
duke
parents:
diff changeset
   171
        }
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 25874
diff changeset
   172
        for (Element field : utils.getFields(te)) {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 25874
diff changeset
   173
            if (utils.getSimpleName(field).equals(memberName)) {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 25874
diff changeset
   174
                return (VariableElement)field;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   175
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   176
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   177
        return null;
06bc494ca11e Initial load
duke
parents:
diff changeset
   178
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   179
06bc494ca11e Initial load
duke
parents:
diff changeset
   180
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   181
     * {@inheritDoc}
06bc494ca11e Initial load
duke
parents:
diff changeset
   182
     */
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 25874
diff changeset
   183
    public Content getTagletOutput(Element holder, DocTree tag, TagletWriter writer) {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 25874
diff changeset
   184
        Utils utils = writer.configuration().utils;
40303
96a1226aca18 8160697: HTMLWriter needs perf cleanup
jjg
parents: 39364
diff changeset
   185
        Messages messages = writer.configuration().getMessages();
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 25874
diff changeset
   186
        VariableElement field = getVariableElement(holder, writer.configuration(), tag);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   187
        if (field == null) {
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 25874
diff changeset
   188
            if (tag.toString().isEmpty()) {
20264
f7527e6828bb 8004825: javadoc crash DocletAbortException
bpatel
parents: 19667
diff changeset
   189
                //Invalid use of @value
40303
96a1226aca18 8160697: HTMLWriter needs perf cleanup
jjg
parents: 39364
diff changeset
   190
                messages.warning(holder,
20264
f7527e6828bb 8004825: javadoc crash DocletAbortException
bpatel
parents: 19667
diff changeset
   191
                        "doclet.value_tag_invalid_use");
f7527e6828bb 8004825: javadoc crash DocletAbortException
bpatel
parents: 19667
diff changeset
   192
            } else {
f7527e6828bb 8004825: javadoc crash DocletAbortException
bpatel
parents: 19667
diff changeset
   193
                //Reference is unknown.
40303
96a1226aca18 8160697: HTMLWriter needs perf cleanup
jjg
parents: 39364
diff changeset
   194
                messages.warning(holder,
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 25874
diff changeset
   195
                        "doclet.value_tag_invalid_reference", tag.toString());
20264
f7527e6828bb 8004825: javadoc crash DocletAbortException
bpatel
parents: 19667
diff changeset
   196
            }
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 25874
diff changeset
   197
        } else if (field.getConstantValue() != null) {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   198
            return writer.valueTagOutput(field,
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 25874
diff changeset
   199
                utils.constantValueExpresion(field),
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 25874
diff changeset
   200
                // TODO: investigate and cleanup
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 25874
diff changeset
   201
                // in the j.l.m world, equals will not be accurate
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 25874
diff changeset
   202
                // !field.equals(tag.holder())
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 25874
diff changeset
   203
                !utils.elementsEqual(field, holder)
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 25874
diff changeset
   204
            );
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   205
        } else {
06bc494ca11e Initial load
duke
parents:
diff changeset
   206
            //Referenced field is not a constant.
40303
96a1226aca18 8160697: HTMLWriter needs perf cleanup
jjg
parents: 39364
diff changeset
   207
            messages.warning(holder,
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 25874
diff changeset
   208
                "doclet.value_tag_invalid_constant", utils.getSimpleName(field));
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   209
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   210
        return writer.getOutputInstance();
06bc494ca11e Initial load
duke
parents:
diff changeset
   211
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   212
}