Skip to content

Commit bcb3ca8

Browse files
authored
Java LoC metric (#694)
* WIP of Java LoC metric * Enables 2 passing simple tests * Adds more individual loc tests * Initial impl of JavaCode Getter trait get_space_kind was needed to fix an off by one issue with ploc * Test cleanup * Fix test * Fixes handling of for loops * Adds while * Remove println * Ran fmt * Reduce to handle only SLOC off by 1 * Adds ternary lloc to test * Adds expression grammar lloc * Removes expressions from count * Do not count expressions in for loop * Removes debugging lines * Fixes for the recent Stats changes * Defines space kinds * Adds interface space
1 parent 08c61f4 commit bcb3ca8

File tree

2 files changed

+418
-2
lines changed

2 files changed

+418
-2
lines changed

src/getter.rs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -509,4 +509,16 @@ impl Getter for CppCode {
509509

510510
impl Getter for PreprocCode {}
511511
impl Getter for CcommentCode {}
512-
impl Getter for JavaCode {}
512+
impl Getter for JavaCode {
513+
fn get_space_kind(node: &Node) -> SpaceKind {
514+
use Java::*;
515+
516+
let typ = node.object().kind_id();
517+
match typ.into() {
518+
InterfaceDeclaration | ClassDeclaration => SpaceKind::Class,
519+
MethodDeclaration | LambdaExpression => SpaceKind::Function,
520+
Program => SpaceKind::Unit,
521+
_ => SpaceKind::Unknown,
522+
}
523+
}
524+
}

0 commit comments

Comments
 (0)