public static SourceFile scanSingleFileConfig ( CxxLanguage language , InputFile file , CxxConfiguration cxxConfig , SquidAstVisitor < Grammar > ... visitors ) { if ( ! file . isFile ( ) ) { throw new IllegalArgumentException ( "File '" + file + "' not found." ) ; } AstScanner < Grammar > scanner = create ( language , cxxConfig , visitors ) ; scanner . scanFile ( file . 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 ( ) ; }
Helper method for scanning a single file