SwiftAstScanner { public static SourceFile scanSingleFile(File file, SquidAstVisitor<SwiftGrammar>... visitors) { if (!file.isFile()) { throw new IllegalArgumentException("File '" + file + "' not found."); } AstScanner<SwiftGrammar> scanner = create(new SwiftConfiguration(), visitors); scanner.scanFile(file); Collection<SourceCode> sources = scanner.getIndex().search(new QueryByType(SourceFile.class)); if (sources.size() != 1) { throw new IllegalStateException("Only one SourceFile was expected whereas " + sources.size() + " has been returned."); } return (SourceFile) sources.iterator().next(); } private  SwiftAstScanner(); static SourceFile scanSingleFile(File file, SquidAstVisitor<SwiftGrammar>... visitors); static AstScanner<SwiftGrammar> create(SwiftConfiguration conf, SquidAstVisitor<SwiftGrammar>... visitors);  }
@Test public void testTotalLineCount() { SourceFile file = SwiftAstScanner.scanSingleFile(new File("src/test/resources/Test.swift")); assertThat(file.getInt(SwiftMetric.LINES), is(21)); }
@Test public void testLineOfCodeCount() { SourceFile file = SwiftAstScanner.scanSingleFile(new File("src/test/resources/Test.swift")); assertThat(file.getInt(SwiftMetric.LINES_OF_CODE), is(11)); }
@Test public void testCommentLineCount() { SourceFile file = SwiftAstScanner.scanSingleFile(new File("src/test/resources/Test.swift")); assertThat(file.getInt(SwiftMetric.COMMENT_LINES), is(3)); }