langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/Util.java
author jjg
Sun, 24 Feb 2013 11:36:58 -0800
changeset 16319 e586bfeb39c5
parent 15385 ee1eebe7e210
child 17569 ef80738645e2
permissions -rw-r--r--
7112427: The doclet needs to be able to generate JavaFX documentation. Reviewed-by: jjg Contributed-by: jan.valenta@oracle.com
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
10
06bc494ca11e Initial load
duke
parents:
diff changeset
     1
/*
15385
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14542
diff changeset
     2
 * Copyright (c) 1999, 2013, 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: 2212
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: 2212
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: 2212
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 2212
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 2212
diff changeset
    23
 * questions.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    24
 */
06bc494ca11e Initial load
duke
parents:
diff changeset
    25
06bc494ca11e Initial load
duke
parents:
diff changeset
    26
package com.sun.tools.doclets.internal.toolkit.util;
06bc494ca11e Initial load
duke
parents:
diff changeset
    27
1869
0e193a8f3520 6794582: javadoc should read files using a FileManager
jjg
parents: 1864
diff changeset
    28
import java.io.*;
15385
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14542
diff changeset
    29
import java.lang.annotation.ElementType;
1869
0e193a8f3520 6794582: javadoc should read files using a FileManager
jjg
parents: 1864
diff changeset
    30
import java.util.*;
0e193a8f3520 6794582: javadoc should read files using a FileManager
jjg
parents: 1864
diff changeset
    31
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    32
import com.sun.javadoc.*;
15385
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14542
diff changeset
    33
import com.sun.javadoc.AnnotationDesc.ElementValuePair;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    34
import com.sun.tools.doclets.internal.toolkit.*;
14368
6f4c62de6985 8001664: refactor javadoc to use abstraction to handle files
jjg
parents: 14366
diff changeset
    35
import javax.tools.StandardLocation;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    36
06bc494ca11e Initial load
duke
parents:
diff changeset
    37
/**
06bc494ca11e Initial load
duke
parents:
diff changeset
    38
 * Utilities Class for Doclets.
06bc494ca11e Initial load
duke
parents:
diff changeset
    39
 *
14260
727a84636f12 8000665: fix "internal API" comments on javadoc files
jjg
parents: 9606
diff changeset
    40
 *  <p><b>This is NOT part of any supported API.
727a84636f12 8000665: fix "internal API" comments on javadoc files
jjg
parents: 9606
diff changeset
    41
 *  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: 9606
diff changeset
    42
 *  This code and its internal interfaces are subject to change or
727a84636f12 8000665: fix "internal API" comments on javadoc files
jjg
parents: 9606
diff changeset
    43
 *  deletion without notice.</b>
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    44
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    45
 * @author Atul M Dambalkar
06bc494ca11e Initial load
duke
parents:
diff changeset
    46
 * @author Jamie Ho
06bc494ca11e Initial load
duke
parents:
diff changeset
    47
 */
06bc494ca11e Initial load
duke
parents:
diff changeset
    48
public class Util {
06bc494ca11e Initial load
duke
parents:
diff changeset
    49
06bc494ca11e Initial load
duke
parents:
diff changeset
    50
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    51
     * Return array of class members whose documentation is to be generated.
06bc494ca11e Initial load
duke
parents:
diff changeset
    52
     * If the member is deprecated do not include such a member in the
06bc494ca11e Initial load
duke
parents:
diff changeset
    53
     * returned array.
06bc494ca11e Initial load
duke
parents:
diff changeset
    54
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
    55
     * @param  members             Array of members to choose from.
06bc494ca11e Initial load
duke
parents:
diff changeset
    56
     * @return ProgramElementDoc[] Array of eligible members for whom
06bc494ca11e Initial load
duke
parents:
diff changeset
    57
     *                             documentation is getting generated.
06bc494ca11e Initial load
duke
parents:
diff changeset
    58
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    59
    public static ProgramElementDoc[] excludeDeprecatedMembers(
06bc494ca11e Initial load
duke
parents:
diff changeset
    60
        ProgramElementDoc[] members) {
06bc494ca11e Initial load
duke
parents:
diff changeset
    61
        return
06bc494ca11e Initial load
duke
parents:
diff changeset
    62
            toProgramElementDocArray(excludeDeprecatedMembersAsList(members));
06bc494ca11e Initial load
duke
parents:
diff changeset
    63
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
    64
06bc494ca11e Initial load
duke
parents:
diff changeset
    65
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    66
     * Return array of class members whose documentation is to be generated.
06bc494ca11e Initial load
duke
parents:
diff changeset
    67
     * If the member is deprecated do not include such a member in the
06bc494ca11e Initial load
duke
parents:
diff changeset
    68
     * returned array.
06bc494ca11e Initial load
duke
parents:
diff changeset
    69
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
    70
     * @param  members    Array of members to choose from.
06bc494ca11e Initial load
duke
parents:
diff changeset
    71
     * @return List       List of eligible members for whom
06bc494ca11e Initial load
duke
parents:
diff changeset
    72
     *                    documentation is getting generated.
06bc494ca11e Initial load
duke
parents:
diff changeset
    73
     */
868
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
    74
    public static List<ProgramElementDoc> excludeDeprecatedMembersAsList(
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    75
        ProgramElementDoc[] members) {
868
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
    76
        List<ProgramElementDoc> list = new ArrayList<ProgramElementDoc>();
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    77
        for (int i = 0; i < members.length; i++) {
06bc494ca11e Initial load
duke
parents:
diff changeset
    78
            if (members[i].tags("deprecated").length == 0) {
06bc494ca11e Initial load
duke
parents:
diff changeset
    79
                list.add(members[i]);
06bc494ca11e Initial load
duke
parents:
diff changeset
    80
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
    81
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
    82
        Collections.sort(list);
06bc494ca11e Initial load
duke
parents:
diff changeset
    83
        return list;
06bc494ca11e Initial load
duke
parents:
diff changeset
    84
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
    85
06bc494ca11e Initial load
duke
parents:
diff changeset
    86
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    87
     * Return the list of ProgramElementDoc objects as Array.
06bc494ca11e Initial load
duke
parents:
diff changeset
    88
     */
1789
7ac8c0815000 6765045: Remove rawtypes warnings from langtools
mcimadamore
parents: 1264
diff changeset
    89
    public static ProgramElementDoc[] toProgramElementDocArray(List<ProgramElementDoc> list) {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    90
        ProgramElementDoc[] pgmarr = new ProgramElementDoc[list.size()];
06bc494ca11e Initial load
duke
parents:
diff changeset
    91
        for (int i = 0; i < list.size(); i++) {
1789
7ac8c0815000 6765045: Remove rawtypes warnings from langtools
mcimadamore
parents: 1264
diff changeset
    92
            pgmarr[i] = list.get(i);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    93
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
    94
        return pgmarr;
06bc494ca11e Initial load
duke
parents:
diff changeset
    95
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
    96
06bc494ca11e Initial load
duke
parents:
diff changeset
    97
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    98
     * Return true if a non-public member found in the given array.
06bc494ca11e Initial load
duke
parents:
diff changeset
    99
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   100
     * @param  members Array of members to look into.
06bc494ca11e Initial load
duke
parents:
diff changeset
   101
     * @return boolean True if non-public member found, false otherwise.
06bc494ca11e Initial load
duke
parents:
diff changeset
   102
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   103
    public static boolean nonPublicMemberFound(ProgramElementDoc[] members) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   104
        for (int i = 0; i < members.length; i++) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   105
            if (!members[i].isPublic()) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   106
                return true;
06bc494ca11e Initial load
duke
parents:
diff changeset
   107
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   108
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   109
        return false;
06bc494ca11e Initial load
duke
parents:
diff changeset
   110
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   111
06bc494ca11e Initial load
duke
parents:
diff changeset
   112
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   113
     * Search for the given method in the given class.
06bc494ca11e Initial load
duke
parents:
diff changeset
   114
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   115
     * @param  cd        Class to search into.
06bc494ca11e Initial load
duke
parents:
diff changeset
   116
     * @param  method    Method to be searched.
06bc494ca11e Initial load
duke
parents:
diff changeset
   117
     * @return MethodDoc Method found, null otherwise.
06bc494ca11e Initial load
duke
parents:
diff changeset
   118
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   119
    public static MethodDoc findMethod(ClassDoc cd, MethodDoc method) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   120
        MethodDoc[] methods = cd.methods();
06bc494ca11e Initial load
duke
parents:
diff changeset
   121
        for (int i = 0; i < methods.length; i++) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   122
            if (executableMembersEqual(method, methods[i])) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   123
                return methods[i];
06bc494ca11e Initial load
duke
parents:
diff changeset
   124
06bc494ca11e Initial load
duke
parents:
diff changeset
   125
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   126
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   127
        return null;
06bc494ca11e Initial load
duke
parents:
diff changeset
   128
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   129
06bc494ca11e Initial load
duke
parents:
diff changeset
   130
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   131
     * @param member1 the first method to compare.
06bc494ca11e Initial load
duke
parents:
diff changeset
   132
     * @param member2 the second method to compare.
06bc494ca11e Initial load
duke
parents:
diff changeset
   133
     * @return true if member1 overrides/hides or is overriden/hidden by member2.
06bc494ca11e Initial load
duke
parents:
diff changeset
   134
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   135
    public static boolean executableMembersEqual(ExecutableMemberDoc member1,
06bc494ca11e Initial load
duke
parents:
diff changeset
   136
            ExecutableMemberDoc member2) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   137
        if (! (member1 instanceof MethodDoc && member2 instanceof MethodDoc))
06bc494ca11e Initial load
duke
parents:
diff changeset
   138
            return false;
06bc494ca11e Initial load
duke
parents:
diff changeset
   139
06bc494ca11e Initial load
duke
parents:
diff changeset
   140
        MethodDoc method1 = (MethodDoc) member1;
06bc494ca11e Initial load
duke
parents:
diff changeset
   141
        MethodDoc method2 = (MethodDoc) member2;
06bc494ca11e Initial load
duke
parents:
diff changeset
   142
        if (method1.isStatic() && method2.isStatic()) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   143
            Parameter[] targetParams = method1.parameters();
06bc494ca11e Initial load
duke
parents:
diff changeset
   144
            Parameter[] currentParams;
06bc494ca11e Initial load
duke
parents:
diff changeset
   145
            if (method1.name().equals(method2.name()) &&
06bc494ca11e Initial load
duke
parents:
diff changeset
   146
                   (currentParams = method2.parameters()).length ==
06bc494ca11e Initial load
duke
parents:
diff changeset
   147
                targetParams.length) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   148
                int j;
06bc494ca11e Initial load
duke
parents:
diff changeset
   149
                for (j = 0; j < targetParams.length; j++) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   150
                    if (! (targetParams[j].typeName().equals(
06bc494ca11e Initial load
duke
parents:
diff changeset
   151
                              currentParams[j].typeName()) ||
06bc494ca11e Initial load
duke
parents:
diff changeset
   152
                                   currentParams[j].type() instanceof TypeVariable ||
06bc494ca11e Initial load
duke
parents:
diff changeset
   153
                                   targetParams[j].type() instanceof TypeVariable)) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   154
                        break;
06bc494ca11e Initial load
duke
parents:
diff changeset
   155
                    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   156
                }
06bc494ca11e Initial load
duke
parents:
diff changeset
   157
                if (j == targetParams.length) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   158
                    return true;
06bc494ca11e Initial load
duke
parents:
diff changeset
   159
                }
06bc494ca11e Initial load
duke
parents:
diff changeset
   160
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   161
            return false;
06bc494ca11e Initial load
duke
parents:
diff changeset
   162
        } else {
06bc494ca11e Initial load
duke
parents:
diff changeset
   163
                return method1.overrides(method2) ||
06bc494ca11e Initial load
duke
parents:
diff changeset
   164
                method2.overrides(method1) ||
06bc494ca11e Initial load
duke
parents:
diff changeset
   165
                                member1 == member2;
06bc494ca11e Initial load
duke
parents:
diff changeset
   166
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   167
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   168
06bc494ca11e Initial load
duke
parents:
diff changeset
   169
    /**
9303
eae35c201e19 7032975: API files in javax.annotation.processing need to be updated for references to JLS
jjh
parents: 8631
diff changeset
   170
     * According to
eae35c201e19 7032975: API files in javax.annotation.processing need to be updated for references to JLS
jjh
parents: 8631
diff changeset
   171
     * <cite>The Java&trade; Language Specification</cite>,
eae35c201e19 7032975: API files in javax.annotation.processing need to be updated for references to JLS
jjh
parents: 8631
diff changeset
   172
     * all the outer classes and static inner classes are core classes.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   173
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   174
    public static boolean isCoreClass(ClassDoc cd) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   175
        return cd.containingClass() == null || cd.isStatic();
06bc494ca11e Initial load
duke
parents:
diff changeset
   176
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   177
06bc494ca11e Initial load
duke
parents:
diff changeset
   178
    public static boolean matches(ProgramElementDoc doc1,
06bc494ca11e Initial load
duke
parents:
diff changeset
   179
            ProgramElementDoc doc2) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   180
        if (doc1 instanceof ExecutableMemberDoc &&
06bc494ca11e Initial load
duke
parents:
diff changeset
   181
            doc2 instanceof ExecutableMemberDoc) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   182
            ExecutableMemberDoc ed1 = (ExecutableMemberDoc)doc1;
06bc494ca11e Initial load
duke
parents:
diff changeset
   183
            ExecutableMemberDoc ed2 = (ExecutableMemberDoc)doc2;
06bc494ca11e Initial load
duke
parents:
diff changeset
   184
            return executableMembersEqual(ed1, ed2);
06bc494ca11e Initial load
duke
parents:
diff changeset
   185
        } else {
06bc494ca11e Initial load
duke
parents:
diff changeset
   186
            return doc1.name().equals(doc2.name());
06bc494ca11e Initial load
duke
parents:
diff changeset
   187
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   188
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   189
06bc494ca11e Initial load
duke
parents:
diff changeset
   190
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   191
     * Copy the given directory contents from the source package directory
06bc494ca11e Initial load
duke
parents:
diff changeset
   192
     * to the generated documentation directory. For example for a package
06bc494ca11e Initial load
duke
parents:
diff changeset
   193
     * java.lang this method find out the source location of the package using
06bc494ca11e Initial load
duke
parents:
diff changeset
   194
     * {@link SourcePath} and if given directory is found in the source
06bc494ca11e Initial load
duke
parents:
diff changeset
   195
     * directory structure, copy the entire directory, to the generated
06bc494ca11e Initial load
duke
parents:
diff changeset
   196
     * documentation hierarchy.
06bc494ca11e Initial load
duke
parents:
diff changeset
   197
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   198
     * @param configuration The configuration of the current doclet.
06bc494ca11e Initial load
duke
parents:
diff changeset
   199
     * @param path The relative path to the directory to be copied.
06bc494ca11e Initial load
duke
parents:
diff changeset
   200
     * @param dir The original directory name to copy from.
06bc494ca11e Initial load
duke
parents:
diff changeset
   201
     * @param overwrite Overwrite files if true.
06bc494ca11e Initial load
duke
parents:
diff changeset
   202
     */
14368
6f4c62de6985 8001664: refactor javadoc to use abstraction to handle files
jjg
parents: 14366
diff changeset
   203
    public static void copyDocFiles(Configuration configuration, PackageDoc pd) {
6f4c62de6985 8001664: refactor javadoc to use abstraction to handle files
jjg
parents: 14366
diff changeset
   204
        copyDocFiles(configuration, DocPath.forPackage(pd).resolve(DocPaths.DOC_FILES));
6f4c62de6985 8001664: refactor javadoc to use abstraction to handle files
jjg
parents: 14366
diff changeset
   205
    }
6f4c62de6985 8001664: refactor javadoc to use abstraction to handle files
jjg
parents: 14366
diff changeset
   206
6f4c62de6985 8001664: refactor javadoc to use abstraction to handle files
jjg
parents: 14366
diff changeset
   207
    public static void copyDocFiles(Configuration configuration, DocPath dir) {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   208
        try {
14368
6f4c62de6985 8001664: refactor javadoc to use abstraction to handle files
jjg
parents: 14366
diff changeset
   209
            boolean first = true;
6f4c62de6985 8001664: refactor javadoc to use abstraction to handle files
jjg
parents: 14366
diff changeset
   210
            for (DocFile f : DocFile.list(configuration, StandardLocation.SOURCE_PATH, dir)) {
6f4c62de6985 8001664: refactor javadoc to use abstraction to handle files
jjg
parents: 14366
diff changeset
   211
                if (!f.isDirectory()) {
6f4c62de6985 8001664: refactor javadoc to use abstraction to handle files
jjg
parents: 14366
diff changeset
   212
                    continue;
6f4c62de6985 8001664: refactor javadoc to use abstraction to handle files
jjg
parents: 14366
diff changeset
   213
                }
6f4c62de6985 8001664: refactor javadoc to use abstraction to handle files
jjg
parents: 14366
diff changeset
   214
                DocFile srcdir = f;
6f4c62de6985 8001664: refactor javadoc to use abstraction to handle files
jjg
parents: 14366
diff changeset
   215
                DocFile destdir = DocFile.createFileForOutput(configuration, dir);
6f4c62de6985 8001664: refactor javadoc to use abstraction to handle files
jjg
parents: 14366
diff changeset
   216
                if (srcdir.isSameFile(destdir)) {
6f4c62de6985 8001664: refactor javadoc to use abstraction to handle files
jjg
parents: 14366
diff changeset
   217
                    continue;
6f4c62de6985 8001664: refactor javadoc to use abstraction to handle files
jjg
parents: 14366
diff changeset
   218
                }
6f4c62de6985 8001664: refactor javadoc to use abstraction to handle files
jjg
parents: 14366
diff changeset
   219
6f4c62de6985 8001664: refactor javadoc to use abstraction to handle files
jjg
parents: 14366
diff changeset
   220
                for (DocFile srcfile: srcdir.list()) {
6f4c62de6985 8001664: refactor javadoc to use abstraction to handle files
jjg
parents: 14366
diff changeset
   221
                    DocFile destfile = destdir.resolve(srcfile.getName());
6f4c62de6985 8001664: refactor javadoc to use abstraction to handle files
jjg
parents: 14366
diff changeset
   222
                    if (srcfile.isFile()) {
6f4c62de6985 8001664: refactor javadoc to use abstraction to handle files
jjg
parents: 14366
diff changeset
   223
                        if (destfile.exists() && !first) {
6f4c62de6985 8001664: refactor javadoc to use abstraction to handle files
jjg
parents: 14366
diff changeset
   224
                            configuration.message.warning((SourcePosition) null,
6f4c62de6985 8001664: refactor javadoc to use abstraction to handle files
jjg
parents: 14366
diff changeset
   225
                                    "doclet.Copy_Overwrite_warning",
6f4c62de6985 8001664: refactor javadoc to use abstraction to handle files
jjg
parents: 14366
diff changeset
   226
                                    srcfile.getPath(), destdir.getPath());
6f4c62de6985 8001664: refactor javadoc to use abstraction to handle files
jjg
parents: 14366
diff changeset
   227
                        } else {
6f4c62de6985 8001664: refactor javadoc to use abstraction to handle files
jjg
parents: 14366
diff changeset
   228
                            configuration.message.notice(
6f4c62de6985 8001664: refactor javadoc to use abstraction to handle files
jjg
parents: 14366
diff changeset
   229
                                    "doclet.Copying_File_0_To_Dir_1",
6f4c62de6985 8001664: refactor javadoc to use abstraction to handle files
jjg
parents: 14366
diff changeset
   230
                                    srcfile.getPath(), destdir.getPath());
6f4c62de6985 8001664: refactor javadoc to use abstraction to handle files
jjg
parents: 14366
diff changeset
   231
                            destfile.copyFile(srcfile);
6f4c62de6985 8001664: refactor javadoc to use abstraction to handle files
jjg
parents: 14366
diff changeset
   232
                        }
6f4c62de6985 8001664: refactor javadoc to use abstraction to handle files
jjg
parents: 14366
diff changeset
   233
                    } else if (srcfile.isDirectory()) {
6f4c62de6985 8001664: refactor javadoc to use abstraction to handle files
jjg
parents: 14366
diff changeset
   234
                        if (configuration.copydocfilesubdirs
6f4c62de6985 8001664: refactor javadoc to use abstraction to handle files
jjg
parents: 14366
diff changeset
   235
                                && !configuration.shouldExcludeDocFileDir(srcfile.getName())) {
6f4c62de6985 8001664: refactor javadoc to use abstraction to handle files
jjg
parents: 14366
diff changeset
   236
                            copyDocFiles(configuration, dir.resolve(srcfile.getName()));
6f4c62de6985 8001664: refactor javadoc to use abstraction to handle files
jjg
parents: 14366
diff changeset
   237
                        }
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   238
                    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   239
                }
14368
6f4c62de6985 8001664: refactor javadoc to use abstraction to handle files
jjg
parents: 14366
diff changeset
   240
6f4c62de6985 8001664: refactor javadoc to use abstraction to handle files
jjg
parents: 14366
diff changeset
   241
                first = false;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   242
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   243
        } catch (SecurityException exc) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   244
            throw new DocletAbortException();
06bc494ca11e Initial load
duke
parents:
diff changeset
   245
        } catch (IOException exc) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   246
            throw new DocletAbortException();
06bc494ca11e Initial load
duke
parents:
diff changeset
   247
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   248
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   249
06bc494ca11e Initial load
duke
parents:
diff changeset
   250
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   251
     * We want the list of types in alphabetical order.  However, types are not
06bc494ca11e Initial load
duke
parents:
diff changeset
   252
     * comparable.  We need a comparator for now.
06bc494ca11e Initial load
duke
parents:
diff changeset
   253
     */
868
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   254
    private static class TypeComparator implements Comparator<Type> {
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   255
        public int compare(Type type1, Type type2) {
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   256
            return type1.qualifiedTypeName().toLowerCase().compareTo(
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   257
                type2.qualifiedTypeName().toLowerCase());
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   258
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   259
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   260
06bc494ca11e Initial load
duke
parents:
diff changeset
   261
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   262
     * For the class return all implemented interfaces including the
06bc494ca11e Initial load
duke
parents:
diff changeset
   263
     * superinterfaces of the implementing interfaces, also iterate over for
06bc494ca11e Initial load
duke
parents:
diff changeset
   264
     * all the superclasses. For interface return all the extended interfaces
06bc494ca11e Initial load
duke
parents:
diff changeset
   265
     * as well as superinterfaces for those extended interfaces.
06bc494ca11e Initial load
duke
parents:
diff changeset
   266
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   267
     * @param  type       type whose implemented or
06bc494ca11e Initial load
duke
parents:
diff changeset
   268
     *                    super interfaces are sought.
06bc494ca11e Initial load
duke
parents:
diff changeset
   269
     * @param  configuration the current configuration of the doclet.
06bc494ca11e Initial load
duke
parents:
diff changeset
   270
     * @param  sort if true, return list of interfaces sorted alphabetically.
06bc494ca11e Initial load
duke
parents:
diff changeset
   271
     * @return List of all the required interfaces.
06bc494ca11e Initial load
duke
parents:
diff changeset
   272
     */
868
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   273
    public static List<Type> getAllInterfaces(Type type,
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   274
            Configuration configuration, boolean sort) {
868
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   275
        Map<ClassDoc,Type> results = sort ? new TreeMap<ClassDoc,Type>() : new LinkedHashMap<ClassDoc,Type>();
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   276
        Type[] interfaceTypes = null;
06bc494ca11e Initial load
duke
parents:
diff changeset
   277
        Type superType = null;
06bc494ca11e Initial load
duke
parents:
diff changeset
   278
        if (type instanceof ParameterizedType) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   279
            interfaceTypes = ((ParameterizedType) type).interfaceTypes();
06bc494ca11e Initial load
duke
parents:
diff changeset
   280
            superType = ((ParameterizedType) type).superclassType();
06bc494ca11e Initial load
duke
parents:
diff changeset
   281
        } else if (type instanceof ClassDoc) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   282
            interfaceTypes = ((ClassDoc) type).interfaceTypes();
06bc494ca11e Initial load
duke
parents:
diff changeset
   283
            superType = ((ClassDoc) type).superclassType();
06bc494ca11e Initial load
duke
parents:
diff changeset
   284
        } else {
06bc494ca11e Initial load
duke
parents:
diff changeset
   285
            interfaceTypes = type.asClassDoc().interfaceTypes();
06bc494ca11e Initial load
duke
parents:
diff changeset
   286
            superType = type.asClassDoc().superclassType();
06bc494ca11e Initial load
duke
parents:
diff changeset
   287
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   288
06bc494ca11e Initial load
duke
parents:
diff changeset
   289
        for (int i = 0; i < interfaceTypes.length; i++) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   290
            Type interfaceType = interfaceTypes[i];
06bc494ca11e Initial load
duke
parents:
diff changeset
   291
            ClassDoc interfaceClassDoc = interfaceType.asClassDoc();
06bc494ca11e Initial load
duke
parents:
diff changeset
   292
            if (! (interfaceClassDoc.isPublic() ||
06bc494ca11e Initial load
duke
parents:
diff changeset
   293
                (configuration == null ||
06bc494ca11e Initial load
duke
parents:
diff changeset
   294
                isLinkable(interfaceClassDoc, configuration)))) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   295
                continue;
06bc494ca11e Initial load
duke
parents:
diff changeset
   296
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   297
            results.put(interfaceClassDoc, interfaceType);
1789
7ac8c0815000 6765045: Remove rawtypes warnings from langtools
mcimadamore
parents: 1264
diff changeset
   298
            List<Type> superInterfaces = getAllInterfaces(interfaceType, configuration, sort);
7ac8c0815000 6765045: Remove rawtypes warnings from langtools
mcimadamore
parents: 1264
diff changeset
   299
            for (Iterator<Type> iter = superInterfaces.iterator(); iter.hasNext(); ) {
7ac8c0815000 6765045: Remove rawtypes warnings from langtools
mcimadamore
parents: 1264
diff changeset
   300
                Type t = iter.next();
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   301
                results.put(t.asClassDoc(), t);
06bc494ca11e Initial load
duke
parents:
diff changeset
   302
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   303
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   304
        if (superType == null)
868
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   305
            return new ArrayList<Type>(results.values());
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   306
        //Try walking the tree.
06bc494ca11e Initial load
duke
parents:
diff changeset
   307
        addAllInterfaceTypes(results,
06bc494ca11e Initial load
duke
parents:
diff changeset
   308
            superType,
15385
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14542
diff changeset
   309
            interfaceTypesOf(superType),
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   310
            false, configuration);
868
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   311
        List<Type> resultsList = new ArrayList<Type>(results.values());
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   312
        if (sort) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   313
                Collections.sort(resultsList, new TypeComparator());
06bc494ca11e Initial load
duke
parents:
diff changeset
   314
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   315
        return resultsList;
06bc494ca11e Initial load
duke
parents:
diff changeset
   316
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   317
15385
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14542
diff changeset
   318
    private static Type[] interfaceTypesOf(Type type) {
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14542
diff changeset
   319
        if (type instanceof AnnotatedType)
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14542
diff changeset
   320
            type = ((AnnotatedType)type).underlyingType();
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14542
diff changeset
   321
        return type instanceof ClassDoc ?
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14542
diff changeset
   322
                ((ClassDoc)type).interfaceTypes() :
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14542
diff changeset
   323
                ((ParameterizedType)type).interfaceTypes();
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14542
diff changeset
   324
    }
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14542
diff changeset
   325
1789
7ac8c0815000 6765045: Remove rawtypes warnings from langtools
mcimadamore
parents: 1264
diff changeset
   326
    public static List<Type> getAllInterfaces(Type type, Configuration configuration) {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   327
        return getAllInterfaces(type, configuration, true);
06bc494ca11e Initial load
duke
parents:
diff changeset
   328
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   329
868
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   330
    private static void findAllInterfaceTypes(Map<ClassDoc,Type> results, ClassDoc c, boolean raw,
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   331
            Configuration configuration) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   332
        Type superType = c.superclassType();
06bc494ca11e Initial load
duke
parents:
diff changeset
   333
        if (superType == null)
06bc494ca11e Initial load
duke
parents:
diff changeset
   334
            return;
06bc494ca11e Initial load
duke
parents:
diff changeset
   335
        addAllInterfaceTypes(results, superType,
15385
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14542
diff changeset
   336
                interfaceTypesOf(superType),
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   337
                raw, configuration);
06bc494ca11e Initial load
duke
parents:
diff changeset
   338
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   339
868
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   340
    private static void findAllInterfaceTypes(Map<ClassDoc,Type> results, ParameterizedType p,
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   341
            Configuration configuration) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   342
        Type superType = p.superclassType();
06bc494ca11e Initial load
duke
parents:
diff changeset
   343
        if (superType == null)
06bc494ca11e Initial load
duke
parents:
diff changeset
   344
            return;
06bc494ca11e Initial load
duke
parents:
diff changeset
   345
        addAllInterfaceTypes(results, superType,
15385
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14542
diff changeset
   346
                interfaceTypesOf(superType),
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   347
                false, configuration);
06bc494ca11e Initial load
duke
parents:
diff changeset
   348
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   349
868
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   350
    private static void addAllInterfaceTypes(Map<ClassDoc,Type> results, Type type,
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   351
            Type[] interfaceTypes, boolean raw,
06bc494ca11e Initial load
duke
parents:
diff changeset
   352
            Configuration configuration) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   353
        for (int i = 0; i < interfaceTypes.length; i++) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   354
            Type interfaceType = interfaceTypes[i];
06bc494ca11e Initial load
duke
parents:
diff changeset
   355
            ClassDoc interfaceClassDoc = interfaceType.asClassDoc();
06bc494ca11e Initial load
duke
parents:
diff changeset
   356
            if (! (interfaceClassDoc.isPublic() ||
06bc494ca11e Initial load
duke
parents:
diff changeset
   357
                (configuration != null &&
06bc494ca11e Initial load
duke
parents:
diff changeset
   358
                isLinkable(interfaceClassDoc, configuration)))) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   359
                continue;
06bc494ca11e Initial load
duke
parents:
diff changeset
   360
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   361
            if (raw)
06bc494ca11e Initial load
duke
parents:
diff changeset
   362
                interfaceType = interfaceType.asClassDoc();
06bc494ca11e Initial load
duke
parents:
diff changeset
   363
            results.put(interfaceClassDoc, interfaceType);
1789
7ac8c0815000 6765045: Remove rawtypes warnings from langtools
mcimadamore
parents: 1264
diff changeset
   364
            List<Type> superInterfaces = getAllInterfaces(interfaceType, configuration);
7ac8c0815000 6765045: Remove rawtypes warnings from langtools
mcimadamore
parents: 1264
diff changeset
   365
            for (Iterator<Type> iter = superInterfaces.iterator(); iter.hasNext(); ) {
7ac8c0815000 6765045: Remove rawtypes warnings from langtools
mcimadamore
parents: 1264
diff changeset
   366
                Type superInterface = iter.next();
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   367
                results.put(superInterface.asClassDoc(), superInterface);
06bc494ca11e Initial load
duke
parents:
diff changeset
   368
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   369
        }
15385
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14542
diff changeset
   370
        if (type instanceof AnnotatedType)
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14542
diff changeset
   371
            type = ((AnnotatedType)type).underlyingType();
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14542
diff changeset
   372
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   373
        if (type instanceof ParameterizedType)
06bc494ca11e Initial load
duke
parents:
diff changeset
   374
            findAllInterfaceTypes(results, (ParameterizedType) type, configuration);
06bc494ca11e Initial load
duke
parents:
diff changeset
   375
        else if (((ClassDoc) type).typeParameters().length == 0)
06bc494ca11e Initial load
duke
parents:
diff changeset
   376
            findAllInterfaceTypes(results, (ClassDoc) type, raw, configuration);
06bc494ca11e Initial load
duke
parents:
diff changeset
   377
        else
06bc494ca11e Initial load
duke
parents:
diff changeset
   378
            findAllInterfaceTypes(results, (ClassDoc) type, true, configuration);
06bc494ca11e Initial load
duke
parents:
diff changeset
   379
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   380
06bc494ca11e Initial load
duke
parents:
diff changeset
   381
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   382
     * Enclose in quotes, used for paths and filenames that contains spaces
06bc494ca11e Initial load
duke
parents:
diff changeset
   383
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   384
    public static String quote(String filepath) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   385
        return ("\"" + filepath + "\"");
06bc494ca11e Initial load
duke
parents:
diff changeset
   386
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   387
06bc494ca11e Initial load
duke
parents:
diff changeset
   388
    /**
14357
faf9cde2817b 8000741: refactor javadoc to use abstraction to handle relative paths
jjg
parents: 14265
diff changeset
   389
     * Given a package, return its name.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   390
     * @param packageDoc the package to check.
06bc494ca11e Initial load
duke
parents:
diff changeset
   391
     * @return the name of the given package.
06bc494ca11e Initial load
duke
parents:
diff changeset
   392
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   393
    public static String getPackageName(PackageDoc packageDoc) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   394
        return packageDoc == null || packageDoc.name().length() == 0 ?
06bc494ca11e Initial load
duke
parents:
diff changeset
   395
            DocletConstants.DEFAULT_PACKAGE_NAME : packageDoc.name();
06bc494ca11e Initial load
duke
parents:
diff changeset
   396
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   397
06bc494ca11e Initial load
duke
parents:
diff changeset
   398
    /**
14357
faf9cde2817b 8000741: refactor javadoc to use abstraction to handle relative paths
jjg
parents: 14265
diff changeset
   399
     * Given a package, return its file name without the extension.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   400
     * @param packageDoc the package to check.
06bc494ca11e Initial load
duke
parents:
diff changeset
   401
     * @return the file name of the given package.
06bc494ca11e Initial load
duke
parents:
diff changeset
   402
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   403
    public static String getPackageFileHeadName(PackageDoc packageDoc) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   404
        return packageDoc == null || packageDoc.name().length() == 0 ?
06bc494ca11e Initial load
duke
parents:
diff changeset
   405
            DocletConstants.DEFAULT_PACKAGE_FILE_NAME : packageDoc.name();
06bc494ca11e Initial load
duke
parents:
diff changeset
   406
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   407
06bc494ca11e Initial load
duke
parents:
diff changeset
   408
    /**
14357
faf9cde2817b 8000741: refactor javadoc to use abstraction to handle relative paths
jjg
parents: 14265
diff changeset
   409
     * Given a string, replace all occurrences of 'newStr' with 'oldStr'.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   410
     * @param originalStr the string to modify.
06bc494ca11e Initial load
duke
parents:
diff changeset
   411
     * @param oldStr the string to replace.
06bc494ca11e Initial load
duke
parents:
diff changeset
   412
     * @param newStr the string to insert in place of the old string.
06bc494ca11e Initial load
duke
parents:
diff changeset
   413
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   414
    public static String replaceText(String originalStr, String oldStr,
06bc494ca11e Initial load
duke
parents:
diff changeset
   415
            String newStr) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   416
        if (oldStr == null || newStr == null || oldStr.equals(newStr)) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   417
            return originalStr;
06bc494ca11e Initial load
duke
parents:
diff changeset
   418
        }
8631
664f84942e74 6866185: Util.getPackageSourcePath should use lastIndexOf not indexOf and related cleanup
jjg
parents: 7681
diff changeset
   419
        return originalStr.replace(oldStr, newStr);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   420
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   421
06bc494ca11e Initial load
duke
parents:
diff changeset
   422
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   423
     * Given a string, escape all special html characters and
06bc494ca11e Initial load
duke
parents:
diff changeset
   424
     * return the result.
06bc494ca11e Initial load
duke
parents:
diff changeset
   425
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   426
     * @param s The string to check.
14542
7062120649c2 8000800: javadoc uses static non-final fields
jjg
parents: 14447
diff changeset
   427
     * @return the original string with all of the HTML characters escaped.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   428
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   429
    public static String escapeHtmlChars(String s) {
14542
7062120649c2 8000800: javadoc uses static non-final fields
jjg
parents: 14447
diff changeset
   430
        for (int i = 0; i < s.length(); i++) {
7062120649c2 8000800: javadoc uses static non-final fields
jjg
parents: 14447
diff changeset
   431
            char ch = s.charAt(i);
7062120649c2 8000800: javadoc uses static non-final fields
jjg
parents: 14447
diff changeset
   432
            switch (ch) {
7062120649c2 8000800: javadoc uses static non-final fields
jjg
parents: 14447
diff changeset
   433
                // only start building a new string if we need to
7062120649c2 8000800: javadoc uses static non-final fields
jjg
parents: 14447
diff changeset
   434
                case '<': case '>': case '&':
7062120649c2 8000800: javadoc uses static non-final fields
jjg
parents: 14447
diff changeset
   435
                    StringBuilder sb = new StringBuilder(s.substring(0, i));
7062120649c2 8000800: javadoc uses static non-final fields
jjg
parents: 14447
diff changeset
   436
                    for ( ; i < s.length(); i++) {
7062120649c2 8000800: javadoc uses static non-final fields
jjg
parents: 14447
diff changeset
   437
                        ch = s.charAt(i);
7062120649c2 8000800: javadoc uses static non-final fields
jjg
parents: 14447
diff changeset
   438
                        switch (ch) {
7062120649c2 8000800: javadoc uses static non-final fields
jjg
parents: 14447
diff changeset
   439
                            case '<': sb.append("&lt;");  break;
7062120649c2 8000800: javadoc uses static non-final fields
jjg
parents: 14447
diff changeset
   440
                            case '>': sb.append("&gt;");  break;
7062120649c2 8000800: javadoc uses static non-final fields
jjg
parents: 14447
diff changeset
   441
                            case '&': sb.append("&amp;"); break;
7062120649c2 8000800: javadoc uses static non-final fields
jjg
parents: 14447
diff changeset
   442
                            default:  sb.append(ch);      break;
7062120649c2 8000800: javadoc uses static non-final fields
jjg
parents: 14447
diff changeset
   443
                        }
7062120649c2 8000800: javadoc uses static non-final fields
jjg
parents: 14447
diff changeset
   444
                    }
7062120649c2 8000800: javadoc uses static non-final fields
jjg
parents: 14447
diff changeset
   445
                    return sb.toString();
7062120649c2 8000800: javadoc uses static non-final fields
jjg
parents: 14447
diff changeset
   446
            }
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   447
        }
14542
7062120649c2 8000800: javadoc uses static non-final fields
jjg
parents: 14447
diff changeset
   448
        return s;
7062120649c2 8000800: javadoc uses static non-final fields
jjg
parents: 14447
diff changeset
   449
    }
7062120649c2 8000800: javadoc uses static non-final fields
jjg
parents: 14447
diff changeset
   450
7062120649c2 8000800: javadoc uses static non-final fields
jjg
parents: 14447
diff changeset
   451
    /**
7062120649c2 8000800: javadoc uses static non-final fields
jjg
parents: 14447
diff changeset
   452
     * Escape all special html characters in a string buffer.
7062120649c2 8000800: javadoc uses static non-final fields
jjg
parents: 14447
diff changeset
   453
     *
7062120649c2 8000800: javadoc uses static non-final fields
jjg
parents: 14447
diff changeset
   454
     * @param sb The string buffer to update
7062120649c2 8000800: javadoc uses static non-final fields
jjg
parents: 14447
diff changeset
   455
     */
7062120649c2 8000800: javadoc uses static non-final fields
jjg
parents: 14447
diff changeset
   456
    public static void escapeHtmlChars(StringBuilder sb) {
7062120649c2 8000800: javadoc uses static non-final fields
jjg
parents: 14447
diff changeset
   457
        // scan backwards, replacing characters as needed.
7062120649c2 8000800: javadoc uses static non-final fields
jjg
parents: 14447
diff changeset
   458
        for (int i = sb.length() - 1; i >= 0; i--) {
7062120649c2 8000800: javadoc uses static non-final fields
jjg
parents: 14447
diff changeset
   459
            switch (sb.charAt(i)) {
7062120649c2 8000800: javadoc uses static non-final fields
jjg
parents: 14447
diff changeset
   460
                case '<': sb.replace(i, i+1, "&lt;"); break;
7062120649c2 8000800: javadoc uses static non-final fields
jjg
parents: 14447
diff changeset
   461
                case '>': sb.replace(i, i+1, "&gt;"); break;
7062120649c2 8000800: javadoc uses static non-final fields
jjg
parents: 14447
diff changeset
   462
                case '&': sb.replace(i, i+1, "&amp;"); break;
7062120649c2 8000800: javadoc uses static non-final fields
jjg
parents: 14447
diff changeset
   463
            }
7062120649c2 8000800: javadoc uses static non-final fields
jjg
parents: 14447
diff changeset
   464
        }
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   465
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   466
06bc494ca11e Initial load
duke
parents:
diff changeset
   467
    /**
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   468
     * Given a string, strips all html characters and
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   469
     * return the result.
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   470
     *
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   471
     * @param rawString The string to check.
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   472
     * @return the original string with all of the HTML characters
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   473
     * stripped.
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   474
     *
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   475
     */
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   476
    public static String stripHtml(String rawString) {
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   477
        // remove HTML tags
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   478
        rawString = rawString.replaceAll("\\<.*?>", " ");
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   479
        // consolidate multiple spaces between a word to a single space
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   480
        rawString = rawString.replaceAll("\\b\\s{2,}\\b", " ");
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   481
        // remove extra whitespaces
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   482
        return rawString.trim();
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   483
    }
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   484
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   485
    /**
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   486
     * Given an annotation, return true if it should be documented and false
06bc494ca11e Initial load
duke
parents:
diff changeset
   487
     * otherwise.
06bc494ca11e Initial load
duke
parents:
diff changeset
   488
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   489
     * @param annotationDoc the annotation to check.
06bc494ca11e Initial load
duke
parents:
diff changeset
   490
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   491
     * @return true return true if it should be documented and false otherwise.
06bc494ca11e Initial load
duke
parents:
diff changeset
   492
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   493
    public static boolean isDocumentedAnnotation(AnnotationTypeDoc annotationDoc) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   494
        AnnotationDesc[] annotationDescList = annotationDoc.annotations();
06bc494ca11e Initial load
duke
parents:
diff changeset
   495
        for (int i = 0; i < annotationDescList.length; i++) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   496
            if (annotationDescList[i].annotationType().qualifiedName().equals(
06bc494ca11e Initial load
duke
parents:
diff changeset
   497
                   java.lang.annotation.Documented.class.getName())){
06bc494ca11e Initial load
duke
parents:
diff changeset
   498
                return true;
06bc494ca11e Initial load
duke
parents:
diff changeset
   499
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   500
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   501
        return false;
06bc494ca11e Initial load
duke
parents:
diff changeset
   502
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   503
15385
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14542
diff changeset
   504
    private static boolean isDeclarationTarget(AnnotationDesc targetAnno) {
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14542
diff changeset
   505
        // The error recovery steps here are analogous to TypeAnnotations
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14542
diff changeset
   506
        ElementValuePair[] elems = targetAnno.elementValues();
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14542
diff changeset
   507
        if (elems == null
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14542
diff changeset
   508
            || elems.length != 1
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14542
diff changeset
   509
            || !"value".equals(elems[0].element().name())
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14542
diff changeset
   510
            || !(elems[0].value().value() instanceof AnnotationValue[]))
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14542
diff changeset
   511
            return true;    // error recovery
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14542
diff changeset
   512
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14542
diff changeset
   513
        AnnotationValue[] values = (AnnotationValue[])elems[0].value().value();
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14542
diff changeset
   514
        for (int i = 0; i < values.length; i++) {
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14542
diff changeset
   515
            Object value = values[i].value();
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14542
diff changeset
   516
            if (!(value instanceof FieldDoc))
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14542
diff changeset
   517
                return true; // error recovery
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14542
diff changeset
   518
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14542
diff changeset
   519
            FieldDoc eValue = (FieldDoc)value;
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14542
diff changeset
   520
            if (Util.isJava5DeclarationElementType(eValue)) {
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14542
diff changeset
   521
                return true;
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14542
diff changeset
   522
            }
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14542
diff changeset
   523
        }
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14542
diff changeset
   524
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14542
diff changeset
   525
        return false;
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14542
diff changeset
   526
    }
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14542
diff changeset
   527
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14542
diff changeset
   528
    /**
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14542
diff changeset
   529
     * Returns true if the {@code annotationDoc} is to be treated
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14542
diff changeset
   530
     * as a declaration annotation, when targeting the
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14542
diff changeset
   531
     * {@code elemType} element type.
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14542
diff changeset
   532
     *
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14542
diff changeset
   533
     * @param annotationDoc the annotationDoc to check
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14542
diff changeset
   534
     * @param elemType  the targeted elemType
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14542
diff changeset
   535
     * @return true if annotationDoc is a declaration annotation
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14542
diff changeset
   536
     */
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14542
diff changeset
   537
    public static boolean isDeclarationAnnotation(AnnotationTypeDoc annotationDoc,
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14542
diff changeset
   538
            boolean isJava5DeclarationLocation) {
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14542
diff changeset
   539
        if (!isJava5DeclarationLocation)
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14542
diff changeset
   540
            return false;
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14542
diff changeset
   541
        AnnotationDesc[] annotationDescList = annotationDoc.annotations();
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14542
diff changeset
   542
        // Annotations with no target are treated as declaration as well
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14542
diff changeset
   543
        if (annotationDescList.length==0)
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14542
diff changeset
   544
            return true;
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14542
diff changeset
   545
        for (int i = 0; i < annotationDescList.length; i++) {
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14542
diff changeset
   546
            if (annotationDescList[i].annotationType().qualifiedName().equals(
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14542
diff changeset
   547
                    java.lang.annotation.Target.class.getName())) {
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14542
diff changeset
   548
                if (isDeclarationTarget(annotationDescList[i]))
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14542
diff changeset
   549
                    return true;
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14542
diff changeset
   550
            }
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14542
diff changeset
   551
        }
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14542
diff changeset
   552
        return false;
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14542
diff changeset
   553
    }
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14542
diff changeset
   554
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   555
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   556
     * Return true if this class is linkable and false if we can't link to the
06bc494ca11e Initial load
duke
parents:
diff changeset
   557
     * desired class.
06bc494ca11e Initial load
duke
parents:
diff changeset
   558
     * <br>
06bc494ca11e Initial load
duke
parents:
diff changeset
   559
     * <b>NOTE:</b>  You can only link to external classes if they are public or
06bc494ca11e Initial load
duke
parents:
diff changeset
   560
     * protected.
06bc494ca11e Initial load
duke
parents:
diff changeset
   561
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   562
     * @param classDoc the class to check.
06bc494ca11e Initial load
duke
parents:
diff changeset
   563
     * @param configuration the current configuration of the doclet.
06bc494ca11e Initial load
duke
parents:
diff changeset
   564
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   565
     * @return true if this class is linkable and false if we can't link to the
06bc494ca11e Initial load
duke
parents:
diff changeset
   566
     * desired class.
06bc494ca11e Initial load
duke
parents:
diff changeset
   567
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   568
    public static boolean isLinkable(ClassDoc classDoc,
06bc494ca11e Initial load
duke
parents:
diff changeset
   569
            Configuration configuration) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   570
        return
06bc494ca11e Initial load
duke
parents:
diff changeset
   571
            ((classDoc.isIncluded() && configuration.isGeneratedDoc(classDoc))) ||
06bc494ca11e Initial load
duke
parents:
diff changeset
   572
            (configuration.extern.isExternal(classDoc) &&
06bc494ca11e Initial load
duke
parents:
diff changeset
   573
                (classDoc.isPublic() || classDoc.isProtected()));
06bc494ca11e Initial load
duke
parents:
diff changeset
   574
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   575
06bc494ca11e Initial load
duke
parents:
diff changeset
   576
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   577
     * Given a class, return the closest visible super class.
06bc494ca11e Initial load
duke
parents:
diff changeset
   578
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   579
     * @param classDoc the class we are searching the parent for.
06bc494ca11e Initial load
duke
parents:
diff changeset
   580
     * @param configuration the current configuration of the doclet.
06bc494ca11e Initial load
duke
parents:
diff changeset
   581
     * @return the closest visible super class.  Return null if it cannot
06bc494ca11e Initial load
duke
parents:
diff changeset
   582
     *         be found (i.e. classDoc is java.lang.Object).
06bc494ca11e Initial load
duke
parents:
diff changeset
   583
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   584
    public static Type getFirstVisibleSuperClass(ClassDoc classDoc,
06bc494ca11e Initial load
duke
parents:
diff changeset
   585
            Configuration configuration) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   586
        if (classDoc == null) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   587
            return null;
06bc494ca11e Initial load
duke
parents:
diff changeset
   588
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   589
        Type sup = classDoc.superclassType();
06bc494ca11e Initial load
duke
parents:
diff changeset
   590
        ClassDoc supClassDoc = classDoc.superclass();
06bc494ca11e Initial load
duke
parents:
diff changeset
   591
        while (sup != null &&
06bc494ca11e Initial load
duke
parents:
diff changeset
   592
                  (! (supClassDoc.isPublic() ||
06bc494ca11e Initial load
duke
parents:
diff changeset
   593
                              isLinkable(supClassDoc, configuration))) ) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   594
            if (supClassDoc.superclass().qualifiedName().equals(supClassDoc.qualifiedName()))
06bc494ca11e Initial load
duke
parents:
diff changeset
   595
                break;
06bc494ca11e Initial load
duke
parents:
diff changeset
   596
            sup = supClassDoc.superclassType();
06bc494ca11e Initial load
duke
parents:
diff changeset
   597
            supClassDoc = supClassDoc.superclass();
06bc494ca11e Initial load
duke
parents:
diff changeset
   598
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   599
        if (classDoc.equals(supClassDoc)) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   600
            return null;
06bc494ca11e Initial load
duke
parents:
diff changeset
   601
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   602
        return sup;
06bc494ca11e Initial load
duke
parents:
diff changeset
   603
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   604
06bc494ca11e Initial load
duke
parents:
diff changeset
   605
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   606
     * Given a class, return the closest visible super class.
06bc494ca11e Initial load
duke
parents:
diff changeset
   607
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   608
     * @param classDoc the class we are searching the parent for.
06bc494ca11e Initial load
duke
parents:
diff changeset
   609
     * @param configuration the current configuration of the doclet.
06bc494ca11e Initial load
duke
parents:
diff changeset
   610
     * @return the closest visible super class.  Return null if it cannot
06bc494ca11e Initial load
duke
parents:
diff changeset
   611
     *         be found (i.e. classDoc is java.lang.Object).
06bc494ca11e Initial load
duke
parents:
diff changeset
   612
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   613
    public static ClassDoc getFirstVisibleSuperClassCD(ClassDoc classDoc,
06bc494ca11e Initial load
duke
parents:
diff changeset
   614
            Configuration configuration) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   615
        if (classDoc == null) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   616
            return null;
06bc494ca11e Initial load
duke
parents:
diff changeset
   617
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   618
        ClassDoc supClassDoc = classDoc.superclass();
06bc494ca11e Initial load
duke
parents:
diff changeset
   619
        while (supClassDoc != null &&
06bc494ca11e Initial load
duke
parents:
diff changeset
   620
                  (! (supClassDoc.isPublic() ||
06bc494ca11e Initial load
duke
parents:
diff changeset
   621
                              isLinkable(supClassDoc, configuration))) ) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   622
            supClassDoc = supClassDoc.superclass();
06bc494ca11e Initial load
duke
parents:
diff changeset
   623
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   624
        if (classDoc.equals(supClassDoc)) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   625
            return null;
06bc494ca11e Initial load
duke
parents:
diff changeset
   626
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   627
        return supClassDoc;
06bc494ca11e Initial load
duke
parents:
diff changeset
   628
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   629
06bc494ca11e Initial load
duke
parents:
diff changeset
   630
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   631
     * Given a ClassDoc, return the name of its type (Class, Interface, etc.).
06bc494ca11e Initial load
duke
parents:
diff changeset
   632
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   633
     * @param cd the ClassDoc to check.
06bc494ca11e Initial load
duke
parents:
diff changeset
   634
     * @param lowerCaseOnly true if you want the name returned in lower case.
14447
6f87132c2e54 8000612: Discrepancy between resources provided in javadoc resource files and resources required by code
jjg
parents: 14368
diff changeset
   635
     *                      If false, the first letter of the name is capitalized.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   636
     * @return
06bc494ca11e Initial load
duke
parents:
diff changeset
   637
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   638
    public static String getTypeName(Configuration config,
06bc494ca11e Initial load
duke
parents:
diff changeset
   639
        ClassDoc cd, boolean lowerCaseOnly) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   640
        String typeName = "";
06bc494ca11e Initial load
duke
parents:
diff changeset
   641
        if (cd.isOrdinaryClass()) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   642
            typeName = "doclet.Class";
06bc494ca11e Initial load
duke
parents:
diff changeset
   643
        } else if (cd.isInterface()) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   644
            typeName = "doclet.Interface";
06bc494ca11e Initial load
duke
parents:
diff changeset
   645
        } else if (cd.isException()) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   646
            typeName = "doclet.Exception";
06bc494ca11e Initial load
duke
parents:
diff changeset
   647
        } else if (cd.isError()) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   648
            typeName = "doclet.Error";
06bc494ca11e Initial load
duke
parents:
diff changeset
   649
        } else if (cd.isAnnotationType()) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   650
            typeName = "doclet.AnnotationType";
06bc494ca11e Initial load
duke
parents:
diff changeset
   651
        } else if (cd.isEnum()) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   652
            typeName = "doclet.Enum";
06bc494ca11e Initial load
duke
parents:
diff changeset
   653
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   654
        return config.getText(
06bc494ca11e Initial load
duke
parents:
diff changeset
   655
            lowerCaseOnly ? typeName.toLowerCase() : typeName);
06bc494ca11e Initial load
duke
parents:
diff changeset
   656
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   657
06bc494ca11e Initial load
duke
parents:
diff changeset
   658
    /**
14542
7062120649c2 8000800: javadoc uses static non-final fields
jjg
parents: 14447
diff changeset
   659
     * Replace all tabs with the appropriate number of spaces.
7062120649c2 8000800: javadoc uses static non-final fields
jjg
parents: 14447
diff changeset
   660
     * @param configuration the doclet configuration defining the setting for the
7062120649c2 8000800: javadoc uses static non-final fields
jjg
parents: 14447
diff changeset
   661
     *                      tab length.
7062120649c2 8000800: javadoc uses static non-final fields
jjg
parents: 14447
diff changeset
   662
     * @param sb the StringBuilder in which to replace the tabs
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   663
     */
14542
7062120649c2 8000800: javadoc uses static non-final fields
jjg
parents: 14447
diff changeset
   664
    public static void replaceTabs(Configuration configuration, StringBuilder sb) {
7062120649c2 8000800: javadoc uses static non-final fields
jjg
parents: 14447
diff changeset
   665
        int tabLength = configuration.sourcetab;
7062120649c2 8000800: javadoc uses static non-final fields
jjg
parents: 14447
diff changeset
   666
        String whitespace = configuration.tabSpaces;
8631
664f84942e74 6866185: Util.getPackageSourcePath should use lastIndexOf not indexOf and related cleanup
jjg
parents: 7681
diff changeset
   667
        int index = 0;
14542
7062120649c2 8000800: javadoc uses static non-final fields
jjg
parents: 14447
diff changeset
   668
        while ((index = sb.indexOf("\t", index)) != -1) {
8631
664f84942e74 6866185: Util.getPackageSourcePath should use lastIndexOf not indexOf and related cleanup
jjg
parents: 7681
diff changeset
   669
            int spaceCount = tabLength - index % tabLength;
14542
7062120649c2 8000800: javadoc uses static non-final fields
jjg
parents: 14447
diff changeset
   670
            sb.replace(index, index+1, whitespace.substring(0, spaceCount));
8631
664f84942e74 6866185: Util.getPackageSourcePath should use lastIndexOf not indexOf and related cleanup
jjg
parents: 7681
diff changeset
   671
            index += spaceCount;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   672
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   673
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   674
06bc494ca11e Initial load
duke
parents:
diff changeset
   675
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   676
     * The documentation for values() and valueOf() in Enums are set by the
06bc494ca11e Initial load
duke
parents:
diff changeset
   677
     * doclet.
06bc494ca11e Initial load
duke
parents:
diff changeset
   678
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   679
    public static void setEnumDocumentation(Configuration configuration,
06bc494ca11e Initial load
duke
parents:
diff changeset
   680
            ClassDoc classDoc) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   681
        MethodDoc[] methods = classDoc.methods();
06bc494ca11e Initial load
duke
parents:
diff changeset
   682
        for (int j = 0; j < methods.length; j++) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   683
            MethodDoc currentMethod = methods[j];
06bc494ca11e Initial load
duke
parents:
diff changeset
   684
            if (currentMethod.name().equals("values") &&
06bc494ca11e Initial load
duke
parents:
diff changeset
   685
                currentMethod.parameters().length == 0) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   686
                currentMethod.setRawCommentText(
06bc494ca11e Initial load
duke
parents:
diff changeset
   687
                    configuration.getText("doclet.enum_values_doc", classDoc.name()));
06bc494ca11e Initial load
duke
parents:
diff changeset
   688
            } else if (currentMethod.name().equals("valueOf") &&
06bc494ca11e Initial load
duke
parents:
diff changeset
   689
                currentMethod.parameters().length == 1) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   690
                Type paramType = currentMethod.parameters()[0].type();
06bc494ca11e Initial load
duke
parents:
diff changeset
   691
                if (paramType != null &&
06bc494ca11e Initial load
duke
parents:
diff changeset
   692
                    paramType.qualifiedTypeName().equals(String.class.getName())) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   693
                    currentMethod.setRawCommentText(
06bc494ca11e Initial load
duke
parents:
diff changeset
   694
                        configuration.getText("doclet.enum_valueof_doc"));
06bc494ca11e Initial load
duke
parents:
diff changeset
   695
                }
06bc494ca11e Initial load
duke
parents:
diff changeset
   696
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   697
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   698
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   699
06bc494ca11e Initial load
duke
parents:
diff changeset
   700
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   701
     *  Return true if the given Doc is deprecated.
06bc494ca11e Initial load
duke
parents:
diff changeset
   702
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   703
     * @param doc the Doc to check.
06bc494ca11e Initial load
duke
parents:
diff changeset
   704
     * @return true if the given Doc is deprecated.
06bc494ca11e Initial load
duke
parents:
diff changeset
   705
     */
9606
e5a619cb5dd3 6492694: @deprecated tag doesn't work in package-info files.
bpatel
parents: 9303
diff changeset
   706
    public static boolean isDeprecated(Doc doc) {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   707
        if (doc.tags("deprecated").length > 0) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   708
            return true;
06bc494ca11e Initial load
duke
parents:
diff changeset
   709
        }
9606
e5a619cb5dd3 6492694: @deprecated tag doesn't work in package-info files.
bpatel
parents: 9303
diff changeset
   710
        AnnotationDesc[] annotationDescList;
e5a619cb5dd3 6492694: @deprecated tag doesn't work in package-info files.
bpatel
parents: 9303
diff changeset
   711
        if (doc instanceof PackageDoc)
e5a619cb5dd3 6492694: @deprecated tag doesn't work in package-info files.
bpatel
parents: 9303
diff changeset
   712
            annotationDescList = ((PackageDoc)doc).annotations();
e5a619cb5dd3 6492694: @deprecated tag doesn't work in package-info files.
bpatel
parents: 9303
diff changeset
   713
        else
e5a619cb5dd3 6492694: @deprecated tag doesn't work in package-info files.
bpatel
parents: 9303
diff changeset
   714
            annotationDescList = ((ProgramElementDoc)doc).annotations();
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   715
        for (int i = 0; i < annotationDescList.length; i++) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   716
            if (annotationDescList[i].annotationType().qualifiedName().equals(
06bc494ca11e Initial load
duke
parents:
diff changeset
   717
                   java.lang.Deprecated.class.getName())){
06bc494ca11e Initial load
duke
parents:
diff changeset
   718
                return true;
06bc494ca11e Initial load
duke
parents:
diff changeset
   719
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   720
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   721
        return false;
06bc494ca11e Initial load
duke
parents:
diff changeset
   722
    }
15385
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14542
diff changeset
   723
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14542
diff changeset
   724
    /**
16319
e586bfeb39c5 7112427: The doclet needs to be able to generate JavaFX documentation.
jjg
parents: 15385
diff changeset
   725
     * A convenience method to get property name from the name of the
e586bfeb39c5 7112427: The doclet needs to be able to generate JavaFX documentation.
jjg
parents: 15385
diff changeset
   726
     * getter or setter method.
e586bfeb39c5 7112427: The doclet needs to be able to generate JavaFX documentation.
jjg
parents: 15385
diff changeset
   727
     * @param name name of the getter or setter method.
e586bfeb39c5 7112427: The doclet needs to be able to generate JavaFX documentation.
jjg
parents: 15385
diff changeset
   728
     * @return the name of the property of the given setter of getter.
e586bfeb39c5 7112427: The doclet needs to be able to generate JavaFX documentation.
jjg
parents: 15385
diff changeset
   729
     */
e586bfeb39c5 7112427: The doclet needs to be able to generate JavaFX documentation.
jjg
parents: 15385
diff changeset
   730
    public static String propertyNameFromMethodName(String name) {
e586bfeb39c5 7112427: The doclet needs to be able to generate JavaFX documentation.
jjg
parents: 15385
diff changeset
   731
        String propertyName = null;
e586bfeb39c5 7112427: The doclet needs to be able to generate JavaFX documentation.
jjg
parents: 15385
diff changeset
   732
        if (name.startsWith("get") || name.startsWith("set")) {
e586bfeb39c5 7112427: The doclet needs to be able to generate JavaFX documentation.
jjg
parents: 15385
diff changeset
   733
            propertyName = name.substring(3);
e586bfeb39c5 7112427: The doclet needs to be able to generate JavaFX documentation.
jjg
parents: 15385
diff changeset
   734
        } else if (name.startsWith("is")) {
e586bfeb39c5 7112427: The doclet needs to be able to generate JavaFX documentation.
jjg
parents: 15385
diff changeset
   735
            propertyName = name.substring(2);
e586bfeb39c5 7112427: The doclet needs to be able to generate JavaFX documentation.
jjg
parents: 15385
diff changeset
   736
        }
e586bfeb39c5 7112427: The doclet needs to be able to generate JavaFX documentation.
jjg
parents: 15385
diff changeset
   737
        if ((propertyName == null) || propertyName.isEmpty()){
e586bfeb39c5 7112427: The doclet needs to be able to generate JavaFX documentation.
jjg
parents: 15385
diff changeset
   738
            return "";
e586bfeb39c5 7112427: The doclet needs to be able to generate JavaFX documentation.
jjg
parents: 15385
diff changeset
   739
        }
e586bfeb39c5 7112427: The doclet needs to be able to generate JavaFX documentation.
jjg
parents: 15385
diff changeset
   740
        return propertyName.substring(0, 1).toLowerCase()
e586bfeb39c5 7112427: The doclet needs to be able to generate JavaFX documentation.
jjg
parents: 15385
diff changeset
   741
                + propertyName.substring(1);
e586bfeb39c5 7112427: The doclet needs to be able to generate JavaFX documentation.
jjg
parents: 15385
diff changeset
   742
    }
e586bfeb39c5 7112427: The doclet needs to be able to generate JavaFX documentation.
jjg
parents: 15385
diff changeset
   743
e586bfeb39c5 7112427: The doclet needs to be able to generate JavaFX documentation.
jjg
parents: 15385
diff changeset
   744
    /**
e586bfeb39c5 7112427: The doclet needs to be able to generate JavaFX documentation.
jjg
parents: 15385
diff changeset
   745
     * In case of JavaFX mode on, filters out classes that are private,
e586bfeb39c5 7112427: The doclet needs to be able to generate JavaFX documentation.
jjg
parents: 15385
diff changeset
   746
     * package private or having the @treatAsPrivate annotation. Those are not
e586bfeb39c5 7112427: The doclet needs to be able to generate JavaFX documentation.
jjg
parents: 15385
diff changeset
   747
     * documented in JavaFX mode.
e586bfeb39c5 7112427: The doclet needs to be able to generate JavaFX documentation.
jjg
parents: 15385
diff changeset
   748
     *
e586bfeb39c5 7112427: The doclet needs to be able to generate JavaFX documentation.
jjg
parents: 15385
diff changeset
   749
     * @param classes array of classes to be filtered.
e586bfeb39c5 7112427: The doclet needs to be able to generate JavaFX documentation.
jjg
parents: 15385
diff changeset
   750
     * @param javafx set to true if in JavaFX mode.
e586bfeb39c5 7112427: The doclet needs to be able to generate JavaFX documentation.
jjg
parents: 15385
diff changeset
   751
     * @return list of filtered classes.
e586bfeb39c5 7112427: The doclet needs to be able to generate JavaFX documentation.
jjg
parents: 15385
diff changeset
   752
     */
e586bfeb39c5 7112427: The doclet needs to be able to generate JavaFX documentation.
jjg
parents: 15385
diff changeset
   753
    public static ClassDoc[] filterOutPrivateClasses(final ClassDoc[] classes,
e586bfeb39c5 7112427: The doclet needs to be able to generate JavaFX documentation.
jjg
parents: 15385
diff changeset
   754
                                                     boolean javafx) {
e586bfeb39c5 7112427: The doclet needs to be able to generate JavaFX documentation.
jjg
parents: 15385
diff changeset
   755
        if (!javafx) {
e586bfeb39c5 7112427: The doclet needs to be able to generate JavaFX documentation.
jjg
parents: 15385
diff changeset
   756
            return classes;
e586bfeb39c5 7112427: The doclet needs to be able to generate JavaFX documentation.
jjg
parents: 15385
diff changeset
   757
        }
e586bfeb39c5 7112427: The doclet needs to be able to generate JavaFX documentation.
jjg
parents: 15385
diff changeset
   758
        final List<ClassDoc> filteredOutClasses =
e586bfeb39c5 7112427: The doclet needs to be able to generate JavaFX documentation.
jjg
parents: 15385
diff changeset
   759
                new ArrayList<ClassDoc>(classes.length);
e586bfeb39c5 7112427: The doclet needs to be able to generate JavaFX documentation.
jjg
parents: 15385
diff changeset
   760
        for (ClassDoc classDoc : classes) {
e586bfeb39c5 7112427: The doclet needs to be able to generate JavaFX documentation.
jjg
parents: 15385
diff changeset
   761
            if (classDoc.isPrivate() || classDoc.isPackagePrivate()) {
e586bfeb39c5 7112427: The doclet needs to be able to generate JavaFX documentation.
jjg
parents: 15385
diff changeset
   762
                continue;
e586bfeb39c5 7112427: The doclet needs to be able to generate JavaFX documentation.
jjg
parents: 15385
diff changeset
   763
            }
e586bfeb39c5 7112427: The doclet needs to be able to generate JavaFX documentation.
jjg
parents: 15385
diff changeset
   764
            Tag[] aspTags = classDoc.tags("treatAsPrivate");
e586bfeb39c5 7112427: The doclet needs to be able to generate JavaFX documentation.
jjg
parents: 15385
diff changeset
   765
            if (aspTags != null && aspTags.length > 0) {
e586bfeb39c5 7112427: The doclet needs to be able to generate JavaFX documentation.
jjg
parents: 15385
diff changeset
   766
                continue;
e586bfeb39c5 7112427: The doclet needs to be able to generate JavaFX documentation.
jjg
parents: 15385
diff changeset
   767
            }
e586bfeb39c5 7112427: The doclet needs to be able to generate JavaFX documentation.
jjg
parents: 15385
diff changeset
   768
            filteredOutClasses.add(classDoc);
e586bfeb39c5 7112427: The doclet needs to be able to generate JavaFX documentation.
jjg
parents: 15385
diff changeset
   769
        }
e586bfeb39c5 7112427: The doclet needs to be able to generate JavaFX documentation.
jjg
parents: 15385
diff changeset
   770
e586bfeb39c5 7112427: The doclet needs to be able to generate JavaFX documentation.
jjg
parents: 15385
diff changeset
   771
        return filteredOutClasses.toArray(new ClassDoc[0]);
e586bfeb39c5 7112427: The doclet needs to be able to generate JavaFX documentation.
jjg
parents: 15385
diff changeset
   772
    }
e586bfeb39c5 7112427: The doclet needs to be able to generate JavaFX documentation.
jjg
parents: 15385
diff changeset
   773
e586bfeb39c5 7112427: The doclet needs to be able to generate JavaFX documentation.
jjg
parents: 15385
diff changeset
   774
    /**
15385
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14542
diff changeset
   775
     * Test whether the given FieldDoc is one of the declaration annotation ElementTypes
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14542
diff changeset
   776
     * defined in Java 5.
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14542
diff changeset
   777
     * Instead of testing for one of the new enum constants added in Java 8, test for
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14542
diff changeset
   778
     * the old constants. This prevents bootstrapping problems.
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14542
diff changeset
   779
     *
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14542
diff changeset
   780
     * @param elt The FieldDoc to test
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14542
diff changeset
   781
     * @return true, iff the given ElementType is one of the constants defined in Java 5
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14542
diff changeset
   782
     * @since 1.8
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14542
diff changeset
   783
     */
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14542
diff changeset
   784
    public static boolean isJava5DeclarationElementType(FieldDoc elt) {
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14542
diff changeset
   785
        return elt.name().contentEquals(ElementType.ANNOTATION_TYPE.name()) ||
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14542
diff changeset
   786
                elt.name().contentEquals(ElementType.CONSTRUCTOR.name()) ||
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14542
diff changeset
   787
                elt.name().contentEquals(ElementType.FIELD.name()) ||
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14542
diff changeset
   788
                elt.name().contentEquals(ElementType.LOCAL_VARIABLE.name()) ||
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14542
diff changeset
   789
                elt.name().contentEquals(ElementType.METHOD.name()) ||
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14542
diff changeset
   790
                elt.name().contentEquals(ElementType.PACKAGE.name()) ||
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14542
diff changeset
   791
                elt.name().contentEquals(ElementType.PARAMETER.name()) ||
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14542
diff changeset
   792
                elt.name().contentEquals(ElementType.TYPE.name());
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14542
diff changeset
   793
    }
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   794
}