| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
3 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2479,6 +2479,27 @@ public List<LineMarker> getErrorPoints() { | |||
| 2479 | 2479 | } | |
| 2480 | 2480 | ||
| 2481 | 2481 | ||
| 2482 | + /** | ||
| 2483 | + * @return the LineMarker for the first error or warning on 'line' | ||
| 2484 | + */ | ||
| 2485 | + public LineMarker findError(int line) { | ||
| 2486 | + List<LineMarker> errorPoints = getErrorPoints(); | ||
| 2487 | + JavaTextArea textArea = getJavaTextArea(); | ||
| 2488 | + synchronized (errorPoints) { | ||
| 2489 | + for (LineMarker emarker : errorPoints) { | ||
| 2490 | + Problem p = emarker.getProblem(); | ||
| 2491 | + int pStartLine = p.getLineNumber(); | ||
| 2492 | + int pEndOffset = textArea.getLineStartOffset(pStartLine) + p.getPDELineStopOffset() + 1; | ||
| 2493 | + int pEndLine = textArea.getLineOfOffset(pEndOffset); | ||
| 2494 | + if (line >= pStartLine && line <= pEndLine) { | ||
| 2495 | + return emarker; | ||
| 2496 | + } | ||
| 2497 | + } | ||
| 2498 | + } | ||
| 2499 | + return null; | ||
| 2500 | + } | ||
| 2501 | + | ||
| 2502 | + | ||
| 2482 | 2503 | /* | |
| 2483 | 2504 | public void clearErrorPoints() { | |
| 2484 | 2505 | List<LineMarker> errorPoints = getErrorPoints(); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1064,20 +1064,16 @@ private void updateEditorStatus() { | |||
| 1064 | 1064 | // editor.statusNotice("Position: " + | |
| 1065 | 1065 | // editor.getTextArea().getCaretLine()); | |
| 1066 | 1066 | if (JavaMode.errorCheckEnabled) { | |
| 1067 | - List<LineMarker> errorPoints = editor.getErrorPoints(); | ||
| 1068 | - synchronized (errorPoints) { | ||
| 1069 | - for (LineMarker emarker : errorPoints) { | ||
| 1070 | - if (emarker.getProblem().getLineNumber() == editor.getTextArea().getCaretLine()) { | ||
| 1071 | - if (emarker.getType() == LineMarker.WARNING) { | ||
| 1072 | - editor.statusMessage(emarker.getProblem().getMessage(), | ||
| 1073 | - JavaEditor.STATUS_INFO); | ||
| 1074 | - } else { | ||
| 1075 | - editor.statusMessage(emarker.getProblem().getMessage(), | ||
| 1076 | - JavaEditor.STATUS_COMPILER_ERR); | ||
| 1077 | - } | ||
| 1078 | - return; | ||
| 1079 | - } | ||
| 1067 | + LineMarker errorMarker = editor.findError(editor.getTextArea().getCaretLine()); | ||
| 1068 | + if (errorMarker != null) { | ||
| 1069 | + if (errorMarker.getType() == LineMarker.WARNING) { | ||
| 1070 | + editor.statusMessage(errorMarker.getProblem().getMessage(), | ||
| 1071 | + JavaEditor.STATUS_INFO); | ||
| 1072 | + } else { | ||
| 1073 | + editor.statusMessage(errorMarker.getProblem().getMessage(), | ||
| 1074 | + JavaEditor.STATUS_COMPILER_ERR); | ||
| 1080 | 1075 | } | |
| 1076 | + return; | ||
| 1081 | 1077 | } | |
| 1082 | 1078 | } | |
| 1083 | 1079 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -74,25 +74,8 @@ public class JavaTextAreaPainter extends TextAreaPainter | |||
| 74 | 74 | protected Color gutterTextColor; | |
| 75 | 75 | protected Color gutterLineHighlightColor; | |
| 76 | 76 | ||
| 77 | - public static class ErrorLineCoord { | ||
| 78 | - public int xStart; | ||
| 79 | - public int xEnd; | ||
| 80 | - public int yStart; | ||
| 81 | - public int yEnd; | ||
| 82 | - public Problem problem; | ||
| 83 | - | ||
| 84 | - public ErrorLineCoord(int xStart, int xEnd, int yStart, int yEnd, Problem problem) { | ||
| 85 | - this.xStart = xStart; | ||
| 86 | - this.xEnd = xEnd; | ||
| 87 | - this.yStart = yStart; | ||
| 88 | - this.yEnd = yEnd; | ||
| 89 | - this.problem = problem; | ||
| 90 | - } | ||
| 91 | - } | ||
| 92 | - public List<ErrorLineCoord> errorLineCoords = new ArrayList<>(); | ||
| 93 | 77 | ||
| 94 | - | ||
| 95 | - public JavaTextAreaPainter(JavaTextArea textArea, TextAreaDefaults defaults) { | ||
| 78 | + public JavaTextAreaPainter(final JavaTextArea textArea, TextAreaDefaults defaults) { | ||
| 96 | 79 | super(textArea, defaults); | |
| 97 | 80 | ||
| 98 | 81 | addMouseListener(new MouseAdapter() { | |
@@ -134,11 +117,28 @@ public void mousePressed(MouseEvent event) { | |||
| 134 | 117 | addMouseMotionListener(new MouseMotionAdapter() { | |
| 135 | 118 | @Override | |
| 136 | 119 | public void mouseMoved(final MouseEvent evt) { | |
| 137 | - for (ErrorLineCoord coord : errorLineCoords) { | ||
| 138 | - if (evt.getX() >= coord.xStart && evt.getX() <= coord.xEnd && | ||
| 139 | - evt.getY() >= coord.yStart && evt.getY() <= coord.yEnd + 2) { | ||
| 140 | - setToolTipText(coord.problem.getMessage()); | ||
| 141 | - break; | ||
| 120 | + int line = textArea.yToLine(evt.getY()); | ||
| 121 | + int x = evt.getX(); | ||
| 122 | + | ||
| 123 | + LineMarker marker = getJavaEditor().findError(line); | ||
| 124 | + if (marker != null) { | ||
| 125 | + Problem problem = marker.getProblem(); | ||
| 126 | + | ||
| 127 | + int lineOffset = textArea.getLineStartOffset(problem.getLineNumber()); | ||
| 128 | + | ||
| 129 | + int lineStart = textArea.getLineStartOffset(line); | ||
| 130 | + int lineEnd = textArea.getLineStopOffset(line); | ||
| 131 | + | ||
| 132 | + int errorStart = lineOffset + problem.getPDELineStartOffset(); | ||
| 133 | + int errorEnd = lineOffset + problem.getPDELineStopOffset() + 1; | ||
| 134 | + | ||
| 135 | + int startOffset = Math.max(errorStart, lineStart) - lineStart; | ||
| 136 | + int stopOffset = Math.min(errorEnd, lineEnd) - lineStart; | ||
| 137 | + | ||
| 138 | + if (x >= getTextArea().offsetToX(line, startOffset) && | ||
| 139 | + x <= getTextArea().offsetToX(line, stopOffset)) { | ||
| 140 | + setToolTipText(problem.getMessage()); | ||
| 141 | + evt.consume(); | ||
| 142 | 142 | } | |
| 143 | 143 | } | |
| 144 | 144 | } | |
@@ -337,22 +337,6 @@ static private String trimRight(String str) { | |||
| 337 | 337 | } | |
| 338 | 338 | ||
| 339 | 339 | ||
| 340 | - /** | ||
| 341 | - * @return the LineMarker for the first error or warning on 'line' | ||
| 342 | - */ | ||
| 343 | - private LineMarker findError(int line) { | ||
| 344 | - List<LineMarker> errorPoints = getJavaEditor().getErrorPoints(); | ||
| 345 | - synchronized (errorPoints) { | ||
| 346 | - for (LineMarker emarker : errorPoints) { | ||
| 347 | - if (emarker.getProblem().getLineNumber() == line) { | ||
| 348 | - return emarker; | ||
| 349 | - } | ||
| 350 | - } | ||
| 351 | - } | ||
| 352 | - return null; | ||
| 353 | - } | ||
| 354 | - | ||
| 355 | - | ||
| 356 | 340 | /** | |
| 357 | 341 | * Paints the underline for an error/warning line | |
| 358 | 342 | * | |
@@ -369,22 +353,29 @@ protected void paintErrorLine(Graphics gfx, int line, int x) { | |||
| 369 | 353 | return; | |
| 370 | 354 | } | |
| 371 | 355 | ||
| 372 | - errorLineCoords.clear(); | ||
| 373 | - LineMarker marker = findError(line); | ||
| 356 | + LineMarker marker = getJavaEditor().findError(line); | ||
| 374 | 357 | if (marker != null) { | |
| 375 | 358 | Problem problem = marker.getProblem(); | |
| 376 | 359 | ||
| 360 | + int offset = textArea.getLineStartOffset(problem.getLineNumber()); | ||
| 361 | + | ||
| 362 | + int startOffset = offset + problem.getPDELineStartOffset(); | ||
| 363 | + int stopOffset = offset + problem.getPDELineStopOffset() + 1; | ||
| 364 | + | ||
| 365 | + int lineOffset = textArea.getLineStartOffset(line); | ||
| 366 | + | ||
| 367 | + int wiggleStart = Math.max(startOffset, lineOffset); | ||
| 368 | + int wiggleStop = Math.min(stopOffset, textArea.getLineStopOffset(line)); | ||
| 369 | + | ||
| 377 | 370 | int y = textArea.lineToY(line) + fm.getLeading() + fm.getMaxDescent(); | |
| 378 | - int start = textArea.getLineStartOffset(line) + problem.getPDELineStartOffset(); | ||
| 379 | - int length = 1 + problem.getPDELineStopOffset() - problem.getPDELineStartOffset(); | ||
| 380 | 371 | ||
| 381 | 372 | try { | |
| 382 | 373 | String badCode = null; | |
| 383 | 374 | String goodCode = null; | |
| 384 | 375 | try { | |
| 385 | 376 | SyntaxDocument doc = textArea.getDocument(); | |
| 386 | - badCode = doc.getText(start, length); | ||
| 387 | - goodCode = doc.getText(textArea.getLineStartOffset(line), problem.getPDELineStartOffset()); | ||
| 377 | + badCode = doc.getText(wiggleStart, wiggleStop - wiggleStart); | ||
| 378 | + goodCode = doc.getText(lineOffset, wiggleStart - lineOffset); | ||
| 388 | 379 | //log("paintErrorLine() LineText GC: " + goodCode); | |
| 389 | 380 | //log("paintErrorLine() LineText BC: " + badCode); | |
| 390 | 381 | } catch (BadLocationException bl) { | |
@@ -402,12 +393,14 @@ protected void paintErrorLine(Graphics gfx, int line, int x) { | |||
| 402 | 393 | int rw = fm.stringWidth(badCode.trim()); // real width | |
| 403 | 394 | int x1 = fm.stringWidth(goodCode) + (aw - rw); | |
| 404 | 395 | int y1 = y + fm.getHeight() - 2, x2 = x1 + rw; | |
| 396 | + | ||
| 397 | + if (line != problem.getLineNumber()) { | ||
| 398 | + x1 = 0; // on the following lines, wiggle extends to the left border | ||
| 399 | + } | ||
| 405 | 400 | // Adding offsets for the gutter | |
| 406 | 401 | x1 += Editor.LEFT_GUTTER; | |
| 407 | 402 | x2 += Editor.LEFT_GUTTER; | |
| 408 | 403 | ||
| 409 | - errorLineCoords.add(new ErrorLineCoord(x1, x2, y, y1, problem)); | ||
| 410 | - | ||
| 411 | 404 | gfx.setColor(errorUnderlineColor); | |
| 412 | 405 | if (marker.getType() == LineMarker.WARNING) { | |
| 413 | 406 | gfx.setColor(warningUnderlineColor); | |
@@ -480,7 +473,8 @@ public String getToolTipText(MouseEvent event) { | |||
| 480 | 473 | return super.getToolTipText(event); | |
| 481 | 474 | } | |
| 482 | 475 | if (!(Character.isLetterOrDigit(s.charAt(x)) || | |
| 483 | - s.charAt(x) == '_' || s.charAt(x) == '$')) { | ||
| 476 | + s.charAt(x) == '_' || s.charAt(x) == '$' || s.charAt(x) == '{' || | ||
| 477 | + s.charAt(x) == '}')) { | ||
| 484 | 478 | setToolTipText(null); | |
| 485 | 479 | return super.getToolTipText(event); | |
| 486 | 480 | } | |
| Back | FazBrowse Home | New Git URL |
0 commit comments