Пример #1
0
 private void parseErrorWalkAndVisit(RecognitionException e, File file) {
   try {
     // Process the exception
     visitor.visitFile(null);
     visitor.processRecognitionException(e);
   } catch (Exception e2) {
     throw new AnalysisException(getAnalyisExceptionMessage(file), e2);
   }
 }
Пример #2
0
  /**
   * Used to do scan of test files.
   *
   * @param files
   */
  public void simpleScan(Iterable<File> files) {
    SourceProject project = (SourceProject) index.search("Java Project");
    VisitorContext context = new VisitorContext(project);
    visitor.setContext(context);

    ProgressReport progressReport =
        new ProgressReport(
            "Report about progress of Java AST analyzer", TimeUnit.SECONDS.toMillis(10));
    progressReport.start(Lists.newArrayList(files));

    boolean successfulyCompleted = false;
    try {
      for (File file : files) {
        simpleScan(file, context);
        progressReport.nextFile();
      }
      successfulyCompleted = true;
    } finally {
      if (successfulyCompleted) {
        progressReport.stop();
      } else {
        progressReport.cancel();
      }
    }
  }
Пример #3
0
  private void simpleScan(File file, VisitorContext context) {
    context.setFile(file);
    try {
      Tree ast = parser.parse(file);
      visitor.visitFile(ast);
    } catch (RecognitionException e) {
      checkInterrrupted(e);
      LOG.error("Unable to parse source file : " + file.getAbsolutePath());
      LOG.error(e.getMessage());

      parseErrorWalkAndVisit(e, file);
    } catch (Exception e) {
      checkInterrrupted(e);
      throw new AnalysisException(getAnalyisExceptionMessage(file), e);
    }
  }