45 |
45 |
46 import static com.sun.tools.javac.tree.JCTree.Tag.*; |
46 import static com.sun.tools.javac.tree.JCTree.Tag.*; |
47 |
47 |
48 import javax.tools.JavaFileManager.Location; |
48 import javax.tools.JavaFileManager.Location; |
49 |
49 |
50 import com.sun.source.tree.CaseTree.CaseKind; |
|
51 import com.sun.source.tree.ModuleTree.ModuleKind; |
50 import com.sun.source.tree.ModuleTree.ModuleKind; |
52 import com.sun.tools.javac.code.Directive.ExportsDirective; |
51 import com.sun.tools.javac.code.Directive.ExportsDirective; |
53 import com.sun.tools.javac.code.Directive.OpensDirective; |
52 import com.sun.tools.javac.code.Directive.OpensDirective; |
54 import com.sun.tools.javac.code.Type.ModuleType; |
53 import com.sun.tools.javac.code.Type.ModuleType; |
55 import com.sun.tools.javac.tree.JCTree.JCPolyExpression.PolyKind; |
54 import com.sun.tools.javac.tree.JCTree.JCPolyExpression.PolyKind; |
1248 * A "case :" of a switch. |
1247 * A "case :" of a switch. |
1249 */ |
1248 */ |
1250 public static class JCCase extends JCStatement implements CaseTree { |
1249 public static class JCCase extends JCStatement implements CaseTree { |
1251 //as CaseKind is deprecated for removal (as it is part of a preview feature), |
1250 //as CaseKind is deprecated for removal (as it is part of a preview feature), |
1252 //using indirection through these fields to avoid unnecessary @SuppressWarnings: |
1251 //using indirection through these fields to avoid unnecessary @SuppressWarnings: |
1253 @SuppressWarnings("removal") |
1252 @SuppressWarnings("preview") |
1254 public static final CaseKind STATEMENT = CaseKind.STATEMENT; |
1253 public static final CaseKind STATEMENT = CaseKind.STATEMENT; |
1255 @SuppressWarnings("removal") |
1254 @SuppressWarnings("preview") |
1256 public static final CaseKind RULE = CaseKind.RULE; |
1255 public static final CaseKind RULE = CaseKind.RULE; |
1257 @SuppressWarnings("removal") |
1256 @SuppressWarnings("preview") |
1258 public final CaseKind caseKind; |
1257 public final CaseKind caseKind; |
1259 public List<JCExpression> pats; |
1258 public List<JCExpression> pats; |
1260 public List<JCStatement> stats; |
1259 public List<JCStatement> stats; |
1261 public JCTree body; |
1260 public JCTree body; |
1262 public boolean completesNormally; |
1261 public boolean completesNormally; |
1263 protected JCCase(@SuppressWarnings("removal") CaseKind caseKind, List<JCExpression> pats, |
1262 protected JCCase(@SuppressWarnings("preview") CaseKind caseKind, List<JCExpression> pats, |
1264 List<JCStatement> stats, JCTree body) { |
1263 List<JCStatement> stats, JCTree body) { |
1265 Assert.checkNonNull(pats); |
1264 Assert.checkNonNull(pats); |
1266 Assert.check(pats.isEmpty() || pats.head != null); |
1265 Assert.check(pats.isEmpty() || pats.head != null); |
1267 this.caseKind = caseKind; |
1266 this.caseKind = caseKind; |
1268 this.pats = pats; |
1267 this.pats = pats; |
1275 @Override @DefinedBy(Api.COMPILER_TREE) |
1274 @Override @DefinedBy(Api.COMPILER_TREE) |
1276 public Kind getKind() { return Kind.CASE; } |
1275 public Kind getKind() { return Kind.CASE; } |
1277 @Override @DefinedBy(Api.COMPILER_TREE) |
1276 @Override @DefinedBy(Api.COMPILER_TREE) |
1278 public JCExpression getExpression() { return pats.head; } |
1277 public JCExpression getExpression() { return pats.head; } |
1279 @Override @DefinedBy(Api.COMPILER_TREE) |
1278 @Override @DefinedBy(Api.COMPILER_TREE) |
1280 @SuppressWarnings("removal") |
1279 @SuppressWarnings("preview") |
1281 public List<JCExpression> getExpressions() { return pats; } |
1280 public List<JCExpression> getExpressions() { return pats; } |
1282 @Override @DefinedBy(Api.COMPILER_TREE) |
1281 @Override @DefinedBy(Api.COMPILER_TREE) |
1283 @SuppressWarnings("removal") |
1282 @SuppressWarnings("preview") |
1284 public List<JCStatement> getStatements() { |
1283 public List<JCStatement> getStatements() { |
1285 return caseKind == CaseKind.STATEMENT ? stats : null; |
1284 return caseKind == CaseKind.STATEMENT ? stats : null; |
1286 } |
1285 } |
1287 @Override @DefinedBy(Api.COMPILER_TREE) |
1286 @Override @DefinedBy(Api.COMPILER_TREE) |
1288 @SuppressWarnings("removal") |
1287 @SuppressWarnings("preview") |
1289 public JCTree getBody() { return body; } |
1288 public JCTree getBody() { return body; } |
1290 @Override @DefinedBy(Api.COMPILER_TREE) |
1289 @Override @DefinedBy(Api.COMPILER_TREE) |
1291 @SuppressWarnings("removal") |
1290 @SuppressWarnings("preview") |
1292 public CaseKind getCaseKind() { |
1291 public CaseKind getCaseKind() { |
1293 return caseKind; |
1292 return caseKind; |
1294 } |
1293 } |
1295 @Override @DefinedBy(Api.COMPILER_TREE) |
1294 @Override @DefinedBy(Api.COMPILER_TREE) |
1296 public <R,D> R accept(TreeVisitor<R,D> v, D d) { |
1295 public <R,D> R accept(TreeVisitor<R,D> v, D d) { |
1303 } |
1302 } |
1304 |
1303 |
1305 /** |
1304 /** |
1306 * A "switch ( ) { }" construction. |
1305 * A "switch ( ) { }" construction. |
1307 */ |
1306 */ |
1308 @SuppressWarnings("removal") |
1307 @SuppressWarnings("preview") |
1309 public static class JCSwitchExpression extends JCPolyExpression implements SwitchExpressionTree { |
1308 public static class JCSwitchExpression extends JCPolyExpression implements SwitchExpressionTree { |
1310 public JCExpression selector; |
1309 public JCExpression selector; |
1311 public List<JCCase> cases; |
1310 public List<JCCase> cases; |
1312 /** Position of closing brace, optional. */ |
1311 /** Position of closing brace, optional. */ |
1313 public int endpos = Position.NOPOS; |
1312 public int endpos = Position.NOPOS; |
1584 } |
1583 } |
1585 |
1584 |
1586 /** |
1585 /** |
1587 * A break-with from a switch expression. |
1586 * A break-with from a switch expression. |
1588 */ |
1587 */ |
1589 @SuppressWarnings("removal") |
1588 @SuppressWarnings("preview") |
1590 public static class JCYield extends JCStatement implements YieldTree { |
1589 public static class JCYield extends JCStatement implements YieldTree { |
1591 public JCExpression value; |
1590 public JCExpression value; |
1592 public JCTree target; |
1591 public JCTree target; |
1593 protected JCYield(JCExpression value, JCTree target) { |
1592 protected JCYield(JCExpression value, JCTree target) { |
1594 this.value = value; |
1593 this.value = value; |
3103 JCStatement body); |
3102 JCStatement body); |
3104 JCEnhancedForLoop ForeachLoop(JCVariableDecl var, JCExpression expr, JCStatement body); |
3103 JCEnhancedForLoop ForeachLoop(JCVariableDecl var, JCExpression expr, JCStatement body); |
3105 JCLabeledStatement Labelled(Name label, JCStatement body); |
3104 JCLabeledStatement Labelled(Name label, JCStatement body); |
3106 JCSwitch Switch(JCExpression selector, List<JCCase> cases); |
3105 JCSwitch Switch(JCExpression selector, List<JCCase> cases); |
3107 JCSwitchExpression SwitchExpression(JCExpression selector, List<JCCase> cases); |
3106 JCSwitchExpression SwitchExpression(JCExpression selector, List<JCCase> cases); |
3108 JCCase Case(@SuppressWarnings("removal") CaseKind caseKind, List<JCExpression> pat, |
3107 JCCase Case(@SuppressWarnings("preview") CaseTree.CaseKind caseKind, List<JCExpression> pat, |
3109 List<JCStatement> stats, JCTree body); |
3108 List<JCStatement> stats, JCTree body); |
3110 JCSynchronized Synchronized(JCExpression lock, JCBlock body); |
3109 JCSynchronized Synchronized(JCExpression lock, JCBlock body); |
3111 JCTry Try(JCBlock body, List<JCCatch> catchers, JCBlock finalizer); |
3110 JCTry Try(JCBlock body, List<JCCatch> catchers, JCBlock finalizer); |
3112 JCTry Try(List<JCTree> resources, |
3111 JCTry Try(List<JCTree> resources, |
3113 JCBlock body, |
3112 JCBlock body, |