@Override public void matchFound(PatternMatchEvent event) { try { CppStyleMessageConsole console = (CppStyleMessageConsole) event.getSource(); String line = console.getDocument().get(event.getOffset(), event.getLength()); Matcher m = pattern.matcher(line); if (m.matches()) { String ln = m.group(lineNumGroup); int lineno = Integer.parseInt(ln); FileLink link = new FileLink(file, null, -1, -1, lineno == 0 ? 1 : lineno); console.addFileLink(link, event.getOffset(), event.getLength()); } } catch (BadLocationException e) { CppStyle.log("Failed to add link", e); } } }