@@ -930,14 +930,7 @@ public void test_visit_AnonymousClassDeclaration_withInvocation_doVisit(String r
930930 @ Test
931931 public void test_findLastAssignment_variable () throws Exception {
932932 String code = "void root() {int value = 0; System.out.println(value);}" ;
933- check_findLastAssignment (code , 1 , new I_findLastAssignment () {
934- @ Override
935- public ASTNode getExpected (TypeDeclaration typeDeclaration ,
936- MethodDeclaration methodDeclaration ,
937- Statement [] statements ) {
938- return (ASTNode ) ((VariableDeclarationStatement ) statements [0 ]).fragments ().get (0 );
939- }
940- });
933+ check_findLastAssignment (code , 1 , (typeDeclaration , methodDeclaration , statements ) -> (ASTNode ) ((VariableDeclarationStatement ) statements [0 ]).fragments ().get (0 ));
941934 }
942935
943936 /**
@@ -1001,68 +994,33 @@ void root() {
1001994 @ Test
1002995 public void test_findLastAssignment_variable_reassign () throws Exception {
1003996 String code = "void root() {int value = 0; value = 1; System.out.println(value);}" ;
1004- check_findLastAssignment (code , 2 , new I_findLastAssignment () {
1005- @ Override
1006- public ASTNode getExpected (TypeDeclaration typeDeclaration ,
1007- MethodDeclaration methodDeclaration ,
1008- Statement [] statements ) {
1009- return ((ExpressionStatement ) statements [1 ]).getExpression ();
1010- }
1011- });
997+ check_findLastAssignment (code , 2 , (typeDeclaration , methodDeclaration , statements ) -> ((ExpressionStatement ) statements [1 ]).getExpression ());
1012998 }
1013999
10141000 @ Test
10151001 public void test_findLastAssignment_variable_reassign2 () throws Exception {
10161002 String code =
10171003 "void root() {int value; value = 0; System.out.println(value); value = 1; System.out.println(value);}" ;
1018- check_findLastAssignment (code , 4 , new I_findLastAssignment () {
1019- @ Override
1020- public ASTNode getExpected (TypeDeclaration typeDeclaration ,
1021- MethodDeclaration methodDeclaration ,
1022- Statement [] statements ) {
1023- return ((ExpressionStatement ) statements [3 ]).getExpression ();
1024- }
1025- });
1004+ check_findLastAssignment (code , 4 , (typeDeclaration , methodDeclaration , statements ) -> ((ExpressionStatement ) statements [3 ]).getExpression ());
10261005 }
10271006
10281007 @ Test
10291008 public void test_findLastAssignment_variable_reassign_later () throws Exception {
10301009 String code = "void root() {int value = 0; System.out.println(value); value = 1;}" ;
1031- check_findLastAssignment (code , 1 , new I_findLastAssignment () {
1032- @ Override
1033- public ASTNode getExpected (TypeDeclaration typeDeclaration ,
1034- MethodDeclaration methodDeclaration ,
1035- Statement [] statements ) {
1036- return (ASTNode ) ((VariableDeclarationStatement ) statements [0 ]).fragments ().get (0 );
1037- }
1038- });
1010+ check_findLastAssignment (code , 1 , (typeDeclaration , methodDeclaration , statements ) -> (ASTNode ) ((VariableDeclarationStatement ) statements [0 ]).fragments ().get (0 ));
10391011 }
10401012
10411013 @ Test
10421014 public void test_findLastAssignment_variable_sameInDifferentMethod () throws Exception {
10431015 String code =
10441016 "void root() {int value = 0; foo(); System.out.println(value);} void foo() {int value = 1;}" ;
1045- check_findLastAssignment (code , 2 , new I_findLastAssignment () {
1046- @ Override
1047- public ASTNode getExpected (TypeDeclaration typeDeclaration ,
1048- MethodDeclaration methodDeclaration ,
1049- Statement [] statements ) {
1050- return (ASTNode ) ((VariableDeclarationStatement ) statements [0 ]).fragments ().get (0 );
1051- }
1052- });
1017+ check_findLastAssignment (code , 2 , (typeDeclaration , methodDeclaration , statements ) -> (ASTNode ) ((VariableDeclarationStatement ) statements [0 ]).fragments ().get (0 ));
10531018 }
10541019
10551020 @ Test
10561021 public void test_findLastAssignment_FieldDeclaration () throws Exception {
10571022 String code = "int value = 0; void root() {System.out.println(value);}" ;
1058- check_findLastAssignment (code , 0 , new I_findLastAssignment () {
1059- @ Override
1060- public ASTNode getExpected (TypeDeclaration typeDeclaration ,
1061- MethodDeclaration methodDeclaration ,
1062- Statement [] statements ) {
1063- return (ASTNode ) typeDeclaration .getFields ()[0 ].fragments ().get (0 );
1064- }
1065- });
1023+ check_findLastAssignment (code , 0 , (typeDeclaration , methodDeclaration , statements ) -> (ASTNode ) typeDeclaration .getFields ()[0 ].fragments ().get (0 ));
10661024 }
10671025
10681026 /**
@@ -1181,98 +1139,50 @@ public void test_findLastAssignment_FieldDeclaration_noValue() throws Exception
11811139 @ Test
11821140 public void test_findLastAssignment_FieldDeclaration_variable_thisMethod () throws Exception {
11831141 String code = "int value = 0; void root() {int value = 1; System.out.println(value);}" ;
1184- check_findLastAssignment (code , 1 , new I_findLastAssignment () {
1185- @ Override
1186- public ASTNode getExpected (TypeDeclaration typeDeclaration ,
1187- MethodDeclaration methodDeclaration ,
1188- Statement [] statements ) {
1189- return (ASTNode ) ((VariableDeclarationStatement ) statements [0 ]).fragments ().get (0 );
1190- }
1191- });
1142+ check_findLastAssignment (code , 1 , (typeDeclaration , methodDeclaration , statements ) -> (ASTNode ) ((VariableDeclarationStatement ) statements [0 ]).fragments ().get (0 ));
11921143 }
11931144
11941145 @ Test
11951146 public void test_findLastAssignment_FieldDeclaration_reassign_thisMethod () throws Exception {
11961147 String code = "int value = 0; void root() {value = 1; System.out.println(value);}" ;
1197- check_findLastAssignment (code , 1 , new I_findLastAssignment () {
1198- @ Override
1199- public ASTNode getExpected (TypeDeclaration typeDeclaration ,
1200- MethodDeclaration methodDeclaration ,
1201- Statement [] statements ) {
1202- return ((ExpressionStatement ) statements [0 ]).getExpression ();
1203- }
1204- });
1148+ check_findLastAssignment (code , 1 , (typeDeclaration , methodDeclaration , statements ) -> ((ExpressionStatement ) statements [0 ]).getExpression ());
12051149 }
12061150
12071151 @ Test
12081152 public void test_findLastAssignment_FieldDeclaration_reassign_otherMethod () throws Exception {
12091153 String code =
12101154 "int value = 0; void root() {foo(); System.out.println(value);} void foo() {value = 1;}" ;
1211- check_findLastAssignment (code , 1 , new I_findLastAssignment () {
1212- @ Override
1213- public ASTNode getExpected (TypeDeclaration typeDeclaration ,
1214- MethodDeclaration methodDeclaration ,
1215- Statement [] statements ) {
1216- Statement statement =
1217- (Statement ) typeDeclaration .getMethods ()[1 ].getBody ().statements ().get (0 );
1218- return ((ExpressionStatement ) statement ).getExpression ();
1219- }
1155+ check_findLastAssignment (code , 1 , (typeDeclaration , methodDeclaration , statements ) -> {
1156+ Statement statement = (Statement ) typeDeclaration .getMethods ()[1 ].getBody ().statements ().get (0 );
1157+ return ((ExpressionStatement ) statement ).getExpression ();
12201158 });
12211159 }
12221160
12231161 @ Test
12241162 public void test_findLastAssignment_FieldDeclaration_reassign_otherMethod2 () throws Exception {
12251163 String code =
12261164 "int value = 0; void root() {System.out.println(value); foo();} void foo() {value = 1;}" ;
1227- check_findLastAssignment (code , 0 , new I_findLastAssignment () {
1228- @ Override
1229- public ASTNode getExpected (TypeDeclaration typeDeclaration ,
1230- MethodDeclaration methodDeclaration ,
1231- Statement [] statements ) {
1232- return (ASTNode ) typeDeclaration .getFields ()[0 ].fragments ().get (0 );
1233- }
1234- });
1165+ check_findLastAssignment (code , 0 , (typeDeclaration , methodDeclaration , statements ) -> (ASTNode ) typeDeclaration .getFields ()[0 ].fragments ().get (0 ));
12351166 }
12361167
12371168 @ Test
12381169 public void test_findLastAssignment_FieldDeclaration_reassign_otherMethod3 () throws Exception {
12391170 String code =
12401171 "int value = 0; void foo() {value = 1;} void root() {System.out.println(value); foo();}" ;
1241- check_findLastAssignment (code , 0 , new I_findLastAssignment () {
1242- @ Override
1243- public ASTNode getExpected (TypeDeclaration typeDeclaration ,
1244- MethodDeclaration methodDeclaration ,
1245- Statement [] statements ) {
1246- return (ASTNode ) typeDeclaration .getFields ()[0 ].fragments ().get (0 );
1247- }
1248- });
1172+ check_findLastAssignment (code , 0 , (typeDeclaration , methodDeclaration , statements ) -> (ASTNode ) typeDeclaration .getFields ()[0 ].fragments ().get (0 ));
12491173 }
12501174
12511175 @ Test
12521176 public void test_findLastAssignment_FieldDeclaration_reassign_otherMethod4 () throws Exception {
12531177 String code =
12541178 "int value = 0; void root() {foo(); System.out.println(value);} void foo() {int value = 1;}" ;
1255- check_findLastAssignment (code , 1 , new I_findLastAssignment () {
1256- @ Override
1257- public ASTNode getExpected (TypeDeclaration typeDeclaration ,
1258- MethodDeclaration methodDeclaration ,
1259- Statement [] statements ) {
1260- return (ASTNode ) typeDeclaration .getFields ()[0 ].fragments ().get (0 );
1261- }
1262- });
1179+ check_findLastAssignment (code , 1 , (typeDeclaration , methodDeclaration , statements ) -> (ASTNode ) typeDeclaration .getFields ()[0 ].fragments ().get (0 ));
12631180 }
12641181
12651182 @ Test
12661183 public void test_findLastAssignment_parameters () throws Exception {
12671184 String code = "void root(int value) {System.out.println(value);}" ;
1268- check_findLastAssignment (code , "root(int)" , 0 , new I_findLastAssignment () {
1269- @ Override
1270- public ASTNode getExpected (TypeDeclaration typeDeclaration ,
1271- MethodDeclaration methodDeclaration ,
1272- Statement [] statements ) {
1273- return (ASTNode ) methodDeclaration .parameters ().get (0 );
1274- }
1275- });
1185+ check_findLastAssignment (code , "root(int)" , 0 , (typeDeclaration , methodDeclaration , statements ) -> (ASTNode ) methodDeclaration .parameters ().get (0 ));
12761186 }
12771187
12781188 @ Test
@@ -1320,14 +1230,7 @@ public void foo(int value) {
13201230 @ Test
13211231 public void test_findLastAssignment_parameters_hide_field () throws Exception {
13221232 String code = "int value = 1; void root(int value) {System.out.println(value);}" ;
1323- check_findLastAssignment (code , "root(int)" , 0 , new I_findLastAssignment () {
1324- @ Override
1325- public ASTNode getExpected (TypeDeclaration typeDeclaration ,
1326- MethodDeclaration methodDeclaration ,
1327- Statement [] statements ) {
1328- return (ASTNode ) methodDeclaration .parameters ().get (0 );
1329- }
1330- });
1233+ check_findLastAssignment (code , "root(int)" , 0 , (typeDeclaration , methodDeclaration , statements ) -> (ASTNode ) methodDeclaration .parameters ().get (0 ));
13311234 }
13321235
13331236 /**
0 commit comments