private static void checkInterrrupted(Exception e) { Throwable cause = Throwables.getRootCause(e); if (cause instanceof InterruptedException || cause instanceof InterruptedIOException) { throw new AnalysisException("Analysis cancelled", e); } }
@Override public XPathExpression compile(String expression) { try { return xPath.compile(expression); } catch (XPathExpressionException e) { throw new AnalysisException("Unable to compile XPath expression '" + expression + "'", e); } }
private static void checkInterrupted(Exception e) { Throwable cause = Throwables.getRootCause(e); if (cause instanceof InterruptedException || cause instanceof InterruptedIOException) { throw new AnalysisException("Analysis cancelled", e); } }
private static void checkInterrupted(Exception e) { Throwable cause = Throwables.getRootCause(e); if (cause instanceof InterruptedException || cause instanceof InterruptedIOException) { throw new AnalysisException("Analysis cancelled", e); } }
private static void checkInterrrupted(Exception e) { Throwable cause = Throwables.getRootCause(e); if (cause instanceof InterruptedException || cause instanceof InterruptedIOException) { throw new AnalysisException("Analysis cancelled", e); } }
@Override public Iterable<Node> evaluate(XPathExpression expression, Node node) { try { NodeList nodeList = (NodeList) expression.evaluate(node, XPathConstants.NODESET); if (nodeList.getLength() == 0) { return ImmutableList.of(); } return new NodeListIterable(nodeList); } catch (XPathExpressionException e) { throw new AnalysisException("Unable to evaluate XPath expression", e); } }
private void notifyBytecodeVisitors(Collection<String> keys, AsmClassProvider classProvider) { BytecodeVisitor[] visitorArray = getVisitors().toArray(new BytecodeVisitor[getVisitors().size()]); for (String key : keys) { try { AsmClass asmClass = classProvider.getClass(key, DETAIL_LEVEL.STRUCTURE_AND_CALLS); BytecodeVisitorNotifier visitorNotifier = new BytecodeVisitorNotifier(asmClass, visitorArray); visitorNotifier.notifyVisitors(indexer, javaResourceLocator); } catch (Exception exception) { throw new AnalysisException("Unable to analyze .class file " + key, exception); } } }
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 parseErrorWalkAndVisit(RecognitionException e, File file) { try { // Process the exception for (SquidAstVisitor<? extends Grammar> visitor : visitors) { visitor.visitFile(null); } for (AstScannerExceptionHandler astScannerExceptionHandler : astScannerExceptionHandlers) { astScannerExceptionHandler.processRecognitionException(e); } for (SquidAstVisitor<? extends Grammar> visitor : Lists.reverse(visitors)) { visitor.leaveFile(null); } } catch (Exception e2) { throw new AnalysisException(getAnalyisExceptionMessage(file), e2); } }
private void fillLines(Reader reader) { try { currentLine = new Line(1); int nextChar; do { nextChar = reader.read(); if (isEndOfFile(nextChar)) { notifyHandlersAboutEndOfLine(); break; } lastReadCharacter = (char) nextChar; if (isEndOfLine(nextChar)) { popOptionalRemainingEndOfLineChar(reader); createNewLine(); continue; } appendToStringBuilder(nextChar); notifyHandlersAboutNewChar(); } while (true); } catch (IOException e) { throw new AnalysisException("Unable to read the source code.", e); } catch (Exception e) { throw new AnalysisException("A problem was encountered when analyzing line " + lines.size() + " : '" + currentStringBuilder.toString() + "'", e); } }
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 notifyBytecodeVisitors(Collection<String> keys, AsmClassProvider classProvider) { BytecodeVisitor[] visitorArray = getVisitors().toArray(new BytecodeVisitor[getVisitors().size()]); for (BytecodeVisitor bytecodeVisitor : visitorArray) { bytecodeVisitor.setContext(context); } for (String key : keys) { try { AsmClass asmClass = classProvider.getClass(key, DETAIL_LEVEL.STRUCTURE_AND_CALLS); BytecodeVisitorNotifier visitorNotifier = new BytecodeVisitorNotifier(asmClass, visitorArray); visitorNotifier.notifyVisitors(); } catch (Exception exception) { checkInterrrupted(exception); throw new AnalysisException("Unable to analyze .class file " + key, exception); } } }
LOG.error("Unable to parse file: " + file.getAbsolutePath(), e); } catch (Throwable e) { throw new AnalysisException("Unable to parse file: " + file.getAbsolutePath(), e); throw new AnalysisException("Unable to analyze file: " + file.getAbsolutePath(), e);
private List<Issue> analyzeFile(SensorContext sensorContext, InputFile inputFile, List<TreeVisitor> visitors) { try { TreeImpl cssTree = (TreeImpl) parser.parse(new File(inputFile.absolutePath())); return scanFile(inputFile, cssTree, visitors); } catch (RecognitionException e) { checkInterrupted(e); LOG.error("Unable to parse file: " + inputFile.absolutePath()); LOG.error(e.getMessage()); processRecognitionException(e, sensorContext, inputFile); } catch (Exception e) { checkInterrupted(e); throw new AnalysisException("Unable to analyze file: " + inputFile.absolutePath(), e); } return new ArrayList<>(); }
throw new AnalysisException(getAnalyisExceptionMessage(file), e);