langtools/test/tools/javac/api/TestOperators.java
author peterz
Fri, 28 May 2010 13:32:40 +0400
changeset 5594 3db39773da2e
parent 10 06bc494ca11e
child 5520 86e4b9a9da40
permissions -rw-r--r--
6954231: SynthTextPaneUI.installUI() doesn't set component to opaque even if prop was not set by client progr Reviewed-by: alexp
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 2005-2006 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.
06bc494ca11e Initial load
duke
parents:
diff changeset
     8
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
06bc494ca11e Initial load
duke
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
06bc494ca11e Initial load
duke
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
06bc494ca11e Initial load
duke
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
06bc494ca11e Initial load
duke
parents:
diff changeset
    13
 * accompanied this code).
06bc494ca11e Initial load
duke
parents:
diff changeset
    14
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
06bc494ca11e Initial load
duke
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
06bc494ca11e Initial load
duke
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
06bc494ca11e Initial load
duke
parents:
diff changeset
    18
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    19
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
06bc494ca11e Initial load
duke
parents:
diff changeset
    20
 * CA 95054 USA or visit www.sun.com if you need additional information or
06bc494ca11e Initial load
duke
parents:
diff changeset
    21
 * have any questions.
06bc494ca11e Initial load
duke
parents:
diff changeset
    22
 */
06bc494ca11e Initial load
duke
parents:
diff changeset
    23
06bc494ca11e Initial load
duke
parents:
diff changeset
    24
/*
06bc494ca11e Initial load
duke
parents:
diff changeset
    25
 * @test
06bc494ca11e Initial load
duke
parents:
diff changeset
    26
 * @bug     6338064 6346249 6340951 6392177
06bc494ca11e Initial load
duke
parents:
diff changeset
    27
 * @summary Tree API: can't determine kind of operator
06bc494ca11e Initial load
duke
parents:
diff changeset
    28
 * @author  Peter von der Ah\u00e9
06bc494ca11e Initial load
duke
parents:
diff changeset
    29
 * @compile TestOperators.java
06bc494ca11e Initial load
duke
parents:
diff changeset
    30
 * @compile -processor TestOperators -proc:only TestOperators.java
06bc494ca11e Initial load
duke
parents:
diff changeset
    31
 */
06bc494ca11e Initial load
duke
parents:
diff changeset
    32
06bc494ca11e Initial load
duke
parents:
diff changeset
    33
import java.util.Set;
06bc494ca11e Initial load
duke
parents:
diff changeset
    34
import javax.annotation.processing.*;
06bc494ca11e Initial load
duke
parents:
diff changeset
    35
import javax.lang.model.element.*;
06bc494ca11e Initial load
duke
parents:
diff changeset
    36
import javax.lang.model.util.*;
06bc494ca11e Initial load
duke
parents:
diff changeset
    37
import static javax.tools.Diagnostic.Kind.*;
06bc494ca11e Initial load
duke
parents:
diff changeset
    38
06bc494ca11e Initial load
duke
parents:
diff changeset
    39
import com.sun.source.tree.*;
06bc494ca11e Initial load
duke
parents:
diff changeset
    40
import com.sun.source.util.Trees;
06bc494ca11e Initial load
duke
parents:
diff changeset
    41
06bc494ca11e Initial load
duke
parents:
diff changeset
    42
import static com.sun.source.tree.Tree.Kind.*;
06bc494ca11e Initial load
duke
parents:
diff changeset
    43
06bc494ca11e Initial load
duke
parents:
diff changeset
    44
@interface TestMe {
06bc494ca11e Initial load
duke
parents:
diff changeset
    45
    Tree.Kind value();
06bc494ca11e Initial load
duke
parents:
diff changeset
    46
}
06bc494ca11e Initial load
duke
parents:
diff changeset
    47
06bc494ca11e Initial load
duke
parents:
diff changeset
    48
@SupportedAnnotationTypes("TestMe")
06bc494ca11e Initial load
duke
parents:
diff changeset
    49
public class TestOperators extends AbstractProcessor {
06bc494ca11e Initial load
duke
parents:
diff changeset
    50
06bc494ca11e Initial load
duke
parents:
diff changeset
    51
    @TestMe(POSTFIX_INCREMENT)
06bc494ca11e Initial load
duke
parents:
diff changeset
    52
    public int test_POSTFIX_INCREMENT(int i) {
06bc494ca11e Initial load
duke
parents:
diff changeset
    53
        return i++;
06bc494ca11e Initial load
duke
parents:
diff changeset
    54
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
    55
06bc494ca11e Initial load
duke
parents:
diff changeset
    56
    @TestMe(POSTFIX_DECREMENT)
06bc494ca11e Initial load
duke
parents:
diff changeset
    57
    public int test_POSTFIX_DECREMENT(int i) {
06bc494ca11e Initial load
duke
parents:
diff changeset
    58
        return i--;
06bc494ca11e Initial load
duke
parents:
diff changeset
    59
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
    60
06bc494ca11e Initial load
duke
parents:
diff changeset
    61
    @TestMe(PREFIX_INCREMENT)
06bc494ca11e Initial load
duke
parents:
diff changeset
    62
    public int test_PREFIX_INCREMENT(int i) {
06bc494ca11e Initial load
duke
parents:
diff changeset
    63
        return ++i;
06bc494ca11e Initial load
duke
parents:
diff changeset
    64
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
    65
06bc494ca11e Initial load
duke
parents:
diff changeset
    66
    @TestMe(PREFIX_DECREMENT)
06bc494ca11e Initial load
duke
parents:
diff changeset
    67
    public int test_PREFIX_DECREMENT(int i) {
06bc494ca11e Initial load
duke
parents:
diff changeset
    68
        return --i;
06bc494ca11e Initial load
duke
parents:
diff changeset
    69
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
    70
06bc494ca11e Initial load
duke
parents:
diff changeset
    71
    @TestMe(UNARY_PLUS)
06bc494ca11e Initial load
duke
parents:
diff changeset
    72
    public int test_UNARY_PLUS(int i) {
06bc494ca11e Initial load
duke
parents:
diff changeset
    73
        return +i;
06bc494ca11e Initial load
duke
parents:
diff changeset
    74
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
    75
06bc494ca11e Initial load
duke
parents:
diff changeset
    76
    @TestMe(UNARY_MINUS)
06bc494ca11e Initial load
duke
parents:
diff changeset
    77
    public int test_UNARY_MINUS(int i) {
06bc494ca11e Initial load
duke
parents:
diff changeset
    78
        return -i;
06bc494ca11e Initial load
duke
parents:
diff changeset
    79
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
    80
06bc494ca11e Initial load
duke
parents:
diff changeset
    81
    @TestMe(BITWISE_COMPLEMENT)
06bc494ca11e Initial load
duke
parents:
diff changeset
    82
    public int test_BITWISE_COMPLEMENT(int i) {
06bc494ca11e Initial load
duke
parents:
diff changeset
    83
        return ~i;
06bc494ca11e Initial load
duke
parents:
diff changeset
    84
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
    85
06bc494ca11e Initial load
duke
parents:
diff changeset
    86
    @TestMe(LOGICAL_COMPLEMENT)
06bc494ca11e Initial load
duke
parents:
diff changeset
    87
    public boolean test_LOGICAL_COMPLEMENT(boolean b) {
06bc494ca11e Initial load
duke
parents:
diff changeset
    88
        return !b;
06bc494ca11e Initial load
duke
parents:
diff changeset
    89
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
    90
06bc494ca11e Initial load
duke
parents:
diff changeset
    91
    @TestMe(MULTIPLY)
06bc494ca11e Initial load
duke
parents:
diff changeset
    92
    public int test_MULTIPLY(int i, int j) {
06bc494ca11e Initial load
duke
parents:
diff changeset
    93
        return i * j;
06bc494ca11e Initial load
duke
parents:
diff changeset
    94
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
    95
06bc494ca11e Initial load
duke
parents:
diff changeset
    96
    @TestMe(DIVIDE)
06bc494ca11e Initial load
duke
parents:
diff changeset
    97
    public int test_DIVIDE(int i, int j) {
06bc494ca11e Initial load
duke
parents:
diff changeset
    98
        return i / j;
06bc494ca11e Initial load
duke
parents:
diff changeset
    99
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   100
06bc494ca11e Initial load
duke
parents:
diff changeset
   101
    @TestMe(REMAINDER)
06bc494ca11e Initial load
duke
parents:
diff changeset
   102
    public int test_REMAINDER(int i, int j) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   103
        return i % j;
06bc494ca11e Initial load
duke
parents:
diff changeset
   104
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   105
06bc494ca11e Initial load
duke
parents:
diff changeset
   106
    @TestMe(PLUS)
06bc494ca11e Initial load
duke
parents:
diff changeset
   107
    public int test_PLUS(int i, int j) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   108
        return i + j;
06bc494ca11e Initial load
duke
parents:
diff changeset
   109
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   110
06bc494ca11e Initial load
duke
parents:
diff changeset
   111
    @TestMe(MINUS)
06bc494ca11e Initial load
duke
parents:
diff changeset
   112
    public int test_MINUS(int i, int j) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   113
        return i - j;
06bc494ca11e Initial load
duke
parents:
diff changeset
   114
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   115
06bc494ca11e Initial load
duke
parents:
diff changeset
   116
    @TestMe(LEFT_SHIFT)
06bc494ca11e Initial load
duke
parents:
diff changeset
   117
    public int test_LEFT_SHIFT(int i, int j) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   118
        return i << j;
06bc494ca11e Initial load
duke
parents:
diff changeset
   119
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   120
06bc494ca11e Initial load
duke
parents:
diff changeset
   121
    @TestMe(RIGHT_SHIFT)
06bc494ca11e Initial load
duke
parents:
diff changeset
   122
    public int test_RIGHT_SHIFT(int i, int j) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   123
        return i >> j;
06bc494ca11e Initial load
duke
parents:
diff changeset
   124
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   125
06bc494ca11e Initial load
duke
parents:
diff changeset
   126
    @TestMe(UNSIGNED_RIGHT_SHIFT)
06bc494ca11e Initial load
duke
parents:
diff changeset
   127
    public int test_UNSIGNED_RIGHT_SHIFT(int i, int j) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   128
        return i >>> j;
06bc494ca11e Initial load
duke
parents:
diff changeset
   129
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   130
06bc494ca11e Initial load
duke
parents:
diff changeset
   131
    @TestMe(LESS_THAN)
06bc494ca11e Initial load
duke
parents:
diff changeset
   132
    public boolean test_LESS_THAN(int i, int j) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   133
        return i < j;
06bc494ca11e Initial load
duke
parents:
diff changeset
   134
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   135
06bc494ca11e Initial load
duke
parents:
diff changeset
   136
    @TestMe(GREATER_THAN)
06bc494ca11e Initial load
duke
parents:
diff changeset
   137
    public boolean test_GREATER_THAN(int i, int j) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   138
        return i > j;
06bc494ca11e Initial load
duke
parents:
diff changeset
   139
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   140
06bc494ca11e Initial load
duke
parents:
diff changeset
   141
    @TestMe(LESS_THAN_EQUAL)
06bc494ca11e Initial load
duke
parents:
diff changeset
   142
    public boolean test_LESS_THAN_EQUAL(int i, int j) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   143
        return i <= j;
06bc494ca11e Initial load
duke
parents:
diff changeset
   144
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   145
06bc494ca11e Initial load
duke
parents:
diff changeset
   146
    @TestMe(GREATER_THAN_EQUAL)
06bc494ca11e Initial load
duke
parents:
diff changeset
   147
    public boolean test_GREATER_THAN_EQUAL(int i, int j) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   148
        return i >= j;
06bc494ca11e Initial load
duke
parents:
diff changeset
   149
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   150
06bc494ca11e Initial load
duke
parents:
diff changeset
   151
    @TestMe(EQUAL_TO)
06bc494ca11e Initial load
duke
parents:
diff changeset
   152
    public boolean test_EQUAL_TO(int i, int j) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   153
        return i == j;
06bc494ca11e Initial load
duke
parents:
diff changeset
   154
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   155
06bc494ca11e Initial load
duke
parents:
diff changeset
   156
    @TestMe(NOT_EQUAL_TO)
06bc494ca11e Initial load
duke
parents:
diff changeset
   157
    public boolean test_NOT_EQUAL_TO(int i, int j) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   158
        return i != j;
06bc494ca11e Initial load
duke
parents:
diff changeset
   159
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   160
06bc494ca11e Initial load
duke
parents:
diff changeset
   161
    @TestMe(AND)
06bc494ca11e Initial load
duke
parents:
diff changeset
   162
    public boolean test_AND(boolean a, boolean b) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   163
        return a & b;
06bc494ca11e Initial load
duke
parents:
diff changeset
   164
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   165
06bc494ca11e Initial load
duke
parents:
diff changeset
   166
    @TestMe(XOR)
06bc494ca11e Initial load
duke
parents:
diff changeset
   167
    public boolean test_XOR(boolean a, boolean b) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   168
        return a ^ b;
06bc494ca11e Initial load
duke
parents:
diff changeset
   169
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   170
06bc494ca11e Initial load
duke
parents:
diff changeset
   171
    @TestMe(OR)
06bc494ca11e Initial load
duke
parents:
diff changeset
   172
    public boolean test_OR(boolean a, boolean b) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   173
        return a | b;
06bc494ca11e Initial load
duke
parents:
diff changeset
   174
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   175
06bc494ca11e Initial load
duke
parents:
diff changeset
   176
    @TestMe(CONDITIONAL_AND)
06bc494ca11e Initial load
duke
parents:
diff changeset
   177
    public boolean test_CONDITIONAL_AND(boolean a, boolean b) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   178
        return a && b;
06bc494ca11e Initial load
duke
parents:
diff changeset
   179
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   180
06bc494ca11e Initial load
duke
parents:
diff changeset
   181
    @TestMe(CONDITIONAL_OR)
06bc494ca11e Initial load
duke
parents:
diff changeset
   182
    public boolean test_CONDITIONAL_OR(boolean a, boolean b) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   183
        return a || b;
06bc494ca11e Initial load
duke
parents:
diff changeset
   184
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   185
06bc494ca11e Initial load
duke
parents:
diff changeset
   186
    @TestMe(MULTIPLY_ASSIGNMENT)
06bc494ca11e Initial load
duke
parents:
diff changeset
   187
    public int test_MULTIPLY_ASSIGNMENT(int i, int j) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   188
        return i *= j;
06bc494ca11e Initial load
duke
parents:
diff changeset
   189
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   190
06bc494ca11e Initial load
duke
parents:
diff changeset
   191
    @TestMe(DIVIDE_ASSIGNMENT)
06bc494ca11e Initial load
duke
parents:
diff changeset
   192
    public int test_DIVIDE_ASSIGNMENT(int i, int j) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   193
        return i /= j;
06bc494ca11e Initial load
duke
parents:
diff changeset
   194
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   195
06bc494ca11e Initial load
duke
parents:
diff changeset
   196
    @TestMe(REMAINDER_ASSIGNMENT)
06bc494ca11e Initial load
duke
parents:
diff changeset
   197
    public int test_REMAINDER_ASSIGNMENT(int i, int j) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   198
        return i %= j;
06bc494ca11e Initial load
duke
parents:
diff changeset
   199
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   200
06bc494ca11e Initial load
duke
parents:
diff changeset
   201
    @TestMe(PLUS_ASSIGNMENT)
06bc494ca11e Initial load
duke
parents:
diff changeset
   202
    public int test_PLUS_ASSIGNMENT(int i, int j) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   203
        return i += j;
06bc494ca11e Initial load
duke
parents:
diff changeset
   204
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   205
06bc494ca11e Initial load
duke
parents:
diff changeset
   206
    @TestMe(MINUS_ASSIGNMENT)
06bc494ca11e Initial load
duke
parents:
diff changeset
   207
    public int test_MINUS_ASSIGNMENT(int i, int j) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   208
        return i -= j;
06bc494ca11e Initial load
duke
parents:
diff changeset
   209
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   210
06bc494ca11e Initial load
duke
parents:
diff changeset
   211
    @TestMe(LEFT_SHIFT_ASSIGNMENT)
06bc494ca11e Initial load
duke
parents:
diff changeset
   212
    public int test_LEFT_SHIFT_ASSIGNMENT(int i, int j) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   213
        return i <<= j;
06bc494ca11e Initial load
duke
parents:
diff changeset
   214
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   215
06bc494ca11e Initial load
duke
parents:
diff changeset
   216
    @TestMe(RIGHT_SHIFT_ASSIGNMENT)
06bc494ca11e Initial load
duke
parents:
diff changeset
   217
    public int test_RIGHT_SHIFT_ASSIGNMENT(int i, int j) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   218
        return i >>= j;
06bc494ca11e Initial load
duke
parents:
diff changeset
   219
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   220
06bc494ca11e Initial load
duke
parents:
diff changeset
   221
    @TestMe(UNSIGNED_RIGHT_SHIFT_ASSIGNMENT)
06bc494ca11e Initial load
duke
parents:
diff changeset
   222
    public int test_UNSIGNED_RIGHT_SHIFT_ASSIGNMENT(int i, int j) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   223
        return i >>>= j;
06bc494ca11e Initial load
duke
parents:
diff changeset
   224
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   225
06bc494ca11e Initial load
duke
parents:
diff changeset
   226
    @TestMe(AND_ASSIGNMENT)
06bc494ca11e Initial load
duke
parents:
diff changeset
   227
    public boolean test_AND_ASSIGNMENT(boolean a, boolean b) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   228
        return a &= b;
06bc494ca11e Initial load
duke
parents:
diff changeset
   229
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   230
06bc494ca11e Initial load
duke
parents:
diff changeset
   231
    @TestMe(XOR_ASSIGNMENT)
06bc494ca11e Initial load
duke
parents:
diff changeset
   232
    public boolean test_XOR_ASSIGNMENT(boolean a, boolean b) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   233
        return a ^= b;
06bc494ca11e Initial load
duke
parents:
diff changeset
   234
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   235
06bc494ca11e Initial load
duke
parents:
diff changeset
   236
    @TestMe(OR_ASSIGNMENT)
06bc494ca11e Initial load
duke
parents:
diff changeset
   237
    public boolean test_OR_ASSIGNMENT(boolean a, boolean b) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   238
        return a |= b;
06bc494ca11e Initial load
duke
parents:
diff changeset
   239
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   240
06bc494ca11e Initial load
duke
parents:
diff changeset
   241
    @TestMe(INT_LITERAL)
06bc494ca11e Initial load
duke
parents:
diff changeset
   242
    public Object test_INT_LITERAL() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   243
        return 0;
06bc494ca11e Initial load
duke
parents:
diff changeset
   244
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   245
06bc494ca11e Initial load
duke
parents:
diff changeset
   246
    @TestMe(LONG_LITERAL)
06bc494ca11e Initial load
duke
parents:
diff changeset
   247
    public Object test_LONG_LITERAL() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   248
        return 0L;
06bc494ca11e Initial load
duke
parents:
diff changeset
   249
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   250
06bc494ca11e Initial load
duke
parents:
diff changeset
   251
    @TestMe(FLOAT_LITERAL)
06bc494ca11e Initial load
duke
parents:
diff changeset
   252
    public Object test_FLOAT_LITERAL() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   253
        return 0.0F;
06bc494ca11e Initial load
duke
parents:
diff changeset
   254
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   255
06bc494ca11e Initial load
duke
parents:
diff changeset
   256
    @TestMe(DOUBLE_LITERAL)
06bc494ca11e Initial load
duke
parents:
diff changeset
   257
    public Object test_DOUBLE_LITERAL() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   258
        return 0.0;
06bc494ca11e Initial load
duke
parents:
diff changeset
   259
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   260
06bc494ca11e Initial load
duke
parents:
diff changeset
   261
    @TestMe(BOOLEAN_LITERAL)
06bc494ca11e Initial load
duke
parents:
diff changeset
   262
    public Object test_BOOLEAN_LITERAL() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   263
        return true;
06bc494ca11e Initial load
duke
parents:
diff changeset
   264
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   265
06bc494ca11e Initial load
duke
parents:
diff changeset
   266
    @TestMe(CHAR_LITERAL)
06bc494ca11e Initial load
duke
parents:
diff changeset
   267
    public Object test_CHAR_LITERAL() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   268
        return 'a';
06bc494ca11e Initial load
duke
parents:
diff changeset
   269
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   270
06bc494ca11e Initial load
duke
parents:
diff changeset
   271
    @TestMe(STRING_LITERAL)
06bc494ca11e Initial load
duke
parents:
diff changeset
   272
    public Object test_STRING_LITERAL() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   273
        return "a";
06bc494ca11e Initial load
duke
parents:
diff changeset
   274
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   275
06bc494ca11e Initial load
duke
parents:
diff changeset
   276
    @TestMe(NULL_LITERAL)
06bc494ca11e Initial load
duke
parents:
diff changeset
   277
    public Object test_NULL_LITERAL() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   278
        return null;
06bc494ca11e Initial load
duke
parents:
diff changeset
   279
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   280
06bc494ca11e Initial load
duke
parents:
diff changeset
   281
    @TestMe(UNBOUNDED_WILDCARD)
06bc494ca11e Initial load
duke
parents:
diff changeset
   282
    public Set<?> test_UNBOUNDED_WILDCARD() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   283
        return null;
06bc494ca11e Initial load
duke
parents:
diff changeset
   284
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   285
06bc494ca11e Initial load
duke
parents:
diff changeset
   286
    @TestMe(EXTENDS_WILDCARD)
06bc494ca11e Initial load
duke
parents:
diff changeset
   287
    public Set<? extends Number> test_EXTENDS_WILDCARD() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   288
        return null;
06bc494ca11e Initial load
duke
parents:
diff changeset
   289
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   290
06bc494ca11e Initial load
duke
parents:
diff changeset
   291
    @TestMe(SUPER_WILDCARD)
06bc494ca11e Initial load
duke
parents:
diff changeset
   292
    public Set<? super Number> test_SUPER_WILDCARD() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   293
        return null;
06bc494ca11e Initial load
duke
parents:
diff changeset
   294
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   295
06bc494ca11e Initial load
duke
parents:
diff changeset
   296
    public boolean process(Set<? extends TypeElement> annotations,
06bc494ca11e Initial load
duke
parents:
diff changeset
   297
                           RoundEnvironment roundEnvironment)
06bc494ca11e Initial load
duke
parents:
diff changeset
   298
    {
06bc494ca11e Initial load
duke
parents:
diff changeset
   299
        final Trees trees = Trees.instance(processingEnv);
06bc494ca11e Initial load
duke
parents:
diff changeset
   300
        final Messager log = processingEnv.getMessager();
06bc494ca11e Initial load
duke
parents:
diff changeset
   301
        final Elements elements = processingEnv.getElementUtils();
06bc494ca11e Initial load
duke
parents:
diff changeset
   302
        class Scan extends ElementScanner6<Void,Void> {
06bc494ca11e Initial load
duke
parents:
diff changeset
   303
            @Override
06bc494ca11e Initial load
duke
parents:
diff changeset
   304
            public Void visitExecutable(ExecutableElement e, Void p) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   305
                Object debug = e; // info for exception handler
06bc494ca11e Initial load
duke
parents:
diff changeset
   306
                try {
06bc494ca11e Initial load
duke
parents:
diff changeset
   307
                    TestMe info = e.getAnnotation(TestMe.class);
06bc494ca11e Initial load
duke
parents:
diff changeset
   308
                    if (info == null)
06bc494ca11e Initial load
duke
parents:
diff changeset
   309
                        return null;
06bc494ca11e Initial load
duke
parents:
diff changeset
   310
06bc494ca11e Initial load
duke
parents:
diff changeset
   311
                    Tree.Kind kind = info.value();
06bc494ca11e Initial load
duke
parents:
diff changeset
   312
                    MethodTree node = trees.getTree(e);
06bc494ca11e Initial load
duke
parents:
diff changeset
   313
                    debug = node;
06bc494ca11e Initial load
duke
parents:
diff changeset
   314
                    Tree testNode;
06bc494ca11e Initial load
duke
parents:
diff changeset
   315
                    switch (kind) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   316
                    case UNBOUNDED_WILDCARD:
06bc494ca11e Initial load
duke
parents:
diff changeset
   317
                    case EXTENDS_WILDCARD:
06bc494ca11e Initial load
duke
parents:
diff changeset
   318
                    case SUPER_WILDCARD:
06bc494ca11e Initial load
duke
parents:
diff changeset
   319
                        ParameterizedTypeTree typeTree;
06bc494ca11e Initial load
duke
parents:
diff changeset
   320
                        typeTree = (ParameterizedTypeTree) node.getReturnType();
06bc494ca11e Initial load
duke
parents:
diff changeset
   321
                        testNode = typeTree.getTypeArguments().get(0);
06bc494ca11e Initial load
duke
parents:
diff changeset
   322
                        break;
06bc494ca11e Initial load
duke
parents:
diff changeset
   323
                    default:
06bc494ca11e Initial load
duke
parents:
diff changeset
   324
                        ReturnTree returnNode;
06bc494ca11e Initial load
duke
parents:
diff changeset
   325
                        returnNode = (ReturnTree) node.getBody().getStatements().get(0);
06bc494ca11e Initial load
duke
parents:
diff changeset
   326
                        testNode = returnNode.getExpression();
06bc494ca11e Initial load
duke
parents:
diff changeset
   327
                    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   328
                    if (testNode.getKind() != kind) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   329
                        log.printMessage(ERROR, testNode.getKind() + " != " + kind, e);
06bc494ca11e Initial load
duke
parents:
diff changeset
   330
                        throw new AssertionError(testNode);
06bc494ca11e Initial load
duke
parents:
diff changeset
   331
                    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   332
                    System.err.format("OK: %32s %s%n", kind, testNode);
06bc494ca11e Initial load
duke
parents:
diff changeset
   333
                } catch (Error ex) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   334
                    System.err.println("Error while looking at " + debug);
06bc494ca11e Initial load
duke
parents:
diff changeset
   335
                    throw ex;
06bc494ca11e Initial load
duke
parents:
diff changeset
   336
                }
06bc494ca11e Initial load
duke
parents:
diff changeset
   337
                return null;
06bc494ca11e Initial load
duke
parents:
diff changeset
   338
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   339
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   340
        Scan scan = new Scan();
06bc494ca11e Initial load
duke
parents:
diff changeset
   341
        for (Element e : roundEnvironment.getRootElements()) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   342
            scan.scan(e);
06bc494ca11e Initial load
duke
parents:
diff changeset
   343
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   344
        return true;
06bc494ca11e Initial load
duke
parents:
diff changeset
   345
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   346
06bc494ca11e Initial load
duke
parents:
diff changeset
   347
}