langtools/src/share/classes/com/sun/tools/javac/code/Kinds.java
author mcimadamore
Thu, 24 Jul 2008 19:06:57 +0100
changeset 939 38e24969c7e9
parent 10 06bc494ca11e
child 1264 076a3cde30d5
permissions -rw-r--r--
6717241: some diagnostic argument is prematurely converted into a String object Summary: removed early toString() conversions applied to diagnostic arguments Reviewed-by: jjg
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
10
06bc494ca11e Initial load
duke
parents:
diff changeset
     1
/*
06bc494ca11e Initial load
duke
parents:
diff changeset
     2
 * Copyright 1999-2005 Sun Microsystems, Inc.  All Rights Reserved.
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
06bc494ca11e Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Sun designates this
06bc494ca11e Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
06bc494ca11e Initial load
duke
parents:
diff changeset
     9
 * by Sun in the LICENSE file that accompanied this code.
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
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    21
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
06bc494ca11e Initial load
duke
parents:
diff changeset
    22
 * CA 95054 USA or visit www.sun.com if you need additional information or
06bc494ca11e Initial load
duke
parents:
diff changeset
    23
 * have any questions.
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.javac.code;
06bc494ca11e Initial load
duke
parents:
diff changeset
    27
939
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
    28
import java.util.EnumSet;
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
    29
import java.util.ResourceBundle;
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
    30
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
    31
import com.sun.tools.javac.api.Formattable;
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
    32
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
    33
import static com.sun.tools.javac.code.TypeTags.*;
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
    34
import static com.sun.tools.javac.code.Flags.*;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    35
06bc494ca11e Initial load
duke
parents:
diff changeset
    36
/** Internal symbol kinds, which distinguish between elements of
06bc494ca11e Initial load
duke
parents:
diff changeset
    37
 *  different subclasses of Symbol. Symbol kinds are organized so they can be
06bc494ca11e Initial load
duke
parents:
diff changeset
    38
 *  or'ed to sets.
06bc494ca11e Initial load
duke
parents:
diff changeset
    39
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    40
 *  <p><b>This is NOT part of any API supported by Sun Microsystems.  If
06bc494ca11e Initial load
duke
parents:
diff changeset
    41
 *  you write code that depends on this, you do so at your own risk.
06bc494ca11e Initial load
duke
parents:
diff changeset
    42
 *  This code and its internal interfaces are subject to change or
06bc494ca11e Initial load
duke
parents:
diff changeset
    43
 *  deletion without notice.</b>
06bc494ca11e Initial load
duke
parents:
diff changeset
    44
 */
06bc494ca11e Initial load
duke
parents:
diff changeset
    45
public class Kinds {
06bc494ca11e Initial load
duke
parents:
diff changeset
    46
06bc494ca11e Initial load
duke
parents:
diff changeset
    47
    private Kinds() {} // uninstantiable
06bc494ca11e Initial load
duke
parents:
diff changeset
    48
06bc494ca11e Initial load
duke
parents:
diff changeset
    49
    /** The empty set of kinds.
06bc494ca11e Initial load
duke
parents:
diff changeset
    50
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    51
    public final static int NIL = 0;
06bc494ca11e Initial load
duke
parents:
diff changeset
    52
06bc494ca11e Initial load
duke
parents:
diff changeset
    53
    /** The kind of package symbols.
06bc494ca11e Initial load
duke
parents:
diff changeset
    54
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    55
    public final static int PCK = 1 << 0;
06bc494ca11e Initial load
duke
parents:
diff changeset
    56
06bc494ca11e Initial load
duke
parents:
diff changeset
    57
    /** The kind of type symbols (classes, interfaces and type variables).
06bc494ca11e Initial load
duke
parents:
diff changeset
    58
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    59
    public final static int TYP = 1 << 1;
06bc494ca11e Initial load
duke
parents:
diff changeset
    60
06bc494ca11e Initial load
duke
parents:
diff changeset
    61
    /** The kind of variable symbols.
06bc494ca11e Initial load
duke
parents:
diff changeset
    62
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    63
    public final static int VAR = 1 << 2;
06bc494ca11e Initial load
duke
parents:
diff changeset
    64
06bc494ca11e Initial load
duke
parents:
diff changeset
    65
    /** The kind of values (variables or non-variable expressions), includes VAR.
06bc494ca11e Initial load
duke
parents:
diff changeset
    66
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    67
    public final static int VAL = (1 << 3) | VAR;
06bc494ca11e Initial load
duke
parents:
diff changeset
    68
06bc494ca11e Initial load
duke
parents:
diff changeset
    69
    /** The kind of methods.
06bc494ca11e Initial load
duke
parents:
diff changeset
    70
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    71
    public final static int MTH = 1 << 4;
06bc494ca11e Initial load
duke
parents:
diff changeset
    72
06bc494ca11e Initial load
duke
parents:
diff changeset
    73
    /** The error kind, which includes all other kinds.
06bc494ca11e Initial load
duke
parents:
diff changeset
    74
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    75
    public final static int ERR = (1 << 5) - 1;
06bc494ca11e Initial load
duke
parents:
diff changeset
    76
06bc494ca11e Initial load
duke
parents:
diff changeset
    77
    /** The set of all kinds.
06bc494ca11e Initial load
duke
parents:
diff changeset
    78
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    79
    public final static int AllKinds = ERR;
06bc494ca11e Initial load
duke
parents:
diff changeset
    80
06bc494ca11e Initial load
duke
parents:
diff changeset
    81
    /** Kinds for erroneous symbols that complement the above
06bc494ca11e Initial load
duke
parents:
diff changeset
    82
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    83
    public static final int ERRONEOUS = 1 << 6;
06bc494ca11e Initial load
duke
parents:
diff changeset
    84
    public static final int AMBIGUOUS    = ERRONEOUS+1; // ambiguous reference
06bc494ca11e Initial load
duke
parents:
diff changeset
    85
    public static final int HIDDEN       = ERRONEOUS+2; // hidden method or field
06bc494ca11e Initial load
duke
parents:
diff changeset
    86
    public static final int STATICERR    = ERRONEOUS+3; // nonstatic member from static context
06bc494ca11e Initial load
duke
parents:
diff changeset
    87
    public static final int ABSENT_VAR   = ERRONEOUS+4; // missing variable
06bc494ca11e Initial load
duke
parents:
diff changeset
    88
    public static final int WRONG_MTHS   = ERRONEOUS+5; // methods with wrong arguments
06bc494ca11e Initial load
duke
parents:
diff changeset
    89
    public static final int WRONG_MTH    = ERRONEOUS+6; // one method with wrong arguments
06bc494ca11e Initial load
duke
parents:
diff changeset
    90
    public static final int ABSENT_MTH   = ERRONEOUS+7; // missing method
06bc494ca11e Initial load
duke
parents:
diff changeset
    91
    public static final int ABSENT_TYP   = ERRONEOUS+8; // missing type
939
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
    92
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
    93
    public enum KindName implements Formattable {
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
    94
        ANNOTATION("kindname.interface"),
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
    95
        CONSTRUCTOR("kindname.constructor"),
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
    96
        INTERFACE("kindname.interface"),
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
    97
        STATIC("kindname.static"),
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
    98
        TYPEVAR("kindname.type.variable"),
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
    99
        BOUND("kindname.type.variable.bound"),
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
   100
        VAR("kindname.variable"),
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
   101
        VAL("kindname.value"),
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
   102
        METHOD("kindname.method"),
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
   103
        CLASS("kindname.class"),
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
   104
        PACKAGE("kindname.package");
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
   105
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
   106
        private String name;
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
   107
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
   108
        KindName(String name) {
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
   109
            this.name = name;
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
   110
        }
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
   111
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
   112
        public String toString() {
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
   113
            return name;
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
   114
        }
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
   115
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
   116
        public String getKind() {
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
   117
            return "Kindname";
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
   118
        }
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
   119
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
   120
        public String toString(ResourceBundle bundle) {
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
   121
            String s = toString();
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
   122
            return bundle.getString("compiler.misc." + s);
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
   123
        }
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
   124
    }
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
   125
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
   126
    /** A KindName representing a given symbol kind
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
   127
     */
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
   128
    public static KindName kindName(int kind) {
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
   129
        switch (kind) {
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
   130
        case PCK: return KindName.PACKAGE;
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
   131
        case TYP: return KindName.CLASS;
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
   132
        case VAR: return KindName.VAR;
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
   133
        case VAL: return KindName.VAL;
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
   134
        case MTH: return KindName.METHOD;
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
   135
            default : throw new AssertionError("Unexpected kind: "+kind);
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
   136
        }
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
   137
    }
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
   138
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
   139
    /** A KindName representing a given symbol
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
   140
     */
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
   141
    public static KindName kindName(Symbol sym) {
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
   142
        switch (sym.getKind()) {
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
   143
        case PACKAGE:
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
   144
            return KindName.PACKAGE;
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
   145
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
   146
        case ENUM:
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
   147
        case ANNOTATION_TYPE:
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
   148
        case INTERFACE:
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
   149
        case CLASS:
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
   150
            return KindName.CLASS;
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
   151
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
   152
        case TYPE_PARAMETER:
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
   153
            return KindName.TYPEVAR;
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
   154
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
   155
        case ENUM_CONSTANT:
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
   156
        case FIELD:
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
   157
        case PARAMETER:
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
   158
        case LOCAL_VARIABLE:
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
   159
        case EXCEPTION_PARAMETER:
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
   160
            return KindName.VAR;
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
   161
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
   162
        case METHOD:
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
   163
        case CONSTRUCTOR:
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
   164
        case STATIC_INIT:
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
   165
        case INSTANCE_INIT:
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
   166
            return KindName.METHOD;
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
   167
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
   168
        default:
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
   169
            if (sym.kind == VAL)
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
   170
                // I don't think this can happen but it can't harm
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
   171
                // playing it safe --ahe
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
   172
                return KindName.VAL;
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
   173
            else
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
   174
                throw new AssertionError("Unexpected kind: "+sym.getKind());
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
   175
        }
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
   176
    }
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
   177
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
   178
    /** A set of KindName(s) representing a set of symbol's kinds.
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
   179
     */
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
   180
    public static EnumSet<KindName> kindNames(int kind) {
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
   181
        EnumSet<KindName> kinds = EnumSet.noneOf(KindName.class);
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
   182
        if ((kind & VAL) != 0)
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
   183
            kinds.add(((kind & VAL) == VAR) ? KindName.VAR : KindName.VAL);
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
   184
        if ((kind & MTH) != 0) kinds.add(KindName.METHOD);
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
   185
        if ((kind & TYP) != 0) kinds.add(KindName.CLASS);
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
   186
        if ((kind & PCK) != 0) kinds.add(KindName.PACKAGE);
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
   187
        return kinds;
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
   188
    }
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
   189
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
   190
    /** A KindName representing the kind of a given class/interface type.
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
   191
     */
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
   192
    public static KindName typeKindName(Type t) {
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
   193
        if (t.tag == TYPEVAR ||
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
   194
            t.tag == CLASS && (t.tsym.flags() & COMPOUND) != 0)
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
   195
            return KindName.BOUND;
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
   196
        else if (t.tag == PACKAGE)
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
   197
            return KindName.PACKAGE;
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
   198
        else if ((t.tsym.flags_field & ANNOTATION) != 0)
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
   199
            return KindName.ANNOTATION;
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
   200
        else if ((t.tsym.flags_field & INTERFACE) != 0)
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
   201
            return KindName.INTERFACE;
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
   202
        else
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
   203
            return KindName.CLASS;
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
   204
    }
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
   205
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
   206
    /** A KindName representing the kind of a a missing symbol, given an
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
   207
     *  error kind.
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
   208
     * */
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
   209
    public static KindName absentKind(int kind) {
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
   210
        switch (kind) {
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
   211
        case ABSENT_VAR:
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
   212
            return KindName.VAR;
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
   213
        case WRONG_MTHS: case WRONG_MTH: case ABSENT_MTH:
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
   214
            return KindName.METHOD;
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
   215
        case ABSENT_TYP:
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
   216
            return KindName.CLASS;
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
   217
        default:
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
   218
            throw new AssertionError("Unexpected kind: "+kind);
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
   219
        }
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
   220
    }
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   221
}