| 38 | | if (errorCode == -1) append(msg.toString()); |
|---|
| 39 | | else append(errorCode + " " + msg + "\n\t" + msg.getPath() + ":" + msg.getLine() + ":" |
|---|
| 40 | | + msg.getColumn() + "\n\t" + source); |
|---|
| | 55 | StringBuffer buf = new StringBuffer(); |
|---|
| | 56 | final List<Object[]> links = new ArrayList<Object[]>(3); |
|---|
| | 57 | if (errorCode != -1) { |
|---|
| | 58 | buf.append("#").append(errorCode).append(" "); |
|---|
| | 59 | buf.append(msg).append("\n '"); |
|---|
| | 60 | String path = msg.getPath(); |
|---|
| | 61 | buf.append(path).append(":"); |
|---|
| | 62 | int line = msg.getLine(); |
|---|
| | 63 | buf.append(line).append(":"); |
|---|
| | 64 | int column = msg.getColumn(); |
|---|
| | 65 | buf.append(column).append("'"); |
|---|
| | 66 | buf.append("\n "); |
|---|
| | 67 | buf.append(source); |
|---|
| | 68 | } else buf.append(msg.toString()); |
|---|
| | 69 | final String string = buf.toString(); |
|---|
| | 70 | final boolean error = errorCode != -1; |
|---|
| | 71 | Display.getDefault().asyncExec(new Runnable() { |
|---|
| | 72 | public void run() { |
|---|
| | 73 | if (error) { |
|---|
| | 74 | error(string, links); |
|---|
| | 75 | } else info(string); |
|---|
| | 76 | } |
|---|
| | 77 | }); |
|---|
| | 78 | if (links.size() <= 0) return; |
|---|
| | 79 | Display.getDefault().asyncExec(new Runnable() { |
|---|
| | 80 | public void run() { |
|---|
| | 81 | for (Object[] link:links) { |
|---|
| | 82 | try { |
|---|
| | 83 | addHyperlink((IHyperlink) link[0], (Integer) link[1], (Integer) link[2]); |
|---|
| | 84 | } catch (Exception e) { |
|---|
| | 85 | e.printStackTrace(); |
|---|
| | 86 | } |
|---|
| | 87 | } |
|---|
| | 88 | } |
|---|
| | 89 | }); |
|---|
| | 90 | } |
|---|
| | 91 | |
|---|
| | 92 | private void error(String string, List<Object[]> links) { |
|---|
| | 93 | Color red = Display.getDefault().getSystemColor(SWT.COLOR_DARK_RED); |
|---|
| | 94 | append(string, red); |
|---|
| | 95 | } |
|---|
| | 96 | |
|---|
| | 97 | private void info(String string) { |
|---|
| | 98 | Color gray = Display.getDefault().getSystemColor(SWT.COLOR_DARK_GRAY); |
|---|
| | 99 | append(string, gray); |
|---|
| | 116 | |
|---|
| | 117 | private class ErrorCodeMatcher extends PatternMatchAdapter { |
|---|
| | 118 | |
|---|
| | 119 | public String getPattern() { |
|---|
| | 120 | return "#[0-9]+"; |
|---|
| | 121 | } |
|---|
| | 122 | |
|---|
| | 123 | public void matchFound(PatternMatchEvent event) { |
|---|
| | 124 | IDocument document = getDocument(); |
|---|
| | 125 | try { |
|---|
| | 126 | String string = document.get(event.getOffset() + 1, event.getLength() - 1); |
|---|
| | 127 | ErrorCodeHyperlink hyperlink = new ErrorCodeHyperlink(Integer.parseInt(string)); |
|---|
| | 128 | addHyperlink(hyperlink, event.getOffset(), event.getLength()); |
|---|
| | 129 | } catch (BadLocationException e) { |
|---|
| | 130 | e.printStackTrace(); |
|---|
| | 131 | } |
|---|
| | 132 | } |
|---|
| | 133 | } |
|---|
| | 134 | |
|---|
| | 135 | private class FileMatcher extends PatternMatchAdapter { |
|---|
| | 136 | private IWorkspaceRoot root; |
|---|
| | 137 | private IPath rootLoc; |
|---|
| | 138 | |
|---|
| | 139 | public FileMatcher() { |
|---|
| | 140 | root = ResourcesPlugin.getWorkspace().getRoot(); |
|---|
| | 141 | rootLoc = root.getLocation(); |
|---|
| | 142 | } |
|---|
| | 143 | |
|---|
| | 144 | public String getPattern() { |
|---|
| | 145 | return "'" + rootLoc.toOSString() + "[^']*'"; |
|---|
| | 146 | } |
|---|
| | 147 | |
|---|
| | 148 | public void matchFound(final PatternMatchEvent event) { |
|---|
| | 149 | IDocument document = getDocument(); |
|---|
| | 150 | try { |
|---|
| | 151 | String string = document.get(event.getOffset() + 1, event.getLength() - 2); |
|---|
| | 152 | if (string != null) { |
|---|
| | 153 | String[] split = string.split(":"); |
|---|
| | 154 | IPath path = new Path(split[0]); |
|---|
| | 155 | path = path.removeFirstSegments(rootLoc.matchingFirstSegments(path)); |
|---|
| | 156 | IFile file = root.getFile(path); |
|---|
| | 157 | if (file.exists()) { |
|---|
| | 158 | FileLink link = new FileLink(file, null, -1, -1, Integer.parseInt(split[1])); |
|---|
| | 159 | addHyperlink(link, event.getOffset() + 1, event.getLength() - 2); |
|---|
| | 160 | } |
|---|
| | 161 | } |
|---|
| | 162 | } catch (Exception e) { |
|---|
| | 163 | e.printStackTrace(); |
|---|
| | 164 | } |
|---|
| | 165 | } |
|---|
| | 166 | } |
|---|