@Test
 public void files() {
   AstScanner<LexerlessGrammar> scanner =
       ColdFusionAstScanner.create(new CFConfiguration(Charsets.UTF_8));
   scanner.scanFiles(
       ImmutableList.of(
           new File("src/test/resources/metrics/Comments.cfc"),
           new File("src/test/resources/metrics/Functions.cfc")));
   SourceProject project =
       (SourceProject)
           scanner.getIndex().search(new QueryByType(SourceProject.class)).iterator().next();
   assertThat(project.getInt(CFMetric.FILES)).isEqualTo(2);
 }
Exemple #2
0
 /** Helper method for scanning a single file */
 public static SourceFile scanSingleFileConfig(
     File file, CxxConfiguration cxxConfig, SquidAstVisitor<Grammar>... visitors) {
   if (!file.isFile()) {
     throw new IllegalArgumentException("File '" + file + "' not found.");
   }
   AstScanner<Grammar> scanner = create(cxxConfig, 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();
 }