public ApexNode<Compilation> parse(final Reader reader) { try { final String sourceCode = IOUtils.toString(reader); final Compilation astRoot = parseApex(sourceCode); final ApexTreeBuilder treeBuilder = new ApexTreeBuilder(sourceCode); suppressMap = new HashMap<>(); if (astRoot == null) { throw new ParseException("Couldn't parse the source - there is not root node - Syntax Error??"); } return treeBuilder.build(astRoot); } catch (IOException e) { throw new ParseException(e); } }
private void createKids() { String message = ((ParseException) item).getMessage(); String[] lines = StringUtils.split(message, PMD.EOL); kids = new ExceptionNode[lines.length]; for (int i = 0; i < lines.length; i++) { kids[i] = new ExceptionNode(lines[i]); } }
/** * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent) */ @Override public void actionPerformed(ActionEvent e) { String command = e.getActionCommand(); long t0; long t1; if (ActionCommands.COMPILE_ACTION.equals(command)) { try { t0 = System.currentTimeMillis(); model.commitSource(sourcePanel.getSourceCode(), getLanguageVersion()); t1 = System.currentTimeMillis(); setStatus(NLS.nls("MAIN.FRAME.COMPILATION.TOOK") + " " + (t1 - t0) + " ms"); } catch (ParseException exc) { setStatus(NLS.nls("MAIN.FRAME.COMPILATION.PROBLEM") + " " + exc.toString()); new ParseExceptionHandler(this, exc); } } else if (ActionCommands.EVALUATE_ACTION.equals(command)) { try { t0 = System.currentTimeMillis(); model.evaluateXPathExpression(xPathPanel.getXPathExpression(), this); t1 = System.currentTimeMillis(); setStatus(NLS.nls("MAIN.FRAME.EVALUATION.TOOK") + " " + (t1 - t0) + " ms"); } catch (Exception exc) { setStatus(NLS.nls("MAIN.FRAME.EVALUATION.PROBLEM") + " " + exc.toString()); new ParseExceptionHandler(this, exc); } } }
xpathResults.addElement(pe.fillInStackTrace().getMessage());
/** * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent) */ @Override public void actionPerformed(ActionEvent e) { String command = e.getActionCommand(); long t0; long t1; if (ActionCommands.COMPILE_ACTION.equals(command)) { try { t0 = System.currentTimeMillis(); model.commitSource(sourcePanel.getSourceCode(), getLanguageVersion()); t1 = System.currentTimeMillis(); setStatus(NLS.nls("MAIN.FRAME.COMPILATION.TOOK") + " " + (t1 - t0) + " ms"); } catch (ParseException exc) { setStatus(NLS.nls("MAIN.FRAME.COMPILATION.PROBLEM") + " " + exc.toString()); new ParseExceptionHandler(this, exc); } } else if (ActionCommands.EVALUATE_ACTION.equals(command)) { try { t0 = System.currentTimeMillis(); model.evaluateXPathExpression(xPathPanel.getXPathExpression(), this); t1 = System.currentTimeMillis(); setStatus(NLS.nls("MAIN.FRAME.EVALUATION.TOOK") + " " + (t1 - t0) + " ms"); } catch (Exception exc) { setStatus(NLS.nls("MAIN.FRAME.EVALUATION.PROBLEM") + " " + exc.toString()); new ParseExceptionHandler(this, exc); } } }
xpathResults.addElement(pe.fillInStackTrace().getMessage());
protected Document parseDocument(Reader reader) throws ParseException { nodeCache.clear(); try { String xmlData = IOUtils.toString(reader); DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); dbf.setNamespaceAware(parserOptions.isNamespaceAware()); dbf.setValidating(parserOptions.isValidating()); dbf.setIgnoringComments(parserOptions.isIgnoringComments()); dbf.setIgnoringElementContentWhitespace(parserOptions.isIgnoringElementContentWhitespace()); dbf.setExpandEntityReferences(parserOptions.isExpandEntityReferences()); dbf.setCoalescing(parserOptions.isCoalescing()); dbf.setXIncludeAware(parserOptions.isXincludeAware()); dbf.setFeature("http://xml.org/sax/features/external-general-entities", false); dbf.setFeature("http://xml.org/sax/features/external-parameter-entities", false); DocumentBuilder documentBuilder = dbf.newDocumentBuilder(); documentBuilder.setEntityResolver(parserOptions.getEntityResolver()); Document document = documentBuilder.parse(new InputSource(new StringReader(xmlData))); DOMLineNumbers lineNumbers = new DOMLineNumbers(document, xmlData); lineNumbers.determine(); return document; } catch (ParserConfigurationException | SAXException | IOException e) { throw new ParseException(e); } }
private void createKids() { String message = ((ParseException) item).getMessage(); String[] lines = StringUtils.split(message, PMD.EOL); kids = new ExceptionNode[lines.length]; for (int i = 0; i < lines.length; i++) { kids[i] = new ExceptionNode(lines[i]); } }
public EcmascriptNode<AstRoot> parse(final Reader reader) { try { final List<ParseProblem> parseProblems = new ArrayList<>(); final String sourceCode = IOUtils.toString(reader); final AstRoot astRoot = parseEcmascript(sourceCode, parseProblems); final EcmascriptTreeBuilder treeBuilder = new EcmascriptTreeBuilder(sourceCode, parseProblems); EcmascriptNode<AstRoot> tree = treeBuilder.build(astRoot); suppressMap = new HashMap<>(); if (astRoot.getComments() != null) { for (Comment comment : astRoot.getComments()) { int nopmd = comment.getValue().indexOf(suppressMarker); if (nopmd > -1) { String suppression = comment.getValue().substring(nopmd + suppressMarker.length()); EcmascriptNode<Comment> node = treeBuilder.build(comment); suppressMap.put(node.getBeginLine(), suppression); } } } return tree; } catch (IOException e) { throw new ParseException(e); } }
public ApexNode<Compilation> parse(final Reader reader) { try { final String sourceCode = IOUtils.toString(reader); final Compilation astRoot = parseApex(sourceCode); final ApexTreeBuilder treeBuilder = new ApexTreeBuilder(sourceCode); suppressMap = new HashMap<>(); if (astRoot == null) { throw new ParseException("Couldn't parse the source - there is not root node - Syntax Error??"); } return treeBuilder.build(astRoot); } catch (IOException e) { throw new ParseException(e); } }