author | mcimadamore |
Wed, 13 Feb 2013 17:04:21 +0000 | |
changeset 15720 | e61b2f7a5148 |
parent 14801 | d66cab4ef397 |
child 18643 | fdd7572e0c18 |
permissions | -rw-r--r-- |
10 | 1 |
/* |
14258 | 2 |
* Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved. |
10 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
5520 | 7 |
* published by the Free Software Foundation. Oracle designates this |
10 | 8 |
* particular file as subject to the "Classpath" exception as provided |
5520 | 9 |
* by Oracle in the LICENSE file that accompanied this code. |
10 | 10 |
* |
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
15 |
* accompanied this code). |
|
16 |
* |
|
17 |
* You should have received a copy of the GNU General Public License version |
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
20 |
* |
|
5520 | 21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
22 |
* or visit www.oracle.com if you need additional information or have any |
|
23 |
* questions. |
|
10 | 24 |
*/ |
25 |
||
26 |
package com.sun.tools.javac.code; |
|
27 |
||
939
38e24969c7e9
6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents:
10
diff
changeset
|
28 |
import java.util.EnumSet; |
1471
57506cdfb7b4
6406133: JCDiagnostic.getMessage ignores locale argument
mcimadamore
parents:
1264
diff
changeset
|
29 |
import java.util.Locale; |
939
38e24969c7e9
6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents:
10
diff
changeset
|
30 |
|
14062
b7439971a094
7177386: Add attribution support for method references
mcimadamore
parents:
10626
diff
changeset
|
31 |
import com.sun.source.tree.MemberReferenceTree; |
939
38e24969c7e9
6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents:
10
diff
changeset
|
32 |
import com.sun.tools.javac.api.Formattable; |
1471
57506cdfb7b4
6406133: JCDiagnostic.getMessage ignores locale argument
mcimadamore
parents:
1264
diff
changeset
|
33 |
import com.sun.tools.javac.api.Messages; |
14258 | 34 |
import static com.sun.tools.javac.code.Flags.*; |
14359
d4099818ab70
7200915: convert TypeTags from a series of small ints to an enum
jjg
parents:
14258
diff
changeset
|
35 |
import static com.sun.tools.javac.code.TypeTag.CLASS; |
d4099818ab70
7200915: convert TypeTags from a series of small ints to an enum
jjg
parents:
14258
diff
changeset
|
36 |
import static com.sun.tools.javac.code.TypeTag.PACKAGE; |
d4099818ab70
7200915: convert TypeTags from a series of small ints to an enum
jjg
parents:
14258
diff
changeset
|
37 |
import static com.sun.tools.javac.code.TypeTag.TYPEVAR; |
10 | 38 |
|
39 |
/** Internal symbol kinds, which distinguish between elements of |
|
40 |
* different subclasses of Symbol. Symbol kinds are organized so they can be |
|
41 |
* or'ed to sets. |
|
42 |
* |
|
5847
1908176fd6e3
6944312: Potential rebranding issues in openjdk/langtools repository sources
jjg
parents:
5520
diff
changeset
|
43 |
* <p><b>This is NOT part of any supported API. |
1908176fd6e3
6944312: Potential rebranding issues in openjdk/langtools repository sources
jjg
parents:
5520
diff
changeset
|
44 |
* If you write code that depends on this, you do so at your own risk. |
10 | 45 |
* This code and its internal interfaces are subject to change or |
46 |
* deletion without notice.</b> |
|
47 |
*/ |
|
48 |
public class Kinds { |
|
49 |
||
50 |
private Kinds() {} // uninstantiable |
|
51 |
||
52 |
/** The empty set of kinds. |
|
53 |
*/ |
|
54 |
public final static int NIL = 0; |
|
55 |
||
56 |
/** The kind of package symbols. |
|
57 |
*/ |
|
58 |
public final static int PCK = 1 << 0; |
|
59 |
||
60 |
/** The kind of type symbols (classes, interfaces and type variables). |
|
61 |
*/ |
|
62 |
public final static int TYP = 1 << 1; |
|
63 |
||
64 |
/** The kind of variable symbols. |
|
65 |
*/ |
|
66 |
public final static int VAR = 1 << 2; |
|
67 |
||
68 |
/** The kind of values (variables or non-variable expressions), includes VAR. |
|
69 |
*/ |
|
70 |
public final static int VAL = (1 << 3) | VAR; |
|
71 |
||
72 |
/** The kind of methods. |
|
73 |
*/ |
|
74 |
public final static int MTH = 1 << 4; |
|
75 |
||
76 |
/** The error kind, which includes all other kinds. |
|
77 |
*/ |
|
78 |
public final static int ERR = (1 << 5) - 1; |
|
79 |
||
80 |
/** The set of all kinds. |
|
81 |
*/ |
|
82 |
public final static int AllKinds = ERR; |
|
83 |
||
84 |
/** Kinds for erroneous symbols that complement the above |
|
85 |
*/ |
|
86 |
public static final int ERRONEOUS = 1 << 6; |
|
87 |
public static final int AMBIGUOUS = ERRONEOUS+1; // ambiguous reference |
|
88 |
public static final int HIDDEN = ERRONEOUS+2; // hidden method or field |
|
89 |
public static final int STATICERR = ERRONEOUS+3; // nonstatic member from static context |
|
14062
b7439971a094
7177386: Add attribution support for method references
mcimadamore
parents:
10626
diff
changeset
|
90 |
public static final int MISSING_ENCL = ERRONEOUS+4; // missing enclosing class |
b7439971a094
7177386: Add attribution support for method references
mcimadamore
parents:
10626
diff
changeset
|
91 |
public static final int ABSENT_VAR = ERRONEOUS+5; // missing variable |
b7439971a094
7177386: Add attribution support for method references
mcimadamore
parents:
10626
diff
changeset
|
92 |
public static final int WRONG_MTHS = ERRONEOUS+6; // methods with wrong arguments |
b7439971a094
7177386: Add attribution support for method references
mcimadamore
parents:
10626
diff
changeset
|
93 |
public static final int WRONG_MTH = ERRONEOUS+7; // one method with wrong arguments |
b7439971a094
7177386: Add attribution support for method references
mcimadamore
parents:
10626
diff
changeset
|
94 |
public static final int ABSENT_MTH = ERRONEOUS+8; // missing method |
b7439971a094
7177386: Add attribution support for method references
mcimadamore
parents:
10626
diff
changeset
|
95 |
public static final int ABSENT_TYP = ERRONEOUS+9; // missing type |
939
38e24969c7e9
6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents:
10
diff
changeset
|
96 |
|
38e24969c7e9
6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents:
10
diff
changeset
|
97 |
public enum KindName implements Formattable { |
6031
50004868a787
6964768: need test program to validate javac resource bundles
jjg
parents:
5847
diff
changeset
|
98 |
ANNOTATION("kindname.annotation"), |
939
38e24969c7e9
6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents:
10
diff
changeset
|
99 |
CONSTRUCTOR("kindname.constructor"), |
38e24969c7e9
6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents:
10
diff
changeset
|
100 |
INTERFACE("kindname.interface"), |
3143
0413d5b5b7fd
6822637: ResolveError hierarchy needs to be refactored
mcimadamore
parents:
1471
diff
changeset
|
101 |
ENUM("kindname.enum"), |
939
38e24969c7e9
6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents:
10
diff
changeset
|
102 |
STATIC("kindname.static"), |
38e24969c7e9
6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents:
10
diff
changeset
|
103 |
TYPEVAR("kindname.type.variable"), |
38e24969c7e9
6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents:
10
diff
changeset
|
104 |
BOUND("kindname.type.variable.bound"), |
38e24969c7e9
6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents:
10
diff
changeset
|
105 |
VAR("kindname.variable"), |
38e24969c7e9
6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents:
10
diff
changeset
|
106 |
VAL("kindname.value"), |
38e24969c7e9
6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents:
10
diff
changeset
|
107 |
METHOD("kindname.method"), |
38e24969c7e9
6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents:
10
diff
changeset
|
108 |
CLASS("kindname.class"), |
10626
83f0c2860f5b
7086595: Error message bug: name of initializer is 'null'
mcimadamore
parents:
8620
diff
changeset
|
109 |
STATIC_INIT("kindname.static.init"), |
83f0c2860f5b
7086595: Error message bug: name of initializer is 'null'
mcimadamore
parents:
8620
diff
changeset
|
110 |
INSTANCE_INIT("kindname.instance.init"), |
939
38e24969c7e9
6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents:
10
diff
changeset
|
111 |
PACKAGE("kindname.package"); |
38e24969c7e9
6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents:
10
diff
changeset
|
112 |
|
14801
d66cab4ef397
8003967: detect and remove all mutable implicit static enum fields in langtools
vromero
parents:
14359
diff
changeset
|
113 |
private final String name; |
939
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 |
KindName(String name) { |
38e24969c7e9
6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents:
10
diff
changeset
|
116 |
this.name = name; |
38e24969c7e9
6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents:
10
diff
changeset
|
117 |
} |
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 |
public String toString() { |
38e24969c7e9
6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents:
10
diff
changeset
|
120 |
return name; |
38e24969c7e9
6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents:
10
diff
changeset
|
121 |
} |
38e24969c7e9
6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents:
10
diff
changeset
|
122 |
|
38e24969c7e9
6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents:
10
diff
changeset
|
123 |
public String getKind() { |
38e24969c7e9
6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents:
10
diff
changeset
|
124 |
return "Kindname"; |
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 |
|
1471
57506cdfb7b4
6406133: JCDiagnostic.getMessage ignores locale argument
mcimadamore
parents:
1264
diff
changeset
|
127 |
public String toString(Locale locale, Messages messages) { |
939
38e24969c7e9
6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents:
10
diff
changeset
|
128 |
String s = toString(); |
1471
57506cdfb7b4
6406133: JCDiagnostic.getMessage ignores locale argument
mcimadamore
parents:
1264
diff
changeset
|
129 |
return messages.getLocalizedString(locale, "compiler.misc." + s); |
939
38e24969c7e9
6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents:
10
diff
changeset
|
130 |
} |
38e24969c7e9
6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents:
10
diff
changeset
|
131 |
} |
38e24969c7e9
6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents:
10
diff
changeset
|
132 |
|
38e24969c7e9
6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents:
10
diff
changeset
|
133 |
/** A KindName representing a given symbol kind |
38e24969c7e9
6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents:
10
diff
changeset
|
134 |
*/ |
38e24969c7e9
6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents:
10
diff
changeset
|
135 |
public static KindName kindName(int kind) { |
38e24969c7e9
6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents:
10
diff
changeset
|
136 |
switch (kind) { |
38e24969c7e9
6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents:
10
diff
changeset
|
137 |
case PCK: return KindName.PACKAGE; |
38e24969c7e9
6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents:
10
diff
changeset
|
138 |
case TYP: return KindName.CLASS; |
38e24969c7e9
6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents:
10
diff
changeset
|
139 |
case VAR: return KindName.VAR; |
38e24969c7e9
6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents:
10
diff
changeset
|
140 |
case VAL: return KindName.VAL; |
38e24969c7e9
6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents:
10
diff
changeset
|
141 |
case MTH: return KindName.METHOD; |
38e24969c7e9
6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents:
10
diff
changeset
|
142 |
default : throw new AssertionError("Unexpected kind: "+kind); |
38e24969c7e9
6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents:
10
diff
changeset
|
143 |
} |
38e24969c7e9
6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents:
10
diff
changeset
|
144 |
} |
38e24969c7e9
6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents:
10
diff
changeset
|
145 |
|
14062
b7439971a094
7177386: Add attribution support for method references
mcimadamore
parents:
10626
diff
changeset
|
146 |
public static KindName kindName(MemberReferenceTree.ReferenceMode mode) { |
b7439971a094
7177386: Add attribution support for method references
mcimadamore
parents:
10626
diff
changeset
|
147 |
switch (mode) { |
b7439971a094
7177386: Add attribution support for method references
mcimadamore
parents:
10626
diff
changeset
|
148 |
case INVOKE: return KindName.METHOD; |
b7439971a094
7177386: Add attribution support for method references
mcimadamore
parents:
10626
diff
changeset
|
149 |
case NEW: return KindName.CONSTRUCTOR; |
b7439971a094
7177386: Add attribution support for method references
mcimadamore
parents:
10626
diff
changeset
|
150 |
default : throw new AssertionError("Unexpected mode: "+ mode); |
b7439971a094
7177386: Add attribution support for method references
mcimadamore
parents:
10626
diff
changeset
|
151 |
} |
b7439971a094
7177386: Add attribution support for method references
mcimadamore
parents:
10626
diff
changeset
|
152 |
} |
b7439971a094
7177386: Add attribution support for method references
mcimadamore
parents:
10626
diff
changeset
|
153 |
|
939
38e24969c7e9
6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents:
10
diff
changeset
|
154 |
/** A KindName representing a given symbol |
38e24969c7e9
6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents:
10
diff
changeset
|
155 |
*/ |
38e24969c7e9
6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents:
10
diff
changeset
|
156 |
public static KindName kindName(Symbol sym) { |
38e24969c7e9
6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents:
10
diff
changeset
|
157 |
switch (sym.getKind()) { |
38e24969c7e9
6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents:
10
diff
changeset
|
158 |
case PACKAGE: |
38e24969c7e9
6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents:
10
diff
changeset
|
159 |
return KindName.PACKAGE; |
38e24969c7e9
6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents:
10
diff
changeset
|
160 |
|
38e24969c7e9
6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents:
10
diff
changeset
|
161 |
case ENUM: |
3143
0413d5b5b7fd
6822637: ResolveError hierarchy needs to be refactored
mcimadamore
parents:
1471
diff
changeset
|
162 |
return KindName.ENUM; |
0413d5b5b7fd
6822637: ResolveError hierarchy needs to be refactored
mcimadamore
parents:
1471
diff
changeset
|
163 |
|
939
38e24969c7e9
6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents:
10
diff
changeset
|
164 |
case ANNOTATION_TYPE: |
38e24969c7e9
6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents:
10
diff
changeset
|
165 |
case CLASS: |
38e24969c7e9
6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents:
10
diff
changeset
|
166 |
return KindName.CLASS; |
38e24969c7e9
6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents:
10
diff
changeset
|
167 |
|
3143
0413d5b5b7fd
6822637: ResolveError hierarchy needs to be refactored
mcimadamore
parents:
1471
diff
changeset
|
168 |
case INTERFACE: |
0413d5b5b7fd
6822637: ResolveError hierarchy needs to be refactored
mcimadamore
parents:
1471
diff
changeset
|
169 |
return KindName.INTERFACE; |
0413d5b5b7fd
6822637: ResolveError hierarchy needs to be refactored
mcimadamore
parents:
1471
diff
changeset
|
170 |
|
939
38e24969c7e9
6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents:
10
diff
changeset
|
171 |
case TYPE_PARAMETER: |
38e24969c7e9
6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents:
10
diff
changeset
|
172 |
return KindName.TYPEVAR; |
38e24969c7e9
6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents:
10
diff
changeset
|
173 |
|
38e24969c7e9
6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents:
10
diff
changeset
|
174 |
case ENUM_CONSTANT: |
38e24969c7e9
6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents:
10
diff
changeset
|
175 |
case FIELD: |
38e24969c7e9
6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents:
10
diff
changeset
|
176 |
case PARAMETER: |
38e24969c7e9
6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents:
10
diff
changeset
|
177 |
case LOCAL_VARIABLE: |
38e24969c7e9
6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents:
10
diff
changeset
|
178 |
case EXCEPTION_PARAMETER: |
8620 | 179 |
case RESOURCE_VARIABLE: |
939
38e24969c7e9
6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents:
10
diff
changeset
|
180 |
return KindName.VAR; |
38e24969c7e9
6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents:
10
diff
changeset
|
181 |
|
3143
0413d5b5b7fd
6822637: ResolveError hierarchy needs to be refactored
mcimadamore
parents:
1471
diff
changeset
|
182 |
case CONSTRUCTOR: |
0413d5b5b7fd
6822637: ResolveError hierarchy needs to be refactored
mcimadamore
parents:
1471
diff
changeset
|
183 |
return KindName.CONSTRUCTOR; |
0413d5b5b7fd
6822637: ResolveError hierarchy needs to be refactored
mcimadamore
parents:
1471
diff
changeset
|
184 |
|
939
38e24969c7e9
6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents:
10
diff
changeset
|
185 |
case METHOD: |
10626
83f0c2860f5b
7086595: Error message bug: name of initializer is 'null'
mcimadamore
parents:
8620
diff
changeset
|
186 |
return KindName.METHOD; |
939
38e24969c7e9
6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents:
10
diff
changeset
|
187 |
case STATIC_INIT: |
10626
83f0c2860f5b
7086595: Error message bug: name of initializer is 'null'
mcimadamore
parents:
8620
diff
changeset
|
188 |
return KindName.STATIC_INIT; |
939
38e24969c7e9
6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents:
10
diff
changeset
|
189 |
case INSTANCE_INIT: |
10626
83f0c2860f5b
7086595: Error message bug: name of initializer is 'null'
mcimadamore
parents:
8620
diff
changeset
|
190 |
return KindName.INSTANCE_INIT; |
939
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 |
default: |
38e24969c7e9
6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents:
10
diff
changeset
|
193 |
if (sym.kind == VAL) |
38e24969c7e9
6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents:
10
diff
changeset
|
194 |
// 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
|
195 |
// playing it safe --ahe |
38e24969c7e9
6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents:
10
diff
changeset
|
196 |
return KindName.VAL; |
38e24969c7e9
6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents:
10
diff
changeset
|
197 |
else |
38e24969c7e9
6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents:
10
diff
changeset
|
198 |
throw new AssertionError("Unexpected kind: "+sym.getKind()); |
38e24969c7e9
6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents:
10
diff
changeset
|
199 |
} |
38e24969c7e9
6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents:
10
diff
changeset
|
200 |
} |
38e24969c7e9
6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents:
10
diff
changeset
|
201 |
|
38e24969c7e9
6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents:
10
diff
changeset
|
202 |
/** 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
|
203 |
*/ |
38e24969c7e9
6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents:
10
diff
changeset
|
204 |
public static EnumSet<KindName> kindNames(int kind) { |
38e24969c7e9
6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents:
10
diff
changeset
|
205 |
EnumSet<KindName> kinds = EnumSet.noneOf(KindName.class); |
38e24969c7e9
6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents:
10
diff
changeset
|
206 |
if ((kind & VAL) != 0) |
38e24969c7e9
6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents:
10
diff
changeset
|
207 |
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
|
208 |
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
|
209 |
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
|
210 |
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
|
211 |
return kinds; |
38e24969c7e9
6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents:
10
diff
changeset
|
212 |
} |
38e24969c7e9
6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents:
10
diff
changeset
|
213 |
|
38e24969c7e9
6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents:
10
diff
changeset
|
214 |
/** 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
|
215 |
*/ |
38e24969c7e9
6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents:
10
diff
changeset
|
216 |
public static KindName typeKindName(Type t) { |
38e24969c7e9
6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents:
10
diff
changeset
|
217 |
if (t.tag == TYPEVAR || |
38e24969c7e9
6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents:
10
diff
changeset
|
218 |
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
|
219 |
return KindName.BOUND; |
38e24969c7e9
6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents:
10
diff
changeset
|
220 |
else if (t.tag == PACKAGE) |
38e24969c7e9
6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents:
10
diff
changeset
|
221 |
return KindName.PACKAGE; |
38e24969c7e9
6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents:
10
diff
changeset
|
222 |
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
|
223 |
return KindName.ANNOTATION; |
38e24969c7e9
6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents:
10
diff
changeset
|
224 |
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
|
225 |
return KindName.INTERFACE; |
38e24969c7e9
6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents:
10
diff
changeset
|
226 |
else |
38e24969c7e9
6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents:
10
diff
changeset
|
227 |
return KindName.CLASS; |
38e24969c7e9
6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents:
10
diff
changeset
|
228 |
} |
38e24969c7e9
6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents:
10
diff
changeset
|
229 |
|
38e24969c7e9
6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents:
10
diff
changeset
|
230 |
/** 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
|
231 |
* error kind. |
38e24969c7e9
6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents:
10
diff
changeset
|
232 |
* */ |
38e24969c7e9
6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents:
10
diff
changeset
|
233 |
public static KindName absentKind(int kind) { |
38e24969c7e9
6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents:
10
diff
changeset
|
234 |
switch (kind) { |
38e24969c7e9
6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents:
10
diff
changeset
|
235 |
case ABSENT_VAR: |
38e24969c7e9
6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents:
10
diff
changeset
|
236 |
return KindName.VAR; |
38e24969c7e9
6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents:
10
diff
changeset
|
237 |
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
|
238 |
return KindName.METHOD; |
38e24969c7e9
6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents:
10
diff
changeset
|
239 |
case ABSENT_TYP: |
38e24969c7e9
6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents:
10
diff
changeset
|
240 |
return KindName.CLASS; |
38e24969c7e9
6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents:
10
diff
changeset
|
241 |
default: |
38e24969c7e9
6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents:
10
diff
changeset
|
242 |
throw new AssertionError("Unexpected kind: "+kind); |
38e24969c7e9
6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents:
10
diff
changeset
|
243 |
} |
38e24969c7e9
6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents:
10
diff
changeset
|
244 |
} |
10 | 245 |
} |