LineVisitor extends PHPVisitorCheck { public static int linesOfCode(Tree tree) { return new LineVisitor(tree).getLinesOfCodeNumber(); } private  LineVisitor(Tree tree);  LineVisitor(CompilationUnitTree tree); static int linesOfCode(Tree tree); @Override void visitScript(ScriptTree tree); @Override void visitToken(SyntaxToken token); int getLinesOfCodeNumber(); Set<Integer> getLinesOfCode();  }
@Test public void test_lines_of_code_number_on_tree() throws Exception { CompilationUnitTree cut = parse(LOC_FILE); Optional<ClassDeclarationTree> firstClassTree = cut.script().statements().stream() .filter(statement -> statement.is(Tree.Kind.CLASS_DECLARATION)) .map(ClassDeclarationTree.class::cast) .findFirst(); assertThat(firstClassTree).isPresent(); assertThat(LineVisitor.linesOfCode(firstClassTree.get())).isEqualTo(4); }