test/langtools/tools/javac/importscope/ImportMembersTest.java
author darcy
Fri, 02 Feb 2018 10:29:25 -0800
changeset 48723 6cb86bf0b51e
parent 47216 71c04702a3d5
permissions -rw-r--r--
8196623: Update JavaBaseTest.java to be version agnostic Reviewed-by: vromero
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
27997
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
     1
/*
36526
3b41f1c69604 8142968: Module System implementation
alanb
parents: 30730
diff changeset
     2
 * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
27997
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
     4
 *
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
     7
 * published by the Free Software Foundation.
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
     8
 *
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
    13
 * accompanied this code).
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
    14
 *
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
    18
 *
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
    21
 * questions.
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
    22
 */
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
    23
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
    24
/*
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
    25
 * @test
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
    26
 * @bug 8065360
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
    27
 * @summary The test checks possibility of class members to be imported.
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
    28
 * @library /tools/lib
30730
d3ce7619db2c 8076543: Add @modules as needed to the langtools tests
akulyakh
parents: 27997
diff changeset
    29
 * @modules jdk.compiler/com.sun.tools.javac.api
d3ce7619db2c 8076543: Add @modules as needed to the langtools tests
akulyakh
parents: 27997
diff changeset
    30
 *          jdk.compiler/com.sun.tools.javac.main
36526
3b41f1c69604 8142968: Module System implementation
alanb
parents: 30730
diff changeset
    31
 *          jdk.jdeps/com.sun.tools.javap
36778
e04318f39f92 8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents: 36526
diff changeset
    32
 * @build toolbox.ToolBox ImportMembersTest
27997
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
    33
 * @run main ImportMembersTest
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
    34
 */
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
    35
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
    36
import javax.tools.JavaCompiler;
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
    37
import javax.tools.ToolProvider;
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
    38
import java.io.StringWriter;
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
    39
import java.util.ArrayList;
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
    40
import java.util.Arrays;
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
    41
import java.util.List;
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
    42
36778
e04318f39f92 8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents: 36526
diff changeset
    43
import toolbox.ToolBox;
e04318f39f92 8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents: 36526
diff changeset
    44
27997
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
    45
/**
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
    46
 * The test checks that members of a class, an enum, an interface or annotation
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
    47
 * can be imported with help of a static import or an import statement.
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
    48
 * The tests generates a code, compiles it and checks whether it can be compiled
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
    49
 * successfully or fails with a proper message.
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
    50
 * The following is the example of a test case:
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
    51
 * package pkg;
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
    52
 * class ChildA extends A {}
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
    53
 *
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
    54
 * package pkg;
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
    55
 * class A {
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
    56
 *     static class Inner {}
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
    57
 *     static Object field;
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
    58
 *     static void method() {}
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
    59
 * }
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
    60
 *
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
    61
 * package pkg;
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
    62
 * import static pkg.ChildA.method;
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
    63
 * public class Test {{
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
    64
 *     method();
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
    65
 * }}
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
    66
 *
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
    67
 */
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
    68
public class ImportMembersTest {
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
    69
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
    70
    private static final String[] expectedErrorMessages = {
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
    71
            "Test.java:\\d+:\\d+: compiler.err.cant.resolve.location: .*\n1 error\n",
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
    72
            "Test.java:\\d+:\\d+: compiler.err.import.requires.canonical: .*\n1 error\n"
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
    73
    };
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
    74
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
    75
    private static final String sourceTemplate =
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
    76
            "package pkg;\n" +
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
    77
            "#IMPORT\n" +
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
    78
            "public class Test {{\n" +
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
    79
            "    #STATEMENT\n" +
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
    80
            "}}\n";
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
    81
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
    82
    public static void main(String[] args) {
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
    83
        new ImportMembersTest().test();
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
    84
    }
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
    85
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
    86
    public void test() {
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
    87
        int passed = 0;
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
    88
        int total = 0;
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
    89
        for (ClassType classType : ClassType.values()) {
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
    90
            for (ImportType importType : ImportType.values()) {
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
    91
                for (MemberType memberType : MemberType.values()) {
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
    92
                    ++total;
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
    93
                    List<ToolBox.JavaSource> sources = classType.getSources();
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
    94
                    sources.add(new ToolBox.JavaSource("Test.java",
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
    95
                            generateSource(classType, memberType, importType)));
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
    96
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
    97
                    CompilationResult compilationResult = compile(sources);
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
    98
                    boolean isErrorExpected = importType.hasError(classType, memberType);
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
    99
                    if (!compilationResult.isSuccessful) {
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   100
                        if (isErrorExpected) {
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   101
                            String expectedErrorMessage =
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   102
                                    getExpectedErrorMessage(classType, importType, memberType);
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   103
                            if (compilationResult.message.matches(expectedErrorMessage)) {
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   104
                                ++passed;
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   105
                            } else {
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   106
                                reportFailure(sources, String.format("Expected compilation failure message:\n" +
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   107
                                                "%s\ngot message:\n%s",
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   108
                                        expectedErrorMessage, compilationResult.message));
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   109
                            }
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   110
                        } else {
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   111
                            reportFailure(sources, String.format("Unexpected compilation failure:\n%s",
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   112
                                    compilationResult.message));
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   113
                        }
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   114
                    } else {
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   115
                        if (isErrorExpected) {
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   116
                            reportFailure(sources, "Expected compilation failure.");
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   117
                        } else {
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   118
                            ++passed;
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   119
                        }
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   120
                    }
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   121
                }
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   122
            }
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   123
        }
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   124
        String message = String.format(
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   125
                "Total test cases run: %d, passed: %d, failed: %d.",
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   126
                total, passed, total - passed);
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   127
        if (passed != total) {
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   128
            throw new RuntimeException(message);
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   129
        }
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   130
        echo(message);
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   131
    }
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   132
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   133
    private String getExpectedErrorMessage(ClassType classType, ImportType importType, MemberType memberType) {
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   134
        String expectedErrorMessage;
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   135
        if (importType == ImportType.IMPORT && classType == ClassType.CHILD_A &&
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   136
                memberType == MemberType.CLASS) {
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   137
            expectedErrorMessage = expectedErrorMessages[1];
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   138
        } else {
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   139
            expectedErrorMessage = expectedErrorMessages[0];
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   140
        }
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   141
        return expectedErrorMessage;
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   142
    }
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   143
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   144
    private void reportFailure(List<ToolBox.JavaSource> sources, String message) {
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   145
        echo("Test case failed!");
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   146
        printSources(sources);
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   147
        echo(message);
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   148
        echo();
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   149
    }
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   150
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   151
    private String generateSource(ClassType classType, MemberType memberType, ImportType importType) {
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   152
        String importString = importType.generateImport(classType.getClassName(), memberType.getMemberType());
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   153
        String statement;
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   154
        if (importType.hasError(classType, memberType)) {
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   155
            // if the source code has a compilation error, nothing is added.
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   156
            // just to prevent the compiler from appending additional
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   157
            // compilation errors to output
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   158
            statement = "";
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   159
        } else if (memberType == MemberType.STAR) {
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   160
            // in case of import-on-demand, every class member is used
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   161
            if (importType == ImportType.STATIC_IMPORT) {
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   162
                statement = MemberType.CLASS.getStatement() + "\n    "
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   163
                        + MemberType.FIELD.getStatement();
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   164
                // an annotation does not have a static method.
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   165
                if (classType != ClassType.D) {
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   166
                    statement += "\n    " + MemberType.METHOD.getStatement() + "\n";
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   167
                }
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   168
            } else {
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   169
                statement = classType != ClassType.CHILD_A
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   170
                        ? MemberType.CLASS.getStatement() : "";
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   171
            }
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   172
        } else {
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   173
            statement = memberType.getStatement();
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   174
        }
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   175
        return sourceTemplate
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   176
                .replace("#IMPORT", importString)
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   177
                .replace("#STATEMENT", statement);
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   178
    }
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   179
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   180
    private static class CompilationResult {
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   181
        public final boolean isSuccessful;
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   182
        public final String message;
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   183
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   184
        public CompilationResult(boolean isSuccessful, String message) {
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   185
            this.isSuccessful = isSuccessful;
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   186
            this.message = message;
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   187
        }
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   188
    }
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   189
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   190
    private CompilationResult compile(List<ToolBox.JavaSource> sources) {
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   191
        StringWriter writer = new StringWriter();
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   192
        JavaCompiler jc = ToolProvider.getSystemJavaCompiler();
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   193
        Boolean call = jc.getTask(writer, null, null, Arrays.asList("-XDrawDiagnostics"), null, sources).call();
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   194
        return new CompilationResult(call, writer.toString().replace(ToolBox.lineSeparator, "\n"));
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   195
    }
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   196
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   197
    public void printSources(List<ToolBox.JavaSource> sources) {
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   198
        for (ToolBox.JavaSource javaSource : sources) {
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   199
            echo(javaSource.getCharContent(true).toString());
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   200
        }
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   201
    }
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   202
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   203
    public void echo() {
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   204
        echo("");
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   205
    }
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   206
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   207
    public void echo(String output) {
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   208
        printf(output + "\n");
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   209
    }
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   210
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   211
    public void printf(String template, Object...args) {
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   212
        System.err.print(String.format(template, args).replace("\n", ToolBox.lineSeparator));
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   213
    }
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   214
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   215
    enum ClassType {
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   216
        A("A",
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   217
        "package pkg;\n" +
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   218
        "class A {\n" +
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   219
        "    static class Inner {}\n" +
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   220
        "    static Object field;\n" +
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   221
        "    static void method() {}\n" +
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   222
        "}\n"
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   223
        ),
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   224
        B("B",
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   225
        "package pkg;\n" +
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   226
        "interface B {\n" +
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   227
        "    static class Inner {}\n" +
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   228
        "    static Object field = null;\n" +
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   229
        "    static void method() {}\n" +
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   230
        "}\n"
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   231
        ),
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   232
        C("C",
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   233
        "package pkg;\n" +
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   234
        "enum C {field;\n" +
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   235
        "    static class Inner {}\n" +
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   236
        "    static void method() {}\n" +
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   237
        "}\n"
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   238
        ),
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   239
        D("D",
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   240
        "package pkg;\n" +
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   241
        "@interface D {\n" +
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   242
        "    static class Inner {}\n" +
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   243
        "    static Object field = null;\n" +
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   244
        "}\n"
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   245
        ),
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   246
        CHILD_A("ChildA",
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   247
        "package pkg;\n" +
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   248
        "class ChildA extends A {}\n",
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   249
        A);
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   250
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   251
        private final String className;
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   252
        private final String source;
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   253
        private final ClassType parentType;
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   254
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   255
        private ClassType(String className, String source) {
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   256
            this(className, source, null);
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   257
        }
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   258
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   259
        private ClassType(String className, String source, ClassType classType) {
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   260
            this.className = className;
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   261
            this.source = source;
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   262
            this.parentType = classType;
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   263
        }
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   264
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   265
        public String getClassName() {
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   266
            return className;
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   267
        }
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   268
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   269
        public List<ToolBox.JavaSource> getSources() {
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   270
            List<ToolBox.JavaSource> sourceList = new ArrayList<>();
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   271
            ClassType current = this;
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   272
            while (current != null) {
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   273
                sourceList.add(new ToolBox.JavaSource(current.className, current.source));
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   274
                current = current.parentType;
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   275
            }
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   276
            return sourceList;
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   277
        }
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   278
    }
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   279
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   280
    enum MemberType {
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   281
        CLASS("Inner", "Inner inner = null;"),
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   282
        FIELD("field", "Object o = field;"),
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   283
        METHOD("method", "method();"),
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   284
        STAR("*", ""),
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   285
        NOT_EXIST("NotExist", "");
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   286
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   287
        private final String memberType;
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   288
        private final String statement;
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   289
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   290
        private MemberType(String memberType, String statement) {
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   291
            this.memberType = memberType;
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   292
            this.statement = statement;
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   293
        }
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   294
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   295
        public String getStatement() {
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   296
            return statement;
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   297
        }
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   298
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   299
        public String getMemberType() {
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   300
            return memberType;
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   301
        }
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   302
    }
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   303
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   304
    enum ImportType {
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   305
        IMPORT("import pkg.#CLASS_NAME.#MEMBER_NAME;"),
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   306
        STATIC_IMPORT("import static pkg.#CLASS_NAME.#MEMBER_NAME;");
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   307
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   308
        private final String importType;
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   309
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   310
        private ImportType(String importType) {
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   311
            this.importType = importType;
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   312
        }
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   313
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   314
        public String generateImport(String className, String memberName) {
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   315
            return importType
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   316
                    .replace("#CLASS_NAME", className)
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   317
                    .replace("#MEMBER_NAME", memberName);
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   318
        }
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   319
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   320
        public boolean hasError(ClassType classType, MemberType memberType) {
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   321
            switch (memberType) {
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   322
                case FIELD:
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   323
                    return this != ImportType.STATIC_IMPORT;
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   324
                case METHOD:
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   325
                    return this != ImportType.STATIC_IMPORT || classType == ClassType.D;
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   326
                case NOT_EXIST:
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   327
                    return true;
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   328
                case CLASS:
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   329
                    return classType.parentType != null && this != STATIC_IMPORT;
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   330
                default:
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   331
                    return false;
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   332
            }
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   333
        }
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   334
    }
44407cab4584 8065360: Implement a test that checks possibilty of class members to be imported
aeremeev
parents:
diff changeset
   335
}