| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent dc44a71 commit b7770ab
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -11,6 +11,7 @@ | |||
| 11 | 11 | import java.util.Map; | |
| 12 | 12 | import java.util.logging.Level; | |
| 13 | 13 | import java.util.logging.Logger; | |
| 14 | + import java.util.stream.Collectors; | ||
| 14 | 15 | ||
| 15 | 16 | import javax.swing.*; | |
| 16 | 17 | import javax.swing.border.*; | |
@@ -195,9 +196,7 @@ public void mouseReleased(MouseEvent evt) { | |||
| 195 | 196 | ||
| 196 | 197 | for (SketchCode code : getSketch().getCode()) { | |
| 197 | 198 | Document document = code.getDocument(); | |
| 198 | - if (document != null) { | ||
| 199 | - addDocumentListener(document); | ||
| 200 | - } | ||
| 199 | + addDocumentListener(document); | ||
| 201 | 200 | } | |
| 202 | 201 | } | |
| 203 | 202 | ||
@@ -2513,7 +2512,7 @@ public List<Problem> getProblems() { | |||
| 2513 | 2512 | * line or not | |
| 2514 | 2513 | */ | |
| 2515 | 2514 | public void updateEditorStatus() { | |
| 2516 | - Problem problem = findError(textarea.getCaretLine()); | ||
| 2515 | + Problem problem = findProblem(textarea.getCaretLine()); | ||
| 2517 | 2516 | if (problem != null) { | |
| 2518 | 2517 | int type = problem.isError() ? | |
| 2519 | 2518 | EditorStatus.CURSOR_LINE_ERROR : EditorStatus.CURSOR_LINE_WARNING; | |
@@ -2530,21 +2529,36 @@ public void updateEditorStatus() { | |||
| 2530 | 2529 | ||
| 2531 | 2530 | ||
| 2532 | 2531 | /** | |
| 2533 | - * @return the LineMarker for the first error or warning on 'line' | ||
| 2532 | + * @return the Problem for the first error or warning on 'line' | ||
| 2534 | 2533 | */ | |
| 2535 | - public Problem findError(int line) { | ||
| 2534 | + public Problem findProblem(int line) { | ||
| 2536 | 2535 | JavaTextArea textArea = getJavaTextArea(); | |
| 2537 | 2536 | int currentTab = getSketch().getCurrentCodeIndex(); | |
| 2538 | - for (Problem p : problems) { | ||
| 2539 | - if (p.getTabIndex() != currentTab) continue; | ||
| 2540 | - int pStartLine = p.getLineNumber(); | ||
| 2541 | - int pEndOffset = p.getStopOffset(); | ||
| 2542 | - int pEndLine = textArea.getLineOfOffset(pEndOffset); | ||
| 2543 | - if (line >= pStartLine && line <= pEndLine) { | ||
| 2544 | - return p; | ||
| 2545 | - } | ||
| 2546 | - } | ||
| 2547 | - return null; | ||
| 2537 | + return problems.stream() | ||
| 2538 | + .filter(p -> p.getTabIndex() == currentTab) | ||
| 2539 | + .filter(p -> { | ||
| 2540 | + int pStartLine = p.getLineNumber(); | ||
| 2541 | + int pEndOffset = p.getStopOffset(); | ||
| 2542 | + int pEndLine = textArea.getLineOfOffset(pEndOffset); | ||
| 2543 | + return line >= pStartLine && line <= pEndLine; | ||
| 2544 | + }) | ||
| 2545 | + .findFirst() | ||
| 2546 | + .orElse(null); | ||
| 2547 | + } | ||
| 2548 | + | ||
| 2549 | + | ||
| 2550 | + public List<Problem> findProblems(int line) { | ||
| 2551 | + JavaTextArea textArea = getJavaTextArea(); | ||
| 2552 | + int currentTab = getSketch().getCurrentCodeIndex(); | ||
| 2553 | + return problems.stream() | ||
| 2554 | + .filter(p -> p.getTabIndex() == currentTab) | ||
| 2555 | + .filter(p -> { | ||
| 2556 | + int pStartLine = p.getLineNumber(); | ||
| 2557 | + int pEndOffset = p.getStopOffset(); | ||
| 2558 | + int pEndLine = textArea.getLineOfOffset(pEndOffset); | ||
| 2559 | + return line >= pStartLine && line <= pEndLine; | ||
| 2560 | + }) | ||
| 2561 | + .collect(Collectors.toList()); | ||
| 2548 | 2562 | } | |
| 2549 | 2563 | ||
| 2550 | 2564 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -272,8 +272,8 @@ static private String trimRight(String str) { | |||
| 272 | 272 | * @param x | |
| 273 | 273 | */ | |
| 274 | 274 | protected void paintErrorLine(Graphics gfx, int line, int x) { | |
| 275 | - Problem problem = getJavaEditor().findError(line); | ||
| 276 | - if (problem != null) { | ||
| 275 | + List<Problem> problems = getJavaEditor().findProblems(line); | ||
| 276 | + for (Problem problem : problems) { | ||
| 277 | 277 | int startOffset = problem.getStartOffset(); | |
| 278 | 278 | int stopOffset = problem.getStopOffset(); | |
| 279 | 279 | ||
@@ -362,8 +362,8 @@ public void setMode(Mode mode) { | |||
| 362 | 362 | public String getToolTipText(MouseEvent evt) { | |
| 363 | 363 | int line = evt.getY() / getFontMetrics().getHeight() + textArea.getFirstLine(); | |
| 364 | 364 | if (line >= 0 || line < textArea.getLineCount()) { | |
| 365 | - Problem problem = getJavaEditor().findError(line); | ||
| 366 | - if (problem != null) { | ||
| 365 | + List<Problem> problems = getJavaEditor().findProblems(line); | ||
| 366 | + for (Problem problem : problems) { | ||
| 367 | 367 | int lineStart = textArea.getLineStartOffset(line); | |
| 368 | 368 | int lineEnd = textArea.getLineStopOffset(line); | |
| 369 | 369 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments