@Test public void complexity() { SourceFile file = LuaAstScanner.scanSingleFile(new File("src/test/resources/metrics/complexity.lua")); assertThat(file.getInt(LuaMetric.COMPLEXITY)).isEqualTo(4); }
public static SourceFile scanSingleFile(File file, SquidAstVisitor<LexerlessGrammar>... visitors) { if (!file.isFile()) { throw new IllegalArgumentException("File '" + file + "' not found."); } AstScanner<LexerlessGrammar> scanner = create(new LuaConfiguration(Charsets.UTF_8), Arrays.asList(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(); }
LuaAstScanner { public static SourceFile scanSingleFile(File file, SquidAstVisitor<LexerlessGrammar>... visitors) { if (!file.isFile()) { throw new IllegalArgumentException("File '" + file + "' not found."); } AstScanner<LexerlessGrammar> scanner = create(new LuaConfiguration(Charsets.UTF_8), Arrays.asList(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(); } }
LuaAstScanner { public static SourceFile scanSingleFile(File file, SquidAstVisitor<LexerlessGrammar>... visitors) { if (!file.isFile()) { throw new IllegalArgumentException("File '" + file + "' not found."); } AstScanner<LexerlessGrammar> scanner = create(new LuaConfiguration(Charsets.UTF_8), Arrays.asList(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  LuaAstScanner(); }
LuaAstScanner { public static SourceFile scanSingleFile(File file, SquidAstVisitor<LexerlessGrammar>... visitors) { if (!file.isFile()) { throw new IllegalArgumentException("File '" + file + "' not found."); } AstScanner<LexerlessGrammar> scanner = create(new LuaConfiguration(Charsets.UTF_8), Arrays.asList(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  LuaAstScanner(); static SourceFile scanSingleFile(File file, SquidAstVisitor<LexerlessGrammar>... visitors); static AstScanner<LexerlessGrammar> create(LuaConfiguration conf, List<SquidAstVisitor<LexerlessGrammar>> visitors); }
LuaAstScanner { public static SourceFile scanSingleFile(File file, SquidAstVisitor<LexerlessGrammar>... visitors) { if (!file.isFile()) { throw new IllegalArgumentException("File '" + file + "' not found."); } AstScanner<LexerlessGrammar> scanner = create(new LuaConfiguration(Charsets.UTF_8), Arrays.asList(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  LuaAstScanner(); static SourceFile scanSingleFile(File file, SquidAstVisitor<LexerlessGrammar>... visitors); static AstScanner<LexerlessGrammar> create(LuaConfiguration conf, List<SquidAstVisitor<LexerlessGrammar>> visitors);  }