langtools/test/tools/javac/api/TestGetElementReferenceData.java
author vasya
Mon, 14 Dec 2015 20:18:19 +0100
changeset 34752 9c262a013456
parent 17557 9c6ace1881fe
permissions -rw-r--r--
8145342: Some copyright notices are inconsistently and ill formatted Summary: Adjusted formatting of copyright notices. Reviewed-by: darcy, alundblad
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
17557
9c6ace1881fe 8012929: Trees.getElement should work not only for declaration trees, but also for use-trees
jlahoda
parents:
diff changeset
     1
/*
9c6ace1881fe 8012929: Trees.getElement should work not only for declaration trees, but also for use-trees
jlahoda
parents:
diff changeset
     2
 * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
9c6ace1881fe 8012929: Trees.getElement should work not only for declaration trees, but also for use-trees
jlahoda
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
9c6ace1881fe 8012929: Trees.getElement should work not only for declaration trees, but also for use-trees
jlahoda
parents:
diff changeset
     4
 *
9c6ace1881fe 8012929: Trees.getElement should work not only for declaration trees, but also for use-trees
jlahoda
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
9c6ace1881fe 8012929: Trees.getElement should work not only for declaration trees, but also for use-trees
jlahoda
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
9c6ace1881fe 8012929: Trees.getElement should work not only for declaration trees, but also for use-trees
jlahoda
parents:
diff changeset
     7
 * published by the Free Software Foundation.
9c6ace1881fe 8012929: Trees.getElement should work not only for declaration trees, but also for use-trees
jlahoda
parents:
diff changeset
     8
 *
9c6ace1881fe 8012929: Trees.getElement should work not only for declaration trees, but also for use-trees
jlahoda
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
9c6ace1881fe 8012929: Trees.getElement should work not only for declaration trees, but also for use-trees
jlahoda
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
9c6ace1881fe 8012929: Trees.getElement should work not only for declaration trees, but also for use-trees
jlahoda
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
9c6ace1881fe 8012929: Trees.getElement should work not only for declaration trees, but also for use-trees
jlahoda
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
9c6ace1881fe 8012929: Trees.getElement should work not only for declaration trees, but also for use-trees
jlahoda
parents:
diff changeset
    13
 * accompanied this code).
9c6ace1881fe 8012929: Trees.getElement should work not only for declaration trees, but also for use-trees
jlahoda
parents:
diff changeset
    14
 *
9c6ace1881fe 8012929: Trees.getElement should work not only for declaration trees, but also for use-trees
jlahoda
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
9c6ace1881fe 8012929: Trees.getElement should work not only for declaration trees, but also for use-trees
jlahoda
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
9c6ace1881fe 8012929: Trees.getElement should work not only for declaration trees, but also for use-trees
jlahoda
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
9c6ace1881fe 8012929: Trees.getElement should work not only for declaration trees, but also for use-trees
jlahoda
parents:
diff changeset
    18
 *
9c6ace1881fe 8012929: Trees.getElement should work not only for declaration trees, but also for use-trees
jlahoda
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
9c6ace1881fe 8012929: Trees.getElement should work not only for declaration trees, but also for use-trees
jlahoda
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
9c6ace1881fe 8012929: Trees.getElement should work not only for declaration trees, but also for use-trees
jlahoda
parents:
diff changeset
    21
 * questions.
9c6ace1881fe 8012929: Trees.getElement should work not only for declaration trees, but also for use-trees
jlahoda
parents:
diff changeset
    22
 */
34752
9c262a013456 8145342: Some copyright notices are inconsistently and ill formatted
vasya
parents: 17557
diff changeset
    23
17557
9c6ace1881fe 8012929: Trees.getElement should work not only for declaration trees, but also for use-trees
jlahoda
parents:
diff changeset
    24
package test;
9c6ace1881fe 8012929: Trees.getElement should work not only for declaration trees, but also for use-trees
jlahoda
parents:
diff changeset
    25
/*getElement:PACKAGE:test*/
9c6ace1881fe 8012929: Trees.getElement should work not only for declaration trees, but also for use-trees
jlahoda
parents:
diff changeset
    26
import java.lang.annotation.*;
9c6ace1881fe 8012929: Trees.getElement should work not only for declaration trees, but also for use-trees
jlahoda
parents:
diff changeset
    27
import static test.TestGetElementReferenceData.Sub.*;
9c6ace1881fe 8012929: Trees.getElement should work not only for declaration trees, but also for use-trees
jlahoda
parents:
diff changeset
    28
9c6ace1881fe 8012929: Trees.getElement should work not only for declaration trees, but also for use-trees
jlahoda
parents:
diff changeset
    29
public class TestGetElementReferenceData {
9c6ace1881fe 8012929: Trees.getElement should work not only for declaration trees, but also for use-trees
jlahoda
parents:
diff changeset
    30
9c6ace1881fe 8012929: Trees.getElement should work not only for declaration trees, but also for use-trees
jlahoda
parents:
diff changeset
    31
    private static void test() {
9c6ace1881fe 8012929: Trees.getElement should work not only for declaration trees, but also for use-trees
jlahoda
parents:
diff changeset
    32
        StringBuilder/*getElement:CLASS:java.lang.StringBuilder*/ sb = new/*getElement:CONSTRUCTOR:java.lang.StringBuilder()*/ StringBuilder();
9c6ace1881fe 8012929: Trees.getElement should work not only for declaration trees, but also for use-trees
jlahoda
parents:
diff changeset
    33
        sb/*getElement:LOCAL_VARIABLE:sb*/.append/*getElement:METHOD:java.lang.StringBuilder.append(int)*/(0);
9c6ace1881fe 8012929: Trees.getElement should work not only for declaration trees, but also for use-trees
jlahoda
parents:
diff changeset
    34
        sb.reverse( /*getElement:METHOD:java.lang.StringBuilder.reverse()*/);
9c6ace1881fe 8012929: Trees.getElement should work not only for declaration trees, but also for use-trees
jlahoda
parents:
diff changeset
    35
        java.util.List< /*getElement:INTERFACE:java.util.List*/ String> l;
9c6ace1881fe 8012929: Trees.getElement should work not only for declaration trees, but also for use-trees
jlahoda
parents:
diff changeset
    36
        utility/*getElement:METHOD:test.TestGetElementReferenceData.Base.utility()*/();
9c6ace1881fe 8012929: Trees.getElement should work not only for declaration trees, but also for use-trees
jlahoda
parents:
diff changeset
    37
        target(TestGetElementReferenceData :: test/*getElement:METHOD:test.TestGetElementReferenceData.test()*/);
9c6ace1881fe 8012929: Trees.getElement should work not only for declaration trees, but also for use-trees
jlahoda
parents:
diff changeset
    38
    }
9c6ace1881fe 8012929: Trees.getElement should work not only for declaration trees, but also for use-trees
jlahoda
parents:
diff changeset
    39
    private static void target(Runnable r) { r.run(); }
9c6ace1881fe 8012929: Trees.getElement should work not only for declaration trees, but also for use-trees
jlahoda
parents:
diff changeset
    40
    public static class Base {
9c6ace1881fe 8012929: Trees.getElement should work not only for declaration trees, but also for use-trees
jlahoda
parents:
diff changeset
    41
        public static void utility() {}
9c6ace1881fe 8012929: Trees.getElement should work not only for declaration trees, but also for use-trees
jlahoda
parents:
diff changeset
    42
    }
9c6ace1881fe 8012929: Trees.getElement should work not only for declaration trees, but also for use-trees
jlahoda
parents:
diff changeset
    43
    public static class Sub extends @TypeAnnotation( /*getElement:ANNOTATION_TYPE:test.TestGetElementReferenceData.TypeAnnotation*/) Base {
9c6ace1881fe 8012929: Trees.getElement should work not only for declaration trees, but also for use-trees
jlahoda
parents:
diff changeset
    44
    }
9c6ace1881fe 8012929: Trees.getElement should work not only for declaration trees, but also for use-trees
jlahoda
parents:
diff changeset
    45
   @Deprecated( /*getElement:ANNOTATION_TYPE:java.lang.Deprecated*/)
9c6ace1881fe 8012929: Trees.getElement should work not only for declaration trees, but also for use-trees
jlahoda
parents:
diff changeset
    46
    public static class TypeParam<TT/*getElement:TYPE_PARAMETER:TT*/> {
9c6ace1881fe 8012929: Trees.getElement should work not only for declaration trees, but also for use-trees
jlahoda
parents:
diff changeset
    47
    }
9c6ace1881fe 8012929: Trees.getElement should work not only for declaration trees, but also for use-trees
jlahoda
parents:
diff changeset
    48
    @Target(ElementType.TYPE_USE)
9c6ace1881fe 8012929: Trees.getElement should work not only for declaration trees, but also for use-trees
jlahoda
parents:
diff changeset
    49
    @interface TypeAnnotation {
9c6ace1881fe 8012929: Trees.getElement should work not only for declaration trees, but also for use-trees
jlahoda
parents:
diff changeset
    50
    }
9c6ace1881fe 8012929: Trees.getElement should work not only for declaration trees, but also for use-trees
jlahoda
parents:
diff changeset
    51
}