src/jdk.compiler/share/classes/com/sun/tools/javac/tree/TreeScanner.java
author jlahoda
Wed, 27 Nov 2019 09:00:01 +0100
changeset 59285 7799a51dbe30
parent 55306 ea43db53de91
permissions -rw-r--r--
8231826: Implement javac changes for pattern matching for instanceof Reviewed-by: mcimadamore Contributed-by: brian.goetz@oracle.com, gavin.bierman@oracle.com, maurizio.cimadamore@oracle.com, srikanth.adayapalam@oracle.com, vicente.romero@oracle.com, jan.lahoda@oracle.com
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
10
06bc494ca11e Initial load
duke
parents:
diff changeset
     1
/*
55306
ea43db53de91 8223305: Compiler support for Switch Expressions
jlahoda
parents: 51563
diff changeset
     2
 * Copyright (c) 2001, 2019, Oracle and/or its affiliates. All rights reserved.
10
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
5520
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 5492
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
10
06bc494ca11e Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5520
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 5492
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    10
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
06bc494ca11e Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
06bc494ca11e Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
06bc494ca11e Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
06bc494ca11e Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
06bc494ca11e Initial load
duke
parents:
diff changeset
    16
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
06bc494ca11e Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
06bc494ca11e Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
06bc494ca11e Initial load
duke
parents:
diff changeset
    20
 *
5520
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 5492
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 5492
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 5492
diff changeset
    23
 * questions.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    24
 */
06bc494ca11e Initial load
duke
parents:
diff changeset
    25
06bc494ca11e Initial load
duke
parents:
diff changeset
    26
package com.sun.tools.javac.tree;
06bc494ca11e Initial load
duke
parents:
diff changeset
    27
06bc494ca11e Initial load
duke
parents:
diff changeset
    28
import com.sun.tools.javac.util.*;
06bc494ca11e Initial load
duke
parents:
diff changeset
    29
import com.sun.tools.javac.tree.JCTree.*;
06bc494ca11e Initial load
duke
parents:
diff changeset
    30
06bc494ca11e Initial load
duke
parents:
diff changeset
    31
/** A subclass of Tree.Visitor, this class defines
06bc494ca11e Initial load
duke
parents:
diff changeset
    32
 *  a general tree scanner pattern. Translation proceeds recursively in
06bc494ca11e Initial load
duke
parents:
diff changeset
    33
 *  left-to-right order down a tree. There is one visitor method in this class
06bc494ca11e Initial load
duke
parents:
diff changeset
    34
 *  for every possible kind of tree node.  To obtain a specific
06bc494ca11e Initial load
duke
parents:
diff changeset
    35
 *  scanner, it suffices to override those visitor methods which
06bc494ca11e Initial load
duke
parents:
diff changeset
    36
 *  do some interesting work. The scanner class itself takes care of all
06bc494ca11e Initial load
duke
parents:
diff changeset
    37
 *  navigational aspects.
06bc494ca11e Initial load
duke
parents:
diff changeset
    38
 *
5847
1908176fd6e3 6944312: Potential rebranding issues in openjdk/langtools repository sources
jjg
parents: 5520
diff changeset
    39
 *  <p><b>This is NOT part of any supported API.
1908176fd6e3 6944312: Potential rebranding issues in openjdk/langtools repository sources
jjg
parents: 5520
diff changeset
    40
 *  If you write code that depends on this, you do so at your own risk.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    41
 *  This code and its internal interfaces are subject to change or
06bc494ca11e Initial load
duke
parents:
diff changeset
    42
 *  deletion without notice.</b>
06bc494ca11e Initial load
duke
parents:
diff changeset
    43
 */
06bc494ca11e Initial load
duke
parents:
diff changeset
    44
public class TreeScanner extends Visitor {
06bc494ca11e Initial load
duke
parents:
diff changeset
    45
06bc494ca11e Initial load
duke
parents:
diff changeset
    46
    /** Visitor method: Scan a single node.
06bc494ca11e Initial load
duke
parents:
diff changeset
    47
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    48
    public void scan(JCTree tree) {
06bc494ca11e Initial load
duke
parents:
diff changeset
    49
        if(tree!=null) tree.accept(this);
06bc494ca11e Initial load
duke
parents:
diff changeset
    50
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
    51
06bc494ca11e Initial load
duke
parents:
diff changeset
    52
    /** Visitor method: scan a list of nodes.
06bc494ca11e Initial load
duke
parents:
diff changeset
    53
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    54
    public void scan(List<? extends JCTree> trees) {
06bc494ca11e Initial load
duke
parents:
diff changeset
    55
        if (trees != null)
06bc494ca11e Initial load
duke
parents:
diff changeset
    56
        for (List<? extends JCTree> l = trees; l.nonEmpty(); l = l.tail)
06bc494ca11e Initial load
duke
parents:
diff changeset
    57
            scan(l.head);
06bc494ca11e Initial load
duke
parents:
diff changeset
    58
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
    59
06bc494ca11e Initial load
duke
parents:
diff changeset
    60
06bc494ca11e Initial load
duke
parents:
diff changeset
    61
/* ***************************************************************************
06bc494ca11e Initial load
duke
parents:
diff changeset
    62
 * Visitor methods
06bc494ca11e Initial load
duke
parents:
diff changeset
    63
 ****************************************************************************/
06bc494ca11e Initial load
duke
parents:
diff changeset
    64
06bc494ca11e Initial load
duke
parents:
diff changeset
    65
    public void visitTopLevel(JCCompilationUnit tree) {
24069
dfb8f11542fc 8034245: Refactor TopLevel tree node.
pgovereau
parents: 17578
diff changeset
    66
        scan(tree.defs);
dfb8f11542fc 8034245: Refactor TopLevel tree node.
pgovereau
parents: 17578
diff changeset
    67
    }
dfb8f11542fc 8034245: Refactor TopLevel tree node.
pgovereau
parents: 17578
diff changeset
    68
dfb8f11542fc 8034245: Refactor TopLevel tree node.
pgovereau
parents: 17578
diff changeset
    69
    public void visitPackageDef(JCPackageDecl tree) {
dfb8f11542fc 8034245: Refactor TopLevel tree node.
pgovereau
parents: 17578
diff changeset
    70
        scan(tree.annotations);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    71
        scan(tree.pid);
06bc494ca11e Initial load
duke
parents:
diff changeset
    72
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
    73
36526
3b41f1c69604 8142968: Module System implementation
alanb
parents: 25874
diff changeset
    74
    @Override
3b41f1c69604 8142968: Module System implementation
alanb
parents: 25874
diff changeset
    75
    public void visitModuleDef(JCModuleDecl tree) {
42407
f3702cff2933 8169069: Module system implementation refresh (11/2016)
alanb
parents: 36526
diff changeset
    76
        scan(tree.mods);
36526
3b41f1c69604 8142968: Module System implementation
alanb
parents: 25874
diff changeset
    77
        scan(tree.qualId);
3b41f1c69604 8142968: Module System implementation
alanb
parents: 25874
diff changeset
    78
        scan(tree.directives);
3b41f1c69604 8142968: Module System implementation
alanb
parents: 25874
diff changeset
    79
    }
3b41f1c69604 8142968: Module System implementation
alanb
parents: 25874
diff changeset
    80
3b41f1c69604 8142968: Module System implementation
alanb
parents: 25874
diff changeset
    81
    @Override
3b41f1c69604 8142968: Module System implementation
alanb
parents: 25874
diff changeset
    82
    public void visitExports(JCExports tree) {
3b41f1c69604 8142968: Module System implementation
alanb
parents: 25874
diff changeset
    83
        scan(tree.qualid);
3b41f1c69604 8142968: Module System implementation
alanb
parents: 25874
diff changeset
    84
        scan(tree.moduleNames);
3b41f1c69604 8142968: Module System implementation
alanb
parents: 25874
diff changeset
    85
    }
3b41f1c69604 8142968: Module System implementation
alanb
parents: 25874
diff changeset
    86
3b41f1c69604 8142968: Module System implementation
alanb
parents: 25874
diff changeset
    87
    @Override
42407
f3702cff2933 8169069: Module system implementation refresh (11/2016)
alanb
parents: 36526
diff changeset
    88
    public void visitOpens(JCOpens tree) {
f3702cff2933 8169069: Module system implementation refresh (11/2016)
alanb
parents: 36526
diff changeset
    89
        scan(tree.qualid);
f3702cff2933 8169069: Module system implementation refresh (11/2016)
alanb
parents: 36526
diff changeset
    90
        scan(tree.moduleNames);
f3702cff2933 8169069: Module system implementation refresh (11/2016)
alanb
parents: 36526
diff changeset
    91
    }
f3702cff2933 8169069: Module system implementation refresh (11/2016)
alanb
parents: 36526
diff changeset
    92
f3702cff2933 8169069: Module system implementation refresh (11/2016)
alanb
parents: 36526
diff changeset
    93
    @Override
36526
3b41f1c69604 8142968: Module System implementation
alanb
parents: 25874
diff changeset
    94
    public void visitProvides(JCProvides tree) {
3b41f1c69604 8142968: Module System implementation
alanb
parents: 25874
diff changeset
    95
        scan(tree.serviceName);
42407
f3702cff2933 8169069: Module system implementation refresh (11/2016)
alanb
parents: 36526
diff changeset
    96
        scan(tree.implNames);
36526
3b41f1c69604 8142968: Module System implementation
alanb
parents: 25874
diff changeset
    97
    }
3b41f1c69604 8142968: Module System implementation
alanb
parents: 25874
diff changeset
    98
3b41f1c69604 8142968: Module System implementation
alanb
parents: 25874
diff changeset
    99
    @Override
3b41f1c69604 8142968: Module System implementation
alanb
parents: 25874
diff changeset
   100
    public void visitRequires(JCRequires tree) {
3b41f1c69604 8142968: Module System implementation
alanb
parents: 25874
diff changeset
   101
        scan(tree.moduleName);
3b41f1c69604 8142968: Module System implementation
alanb
parents: 25874
diff changeset
   102
    }
3b41f1c69604 8142968: Module System implementation
alanb
parents: 25874
diff changeset
   103
3b41f1c69604 8142968: Module System implementation
alanb
parents: 25874
diff changeset
   104
    @Override
3b41f1c69604 8142968: Module System implementation
alanb
parents: 25874
diff changeset
   105
    public void visitUses(JCUses tree) {
3b41f1c69604 8142968: Module System implementation
alanb
parents: 25874
diff changeset
   106
        scan(tree.qualid);
3b41f1c69604 8142968: Module System implementation
alanb
parents: 25874
diff changeset
   107
    }
3b41f1c69604 8142968: Module System implementation
alanb
parents: 25874
diff changeset
   108
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   109
    public void visitImport(JCImport tree) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   110
        scan(tree.qualid);
06bc494ca11e Initial load
duke
parents:
diff changeset
   111
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   112
06bc494ca11e Initial load
duke
parents:
diff changeset
   113
    public void visitClassDef(JCClassDecl tree) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   114
        scan(tree.mods);
06bc494ca11e Initial load
duke
parents:
diff changeset
   115
        scan(tree.typarams);
06bc494ca11e Initial load
duke
parents:
diff changeset
   116
        scan(tree.extending);
06bc494ca11e Initial load
duke
parents:
diff changeset
   117
        scan(tree.implementing);
06bc494ca11e Initial load
duke
parents:
diff changeset
   118
        scan(tree.defs);
06bc494ca11e Initial load
duke
parents:
diff changeset
   119
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   120
06bc494ca11e Initial load
duke
parents:
diff changeset
   121
    public void visitMethodDef(JCMethodDecl tree) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   122
        scan(tree.mods);
06bc494ca11e Initial load
duke
parents:
diff changeset
   123
        scan(tree.restype);
06bc494ca11e Initial load
duke
parents:
diff changeset
   124
        scan(tree.typarams);
15385
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14725
diff changeset
   125
        scan(tree.recvparam);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   126
        scan(tree.params);
06bc494ca11e Initial load
duke
parents:
diff changeset
   127
        scan(tree.thrown);
1786
88f03aba5cf9 6512707: "incompatible types" after (unrelated) annotation processing
jjg
parents: 10
diff changeset
   128
        scan(tree.defaultValue);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   129
        scan(tree.body);
06bc494ca11e Initial load
duke
parents:
diff changeset
   130
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   131
06bc494ca11e Initial load
duke
parents:
diff changeset
   132
    public void visitVarDef(JCVariableDecl tree) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   133
        scan(tree.mods);
06bc494ca11e Initial load
duke
parents:
diff changeset
   134
        scan(tree.vartype);
17578
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents: 15385
diff changeset
   135
        scan(tree.nameexpr);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   136
        scan(tree.init);
06bc494ca11e Initial load
duke
parents:
diff changeset
   137
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   138
06bc494ca11e Initial load
duke
parents:
diff changeset
   139
    public void visitSkip(JCSkip tree) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   140
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   141
06bc494ca11e Initial load
duke
parents:
diff changeset
   142
    public void visitBlock(JCBlock tree) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   143
        scan(tree.stats);
06bc494ca11e Initial load
duke
parents:
diff changeset
   144
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   145
06bc494ca11e Initial load
duke
parents:
diff changeset
   146
    public void visitDoLoop(JCDoWhileLoop tree) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   147
        scan(tree.body);
06bc494ca11e Initial load
duke
parents:
diff changeset
   148
        scan(tree.cond);
06bc494ca11e Initial load
duke
parents:
diff changeset
   149
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   150
06bc494ca11e Initial load
duke
parents:
diff changeset
   151
    public void visitWhileLoop(JCWhileLoop tree) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   152
        scan(tree.cond);
06bc494ca11e Initial load
duke
parents:
diff changeset
   153
        scan(tree.body);
06bc494ca11e Initial load
duke
parents:
diff changeset
   154
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   155
06bc494ca11e Initial load
duke
parents:
diff changeset
   156
    public void visitForLoop(JCForLoop tree) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   157
        scan(tree.init);
06bc494ca11e Initial load
duke
parents:
diff changeset
   158
        scan(tree.cond);
06bc494ca11e Initial load
duke
parents:
diff changeset
   159
        scan(tree.step);
06bc494ca11e Initial load
duke
parents:
diff changeset
   160
        scan(tree.body);
06bc494ca11e Initial load
duke
parents:
diff changeset
   161
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   162
06bc494ca11e Initial load
duke
parents:
diff changeset
   163
    public void visitForeachLoop(JCEnhancedForLoop tree) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   164
        scan(tree.var);
06bc494ca11e Initial load
duke
parents:
diff changeset
   165
        scan(tree.expr);
06bc494ca11e Initial load
duke
parents:
diff changeset
   166
        scan(tree.body);
06bc494ca11e Initial load
duke
parents:
diff changeset
   167
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   168
06bc494ca11e Initial load
duke
parents:
diff changeset
   169
    public void visitLabelled(JCLabeledStatement tree) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   170
        scan(tree.body);
06bc494ca11e Initial load
duke
parents:
diff changeset
   171
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   172
06bc494ca11e Initial load
duke
parents:
diff changeset
   173
    public void visitSwitch(JCSwitch tree) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   174
        scan(tree.selector);
06bc494ca11e Initial load
duke
parents:
diff changeset
   175
        scan(tree.cases);
06bc494ca11e Initial load
duke
parents:
diff changeset
   176
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   177
06bc494ca11e Initial load
duke
parents:
diff changeset
   178
    public void visitCase(JCCase tree) {
51563
de411d537aae 8206986: Compiler support for Switch Expressions (Preview)
jlahoda
parents: 47216
diff changeset
   179
        scan(tree.pats);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   180
        scan(tree.stats);
06bc494ca11e Initial load
duke
parents:
diff changeset
   181
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   182
51563
de411d537aae 8206986: Compiler support for Switch Expressions (Preview)
jlahoda
parents: 47216
diff changeset
   183
    public void visitSwitchExpression(JCSwitchExpression tree) {
de411d537aae 8206986: Compiler support for Switch Expressions (Preview)
jlahoda
parents: 47216
diff changeset
   184
        scan(tree.selector);
de411d537aae 8206986: Compiler support for Switch Expressions (Preview)
jlahoda
parents: 47216
diff changeset
   185
        scan(tree.cases);
de411d537aae 8206986: Compiler support for Switch Expressions (Preview)
jlahoda
parents: 47216
diff changeset
   186
    }
de411d537aae 8206986: Compiler support for Switch Expressions (Preview)
jlahoda
parents: 47216
diff changeset
   187
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   188
    public void visitSynchronized(JCSynchronized tree) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   189
        scan(tree.lock);
06bc494ca11e Initial load
duke
parents:
diff changeset
   190
        scan(tree.body);
06bc494ca11e Initial load
duke
parents:
diff changeset
   191
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   192
06bc494ca11e Initial load
duke
parents:
diff changeset
   193
    public void visitTry(JCTry tree) {
6148
3a8158299c51 6911256: Project Coin: Support Automatic Resource Management (ARM) blocks in the compiler
darcy
parents: 5847
diff changeset
   194
        scan(tree.resources);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   195
        scan(tree.body);
06bc494ca11e Initial load
duke
parents:
diff changeset
   196
        scan(tree.catchers);
06bc494ca11e Initial load
duke
parents:
diff changeset
   197
        scan(tree.finalizer);
06bc494ca11e Initial load
duke
parents:
diff changeset
   198
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   199
06bc494ca11e Initial load
duke
parents:
diff changeset
   200
    public void visitCatch(JCCatch tree) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   201
        scan(tree.param);
06bc494ca11e Initial load
duke
parents:
diff changeset
   202
        scan(tree.body);
06bc494ca11e Initial load
duke
parents:
diff changeset
   203
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   204
06bc494ca11e Initial load
duke
parents:
diff changeset
   205
    public void visitConditional(JCConditional tree) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   206
        scan(tree.cond);
06bc494ca11e Initial load
duke
parents:
diff changeset
   207
        scan(tree.truepart);
06bc494ca11e Initial load
duke
parents:
diff changeset
   208
        scan(tree.falsepart);
06bc494ca11e Initial load
duke
parents:
diff changeset
   209
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   210
06bc494ca11e Initial load
duke
parents:
diff changeset
   211
    public void visitIf(JCIf tree) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   212
        scan(tree.cond);
06bc494ca11e Initial load
duke
parents:
diff changeset
   213
        scan(tree.thenpart);
06bc494ca11e Initial load
duke
parents:
diff changeset
   214
        scan(tree.elsepart);
06bc494ca11e Initial load
duke
parents:
diff changeset
   215
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   216
06bc494ca11e Initial load
duke
parents:
diff changeset
   217
    public void visitExec(JCExpressionStatement tree) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   218
        scan(tree.expr);
06bc494ca11e Initial load
duke
parents:
diff changeset
   219
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   220
06bc494ca11e Initial load
duke
parents:
diff changeset
   221
    public void visitBreak(JCBreak tree) {
55306
ea43db53de91 8223305: Compiler support for Switch Expressions
jlahoda
parents: 51563
diff changeset
   222
    }
ea43db53de91 8223305: Compiler support for Switch Expressions
jlahoda
parents: 51563
diff changeset
   223
ea43db53de91 8223305: Compiler support for Switch Expressions
jlahoda
parents: 51563
diff changeset
   224
    public void visitYield(JCYield tree) {
51563
de411d537aae 8206986: Compiler support for Switch Expressions (Preview)
jlahoda
parents: 47216
diff changeset
   225
        scan(tree.value);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   226
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   227
06bc494ca11e Initial load
duke
parents:
diff changeset
   228
    public void visitContinue(JCContinue tree) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   229
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   230
06bc494ca11e Initial load
duke
parents:
diff changeset
   231
    public void visitReturn(JCReturn tree) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   232
        scan(tree.expr);
06bc494ca11e Initial load
duke
parents:
diff changeset
   233
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   234
06bc494ca11e Initial load
duke
parents:
diff changeset
   235
    public void visitThrow(JCThrow tree) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   236
        scan(tree.expr);
06bc494ca11e Initial load
duke
parents:
diff changeset
   237
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   238
06bc494ca11e Initial load
duke
parents:
diff changeset
   239
    public void visitAssert(JCAssert tree) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   240
        scan(tree.cond);
06bc494ca11e Initial load
duke
parents:
diff changeset
   241
        scan(tree.detail);
06bc494ca11e Initial load
duke
parents:
diff changeset
   242
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   243
06bc494ca11e Initial load
duke
parents:
diff changeset
   244
    public void visitApply(JCMethodInvocation tree) {
4877
b642d21c9f74 6923080: TreeScanner.visitNewClass should scan tree.typeargs
jjg
parents: 3149
diff changeset
   245
        scan(tree.typeargs);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   246
        scan(tree.meth);
06bc494ca11e Initial load
duke
parents:
diff changeset
   247
        scan(tree.args);
06bc494ca11e Initial load
duke
parents:
diff changeset
   248
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   249
06bc494ca11e Initial load
duke
parents:
diff changeset
   250
    public void visitNewClass(JCNewClass tree) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   251
        scan(tree.encl);
15385
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14725
diff changeset
   252
        scan(tree.typeargs);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   253
        scan(tree.clazz);
06bc494ca11e Initial load
duke
parents:
diff changeset
   254
        scan(tree.args);
06bc494ca11e Initial load
duke
parents:
diff changeset
   255
        scan(tree.def);
06bc494ca11e Initial load
duke
parents:
diff changeset
   256
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   257
06bc494ca11e Initial load
duke
parents:
diff changeset
   258
    public void visitNewArray(JCNewArray tree) {
15385
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14725
diff changeset
   259
        scan(tree.annotations);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   260
        scan(tree.elemtype);
06bc494ca11e Initial load
duke
parents:
diff changeset
   261
        scan(tree.dims);
15385
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14725
diff changeset
   262
        for (List<JCAnnotation> annos : tree.dimAnnotations)
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14725
diff changeset
   263
            scan(annos);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   264
        scan(tree.elems);
06bc494ca11e Initial load
duke
parents:
diff changeset
   265
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   266
11141
7d112a1ecd0f 7115046: Add AST node for lambda expressions
mcimadamore
parents: 9300
diff changeset
   267
    public void visitLambda(JCLambda tree) {
7d112a1ecd0f 7115046: Add AST node for lambda expressions
mcimadamore
parents: 9300
diff changeset
   268
        scan(tree.body);
7d112a1ecd0f 7115046: Add AST node for lambda expressions
mcimadamore
parents: 9300
diff changeset
   269
        scan(tree.params);
7d112a1ecd0f 7115046: Add AST node for lambda expressions
mcimadamore
parents: 9300
diff changeset
   270
    }
7d112a1ecd0f 7115046: Add AST node for lambda expressions
mcimadamore
parents: 9300
diff changeset
   271
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   272
    public void visitParens(JCParens tree) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   273
        scan(tree.expr);
06bc494ca11e Initial load
duke
parents:
diff changeset
   274
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   275
06bc494ca11e Initial load
duke
parents:
diff changeset
   276
    public void visitAssign(JCAssign tree) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   277
        scan(tree.lhs);
06bc494ca11e Initial load
duke
parents:
diff changeset
   278
        scan(tree.rhs);
06bc494ca11e Initial load
duke
parents:
diff changeset
   279
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   280
06bc494ca11e Initial load
duke
parents:
diff changeset
   281
    public void visitAssignop(JCAssignOp tree) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   282
        scan(tree.lhs);
06bc494ca11e Initial load
duke
parents:
diff changeset
   283
        scan(tree.rhs);
06bc494ca11e Initial load
duke
parents:
diff changeset
   284
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   285
06bc494ca11e Initial load
duke
parents:
diff changeset
   286
    public void visitUnary(JCUnary tree) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   287
        scan(tree.arg);
06bc494ca11e Initial load
duke
parents:
diff changeset
   288
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   289
06bc494ca11e Initial load
duke
parents:
diff changeset
   290
    public void visitBinary(JCBinary tree) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   291
        scan(tree.lhs);
06bc494ca11e Initial load
duke
parents:
diff changeset
   292
        scan(tree.rhs);
06bc494ca11e Initial load
duke
parents:
diff changeset
   293
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   294
06bc494ca11e Initial load
duke
parents:
diff changeset
   295
    public void visitTypeCast(JCTypeCast tree) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   296
        scan(tree.clazz);
06bc494ca11e Initial load
duke
parents:
diff changeset
   297
        scan(tree.expr);
06bc494ca11e Initial load
duke
parents:
diff changeset
   298
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   299
06bc494ca11e Initial load
duke
parents:
diff changeset
   300
    public void visitTypeTest(JCInstanceOf tree) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   301
        scan(tree.expr);
59285
7799a51dbe30 8231826: Implement javac changes for pattern matching for instanceof
jlahoda
parents: 55306
diff changeset
   302
        scan(tree.pattern);
7799a51dbe30 8231826: Implement javac changes for pattern matching for instanceof
jlahoda
parents: 55306
diff changeset
   303
    }
7799a51dbe30 8231826: Implement javac changes for pattern matching for instanceof
jlahoda
parents: 55306
diff changeset
   304
7799a51dbe30 8231826: Implement javac changes for pattern matching for instanceof
jlahoda
parents: 55306
diff changeset
   305
    public void visitBindingPattern(JCBindingPattern tree) {
7799a51dbe30 8231826: Implement javac changes for pattern matching for instanceof
jlahoda
parents: 55306
diff changeset
   306
        if (tree.vartype != null)
7799a51dbe30 8231826: Implement javac changes for pattern matching for instanceof
jlahoda
parents: 55306
diff changeset
   307
            scan(tree.vartype);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   308
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   309
06bc494ca11e Initial load
duke
parents:
diff changeset
   310
    public void visitIndexed(JCArrayAccess tree) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   311
        scan(tree.indexed);
06bc494ca11e Initial load
duke
parents:
diff changeset
   312
        scan(tree.index);
06bc494ca11e Initial load
duke
parents:
diff changeset
   313
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   314
06bc494ca11e Initial load
duke
parents:
diff changeset
   315
    public void visitSelect(JCFieldAccess tree) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   316
        scan(tree.selected);
06bc494ca11e Initial load
duke
parents:
diff changeset
   317
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   318
11142
45d0ec1e7463 7115049: Add AST node for method references
mcimadamore
parents: 11141
diff changeset
   319
    public void visitReference(JCMemberReference tree) {
45d0ec1e7463 7115049: Add AST node for method references
mcimadamore
parents: 11141
diff changeset
   320
        scan(tree.expr);
45d0ec1e7463 7115049: Add AST node for method references
mcimadamore
parents: 11141
diff changeset
   321
        scan(tree.typeargs);
45d0ec1e7463 7115049: Add AST node for method references
mcimadamore
parents: 11141
diff changeset
   322
    }
45d0ec1e7463 7115049: Add AST node for method references
mcimadamore
parents: 11141
diff changeset
   323
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   324
    public void visitIdent(JCIdent tree) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   325
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   326
06bc494ca11e Initial load
duke
parents:
diff changeset
   327
    public void visitLiteral(JCLiteral tree) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   328
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   329
06bc494ca11e Initial load
duke
parents:
diff changeset
   330
    public void visitTypeIdent(JCPrimitiveTypeTree tree) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   331
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   332
06bc494ca11e Initial load
duke
parents:
diff changeset
   333
    public void visitTypeArray(JCArrayTypeTree tree) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   334
        scan(tree.elemtype);
06bc494ca11e Initial load
duke
parents:
diff changeset
   335
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   336
06bc494ca11e Initial load
duke
parents:
diff changeset
   337
    public void visitTypeApply(JCTypeApply tree) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   338
        scan(tree.clazz);
06bc494ca11e Initial load
duke
parents:
diff changeset
   339
        scan(tree.arguments);
06bc494ca11e Initial load
duke
parents:
diff changeset
   340
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   341
9300
c2de4dd9853b 7033809: Rename "disjunctive" to "union" in javax.lang.model
darcy
parents: 8032
diff changeset
   342
    public void visitTypeUnion(JCTypeUnion tree) {
7074
0183c3f9614e 6949587: rename "DisjointType" to "DisjunctType"
jjg
parents: 6148
diff changeset
   343
        scan(tree.alternatives);
5492
515e4b33b335 6943289: Project Coin: Improved Exception Handling for Java (aka 'multicatch')
mcimadamore
parents: 4877
diff changeset
   344
    }
515e4b33b335 6943289: Project Coin: Improved Exception Handling for Java (aka 'multicatch')
mcimadamore
parents: 4877
diff changeset
   345
14725
65836e833f59 8002099: Add support for intersection types in cast expression
mcimadamore
parents: 11142
diff changeset
   346
    public void visitTypeIntersection(JCTypeIntersection tree) {
65836e833f59 8002099: Add support for intersection types in cast expression
mcimadamore
parents: 11142
diff changeset
   347
        scan(tree.bounds);
65836e833f59 8002099: Add support for intersection types in cast expression
mcimadamore
parents: 11142
diff changeset
   348
    }
65836e833f59 8002099: Add support for intersection types in cast expression
mcimadamore
parents: 11142
diff changeset
   349
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   350
    public void visitTypeParameter(JCTypeParameter tree) {
15385
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14725
diff changeset
   351
        scan(tree.annotations);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   352
        scan(tree.bounds);
06bc494ca11e Initial load
duke
parents:
diff changeset
   353
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   354
06bc494ca11e Initial load
duke
parents:
diff changeset
   355
    @Override
06bc494ca11e Initial load
duke
parents:
diff changeset
   356
    public void visitWildcard(JCWildcard tree) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   357
        scan(tree.kind);
06bc494ca11e Initial load
duke
parents:
diff changeset
   358
        if (tree.inner != null)
06bc494ca11e Initial load
duke
parents:
diff changeset
   359
            scan(tree.inner);
06bc494ca11e Initial load
duke
parents:
diff changeset
   360
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   361
06bc494ca11e Initial load
duke
parents:
diff changeset
   362
    @Override
06bc494ca11e Initial load
duke
parents:
diff changeset
   363
    public void visitTypeBoundKind(TypeBoundKind that) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   364
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   365
06bc494ca11e Initial load
duke
parents:
diff changeset
   366
    public void visitModifiers(JCModifiers tree) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   367
        scan(tree.annotations);
06bc494ca11e Initial load
duke
parents:
diff changeset
   368
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   369
06bc494ca11e Initial load
duke
parents:
diff changeset
   370
    public void visitAnnotation(JCAnnotation tree) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   371
        scan(tree.annotationType);
06bc494ca11e Initial load
duke
parents:
diff changeset
   372
        scan(tree.args);
06bc494ca11e Initial load
duke
parents:
diff changeset
   373
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   374
15385
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14725
diff changeset
   375
    public void visitAnnotatedType(JCAnnotatedType tree) {
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14725
diff changeset
   376
        scan(tree.annotations);
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14725
diff changeset
   377
        scan(tree.underlyingType);
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14725
diff changeset
   378
    }
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14725
diff changeset
   379
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   380
    public void visitErroneous(JCErroneous tree) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   381
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   382
06bc494ca11e Initial load
duke
parents:
diff changeset
   383
    public void visitLetExpr(LetExpr tree) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   384
        scan(tree.defs);
06bc494ca11e Initial load
duke
parents:
diff changeset
   385
        scan(tree.expr);
06bc494ca11e Initial load
duke
parents:
diff changeset
   386
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   387
06bc494ca11e Initial load
duke
parents:
diff changeset
   388
    public void visitTree(JCTree tree) {
8032
e1aa25ccdabb 6396503: javac should not require assertions enabled
jjg
parents: 8031
diff changeset
   389
        Assert.error();
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   390
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   391
}