@@ -431,31 +431,36 @@ class BodyScanner extends FilterScanner {
431
431
private Type bodyTarget ;
432
432
private JCTree currentNode ;
433
433
434
- // Only few AST nodes supported for now
435
- private static final Set <JCTree .Tag > SUPPORTED_TAGS =
436
- Set .of (Tag .VARDEF ,
437
- Tag .RETURN , Tag .THROW , Tag .BREAK , Tag .CONTINUE ,
438
- Tag .PLUS , Tag .MINUS , Tag .MUL , Tag .DIV , Tag .MOD ,
439
- Tag .NEG , Tag .NOT ,
440
- Tag .BITOR , Tag .BITAND , Tag .BITXOR ,
441
- Tag .BITOR_ASG , Tag .BITAND_ASG , Tag .BITXOR_ASG ,
442
- Tag .SL , Tag .SR , Tag .USR ,
443
- Tag .SL_ASG , Tag .SR_ASG , Tag .USR_ASG ,
444
- Tag .PLUS_ASG , Tag .MINUS_ASG , Tag .MUL_ASG , Tag .DIV_ASG , Tag .MOD_ASG ,
445
- Tag .POSTINC , Tag .PREINC , Tag .POSTDEC , Tag .PREDEC ,
446
- Tag .EQ , Tag .NE , Tag .LT , Tag .LE , Tag .GT , Tag .GE ,
447
- Tag .AND , Tag .OR ,
448
- Tag .LITERAL , Tag .IDENT , Tag .TYPEIDENT , Tag .ASSIGN , Tag .EXEC , Tag .PARENS ,
449
- Tag .SELECT , Tag .INDEXED , Tag .APPLY ,
450
- Tag .TYPECAST , Tag .TYPETEST ,
451
- Tag .NEWCLASS , Tag .NEWARRAY , Tag .LAMBDA , Tag .REFERENCE ,
452
- Tag .BLOCK , Tag .IF , Tag .WHILELOOP , Tag .DOLOOP , Tag .FOREACHLOOP , Tag .FORLOOP , Tag .TRY ,
453
- Tag .SWITCH_EXPRESSION , Tag .YIELD ,
454
- Tag .CONDEXPR ,
455
- Tag .ASSERT ,
456
- Tag .LABELLED ,
457
- Tag .SKIP ,
458
- Tag .TYPEARRAY );
434
+ // unsupported tree nodes
435
+ private static final EnumSet <JCTree .Tag > UNSUPPORTED_TAGS = EnumSet .of (
436
+ // statements
437
+ Tag .SWITCH , Tag .SYNCHRONIZED ,
438
+ // operators
439
+ Tag .COMPL , Tag .POS ,
440
+
441
+ // the nodes below are not as relevant, either because they have already
442
+ // been handled by an earlier compiler pass, or because they are typically
443
+ // not handled directly, but in the context of some enclosing statement.
444
+
445
+ // modifiers (these are already turned into symbols by Attr and should not be dealt with directly)
446
+ Tag .ANNOTATION , Tag .TYPE_ANNOTATION , Tag .MODIFIERS ,
447
+ // toplevel (likely outside the scope for code models)
448
+ Tag .TOPLEVEL , Tag .PACKAGEDEF , Tag .IMPORT , Tag .CLASSDEF , Tag .METHODDEF ,
449
+ // modules (likely outside the scope for code models)
450
+ Tag .MODULEDEF , Tag .EXPORTS , Tag .OPENS , Tag .PROVIDES , Tag .REQUIRES , Tag .USES ,
451
+ // switch labels (these are handled by the encloising construct, SWITCH or SWITCH_EXPRESSION)
452
+ Tag .CASE , Tag .DEFAULTCASELABEL , Tag .CONSTANTCASELABEL , Tag .PATTERNCASELABEL ,
453
+ // patterns (these are handled by the enclosing construct, like IF, SWITCH_EXPRESSION, TYPETEST)
454
+ Tag .ANYPATTERN , Tag .BINDINGPATTERN , Tag .RECORDPATTERN ,
455
+ // catch (already handled as part of TRY)
456
+ Tag .CATCH ,
457
+ // types (these are used to parse types and should not be dealt with directly)
458
+ Tag .TYPEAPPLY , Tag .TYPEUNION , Tag .TYPEINTERSECTION , Tag .TYPEPARAMETER , Tag .WILDCARD ,
459
+ Tag .TYPEBOUNDKIND , Tag .ANNOTATED_TYPE ,
460
+ // internal (these are synthetic nodes generated by javac)
461
+ Tag .NO_TAG , Tag .ERRONEOUS , Tag .NULLCHK , Tag .LETEXPR );
462
+
463
+ private static final Set <JCTree .Tag > SUPPORTED_TAGS = EnumSet .complementOf (UNSUPPORTED_TAGS );
459
464
460
465
BodyScanner (JCMethodDecl tree ) {
461
466
this (tree , tree .body );
0 commit comments