aravagarwal/CodeCloakPII
0
1================================================================================2local variable3================================================================================4 5class A {6 public int b() {7 int c = 5;8 }9}10 11--------------------------------------------------------------------------------12 13(program14 (class_declaration15 name: (identifier)16 body: (class_body17 (method_declaration18 (modifiers)19 type: (integral_type)20 name: (identifier)21 parameters: (formal_parameters)22 body: (block23 (local_variable_declaration24 type: (integral_type)25 declarator: (variable_declarator26 name: (identifier)27 value: (decimal_integer_literal))))))))28 29================================================================================30local array variable31================================================================================32 33String[] nodeNames = internalCluster().getNodeNames();34Integer[][] inputArrays = new Integer[0x100][];35 36--------------------------------------------------------------------------------37 38(program39 (local_variable_declaration40 type: (array_type41 element: (type_identifier)42 dimensions: (dimensions))43 declarator: (variable_declarator44 name: (identifier)45 value: (method_invocation46 object: (method_invocation47 name: (identifier)48 arguments: (argument_list))49 name: (identifier)50 arguments: (argument_list))))51 (local_variable_declaration52 type: (array_type53 element: (type_identifier)54 dimensions: (dimensions))55 declarator: (variable_declarator56 name: (identifier)57 value: (array_creation_expression58 type: (type_identifier)59 dimensions: (dimensions_expr60 (hex_integer_literal))61 dimensions: (dimensions)))))62 63================================================================================64module65================================================================================66 67module com.foo { }68open module com.foo { }69 70--------------------------------------------------------------------------------71 72(program73 (module_declaration74 name: (scoped_identifier75 scope: (identifier)76 name: (identifier))77 body: (module_body))78 (module_declaration79 name: (scoped_identifier80 scope: (identifier)81 name: (identifier))82 body: (module_body)))83 84================================================================================85module with normal annotation86================================================================================87 88@RequestForEnhancement(89 id = 2868724,90 synopsis = "Provide time-travel functionality",91 engineer = "Mr. Peabody",92 date = "4/1/2004"93)94module com.foo { }95 96--------------------------------------------------------------------------------97 98(program99 (module_declaration100 (annotation101 (identifier)102 (annotation_argument_list103 (element_value_pair104 (identifier)105 (decimal_integer_literal))106 (element_value_pair107 (identifier)108 (string_literal109 (string_fragment)))110 (element_value_pair111 (identifier)112 (string_literal113 (string_fragment)))114 (element_value_pair115 (identifier)116 (string_literal117 (string_fragment)))))118 (scoped_identifier119 (identifier)120 (identifier))121 (module_body)))122 123================================================================================124module with marker annotation125================================================================================126 127@Preliminary module com.foo { }128@Preliminary open module com.foo { }129 130--------------------------------------------------------------------------------131 132(program133 (module_declaration134 (marker_annotation135 (identifier))136 (scoped_identifier137 (identifier)138 (identifier))139 (module_body))140 (module_declaration141 (marker_annotation142 (identifier))143 (scoped_identifier144 (identifier)145 (identifier))146 (module_body)))147 148================================================================================149module with single element annotation150================================================================================151 152@Copyright("a")153module com.foo {}154 155--------------------------------------------------------------------------------156 157(program158 (module_declaration159 (annotation160 (identifier)161 (annotation_argument_list162 (string_literal163 (string_fragment))))164 (scoped_identifier165 (identifier)166 (identifier))167 (module_body)))168 169================================================================================170package_declaration171================================================================================172 173package myVector;174 175--------------------------------------------------------------------------------176 177(program178 (package_declaration179 (identifier)))180 181================================================================================182module directive183================================================================================184 185module com.example.foo {186 requires com.example.foo.http;187}188 189--------------------------------------------------------------------------------190 191(program192 (module_declaration193 name: (scoped_identifier194 scope: (scoped_identifier195 scope: (identifier)196 name: (identifier))197 name: (identifier))198 body: (module_body199 (requires_module_directive200 module: (scoped_identifier201 scope: (scoped_identifier202 scope: (scoped_identifier203 scope: (identifier)204 name: (identifier))205 name: (identifier))206 name: (identifier))))))207 208================================================================================209module directive with requires, exports, opens, uses and provides210================================================================================211 212module com.example.foo {213 requires com.example.http;214 requires java.logging;215 216 requires transitive com.example.network;217 218 exports com.example.bar;219 exports com.example.internal to com.example.probe;220 221 opens com.example.quux;222 opens com.example.internal to com.example.network, com.example.probe;223 224 uses com.example.Intf;225 provides com.example.Intf with com.example.Impl;226}227 228--------------------------------------------------------------------------------229 230(program231 (module_declaration232 (scoped_identifier233 (scoped_identifier234 (identifier)235 (identifier))236 (identifier))237 (module_body238 (requires_module_directive239 (scoped_identifier240 (scoped_identifier241 (identifier)242 (identifier))243 (identifier)))244 (requires_module_directive245 (scoped_identifier246 (identifier)247 (identifier)))248 (requires_module_directive249 (requires_modifier)250 (scoped_identifier251 (scoped_identifier252 (identifier)253 (identifier))254 (identifier)))255 (exports_module_directive256 (scoped_identifier257 (scoped_identifier258 (identifier)259 (identifier))260 (identifier)))261 (exports_module_directive262 (scoped_identifier263 (scoped_identifier264 (identifier)265 (identifier))266 (identifier))267 (scoped_identifier268 (scoped_identifier269 (identifier)270 (identifier))271 (identifier)))272 (opens_module_directive273 (scoped_identifier274 (scoped_identifier275 (identifier)276 (identifier))277 (identifier)))278 (opens_module_directive279 (scoped_identifier280 (scoped_identifier281 (identifier)282 (identifier))283 (identifier))284 (scoped_identifier285 (scoped_identifier286 (identifier)287 (identifier))288 (identifier))289 (scoped_identifier290 (scoped_identifier291 (identifier)292 (identifier))293 (identifier)))294 (uses_module_directive295 (scoped_identifier296 (scoped_identifier297 (identifier)298 (identifier))299 (identifier)))300 (provides_module_directive301 (scoped_identifier302 (scoped_identifier303 (identifier)304 (identifier))305 (identifier))306 (scoped_identifier307 (scoped_identifier308 (identifier)309 (identifier))310 (identifier))))))311 312================================================================================313single type import declaration314================================================================================315 316import java.util.Vector;317 318--------------------------------------------------------------------------------319 320(program321 (import_declaration322 (scoped_identifier323 (scoped_identifier324 (identifier)325 (identifier))326 (identifier))))327 328================================================================================329type_import_on_declaraction330================================================================================331 332import java.util.*;333 334--------------------------------------------------------------------------------335 336(program337 (import_declaration338 (scoped_identifier339 (identifier)340 (identifier))341 (asterisk)))342 343================================================================================344single static import declaration345================================================================================346 347import static java.util.Vector;348 349--------------------------------------------------------------------------------350 351(program352 (import_declaration353 (scoped_identifier354 (scoped_identifier355 (identifier)356 (identifier))357 (identifier))))358 359================================================================================360static import on demand declaration361================================================================================362 363import static java.util.*;364 365--------------------------------------------------------------------------------366 367(program368 (import_declaration369 (scoped_identifier370 (identifier)371 (identifier))372 (asterisk)))373 374================================================================================375class declaration376================================================================================377 378class Point {379}380 381--------------------------------------------------------------------------------382 383(program384 (class_declaration385 (identifier)386 (class_body)))387 388================================================================================389class declaration involving public, private, abstract and superclass390================================================================================391 392public class Point {393}394 395private class Point {396}397 398abstract class ColoredPoint extends Point {399}400 401--------------------------------------------------------------------------------402 403(program404 (class_declaration405 (modifiers)406 (identifier)407 (class_body))408 (class_declaration409 (modifiers)410 (identifier)411 (class_body))412 (class_declaration413 (modifiers)414 (identifier)415 (superclass416 (type_identifier))417 (class_body)))418 419================================================================================420class declaration with implements421================================================================================422 423public class Dog implements ISpeak {424}425 426--------------------------------------------------------------------------------427 428(program429 (class_declaration430 (modifiers)431 (identifier)432 (super_interfaces433 (type_list434 (type_identifier)))435 (class_body)))436 437================================================================================438class declaration with body439================================================================================440 441class Point {442 int x;443 444 void bar() {445 x = 2;446 }447}448 449--------------------------------------------------------------------------------450 451(program452 (class_declaration453 (identifier)454 (class_body455 (field_declaration456 (integral_type)457 (variable_declarator458 (identifier)))459 (method_declaration460 (void_type)461 (identifier)462 (formal_parameters)463 (block464 (expression_statement465 (assignment_expression466 (identifier)467 (decimal_integer_literal))))))))468 469================================================================================470interface declaration471================================================================================472 473interface Top {474}475 476--------------------------------------------------------------------------------477 478(program479 (interface_declaration480 (identifier)481 (interface_body)))482 483================================================================================484interface declaration with extends485================================================================================486 487interface Left extends Top {488}489 490interface Bottom extends Left, Right {}491 492--------------------------------------------------------------------------------493 494(program495 (interface_declaration496 (identifier)497 (extends_interfaces498 (type_list499 (type_identifier)))500 (interface_body))501 (interface_declaration502 (identifier)503 (extends_interfaces504 (type_list505 (type_identifier)506 (type_identifier)))507 (interface_body)))508 509================================================================================510interface with annotation type declaration511================================================================================512 513@interface SelfRef {}514 515--------------------------------------------------------------------------------516 517(program518 (annotation_type_declaration519 (identifier)520 (annotation_type_body)))521 522================================================================================523method declaration524================================================================================525 526class Beyonce {527 void calculateAnswer(double wingSpan, int numberOfEngines,528 double length, double grossTons) {529 //do the calculation here530 }531}532 533--------------------------------------------------------------------------------534 535(program536 (class_declaration537 (identifier)538 (class_body539 (method_declaration540 (void_type)541 (identifier)542 (formal_parameters543 (formal_parameter544 (floating_point_type)545 (identifier))546 (formal_parameter547 (integral_type)548 (identifier))549 (formal_parameter550 (floating_point_type)551 (identifier))552 (formal_parameter553 (floating_point_type)554 (identifier)))555 (block556 (line_comment))))))557 558================================================================================559constructor declaration560================================================================================561 562class Point {563 int x, y;564 Point(int x, int y) {565 this.x = x;566 this.y = y;567 }568 569 Point() {570 this(0, 0);571 }572}573 574--------------------------------------------------------------------------------575 576(program577 (class_declaration578 name: (identifier)579 body: (class_body580 (field_declaration581 type: (integral_type)582 declarator: (variable_declarator583 name: (identifier))584 declarator: (variable_declarator585 name: (identifier)))586 (constructor_declaration587 name: (identifier)588 parameters: (formal_parameters589 (formal_parameter590 type: (integral_type)591 name: (identifier))592 (formal_parameter593 type: (integral_type)594 name: (identifier)))595 body: (constructor_body596 (expression_statement597 (assignment_expression598 left: (field_access599 object: (this)600 field: (identifier))601 right: (identifier)))602 (expression_statement603 (assignment_expression604 left: (field_access605 object: (this)606 field: (identifier))607 right: (identifier)))))608 (constructor_declaration609 name: (identifier)610 parameters: (formal_parameters)611 body: (constructor_body612 (explicit_constructor_invocation613 constructor: (this)614 arguments: (argument_list615 (decimal_integer_literal)616 (decimal_integer_literal))))))))617 618================================================================================619Nested field expression in receiver parameter620================================================================================621 622public class Inner1<T> {623 public class Inner2 {624 public class Inner3 {625 public Inner3(GetAnnotatedReceiverType.Inner1<T>.Inner2 GetAnnotatedReceiverType.Inner1.Inner2.this) {}626 }627 }628}629 630--------------------------------------------------------------------------------631 632(program633 (class_declaration634 (modifiers)635 (identifier)636 (type_parameters637 (type_parameter638 (type_identifier)))639 (class_body640 (class_declaration641 (modifiers)642 (identifier)643 (class_body644 (class_declaration645 (modifiers)646 (identifier)647 (class_body648 (constructor_declaration649 (modifiers)650 (identifier)651 (formal_parameters652 (receiver_parameter653 (scoped_type_identifier654 (generic_type655 (scoped_type_identifier656 (type_identifier)657 (type_identifier))658 (type_arguments659 (type_identifier)))660 (type_identifier))661 (identifier)662 (identifier)663 (identifier)664 (this)))665 (constructor_body)))))))))666 667================================================================================668Receiver parameter with additional parameters669================================================================================670 671public class A {672 public B(A this) {}673 674 public C(A this, D that) {}675}676 677---678 679(program680 (class_declaration681 (modifiers)682 (identifier)683 (class_body684 (constructor_declaration685 (modifiers)686 (identifier)687 (formal_parameters688 (receiver_parameter (type_identifier) (this)))689 (constructor_body))690 (constructor_declaration691 (modifiers)692 (identifier)693 (formal_parameters694 (receiver_parameter (type_identifier) (this))695 (formal_parameter (type_identifier) (identifier)))696 (constructor_body)))))697 698================================================================================699throws700================================================================================701 702class Beyonce {703 BufferedReader newReader() throws FileNotFoundException {704 new BufferedReader(new InputStreamReader(new FileInputStream(file), charset));705 }706}707 708--------------------------------------------------------------------------------709 710(program711 (class_declaration712 (identifier)713 (class_body714 (method_declaration715 (type_identifier)716 (identifier)717 (formal_parameters)718 (throws719 (type_identifier))720 (block721 (expression_statement722 (object_creation_expression723 (type_identifier)724 (argument_list725 (object_creation_expression726 (type_identifier)727 (argument_list728 (object_creation_expression729 (type_identifier)730 (argument_list731 (identifier)))732 (identifier)))))))))))733 734================================================================================735object instantiation736================================================================================737 738class Point {739 public double Foo() {740 new BufferedWriter();741 Foo.new BufferedWriter();742 }743}744 745--------------------------------------------------------------------------------746 747(program748 (class_declaration749 (identifier)750 (class_body751 (method_declaration752 (modifiers)753 (floating_point_type)754 (identifier)755 (formal_parameters)756 (block757 (expression_statement758 (object_creation_expression759 (type_identifier)760 (argument_list)))761 (expression_statement762 (object_creation_expression763 (identifier)764 (type_identifier)765 (argument_list))))))))766 767================================================================================768variable declaration769================================================================================770 771class JayZ {772 public void Beyonce() {773 int blue_ivy_carter;774 };775}776 777--------------------------------------------------------------------------------778 779(program780 (class_declaration781 (identifier)782 (class_body783 (method_declaration784 (modifiers)785 (void_type)786 (identifier)787 (formal_parameters)788 (block789 (local_variable_declaration790 (integral_type)791 (variable_declarator792 (identifier))))))))793 794================================================================================795enum declaration796================================================================================797 798enum HandSign {799 SCISSOR, PAPER, STONE800}801 802--------------------------------------------------------------------------------803 804(program805 (enum_declaration806 name: (identifier)807 body: (enum_body808 (enum_constant809 name: (identifier))810 (enum_constant811 name: (identifier))812 (enum_constant813 name: (identifier)))))814 815================================================================================816enum declaration inside an interface817================================================================================818 819public @interface Foo {820 enum HandSign {821 SCISSOR, PAPER, STONE822 }823}824 825--------------------------------------------------------------------------------826 827(program828 (annotation_type_declaration829 (modifiers)830 name: (identifier)831 body: (annotation_type_body832 (enum_declaration833 name: (identifier)834 body: (enum_body835 (enum_constant836 name: (identifier))837 (enum_constant838 name: (identifier))839 (enum_constant840 name: (identifier)))))))841 842================================================================================843record declaration844================================================================================845 846public record Foo(int bar) {847}848 849--------------------------------------------------------------------------------850 851(program852 (record_declaration853 (modifiers)854 name: (identifier)855 parameters: (formal_parameters856 (formal_parameter857 type: (integral_type)858 name: (identifier)))859 body: (class_body)))860 861================================================================================862record declaration with generics863================================================================================864 865public record Foo<T>(T bar) {866}867 868--------------------------------------------------------------------------------869 870(program871 (record_declaration872 (modifiers)873 name: (identifier)874 type_parameters: (type_parameters875 (type_parameter876 (type_identifier)))877 parameters: (formal_parameters878 (formal_parameter879 type: (type_identifier)880 name: (identifier)))881 body: (class_body)))882 883================================================================================884record declaration inside a class885================================================================================886 887public class Usecase {888 public static record Commande(@NotNull String param) {889 public Commande foo() {890 return new Commande("");891 }892 }893}894 895--------------------------------------------------------------------------------896 897(program898 (class_declaration899 (modifiers)900 name: (identifier)901 body: (class_body902 (record_declaration903 (modifiers)904 name: (identifier)905 parameters: (formal_parameters906 (formal_parameter907 (modifiers908 (marker_annotation909 name: (identifier)))910 type: (type_identifier)911 name: (identifier)))912 body: (class_body913 (method_declaration914 (modifiers)915 type: (type_identifier)916 name: (identifier)917 parameters: (formal_parameters)918 body: (block919 (return_statement920 (object_creation_expression921 type: (type_identifier)922 arguments: (argument_list923 (string_literal)))))))))))924 925================================================================================926record declaration inside an interface927================================================================================928 929interface I { record R(int a) {} }930 931--------------------------------------------------------------------------------932 933(program934 (interface_declaration935 (identifier)936 (interface_body937 (record_declaration938 (identifier)939 (formal_parameters940 (formal_parameter941 (integral_type)942 (identifier)))943 (class_body)))))944 945================================================================================946record declaration with compact constructor947================================================================================948 949record Person(int age) {950 public Person {951 if (age < 0) throw new IllegalArgumentException("invalid age");952 }953}954 955--------------------------------------------------------------------------------956 957(program958 (record_declaration959 (identifier)960 (formal_parameters961 (formal_parameter962 (integral_type)963 (identifier)))964 (class_body965 (compact_constructor_declaration966 (modifiers)967 (identifier)968 (block969 (if_statement970 (condition971 (binary_expression972 (identifier)973 (decimal_integer_literal)))974 (throw_statement975 (object_creation_expression976 (type_identifier)977 (argument_list978 (string_literal979 (string_fragment)))))))))))980 981================================================================================982record declaration that implements interface983================================================================================984 985record R() implements I {}986 987--------------------------------------------------------------------------------988 989(program990 (record_declaration991 (identifier)992 (formal_parameters)993 (super_interfaces994 (type_list995 (type_identifier)))996 (class_body)))997 998================================================================================999class declaration with dollar-sign identifiers1000================================================================================1001 1002class A$B {1003 void func() {1004 $object.$property;1005 $hello();1006 }1007}1008 1009--------------------------------------------------------------------------------1010 1011(program1012 (class_declaration1013 (identifier)1014 (class_body1015 (method_declaration1016 (void_type)1017 (identifier)1018 (formal_parameters)1019 (block1020 (expression_statement1021 (field_access1022 (identifier)1023 (identifier)))1024 (expression_statement1025 (method_invocation1026 (identifier)1027 (argument_list))))))))1028 1029================================================================================1030 Sealed classes1031================================================================================1032 1033sealed interface A permits B, C {1034 1035}1036 1037final class B implements A {}1038non-sealed interface C extends A {}1039 1040--------------------------------------------------------------------------------1041 1042(program1043 (interface_declaration1044 (modifiers)1045 (identifier)1046 (permits1047 (type_list1048 (type_identifier)1049 (type_identifier)))1050 (interface_body))1051 (class_declaration1052 (modifiers)1053 (identifier)1054 (super_interfaces1055 (type_list1056 (type_identifier)))1057 (class_body))1058 (interface_declaration1059 (modifiers)1060 (identifier)1061 (extends_interfaces1062 (type_list1063 (type_identifier)))1064 (interface_body)))1065 1066================================================================================1067Reserved identifiers1068================================================================================1069 1070public @interface Reserved {1071 String module();1072}1073 1074public class Keywords {1075 public void demo() {1076 int sealed = 0;1077 bool yield = false;1078 }1079}1080 1081--------------------------------------------------------------------------------1082 1083(program1084 (annotation_type_declaration1085 (modifiers)1086 (identifier)1087 (annotation_type_body1088 (annotation_type_element_declaration1089 (type_identifier)1090 (identifier))))1091 (class_declaration1092 (modifiers)1093 (identifier)1094 (class_body1095 (method_declaration1096 (modifiers)1097 (void_type)1098 (identifier)1099 (formal_parameters)1100 (block1101 (local_variable_declaration1102 (integral_type)1103 (variable_declarator1104 (identifier)1105 (decimal_integer_literal)))1106 (local_variable_declaration1107 (type_identifier)1108 (variable_declarator1109 (identifier)1110 (false))))))))1111 1112================================================================================1113Annontations1114================================================================================1115 1116public class Anno {1117 public void anno() {1118 this.ABCâ = new @Anno Point();1119 }1120}1121 1122--------------------------------------------------------------------------------1123 1124(program1125 (class_declaration1126 (modifiers)1127 (identifier)1128 (class_body1129 (method_declaration1130 (modifiers)1131 (void_type)1132 (identifier)1133 (formal_parameters)1134 (block1135 (expression_statement1136 (assignment_expression1137 (field_access1138 (this)1139 (identifier))1140 (object_creation_expression1141 (marker_annotation1142 (identifier))1143 (type_identifier)1144 (argument_list)))))))))1145 1146================================================================================1147unnamed class1148================================================================================1149 1150void main() {1151}1152 1153--------------------------------------------------------------------------------1154 1155(program1156 (method_declaration1157 (void_type)1158 (identifier)1159 (formal_parameters)1160 (block)))1161 1162================================================================================1163Annotation following type arguments1164================================================================================1165 1166public class A {1167 public B() {1168 return new <@BG Inner> @BH Inner<@BI Inner>(null);1169 }1170}1171 1172---1173 1174(program1175 (class_declaration1176 (modifiers)1177 (identifier)1178 (class_body1179 (constructor_declaration1180 (modifiers)1181 (identifier)1182 (formal_parameters)1183 (constructor_body1184 (return_statement1185 (object_creation_expression1186 (type_arguments1187 (annotated_type1188 (marker_annotation (identifier))1189 (type_identifier)))1190 (marker_annotation (identifier))1191 (generic_type1192 (type_identifier)1193 (type_arguments1194 (annotated_type1195 (marker_annotation (identifier))1196 (type_identifier))))1197 (argument_list1198 (null_literal)))))))))1199 