public void processRecognitionException(RecognitionException e, File file) { addAnalysisError(e, file.getPath(), AnalysisError.Kind.PARSE_ERROR); if(sonarComponents == null || !sonarComponents.reportAnalysisError(e, file)) { this.visitFile(null); executableScanners.stream() .filter(scanner -> scanner instanceof ExceptionHandler) .forEach(scanner -> ((ExceptionHandler) scanner).processRecognitionException(e)); } }
public void processRecognitionException(RecognitionException e, File file) { addAnalysisError(e, file.getPath(), AnalysisError.Kind.PARSE_ERROR); if(sonarComponents == null || !sonarComponents.reportAnalysisError(e, file)) { this.visitFile(null); executableScanners.stream() .filter(scanner -> scanner instanceof ExceptionHandler) .forEach(scanner -> ((ExceptionHandler) scanner).processRecognitionException(e)); } }
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); } }
private void simpleScan(File file) { visitor.setCurrentFile(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); } }
private void simpleScan(File file) { visitor.setCurrentFile(file); try { String fileContent = getFileContent(file); Tree ast; if(fileContent.isEmpty()) { ast = parser.parse(file); } else { ast = parser.parse(fileContent); } visitor.visitFile(ast); } catch (RecognitionException e) { checkInterrupted(e); LOG.error("Unable to parse source file : " + file.getAbsolutePath()); LOG.error(e.getMessage()); parseErrorWalkAndVisit(e, file); } catch (Exception e) { checkInterrupted(e); throw new AnalysisException(getAnalysisExceptionMessage(file), e); } catch (StackOverflowError error) { LOG.error("A stack overflow error occured while analyzing file: " + file.getAbsolutePath(), error); throw error; } }
private void simpleScan(File file) { visitor.setCurrentFile(file); try { String fileContent = getFileContent(file); Tree ast; if(fileContent.isEmpty()) { ast = parser.parse(file); } else { ast = parser.parse(fileContent); } visitor.visitFile(ast); } catch (RecognitionException e) { checkInterrupted(e); LOG.error("Unable to parse source file : " + file.getAbsolutePath()); LOG.error(e.getMessage()); parseErrorWalkAndVisit(e, file); } catch (Exception e) { checkInterrupted(e); throw new AnalysisException(getAnalysisExceptionMessage(file), e); } catch (StackOverflowError error) { LOG.error("A stack overflow error occured while analyzing file: " + file.getAbsolutePath(), error); throw error; } }