Skip to content

Commit

Permalink
Java LoC metric (#694)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
dburriss authored Mar 23, 2022
1 parent 08c61f4 commit bcb3ca8
Show file tree
Hide file tree
Showing 2 changed files with 418 additions and 2 deletions.
14 changes: 13 additions & 1 deletion src/getter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -509,4 +509,16 @@ impl Getter for CppCode {

impl Getter for PreprocCode {}
impl Getter for CcommentCode {}
impl Getter for JavaCode {}
impl Getter for JavaCode {
fn get_space_kind(node: &Node) -> SpaceKind {
use Java::*;

let typ = node.object().kind_id();
match typ.into() {
InterfaceDeclaration | ClassDeclaration => SpaceKind::Class,
MethodDeclaration | LambdaExpression => SpaceKind::Function,
Program => SpaceKind::Unit,
_ => SpaceKind::Unknown,
}
}
}
Loading

0 comments on commit bcb3ca8

Please sign in to comment.