@@ -430,41 +430,42 @@ impl Loc for CppCode {
430430 }
431431}
432432
433- // impl fmt::Display for Java {
434- // fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
435- // write!(f, "{:?}", self)
436- // }
437- // }
433+ impl fmt:: Display for Java {
434+ fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
435+ write ! ( f, "{:?}" , self )
436+ }
437+ }
438438
439439impl Loc for JavaCode {
440440 fn compute ( node : & Node , stats : & mut Stats , is_func_space : bool , is_unit : bool ) {
441441 use Java :: * ;
442442
443443 let ( start, end) = init ( node, stats, is_func_space, is_unit) ;
444444 let kind_id : Java = node. object ( ) . kind_id ( ) . into ( ) ;
445- // println!("KINDID {}", kind_id.to_string());
445+ println ! ( "KINDID {}" , kind_id. to_string( ) ) ;
446446 match kind_id {
447447 Program => { }
448448 Comment => {
449449 add_cloc_lines ( stats, start, end) ;
450450 }
451451 AssertStatement
452+ | AssignmentExpression
452453 | BreakStatement
453454 | BinaryExpression
454455 | ContinueStatement
455456 | DoStatement
456457 | Declaration
457- | ExpressionStatement
458458 | IfStatement
459459 | LocalVariableDeclaration
460+ | MethodInvocation
460461 | ReturnStatement
461462 | Statement
462463 | SwitchStatement
463464 | TernaryExpression
464465 | ThrowStatement
465466 | TryStatement
466- | UpdateExpression
467- | WhileStatement => {
467+ | UpdateExpression => {
468+ println ! ( " lloc increased by {}" , kind_id . to_string ( ) ) ;
468469 stats. logical_lines += 1 ;
469470 }
470471 For => {
@@ -475,6 +476,7 @@ impl Loc for JavaCode {
475476 {
476477 // handle for(int i:arr)
477478 // otherwise the statements in the for are counted elsewhere
479+ println ! ( " lloc increased by {}" , kind_id. to_string( ) ) ;
478480 stats. logical_lines += 1 ;
479481 }
480482 }
@@ -1380,6 +1382,24 @@ mod tests {
13801382 ) ;
13811383 }
13821384
1385+ #[ test]
1386+ fn java_while_lloc ( ) {
1387+ check_metrics ! (
1388+ "
1389+ int i=0; // +1
1390+ while(i < 10) { // +1
1391+ i++; // +1
1392+ System.out.println(i); // +1
1393+ }" ,
1394+ "foo.java" ,
1395+ JavaParser ,
1396+ loc,
1397+ [
1398+ ( lloc, 4 , usize ) , // The number of statements is 4
1399+ ]
1400+ ) ;
1401+ }
1402+
13831403 #[ test]
13841404 fn java_multi_lloc ( ) {
13851405 check_metrics ! (
0 commit comments