private void analyzeFile(File inputFile,Optional<CommonTokenStream> optTokenStream,Optional<TopLevelContext> optTree,Formatter formatter,Severity maxSeverity,ConstructLengths constructLengths,Set<Rules> enabledRules) throws CLIArgumentParserException {
  try {
    Printer printer=new Printer(inputFile,maxSeverity,formatter);
    if (optTokenStream.isPresent() && optTree.isPresent()) {
      CommonTokenStream tokenStream=optTokenStream.get();
      TopLevelContext tree=optTree.get();
      CommentExtractor commentExtractor=new CommentExtractor(tokenStream);
      ViolationSuppressor disableAnalysis=new ViolationSuppressor(printer,commentExtractor.getSingleLineComments(),commentExtractor.getMultilineComments());
      disableAnalysis.analyze();
      List<SwiftBaseListener> listeners=createListeners(enabledRules,printer,tokenStream,constructLengths,commentExtractor);
      walkParseTree(listeners,tree);
      try (FileListener fileListener=new FileListener(printer,inputFile,constructLengths,enabledRules)){
        fileListener.verify();
      }
       numErrors.addAndGet(printer.getNumErrorMessages());
      numWarnings.addAndGet(printer.getNumWarningMessages());
    }
 else {
      printer.setShouldPrintParseErrorMessage(true);
    }
    printersForAllFiles.add(printer);
  }
 catch (  IOException e) {
    handleIOException(e);
  }
catch (  CLIArgumentParserException e) {
    handleCLIException(e);
  }
}

private void analyzeFile ( File inputFile , Optional < CommonTokenStream > optTokenStream , Optional < TopLevelContext > optTree , Formatter formatter , Severity maxSeverity , ConstructLengths constructLengths , Set < Rules > enabledRules ) throws CLIArgumentParserException { try { Printer printer = new Printer ( inputFile , maxSeverity , formatter ) ; if ( optTokenStream . isPresent ( ) && optTree . isPresent ( ) ) { CommonTokenStream tokenStream = optTokenStream . get ( ) ; TopLevelContext tree = optTree . get ( ) ; CommentExtractor commentExtractor = new CommentExtractor ( tokenStream ) ; ViolationSuppressor disableAnalysis = new ViolationSuppressor ( printer , commentExtractor . getSingleLineComments ( ) , commentExtractor . getMultilineComments ( ) ) ; disableAnalysis . analyze ( ) ; List < SwiftBaseListener > listeners = createListeners ( enabledRules , printer , tokenStream , constructLengths , commentExtractor ) ; walkParseTree ( listeners , tree ) ; try ( FileListener fileListener = new FileListener ( printer , inputFile , constructLengths , enabledRules ) ) { fileListener . verify ( ) ; } numErrors . addAndGet ( printer . getNumErrorMessages ( ) ) ; numWarnings . addAndGet ( printer . getNumWarningMessages ( ) ) ; } else { printer . setShouldPrintParseErrorMessage ( true ) ; } printersForAllFiles . add ( printer ) ; } catch ( IOException e ) { handleIOException ( e ) ; } catch ( CLIArgumentParserException e ) { handleCLIException ( e ) ; } }
analyzes an individual file by creating the corresponding listeners and walking the file ' s parse tree .
