From 4abeea31d278ca75ceb483b5965a7f5a39cf753e Mon Sep 17 00:00:00 2001 From: 0verEngineer Date: Thu, 18 May 2023 19:28:09 +0200 Subject: [PATCH 01/14] Refactoring and performance improvements --- .../DocumentMarkupModelScanner.java | 44 +++++++------------ .../inlineproblems/ListenerManager.java | 5 +-- .../inlineproblems/ProblemManager.java | 37 ++++++---------- .../listeners/MarkupModelProblemListener.java | 31 ++++++++++--- 4 files changed, 55 insertions(+), 62 deletions(-) diff --git a/src/main/java/org/overengineer/inlineproblems/DocumentMarkupModelScanner.java b/src/main/java/org/overengineer/inlineproblems/DocumentMarkupModelScanner.java index 009b455..75a77d1 100644 --- a/src/main/java/org/overengineer/inlineproblems/DocumentMarkupModelScanner.java +++ b/src/main/java/org/overengineer/inlineproblems/DocumentMarkupModelScanner.java @@ -33,9 +33,6 @@ public class DocumentMarkupModelScanner { private int delayMilliseconds = HighlightProblemListener.ADDITIONAL_MANUAL_SCAN_DELAY_MILLIS; - // Used to bypass the listener setting - private boolean isManualScanEnabled = true; - private static DocumentMarkupModelScanner instance; private ScheduledFuture scheduledFuture; @@ -108,52 +105,43 @@ private List getProblemsInEditor(TextEditor textEditor) { ); Arrays.stream(highlighters) - .filter(RangeMarker::isValid) .filter(h -> { - if (h.getErrorStripeTooltip() instanceof HighlightInfo) { + if (h.isValid() && h.getErrorStripeTooltip() instanceof HighlightInfo) { HighlightInfo highlightInfo = (HighlightInfo) h.getErrorStripeTooltip(); return highlightInfo.getDescription() != null && !highlightInfo.getDescription().isEmpty() && problemTextBeginningFilterList.stream() - .noneMatch(f -> highlightInfo.getDescription().stripLeading().toLowerCase().startsWith(f.toLowerCase())); + .noneMatch(f -> highlightInfo.getDescription().stripLeading().toLowerCase().startsWith(f.toLowerCase())) && + fileEndOffset >= highlightInfo.getStartOffset() + ; } return false; }) .forEach(h -> { HighlightInfo highlightInfo = (HighlightInfo) h.getErrorStripeTooltip(); - if (fileEndOffset >= highlightInfo.getStartOffset()) { - int line = document.getLineNumber(highlightInfo.getStartOffset()); - InlineProblem newProblem = new InlineProblem( - line, - highlightInfo, - textEditor, - h - ); + InlineProblem newProblem = new InlineProblem( + document.getLineNumber(highlightInfo.getStartOffset()), + highlightInfo, + textEditor, + h + ); - problems.add(newProblem); - } + problems.add(newProblem); }); return problems; } - public void setIsManualScanEnabled(boolean isEnabled) { - isManualScanEnabled = isEnabled; - - if (isEnabled && scheduledFuture.isCancelled()) { - createAndStartScheduledFuture(); - } - else if (!isEnabled && !scheduledFuture.isCancelled()) { - cancelScheduledFuture(); - } + public void restartManualScan() { + cancelScheduledFuture(); + createAndStartScheduledFuture(); } public void setDelayMilliseconds(int newDelayMilliseconds) { delayMilliseconds = newDelayMilliseconds; - cancelScheduledFuture(); - createAndStartScheduledFuture(); + restartManualScan(); } private void cancelScheduledFuture() { @@ -167,7 +155,7 @@ private void cancelScheduledFuture() { private void createAndStartScheduledFuture() { scheduledFuture = AppExecutorUtil.getAppScheduledExecutorService().scheduleWithFixedDelay( () -> ApplicationManager.getApplication().invokeLater(this::scanForProblemsManually), - 0, + 2000, delayMilliseconds, TimeUnit.MILLISECONDS ); diff --git a/src/main/java/org/overengineer/inlineproblems/ListenerManager.java b/src/main/java/org/overengineer/inlineproblems/ListenerManager.java index 7afa89d..2ab9873 100644 --- a/src/main/java/org/overengineer/inlineproblems/ListenerManager.java +++ b/src/main/java/org/overengineer/inlineproblems/ListenerManager.java @@ -59,16 +59,15 @@ public void changeListener() { } if (settings.getEnabledListener() == Listener.MARKUP_MODEL_LISTENER) { - documentMarkupModelScanner.setIsManualScanEnabled(false); installMarkupModelListenerOnAllProjects(); } else if (settings.getEnabledListener() == Listener.HIGHLIGHT_PROBLEMS_LISTENER) { - documentMarkupModelScanner.setIsManualScanEnabled(true); documentMarkupModelScanner.setDelayMilliseconds(HighlightProblemListener.ADDITIONAL_MANUAL_SCAN_DELAY_MILLIS); } else if (settings.getEnabledListener() == Listener.MANUAL_SCANNING) { - documentMarkupModelScanner.setIsManualScanEnabled(true); documentMarkupModelScanner.setDelayMilliseconds(DocumentMarkupModelScanner.MANUAL_SCAN_DELAY_MILLIS); } + + documentMarkupModelScanner.restartManualScan(); } } diff --git a/src/main/java/org/overengineer/inlineproblems/ProblemManager.java b/src/main/java/org/overengineer/inlineproblems/ProblemManager.java index 7edb55f..cf16a7b 100644 --- a/src/main/java/org/overengineer/inlineproblems/ProblemManager.java +++ b/src/main/java/org/overengineer/inlineproblems/ProblemManager.java @@ -5,6 +5,7 @@ import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.editor.Editor; import com.intellij.openapi.project.Project; +import lombok.Getter; import org.overengineer.inlineproblems.entities.DrawDetails; import org.overengineer.inlineproblems.entities.InlineProblem; import org.overengineer.inlineproblems.settings.SettingsState; @@ -14,6 +15,7 @@ public class ProblemManager implements Disposable { + @Getter private final List activeProblems = new ArrayList<>(); private final InlineDrawer inlineDrawer = new InlineDrawer(); @@ -27,20 +29,13 @@ public void dispose() { } public void removeProblem(InlineProblem problem) { - InlineProblem problemToRemove = findActiveProblemByRangeHighlighterHashCode(problem.getRangeHighlighterHashCode()); - if (problemToRemove == null) { - logger.warn("Removal of problem failed, not found by RangeHighlighterHashCode"); - resetForEditor(problem.getTextEditor().getEditor()); - return; - } + inlineDrawer.undrawErrorLineHighlight(problem); + inlineDrawer.undrawInlineProblemLabel(problem); - inlineDrawer.undrawErrorLineHighlight(problemToRemove); - inlineDrawer.undrawInlineProblemLabel(problemToRemove); - - if (!activeProblems.remove(problemToRemove)) { + if (!activeProblems.remove(problem)) { logger.warn("Removal of problem failed, resetting"); - resetForEditor(problemToRemove.getTextEditor().getEditor()); + resetForEditor(problem.getTextEditor().getEditor()); return; } } @@ -118,9 +113,7 @@ public void resetForEditor(Editor editor) { } public void updateFromNewActiveProblems(List problems) { - final List activeProblemsSnapShot = List.copyOf(activeProblems); - - updateFromNewActiveProblems(problems, activeProblemsSnapShot); + updateFromNewActiveProblems(problems, List.copyOf(activeProblems)); } public void updateFromNewActiveProblemsForProjectAndFile(List problems, Project project, String filePath) { @@ -143,7 +136,7 @@ private List getProblemsInLineForProblem(InlineProblem problem) { * this function needs to be used. */ private void updateFromNewActiveProblems(List newProblems, List activeProblemsSnapShot) { - final List processedProblems = new ArrayList<>(); + final List processedProblemHashCodes = new ArrayList<>(); List usedProblems; if (settingsState.isShowOnlyHighestSeverityPerLine()) { @@ -171,17 +164,13 @@ private void updateFromNewActiveProblems(List newProblems, List !usedProblems.contains(p)) - .forEach(p -> {processedProblems.add(p); removeProblem(p);}); + .forEach(p -> { + processedProblemHashCodes.add(p.hashCode()); + removeProblem(p); + }); usedProblems.stream() - .filter(p -> !activeProblemsSnapShot.contains(p) && !processedProblems.contains(p)) + .filter(p -> !activeProblemsSnapShot.contains(p) && !processedProblemHashCodes.contains(p.hashCode())) .forEach(this::addProblem); } - - private InlineProblem findActiveProblemByRangeHighlighterHashCode(int hashCode) { - return activeProblems.stream() - .filter(p -> p.getRangeHighlighterHashCode() == hashCode) - .findFirst() - .orElse(null); - } } diff --git a/src/main/java/org/overengineer/inlineproblems/listeners/MarkupModelProblemListener.java b/src/main/java/org/overengineer/inlineproblems/listeners/MarkupModelProblemListener.java index a6034d8..e69d634 100644 --- a/src/main/java/org/overengineer/inlineproblems/listeners/MarkupModelProblemListener.java +++ b/src/main/java/org/overengineer/inlineproblems/listeners/MarkupModelProblemListener.java @@ -27,7 +27,6 @@ public class MarkupModelProblemListener implements MarkupModelListener { private final SettingsState settingsState; private final ProblemManager problemManager; - private final String filePath; private final TextEditor textEditor; private static final List disposables = new ArrayList<>(); @@ -42,7 +41,6 @@ private MarkupModelProblemListener( final TextEditor textEditor ) { this.textEditor = textEditor; - this.filePath = textEditor.getFile().getPath(); problemManager = ApplicationManager.getApplication().getService(ProblemManager.class); settingsState = SettingsState.getInstance(); @@ -134,11 +132,23 @@ private void handleEvent(EventType type, @NotNull RangeHighlighterEx highlighter return; } - InlineProblem problem = constructProblem( - editor.getDocument().getLineNumber(highlighter.getStartOffset()), - (HighlightInfo) highlighter.getErrorStripeTooltip(), - highlighter - ); + InlineProblem problem; + + if (type == EventType.ADD) { + problem = constructProblem( + editor.getDocument().getLineNumber(highlighter.getStartOffset()), + (HighlightInfo) highlighter.getErrorStripeTooltip(), + highlighter + ); + } + else { + // todo test in Rider with Unity + problem = findActiveProblemByRangeHighlighterHashCode(highlighter.hashCode()); + + if (problem == null) { + return; + } + } List problemTextBeginningFilterList = new ArrayList<>( Arrays.asList(SettingsState.getInstance().getProblemFilterList().split(";")) @@ -174,4 +184,11 @@ private InlineProblem constructProblem(int line, HighlightInfo info, RangeHighli highlighter ); } + + private InlineProblem findActiveProblemByRangeHighlighterHashCode(int hashCode) { + return problemManager.getActiveProblems().stream() + .filter(p -> p.getRangeHighlighterHashCode() == hashCode) + .findFirst() + .orElse(null); + } } From d8f5ebd9bf25e7c0d7fa5b25fdcdc5b917377c2e Mon Sep 17 00:00:00 2001 From: 0verEngineer Date: Thu, 18 May 2023 22:05:04 +0200 Subject: [PATCH 02/14] Adds description to for the different listeners, adds configurable manual scanner delay --- .../DocumentMarkupModelScanner.java | 4 +-- .../inlineproblems/ListenerManager.java | 3 ++- .../listeners/MarkupModelProblemListener.java | 1 - .../settings/SettingsComponent.java | 27 +++++++++++++++++++ .../settings/SettingsConfigurable.java | 11 ++++++++ .../settings/SettingsState.java | 1 + 6 files changed, 42 insertions(+), 5 deletions(-) diff --git a/src/main/java/org/overengineer/inlineproblems/DocumentMarkupModelScanner.java b/src/main/java/org/overengineer/inlineproblems/DocumentMarkupModelScanner.java index 75a77d1..8845b2a 100644 --- a/src/main/java/org/overengineer/inlineproblems/DocumentMarkupModelScanner.java +++ b/src/main/java/org/overengineer/inlineproblems/DocumentMarkupModelScanner.java @@ -39,8 +39,6 @@ public class DocumentMarkupModelScanner { public static final String NAME = "ManualScanner"; - public static final int MANUAL_SCAN_DELAY_MILLIS = 250; - public static DocumentMarkupModelScanner getInstance() { if (instance == null) instance = new DocumentMarkupModelScanner(); @@ -50,7 +48,7 @@ public static DocumentMarkupModelScanner getInstance() { private DocumentMarkupModelScanner() { if (settingsState.getEnabledListener() == Listener.MANUAL_SCANNING) { - delayMilliseconds = MANUAL_SCAN_DELAY_MILLIS; + delayMilliseconds = settingsState.getManualScannerDelay(); } createAndStartScheduledFuture(); diff --git a/src/main/java/org/overengineer/inlineproblems/ListenerManager.java b/src/main/java/org/overengineer/inlineproblems/ListenerManager.java index 2ab9873..a00f2b1 100644 --- a/src/main/java/org/overengineer/inlineproblems/ListenerManager.java +++ b/src/main/java/org/overengineer/inlineproblems/ListenerManager.java @@ -59,13 +59,14 @@ public void changeListener() { } if (settings.getEnabledListener() == Listener.MARKUP_MODEL_LISTENER) { + documentMarkupModelScanner.setDelayMilliseconds(HighlightProblemListener.ADDITIONAL_MANUAL_SCAN_DELAY_MILLIS); installMarkupModelListenerOnAllProjects(); } else if (settings.getEnabledListener() == Listener.HIGHLIGHT_PROBLEMS_LISTENER) { documentMarkupModelScanner.setDelayMilliseconds(HighlightProblemListener.ADDITIONAL_MANUAL_SCAN_DELAY_MILLIS); } else if (settings.getEnabledListener() == Listener.MANUAL_SCANNING) { - documentMarkupModelScanner.setDelayMilliseconds(DocumentMarkupModelScanner.MANUAL_SCAN_DELAY_MILLIS); + documentMarkupModelScanner.setDelayMilliseconds(settings.getManualScannerDelay()); } documentMarkupModelScanner.restartManualScan(); diff --git a/src/main/java/org/overengineer/inlineproblems/listeners/MarkupModelProblemListener.java b/src/main/java/org/overengineer/inlineproblems/listeners/MarkupModelProblemListener.java index e69d634..87e47da 100644 --- a/src/main/java/org/overengineer/inlineproblems/listeners/MarkupModelProblemListener.java +++ b/src/main/java/org/overengineer/inlineproblems/listeners/MarkupModelProblemListener.java @@ -142,7 +142,6 @@ private void handleEvent(EventType type, @NotNull RangeHighlighterEx highlighter ); } else { - // todo test in Rider with Unity problem = findActiveProblemByRangeHighlighterHashCode(highlighter.hashCode()); if (problem == null) { diff --git a/src/main/java/org/overengineer/inlineproblems/settings/SettingsComponent.java b/src/main/java/org/overengineer/inlineproblems/settings/SettingsComponent.java index eebe746..943ffc5 100644 --- a/src/main/java/org/overengineer/inlineproblems/settings/SettingsComponent.java +++ b/src/main/java/org/overengineer/inlineproblems/settings/SettingsComponent.java @@ -49,6 +49,7 @@ public class SettingsComponent { private final JBCheckBox showOnlyHighestSeverityPerLine = new JBCheckBox("Show only the problem with the highest severity per line"); private final JFormattedTextField inlayFontSizeDeltaText; + private final JFormattedTextField manualScannerDelay; private final JBCheckBox fillProblemLabels = new JBCheckBox("Fill problem label background"); private final JBCheckBox boldProblemLabels = new JBCheckBox("Bold problem labels"); private final JBCheckBox italicProblemLabels = new JBCheckBox("Italic problem labels"); @@ -99,12 +100,16 @@ public SettingsComponent() { useEditorFont.setSelected(settingsState.isUseEditorFont()); NumberFormat intFormat = NumberFormat.getIntegerInstance(); + intFormat.setGroupingUsed(false); NumberFormatter numberFormatter = new NumberFormatter(intFormat); numberFormatter.setValueClass(Integer.class); // Optional, ensures we always get a int value inlayFontSizeDeltaText = new JFormattedTextField(numberFormatter); inlayFontSizeDeltaText.setText(Integer.toString(settingsState.getInlayFontSizeDelta())); + manualScannerDelay = new JFormattedTextField(numberFormatter); + manualScannerDelay.setText(Integer.toString(settingsState.getManualScannerDelay())); + fillProblemLabels.setSelected(settingsState.isFillProblemLabels()); boldProblemLabels.setSelected(settingsState.isBoldProblemLabels()); italicProblemLabels.setSelected(settingsState.isItalicProblemLabels()); @@ -131,6 +136,11 @@ public SettingsComponent() { .addSeparator() .addComponent(new JBLabel("General")) .addLabeledComponent(new JBLabel("Enabled problem listener"), enabledListener) + .addTooltip("HighlightProblemListener: Faster on small to medium sized files, slower on large ones (uses more cpu power than MarkupModelListener)") + .addTooltip("MarkupModelListener: Faster on large files, slower on small ones") + .addTooltip("ManualScanner: Same as the HighlightProblemListener but called at a fixed delay") + .addLabeledComponent(new JBLabel("ManualScanner delay in milliseconds"), manualScannerDelay) + .addTooltip("Delay between manual scans, only used when ManualScanner is enabled") .addComponent(forceErrorsInSameLine, 0) .addComponent(useEditorFont, 0) .addComponent(showOnlyHighestSeverityPerLine, 0) @@ -225,6 +235,10 @@ public int getInlayFontSizeDelta() { return val; } + public void setInlayFontSizeDelta(int val) { + inlayFontSizeDeltaText.setText(String.valueOf(Math.max(0, val))); + } + public void setUseEditorFont(boolean isSelected) { useEditorFont.setSelected(isSelected); } @@ -496,4 +510,17 @@ private List getSeverityIntegerList(String text) { .map(Integer::parseInt) .collect(Collectors.toList()); } + + public int getManualScannerDelay() { + try { + return Math.max(Integer.parseInt(manualScannerDelay.getText()), 0); + } + catch (NumberFormatException e) { + return 0; + } + } + + public void setManualScannerDelay(int delay) { + manualScannerDelay.setText(Integer.toString(Math.max(0, delay))); + } } diff --git a/src/main/java/org/overengineer/inlineproblems/settings/SettingsConfigurable.java b/src/main/java/org/overengineer/inlineproblems/settings/SettingsConfigurable.java index 4238d8b..cc50247 100644 --- a/src/main/java/org/overengineer/inlineproblems/settings/SettingsConfigurable.java +++ b/src/main/java/org/overengineer/inlineproblems/settings/SettingsConfigurable.java @@ -3,7 +3,9 @@ import com.intellij.openapi.options.Configurable; import com.intellij.openapi.util.NlsContexts; import org.jetbrains.annotations.Nullable; +import org.overengineer.inlineproblems.DocumentMarkupModelScanner; import org.overengineer.inlineproblems.ListenerManager; +import org.overengineer.inlineproblems.entities.enums.Listener; import javax.swing.*; @@ -73,6 +75,7 @@ public boolean isModified() { state.isShowInfos() == settingsComponent.isShowInfos() && state.isHighlightInfos() == settingsComponent.isHighlightInfo() && state.getEnabledListener() == settingsComponent.getEnabledListener() && + state.getManualScannerDelay() == settingsComponent.getManualScannerDelay() && state.getProblemFilterList().equals(settingsComponent.getProblemFilterList()) && @@ -90,6 +93,7 @@ public void apply() { SettingsState state = SettingsState.getInstance(); boolean listenerChanged = state.getEnabledListener() != settingsComponent.getEnabledListener(); + boolean manualScannerDelayChanged = state.getManualScannerDelay() != settingsComponent.getManualScannerDelay(); state.setShowErrors(settingsComponent.isShowErrors()); state.setHighlightErrors(settingsComponent.isHighlightErrors()); @@ -126,6 +130,7 @@ public void apply() { state.setItalicProblemLabels(settingsComponent.isItalicProblemLabels()); state.setEnabledListener(settingsComponent.getEnabledListener()); + state.setManualScannerDelay(settingsComponent.getManualScannerDelay()); state.setProblemFilterList(settingsComponent.getProblemFilterList()); state.setAdditionalInfoSeverities(settingsComponent.getAdditionalInfoSeveritiesList()); @@ -133,6 +138,10 @@ public void apply() { state.setAdditionalWeakWarningSeverities(settingsComponent.getAdditionalWeakWarningSeveritiesList()); state.setAdditionalErrorSeverities(settingsComponent.getAdditionalErrorSeveritiesList()); + if (manualScannerDelayChanged && state.getEnabledListener() == Listener.MANUAL_SCANNING) { + DocumentMarkupModelScanner.getInstance().setDelayMilliseconds(state.getManualScannerDelay()); + } + listenerManager.resetAndRescan(); if (listenerChanged) { @@ -173,11 +182,13 @@ public void reset() { settingsComponent.setRoundedCornerBoxes(state.isRoundedCornerBoxes()); settingsComponent.setUseEditorFont(state.isUseEditorFont()); settingsComponent.setShowOnlyHighestSeverityPerLine(state.isShowOnlyHighestSeverityPerLine()); + settingsComponent.setInlayFontSizeDelta(state.getInlayFontSizeDelta()); settingsComponent.setFillProblemLabels(state.isFillProblemLabels()); settingsComponent.setBoldProblemLabels(state.isBoldProblemLabels()); settingsComponent.setItalicProblemLabels(state.isItalicProblemLabels()); settingsComponent.setEnabledListener(state.getEnabledListener()); + settingsComponent.setManualScannerDelay(state.getManualScannerDelay()); settingsComponent.setProblemFilterList(state.getProblemFilterList()); settingsComponent.setAdditionalInfoSeverities(state.getAdditionalInfoSeveritiesAsString()); diff --git a/src/main/java/org/overengineer/inlineproblems/settings/SettingsState.java b/src/main/java/org/overengineer/inlineproblems/settings/SettingsState.java index ba1db65..11e826d 100644 --- a/src/main/java/org/overengineer/inlineproblems/settings/SettingsState.java +++ b/src/main/java/org/overengineer/inlineproblems/settings/SettingsState.java @@ -80,6 +80,7 @@ public class SettingsState implements PersistentStateComponent { @OptionTag(converter = ColorConverter.class) private Color infoHighlightCol = infoBackgroundCol; + private int manualScannerDelay = 250; private boolean drawBoxesAroundErrorLabels = true; private boolean roundedCornerBoxes = true; private boolean forceProblemsInSameLine = true; From eef4ab1d937a22e60bcf150beb86d9d13ba72f6b Mon Sep 17 00:00:00 2001 From: 0verEngineer Date: Thu, 18 May 2023 23:15:03 +0200 Subject: [PATCH 03/14] Refactoring and warning fixes --- .../DocumentMarkupModelScanner.java | 16 +++++++++--- .../inlineproblems/InlineProblemLabel.java | 9 ++----- .../entities/InlineProblem.java | 3 ++- .../listeners/MarkupModelProblemListener.java | 26 +++++++------------ .../listeners/PluginListener.java | 2 +- 5 files changed, 27 insertions(+), 29 deletions(-) diff --git a/src/main/java/org/overengineer/inlineproblems/DocumentMarkupModelScanner.java b/src/main/java/org/overengineer/inlineproblems/DocumentMarkupModelScanner.java index 8845b2a..a8d6eb7 100644 --- a/src/main/java/org/overengineer/inlineproblems/DocumentMarkupModelScanner.java +++ b/src/main/java/org/overengineer/inlineproblems/DocumentMarkupModelScanner.java @@ -5,7 +5,6 @@ import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.editor.Document; import com.intellij.openapi.editor.Editor; -import com.intellij.openapi.editor.RangeMarker; import com.intellij.openapi.editor.impl.DocumentMarkupModel; import com.intellij.openapi.editor.markup.RangeHighlighter; import com.intellij.openapi.fileEditor.FileEditorManager; @@ -27,8 +26,6 @@ public class DocumentMarkupModelScanner { private final ProblemManager problemManager = ApplicationManager.getApplication().getService(ProblemManager.class); - private final SettingsState settingsState = SettingsState.getInstance(); - private final Logger logger = Logger.getInstance(DocumentMarkupModelScanner.class); private int delayMilliseconds = HighlightProblemListener.ADDITIONAL_MANUAL_SCAN_DELAY_MILLIS; @@ -47,6 +44,7 @@ public static DocumentMarkupModelScanner getInstance() { } private DocumentMarkupModelScanner() { + SettingsState settingsState = SettingsState.getInstance(); if (settingsState.getEnabledListener() == Listener.MANUAL_SCANNING) { delayMilliseconds = settingsState.getManualScannerDelay(); } @@ -64,7 +62,11 @@ public void scanForProblemsManually() { FileEditorManager fileEditorManager = FileEditorManager.getInstance(project); for (var editor : fileEditorManager.getAllEditors()) { if (editor instanceof TextEditor) { - problems.addAll(getProblemsInEditor((TextEditor) editor)); + var textEditor = (TextEditor) editor; + if (textEditor.getFile() == null) { + continue; + } + problems.addAll(getProblemsInEditor(textEditor)); } } } @@ -74,7 +76,12 @@ public void scanForProblemsManually() { } public void scanForProblemsManuallyInTextEditor(TextEditor textEditor) { + if (textEditor.getFile() == null) { + return; + } + List problems = getProblemsInEditor(textEditor); + problemManager.updateFromNewActiveProblemsForProjectAndFile( problems, textEditor.getEditor().getProject(), @@ -121,6 +128,7 @@ private List getProblemsInEditor(TextEditor textEditor) { InlineProblem newProblem = new InlineProblem( document.getLineNumber(highlightInfo.getStartOffset()), + textEditor.getFile().getPath(), highlightInfo, textEditor, h diff --git a/src/main/java/org/overengineer/inlineproblems/InlineProblemLabel.java b/src/main/java/org/overengineer/inlineproblems/InlineProblemLabel.java index 62e53ff..2024bab 100644 --- a/src/main/java/org/overengineer/inlineproblems/InlineProblemLabel.java +++ b/src/main/java/org/overengineer/inlineproblems/InlineProblemLabel.java @@ -33,8 +33,8 @@ public class InlineProblemLabel implements EditorCustomElementRenderer { @Setter private boolean isBlockElement; - private int inlayFontSizeDelta; - private boolean isUseEditorFont = false; + private final int inlayFontSizeDelta; + private final boolean isUseEditorFont; private static final int WIDTH_OFFSET = 7; private static final int DRAW_BOX_HEIGHT_OFFSET = -2; // Makes the box lines visible even if line below / above is highlighted @@ -77,11 +77,6 @@ public int calcWidthInPixels(@NotNull Editor editor) { return fontMetrics.stringWidth(text) + WIDTH_OFFSET; } - @Override - public int calcHeightInPixels(@NotNull Inlay inlay) { - return inlay.getEditor().getLineHeight(); - } - @Override public void paint(@NotNull Inlay inlay, @NotNull Graphics graphics, @NotNull Rectangle targetRegion, @NotNull TextAttributes textAttributes) { Editor editor = inlay.getEditor(); diff --git a/src/main/java/org/overengineer/inlineproblems/entities/InlineProblem.java b/src/main/java/org/overengineer/inlineproblems/entities/InlineProblem.java index 261ee4d..de3a3c4 100644 --- a/src/main/java/org/overengineer/inlineproblems/entities/InlineProblem.java +++ b/src/main/java/org/overengineer/inlineproblems/entities/InlineProblem.java @@ -44,6 +44,7 @@ public class InlineProblem { public InlineProblem( int line, + String filePath, HighlightInfo highlightInfo, TextEditor textEditor, RangeHighlighter rangeHighlighter @@ -58,7 +59,7 @@ public InlineProblem( this.text = usedText; this.severity = highlightInfo.getSeverity().myVal; this.textEditor = textEditor; - this.file = textEditor.getFile().getPath(); + this.file = filePath; this.project = textEditor.getEditor().getProject(); this.highlightInfoStartOffset = highlightInfo.hashCode(); this.rangeHighlighterHashCode = rangeHighlighter.hashCode(); diff --git a/src/main/java/org/overengineer/inlineproblems/listeners/MarkupModelProblemListener.java b/src/main/java/org/overengineer/inlineproblems/listeners/MarkupModelProblemListener.java index 87e47da..16ad167 100644 --- a/src/main/java/org/overengineer/inlineproblems/listeners/MarkupModelProblemListener.java +++ b/src/main/java/org/overengineer/inlineproblems/listeners/MarkupModelProblemListener.java @@ -8,7 +8,6 @@ import com.intellij.openapi.editor.ex.RangeHighlighterEx; import com.intellij.openapi.editor.impl.DocumentMarkupModel; import com.intellij.openapi.editor.impl.event.MarkupModelListener; -import com.intellij.openapi.editor.markup.RangeHighlighter; import com.intellij.openapi.fileEditor.TextEditor; import com.intellij.openapi.util.Disposer; import org.jetbrains.annotations.NotNull; @@ -94,7 +93,7 @@ private void handleEvent(EventType type, @NotNull RangeHighlighterEx highlighter Editor editor = textEditor.getEditor(); - if (editor.isDisposed()) + if (editor.isDisposed() || textEditor.getFile() == null) return; int lineCount = editor.getDocument().getLineCount(); @@ -123,9 +122,7 @@ private void handleEvent(EventType type, @NotNull RangeHighlighterEx highlighter ) { /* If scanForProblemsManuallyInTextEditor is called directly, problems that should be already removed are still there and will be found and thus not removed as they should */ - ApplicationManager.getApplication().invokeLater(() -> { - DocumentMarkupModelScanner.getInstance().scanForProblemsManuallyInTextEditor(textEditor); - }); + ApplicationManager.getApplication().invokeLater(() -> DocumentMarkupModelScanner.getInstance().scanForProblemsManuallyInTextEditor(textEditor)); return; } @@ -135,9 +132,15 @@ private void handleEvent(EventType type, @NotNull RangeHighlighterEx highlighter InlineProblem problem; if (type == EventType.ADD) { - problem = constructProblem( + var highlightInfo = (HighlightInfo) highlighter.getErrorStripeTooltip(); + if (highlightInfo == null) + return; + + problem = new InlineProblem( editor.getDocument().getLineNumber(highlighter.getStartOffset()), - (HighlightInfo) highlighter.getErrorStripeTooltip(), + textEditor.getFile().getPath(), + highlightInfo, + textEditor, highlighter ); } @@ -175,15 +178,6 @@ private void handleEvent(EventType type, @NotNull RangeHighlighterEx highlighter } } - private InlineProblem constructProblem(int line, HighlightInfo info, RangeHighlighter highlighter) { - return new InlineProblem( - line, - info, - textEditor, - highlighter - ); - } - private InlineProblem findActiveProblemByRangeHighlighterHashCode(int hashCode) { return problemManager.getActiveProblems().stream() .filter(p -> p.getRangeHighlighterHashCode() == hashCode) diff --git a/src/main/java/org/overengineer/inlineproblems/listeners/PluginListener.java b/src/main/java/org/overengineer/inlineproblems/listeners/PluginListener.java index e95f2d2..e7639cb 100644 --- a/src/main/java/org/overengineer/inlineproblems/listeners/PluginListener.java +++ b/src/main/java/org/overengineer/inlineproblems/listeners/PluginListener.java @@ -12,7 +12,7 @@ public class PluginListener implements DynamicPluginListener { - private SettingsState settingsState = SettingsState.getInstance(); + private final SettingsState settingsState = SettingsState.getInstance(); private final ListenerManager listenerManager = ListenerManager.getInstance(); From 2010ea3472aaf629c7d5362506480844d46d89fc Mon Sep 17 00:00:00 2001 From: 0verEngineer Date: Thu, 18 May 2023 23:23:44 +0200 Subject: [PATCH 04/14] Bump version and add changelog for 0.4.3 --- CHANGELOG.md | 12 ++++++++++++ gradle.properties | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 21ee337..61725bb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,16 @@ ## [Unreleased] +## [0.4.3] + +### Added +- Some performance improvements +- Description for the listeners in the settings +- Configurable delay for the manual scan listener + +### Fixed +- Some possible null pointer exeptions + ## [0.4.2] ### Added @@ -95,6 +105,8 @@ - Initial release with basic functionality [Unreleased]: https://github.com/OverEngineer/InlineProblems/compare/v0.4.0...HEAD +[0.4.3]: https://github.com/0verEngineer/InlineProblems/compare/v0.4.2...v0.4.3 +[0.4.2]: https://github.com/0verEngineer/InlineProblems/compare/v0.4.0...v0.4.2 [0.4.0]: https://github.com/0verEngineer/InlineProblems/compare/v0.3.3...v0.4.0 [0.3.3]: https://github.com/0verEngineer/InlineProblems/compare/0.3.2...v0.3.3 [0.3.2]: https://github.com/0verEngineer/InlineProblems/compare/0.3.1...0.3.2 diff --git a/gradle.properties b/gradle.properties index 31b25fc..15ea7db 100644 --- a/gradle.properties +++ b/gradle.properties @@ -2,7 +2,7 @@ pluginGroup = org.OverEngineer pluginName = InlineProblems pluginRepositoryUrl = https://github.com/OverEngineer/InlineProblems # SemVer format -> https://semver.org -pluginVersion = 0.4.2 +pluginVersion = 0.4.3 # Supported build number ranges and IntelliJ Platform versions -> https://plugins.jetbrains.com/docs/intellij/build-number-ranges.html pluginSinceBuild = 212.5 From 86fd6e0dc06a5d00e406fc3dcff20093da623d4c Mon Sep 17 00:00:00 2001 From: 0verEngineer Date: Thu, 18 May 2023 23:25:29 +0200 Subject: [PATCH 05/14] Update CHANGELOG.md - fix typo --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 61725bb..4a42df8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,7 +12,7 @@ - Configurable delay for the manual scan listener ### Fixed -- Some possible null pointer exeptions +- Some possible null pointer exceptions ## [0.4.2] From cbcc59103b18d52c4d1fa72e48f6b82bac504a69 Mon Sep 17 00:00:00 2001 From: 0verEngineer Date: Fri, 19 May 2023 11:23:40 +0200 Subject: [PATCH 06/14] Fixes 2 Qodana code issues --- .../org/overengineer/inlineproblems/InlineProblemLabel.java | 2 +- .../inlineproblems/listeners/MarkupModelProblemListener.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/overengineer/inlineproblems/InlineProblemLabel.java b/src/main/java/org/overengineer/inlineproblems/InlineProblemLabel.java index 2024bab..6adb7ab 100644 --- a/src/main/java/org/overengineer/inlineproblems/InlineProblemLabel.java +++ b/src/main/java/org/overengineer/inlineproblems/InlineProblemLabel.java @@ -91,7 +91,7 @@ public void paint(@NotNull Inlay inlay, @NotNull Graphics graphics, @NotNull Rec // Apply delta on the boxes if (inlayFontSizeDelta != 0 && editorFontSize > inlayFontSizeDelta) { - height = height - inlayFontSizeDelta; + height -= inlayFontSizeDelta; targetRegionY += (int)(inlayFontSizeDelta / 1.5); } diff --git a/src/main/java/org/overengineer/inlineproblems/listeners/MarkupModelProblemListener.java b/src/main/java/org/overengineer/inlineproblems/listeners/MarkupModelProblemListener.java index 16ad167..904a7e8 100644 --- a/src/main/java/org/overengineer/inlineproblems/listeners/MarkupModelProblemListener.java +++ b/src/main/java/org/overengineer/inlineproblems/listeners/MarkupModelProblemListener.java @@ -157,7 +157,7 @@ private void handleEvent(EventType type, @NotNull RangeHighlighterEx highlighter ); if ( - problem.getText().equals("") || + problem.getText().isEmpty() || problemTextBeginningFilterList.stream() .anyMatch(f -> problem.getText().toLowerCase().startsWith(f.toLowerCase())) ) { From 2c1d67deaa356e272750d08c2e5817019cc1907b Mon Sep 17 00:00:00 2001 From: 0verEngineer Date: Sat, 20 May 2023 14:30:51 +0200 Subject: [PATCH 07/14] Deprecates HighlightProblemListener and fixes invokeLater queuing for MarkupModelListener, also changes MarkupModelListener to the default --- .../DocumentMarkupModelScanner.java | 5 ++- .../listeners/HighlightProblemListener.java | 8 ++++- .../listeners/MarkupModelProblemListener.java | 4 ++- .../settings/SettingsComponent.java | 13 +++---- .../settings/SettingsState.java | 35 +++++++++++++++---- 5 files changed, 50 insertions(+), 15 deletions(-) diff --git a/src/main/java/org/overengineer/inlineproblems/DocumentMarkupModelScanner.java b/src/main/java/org/overengineer/inlineproblems/DocumentMarkupModelScanner.java index a8d6eb7..4016360 100644 --- a/src/main/java/org/overengineer/inlineproblems/DocumentMarkupModelScanner.java +++ b/src/main/java/org/overengineer/inlineproblems/DocumentMarkupModelScanner.java @@ -59,6 +59,9 @@ public void scanForProblemsManually() { List problems = new ArrayList<>(); for (var project : projectManager.getOpenProjects()) { + if (!project.isInitialized()) + continue; + FileEditorManager fileEditorManager = FileEditorManager.getInstance(project); for (var editor : fileEditorManager.getAllEditors()) { if (editor instanceof TextEditor) { @@ -160,7 +163,7 @@ private void cancelScheduledFuture() { private void createAndStartScheduledFuture() { scheduledFuture = AppExecutorUtil.getAppScheduledExecutorService().scheduleWithFixedDelay( - () -> ApplicationManager.getApplication().invokeLater(this::scanForProblemsManually), + () -> ApplicationManager.getApplication().invokeAndWait(this::scanForProblemsManually), 2000, delayMilliseconds, TimeUnit.MILLISECONDS diff --git a/src/main/java/org/overengineer/inlineproblems/listeners/HighlightProblemListener.java b/src/main/java/org/overengineer/inlineproblems/listeners/HighlightProblemListener.java index 71c968e..b3d7f15 100644 --- a/src/main/java/org/overengineer/inlineproblems/listeners/HighlightProblemListener.java +++ b/src/main/java/org/overengineer/inlineproblems/listeners/HighlightProblemListener.java @@ -17,7 +17,7 @@ public class HighlightProblemListener implements HighlightInfoFilter { private final DocumentMarkupModelScanner markupModelScanner = DocumentMarkupModelScanner.getInstance(); private final SettingsState settingsState = SettingsState.getInstance(); - public static final String NAME = "HighlightProblemListener"; + public static final String NAME = "HighlightProblemListener (Deprecated)"; public static final int ADDITIONAL_MANUAL_SCAN_DELAY_MILLIS = 2000; @Override @@ -28,6 +28,9 @@ public boolean accept(@NotNull HighlightInfo highlightInfo, @Nullable PsiFile fi if (file == null || !file.isValid()) return true; + // The HighlightProblemListener is deprecated because the accept function is called a lot of times per second + // and the invokeLater queues the invocations, so this is often called before handleAccept is finished. + // invokeAndWait also doesn't work because it can cause a deadlock. if (!file.getProject().isDisposed()) { ApplicationManager.getApplication().invokeLater(() -> handleAccept(file)); } @@ -36,6 +39,9 @@ public boolean accept(@NotNull HighlightInfo highlightInfo, @Nullable PsiFile fi } public void handleAccept(PsiFile file) { + if (settingsState.getEnabledListener() != Listener.HIGHLIGHT_PROBLEMS_LISTENER) + return; + if (file.getVirtualFile() == null) return; diff --git a/src/main/java/org/overengineer/inlineproblems/listeners/MarkupModelProblemListener.java b/src/main/java/org/overengineer/inlineproblems/listeners/MarkupModelProblemListener.java index 904a7e8..c60b7ce 100644 --- a/src/main/java/org/overengineer/inlineproblems/listeners/MarkupModelProblemListener.java +++ b/src/main/java/org/overengineer/inlineproblems/listeners/MarkupModelProblemListener.java @@ -122,7 +122,9 @@ private void handleEvent(EventType type, @NotNull RangeHighlighterEx highlighter ) { /* If scanForProblemsManuallyInTextEditor is called directly, problems that should be already removed are still there and will be found and thus not removed as they should */ - ApplicationManager.getApplication().invokeLater(() -> DocumentMarkupModelScanner.getInstance().scanForProblemsManuallyInTextEditor(textEditor)); + ApplicationManager.getApplication().invokeAndWait( + () -> DocumentMarkupModelScanner.getInstance().scanForProblemsManuallyInTextEditor(textEditor) + ); return; } diff --git a/src/main/java/org/overengineer/inlineproblems/settings/SettingsComponent.java b/src/main/java/org/overengineer/inlineproblems/settings/SettingsComponent.java index 943ffc5..0f327fb 100644 --- a/src/main/java/org/overengineer/inlineproblems/settings/SettingsComponent.java +++ b/src/main/java/org/overengineer/inlineproblems/settings/SettingsComponent.java @@ -136,9 +136,10 @@ public SettingsComponent() { .addSeparator() .addComponent(new JBLabel("General")) .addLabeledComponent(new JBLabel("Enabled problem listener"), enabledListener) - .addTooltip("HighlightProblemListener: Faster on small to medium sized files, slower on large ones (uses more cpu power than MarkupModelListener)") - .addTooltip("MarkupModelListener: Faster on large files, slower on small ones") - .addTooltip("ManualScanner: Same as the HighlightProblemListener but called at a fixed delay") + .addTooltip("- MarkupModelListener: Called after addition of a RangeHighlighter to a file. Faster on large files, slower on small ones") + .addTooltip("- ManualScanner: Scans the DocumentMarkupModel for all highlighters at a fixed delay") + .addTooltip("- HighlightProblemListener (DEPRECATED): Faster on small to medium sized files, slower on large ones.") + .addTooltip(" Called way to often and can cause freezes. If you want similar performance use the ManualScanner instead") .addLabeledComponent(new JBLabel("ManualScanner delay in milliseconds"), manualScannerDelay) .addTooltip("Delay between manual scans, only used when ManualScanner is enabled") .addComponent(forceErrorsInSameLine, 0) @@ -513,14 +514,14 @@ private List getSeverityIntegerList(String text) { public int getManualScannerDelay() { try { - return Math.max(Integer.parseInt(manualScannerDelay.getText()), 0); + return Math.max(Integer.parseInt(manualScannerDelay.getText()), 10); } catch (NumberFormatException e) { - return 0; + return 100; } } public void setManualScannerDelay(int delay) { - manualScannerDelay.setText(Integer.toString(Math.max(0, delay))); + manualScannerDelay.setText(Integer.toString(Math.max(10, delay))); } } diff --git a/src/main/java/org/overengineer/inlineproblems/settings/SettingsState.java b/src/main/java/org/overengineer/inlineproblems/settings/SettingsState.java index 11e826d..93536f6 100644 --- a/src/main/java/org/overengineer/inlineproblems/settings/SettingsState.java +++ b/src/main/java/org/overengineer/inlineproblems/settings/SettingsState.java @@ -80,7 +80,7 @@ public class SettingsState implements PersistentStateComponent { @OptionTag(converter = ColorConverter.class) private Color infoHighlightCol = infoBackgroundCol; - private int manualScannerDelay = 250; + private int manualScannerDelay = 200; private boolean drawBoxesAroundErrorLabels = true; private boolean roundedCornerBoxes = true; private boolean forceProblemsInSameLine = true; @@ -90,7 +90,7 @@ public class SettingsState implements PersistentStateComponent { private boolean boldProblemLabels = false; private boolean italicProblemLabels = false; private int problemLineLengthOffsetPixels = 50; - private int enabledListener = Listener.HIGHLIGHT_PROBLEMS_LISTENER; + private int enabledListener = Listener.MARKUP_MODEL_LISTENER; private String problemFilterList = "todo;fixme;open in browser"; private List additionalErrorSeverities = new ArrayList<>(); @@ -100,6 +100,10 @@ public class SettingsState implements PersistentStateComponent { private boolean showOnlyHighestSeverityPerLine = false; + // migration booleans + private boolean highlightProblemListenerDeprecateMigrationDone = false; + private boolean filterListMigrationDone01 = false; + public static SettingsState getInstance() { return ApplicationManager.getApplication().getService(SettingsState.class); } @@ -116,12 +120,31 @@ public void loadState(@NotNull SettingsState state) { migrateState(); } + @Override + public void noStateLoaded() { + migrateState(); + } + private void migrateState() { - List newFilterListEntries = List.of("Consider unknown contexts non-blocking"); - for (String entry : newFilterListEntries) { - if (!problemFilterList.contains(entry)) { - problemFilterList += ";" + entry; + // filter list + if (!filterListMigrationDone01) { + List newFilterListEntries = List.of("Consider unknown contexts non-blocking"); + for (String entry : newFilterListEntries) { + if (!problemFilterList.contains(entry)) { + problemFilterList += ";" + entry; + } } + + filterListMigrationDone01 = true; + } + + // listener + if (!highlightProblemListenerDeprecateMigrationDone) { + if (enabledListener == Listener.HIGHLIGHT_PROBLEMS_LISTENER) { + enabledListener = Listener.MARKUP_MODEL_LISTENER; + } + + highlightProblemListenerDeprecateMigrationDone = true; } } From f1c20abba68f776e7492c1b8f00aaff0508df258 Mon Sep 17 00:00:00 2001 From: 0verEngineer Date: Sat, 20 May 2023 14:31:03 +0200 Subject: [PATCH 08/14] Changelog update --- CHANGELOG.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4a42df8..8d4dee6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,8 +11,13 @@ - Description for the listeners in the settings - Configurable delay for the manual scan listener +### Changed +- HighlightProblemListener is now deprecated +- MarkupModelListener is now the default listener + ### Fixed - Some possible null pointer exceptions +- invokeLater queuing issue of MarkupModelListener if used with the only one problem per line feature ## [0.4.2] From c6b3dc52917b69a98d315e320d4eafde315b9fad Mon Sep 17 00:00:00 2001 From: 0verEngineer Date: Tue, 23 May 2023 18:38:29 +0200 Subject: [PATCH 09/14] Fixes broken problem update from MarkupModelListener --- .../inlineproblems/ProblemManager.java | 7 ++- .../listeners/MarkupModelProblemListener.java | 44 +++++++++---------- 2 files changed, 28 insertions(+), 23 deletions(-) diff --git a/src/main/java/org/overengineer/inlineproblems/ProblemManager.java b/src/main/java/org/overengineer/inlineproblems/ProblemManager.java index cf16a7b..d4417fc 100644 --- a/src/main/java/org/overengineer/inlineproblems/ProblemManager.java +++ b/src/main/java/org/overengineer/inlineproblems/ProblemManager.java @@ -59,7 +59,7 @@ public void addProblem(InlineProblem problem) { }); /* This only works when using a method reference, if we move the code from the addProblemPrivate func into a lambda - * it does not work like expected, that is because there are differences the evaluation and the way it is called */ + * it does not work like expected, that is because there are differences in the evaluation and the way it is called */ problemsInLine.forEach(this::addProblemPrivate); } @@ -68,6 +68,11 @@ private void addProblemPrivate(InlineProblem problem) { DrawDetails drawDetails = new DrawDetails(problem, problem.getTextEditor().getEditor()); + if (problem.getTextEditor().getEditor().getDocument().getLineCount() <= problem.getLine()) { + logger.warn("Line count is less or equal than problem line, problem not added"); + return; + } + inlineDrawer.drawProblemLabel(problem, drawDetails); inlineDrawer.drawProblemLineHighlight(problem, drawDetails); diff --git a/src/main/java/org/overengineer/inlineproblems/listeners/MarkupModelProblemListener.java b/src/main/java/org/overengineer/inlineproblems/listeners/MarkupModelProblemListener.java index c60b7ce..b1571b3 100644 --- a/src/main/java/org/overengineer/inlineproblems/listeners/MarkupModelProblemListener.java +++ b/src/main/java/org/overengineer/inlineproblems/listeners/MarkupModelProblemListener.java @@ -131,25 +131,25 @@ private void handleEvent(EventType type, @NotNull RangeHighlighterEx highlighter return; } - InlineProblem problem; + InlineProblem newProblem; + InlineProblem problemToRemove = null; - if (type == EventType.ADD) { - var highlightInfo = (HighlightInfo) highlighter.getErrorStripeTooltip(); - if (highlightInfo == null) - return; + var highlightInfo = (HighlightInfo) highlighter.getErrorStripeTooltip(); + if (highlightInfo == null) + return; - problem = new InlineProblem( - editor.getDocument().getLineNumber(highlighter.getStartOffset()), - textEditor.getFile().getPath(), - highlightInfo, - textEditor, - highlighter - ); - } - else { - problem = findActiveProblemByRangeHighlighterHashCode(highlighter.hashCode()); + newProblem = new InlineProblem( + editor.getDocument().getLineNumber(highlighter.getStartOffset()), + textEditor.getFile().getPath(), + highlightInfo, + textEditor, + highlighter + ); + + if (type == EventType.CHANGE || type == EventType.REMOVE) { + problemToRemove = findActiveProblemByRangeHighlighterHashCode(highlighter.hashCode()); - if (problem == null) { + if (problemToRemove == null) { return; } } @@ -159,23 +159,23 @@ private void handleEvent(EventType type, @NotNull RangeHighlighterEx highlighter ); if ( - problem.getText().isEmpty() || + newProblem.getText().isEmpty() || problemTextBeginningFilterList.stream() - .anyMatch(f -> problem.getText().toLowerCase().startsWith(f.toLowerCase())) + .anyMatch(f -> newProblem.getText().toLowerCase().startsWith(f.toLowerCase())) ) { return; } switch (type) { case ADD: - problemManager.addProblem(problem); + problemManager.addProblem(newProblem); break; case REMOVE: - problemManager.removeProblem(problem); + problemManager.removeProblem(problemToRemove); break; case CHANGE: - problemManager.removeProblem(problem); - problemManager.addProblem(problem); + problemManager.removeProblem(problemToRemove); + problemManager.addProblem(newProblem); break; } } From 70d54b28ad96032bc89e9e6719528f9296d2db8c Mon Sep 17 00:00:00 2001 From: 0verEngineer Date: Wed, 24 May 2023 12:28:36 +0200 Subject: [PATCH 10/14] Fixes customSeverity bug that leads to useless problem updates because severity was modified to late --- .../inlineproblems/DocumentMarkupModelScanner.java | 2 ++ .../overengineer/inlineproblems/ProblemManager.java | 12 +++++------- .../listeners/MarkupModelProblemListener.java | 1 + 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/main/java/org/overengineer/inlineproblems/DocumentMarkupModelScanner.java b/src/main/java/org/overengineer/inlineproblems/DocumentMarkupModelScanner.java index 4016360..3772693 100644 --- a/src/main/java/org/overengineer/inlineproblems/DocumentMarkupModelScanner.java +++ b/src/main/java/org/overengineer/inlineproblems/DocumentMarkupModelScanner.java @@ -137,6 +137,8 @@ private List getProblemsInEditor(TextEditor textEditor) { h ); + problemManager.applyCustomSeverity(newProblem); + problems.add(newProblem); }); diff --git a/src/main/java/org/overengineer/inlineproblems/ProblemManager.java b/src/main/java/org/overengineer/inlineproblems/ProblemManager.java index d4417fc..f11b678 100644 --- a/src/main/java/org/overengineer/inlineproblems/ProblemManager.java +++ b/src/main/java/org/overengineer/inlineproblems/ProblemManager.java @@ -64,8 +64,6 @@ public void addProblem(InlineProblem problem) { } private void addProblemPrivate(InlineProblem problem) { - applyCustomSeverity(problem); - DrawDetails drawDetails = new DrawDetails(problem, problem.getTextEditor().getEditor()); if (problem.getTextEditor().getEditor().getDocument().getLineCount() <= problem.getLine()) { @@ -79,25 +77,25 @@ private void addProblemPrivate(InlineProblem problem) { activeProblems.add(problem); } - private void applyCustomSeverity(InlineProblem problem) { + public void applyCustomSeverity(InlineProblem problem) { int severity = problem.getSeverity(); - if (severity >= HighlightSeverity.ERROR.myVal || + if (severity >= HighlightSeverity.ERROR.myVal && settingsState.getAdditionalErrorSeverities().stream().anyMatch(s -> s == severity) ) { problem.setSeverity(HighlightSeverity.ERROR.myVal); } - else if (severity >= HighlightSeverity.WARNING.myVal || + else if (severity >= HighlightSeverity.WARNING.myVal && settingsState.getAdditionalWarningSeverities().stream().anyMatch(s -> s == severity) ) { problem.setSeverity(HighlightSeverity.WARNING.myVal); } - else if (severity >= HighlightSeverity.WEAK_WARNING.myVal || + else if (severity >= HighlightSeverity.WEAK_WARNING.myVal && settingsState.getAdditionalWeakWarningSeverities().stream().anyMatch(s -> s == severity) ) { problem.setSeverity(HighlightSeverity.WEAK_WARNING.myVal); } - else if (severity >= HighlightSeverity.INFORMATION.myVal || + else if (severity >= HighlightSeverity.INFORMATION.myVal && settingsState.getAdditionalInfoSeverities().stream().anyMatch(s -> s == severity) ) { problem.setSeverity(HighlightSeverity.INFORMATION.myVal); diff --git a/src/main/java/org/overengineer/inlineproblems/listeners/MarkupModelProblemListener.java b/src/main/java/org/overengineer/inlineproblems/listeners/MarkupModelProblemListener.java index b1571b3..de4b389 100644 --- a/src/main/java/org/overengineer/inlineproblems/listeners/MarkupModelProblemListener.java +++ b/src/main/java/org/overengineer/inlineproblems/listeners/MarkupModelProblemListener.java @@ -166,6 +166,7 @@ private void handleEvent(EventType type, @NotNull RangeHighlighterEx highlighter return; } + problemManager.applyCustomSeverity(newProblem); switch (type) { case ADD: problemManager.addProblem(newProblem); From 6769a7c6d6217b56c3bd22ea23df2a16fc078e02 Mon Sep 17 00:00:00 2001 From: 0verEngineer Date: Wed, 24 May 2023 17:52:30 +0200 Subject: [PATCH 11/14] Updates plugin for new IDE EAP versions --- gradle.properties | 2 +- .../DocumentMarkupModelScanner.java | 2 +- .../inlineproblems/ProblemManager.java | 1 - .../listeners/MarkupModelProblemListener.java | 22 ++++++++++--------- 4 files changed, 14 insertions(+), 13 deletions(-) diff --git a/gradle.properties b/gradle.properties index 15ea7db..9b98eb6 100644 --- a/gradle.properties +++ b/gradle.properties @@ -6,7 +6,7 @@ pluginVersion = 0.4.3 # Supported build number ranges and IntelliJ Platform versions -> https://plugins.jetbrains.com/docs/intellij/build-number-ranges.html pluginSinceBuild = 212.5 -pluginUntilBuild = 231.* +pluginUntilBuild = 233.* # IntelliJ Platform Properties -> https://plugins.jetbrains.com/docs/intellij/tools-gradle-intellij-plugin.html#configuration-intellij-extension platformType = IC diff --git a/src/main/java/org/overengineer/inlineproblems/DocumentMarkupModelScanner.java b/src/main/java/org/overengineer/inlineproblems/DocumentMarkupModelScanner.java index 3772693..fcbfe55 100644 --- a/src/main/java/org/overengineer/inlineproblems/DocumentMarkupModelScanner.java +++ b/src/main/java/org/overengineer/inlineproblems/DocumentMarkupModelScanner.java @@ -59,7 +59,7 @@ public void scanForProblemsManually() { List problems = new ArrayList<>(); for (var project : projectManager.getOpenProjects()) { - if (!project.isInitialized()) + if (!project.isInitialized() || project.isDisposed()) continue; FileEditorManager fileEditorManager = FileEditorManager.getInstance(project); diff --git a/src/main/java/org/overengineer/inlineproblems/ProblemManager.java b/src/main/java/org/overengineer/inlineproblems/ProblemManager.java index f11b678..9f93902 100644 --- a/src/main/java/org/overengineer/inlineproblems/ProblemManager.java +++ b/src/main/java/org/overengineer/inlineproblems/ProblemManager.java @@ -29,7 +29,6 @@ public void dispose() { } public void removeProblem(InlineProblem problem) { - inlineDrawer.undrawErrorLineHighlight(problem); inlineDrawer.undrawInlineProblemLabel(problem); diff --git a/src/main/java/org/overengineer/inlineproblems/listeners/MarkupModelProblemListener.java b/src/main/java/org/overengineer/inlineproblems/listeners/MarkupModelProblemListener.java index de4b389..f9e26b6 100644 --- a/src/main/java/org/overengineer/inlineproblems/listeners/MarkupModelProblemListener.java +++ b/src/main/java/org/overengineer/inlineproblems/listeners/MarkupModelProblemListener.java @@ -47,17 +47,17 @@ private MarkupModelProblemListener( @Override public void afterAdded(@NotNull RangeHighlighterEx highlighter) { - handleEvent(EventType.ADD, highlighter); + ApplicationManager.getApplication().invokeLater(() -> handleEvent(EventType.ADD, highlighter)); } @Override public void beforeRemoved(@NotNull RangeHighlighterEx highlighter) { - handleEvent(EventType.REMOVE, highlighter); + ApplicationManager.getApplication().invokeLater(() -> handleEvent(EventType.REMOVE, highlighter)); } @Override public void attributesChanged(@NotNull RangeHighlighterEx highlighter, boolean renderersChanged, boolean fontStyleOrColorChanged) { - handleEvent(EventType.CHANGE, highlighter); + ApplicationManager.getApplication().invokeLater(() -> handleEvent(EventType.CHANGE, highlighter)); } public static void setup(TextEditor textEditor) { @@ -88,12 +88,13 @@ public static void disposeAll() { } private void handleEvent(EventType type, @NotNull RangeHighlighterEx highlighter) { + if (settingsState.getEnabledListener() != Listener.MARKUP_MODEL_LISTENER) return; Editor editor = textEditor.getEditor(); - if (editor.isDisposed() || textEditor.getFile() == null) + if (editor.isDisposed() || editor.getProject().isDisposed() || !editor.getProject().isInitialized() || textEditor.getFile() == null) return; int lineCount = editor.getDocument().getLineCount(); @@ -120,11 +121,7 @@ private void handleEvent(EventType type, @NotNull RangeHighlighterEx highlighter highlightInfo.getDescription() != null && !Objects.equals(highlightInfo.getDescription(), "") ) { - /* If scanForProblemsManuallyInTextEditor is called directly, problems that should be already removed are - still there and will be found and thus not removed as they should */ - ApplicationManager.getApplication().invokeAndWait( - () -> DocumentMarkupModelScanner.getInstance().scanForProblemsManuallyInTextEditor(textEditor) - ); + DocumentMarkupModelScanner.getInstance().scanForProblemsManuallyInTextEditor(textEditor); return; } @@ -138,8 +135,12 @@ private void handleEvent(EventType type, @NotNull RangeHighlighterEx highlighter if (highlightInfo == null) return; + int startOffset = highlighter.getStartOffset(); + if (startOffset < 0) + return; + newProblem = new InlineProblem( - editor.getDocument().getLineNumber(highlighter.getStartOffset()), + editor.getDocument().getLineNumber(startOffset), textEditor.getFile().getPath(), highlightInfo, textEditor, @@ -167,6 +168,7 @@ private void handleEvent(EventType type, @NotNull RangeHighlighterEx highlighter } problemManager.applyCustomSeverity(newProblem); + switch (type) { case ADD: problemManager.addProblem(newProblem); From 5af0b21cb57ca9043623d8bdbf6ed01deb7d9f15 Mon Sep 17 00:00:00 2001 From: 0verEngineer Date: Wed, 24 May 2023 19:33:52 +0200 Subject: [PATCH 12/14] Fixes custom severity bug and improve performance by not adding problems to the cached list if they are not shown --- .../DocumentMarkupModelScanner.java | 3 + .../inlineproblems/ProblemManager.java | 56 +++++++++++++------ .../listeners/MarkupModelProblemListener.java | 3 + 3 files changed, 46 insertions(+), 16 deletions(-) diff --git a/src/main/java/org/overengineer/inlineproblems/DocumentMarkupModelScanner.java b/src/main/java/org/overengineer/inlineproblems/DocumentMarkupModelScanner.java index fcbfe55..ea51e91 100644 --- a/src/main/java/org/overengineer/inlineproblems/DocumentMarkupModelScanner.java +++ b/src/main/java/org/overengineer/inlineproblems/DocumentMarkupModelScanner.java @@ -138,6 +138,9 @@ private List getProblemsInEditor(TextEditor textEditor) { ); problemManager.applyCustomSeverity(newProblem); + if (problemManager.shouldProblemBeIgnored(newProblem.getSeverity())) { + return; + } problems.add(newProblem); }); diff --git a/src/main/java/org/overengineer/inlineproblems/ProblemManager.java b/src/main/java/org/overengineer/inlineproblems/ProblemManager.java index 9f93902..5ea4903 100644 --- a/src/main/java/org/overengineer/inlineproblems/ProblemManager.java +++ b/src/main/java/org/overengineer/inlineproblems/ProblemManager.java @@ -76,28 +76,52 @@ private void addProblemPrivate(InlineProblem problem) { activeProblems.add(problem); } + public boolean shouldProblemBeIgnored(int severity) { + if (severity >= HighlightSeverity.ERROR.myVal) { + return !settingsState.isHighlightErrors() && !settingsState.isShowErrors(); + } + else if (severity >= HighlightSeverity.WARNING.myVal) { + return !settingsState.isHighlightWarnings() && !settingsState.isShowWarnings(); + } + else if (severity >= HighlightSeverity.WEAK_WARNING.myVal) { + return !settingsState.isHighlightWeakWarnings() && !settingsState.isShowWeakWarnings(); + } + else if (severity >= HighlightSeverity.INFORMATION.myVal) { + return !settingsState.isHighlightInfos() && !settingsState.isShowInfos(); + } + + return true; + } + public void applyCustomSeverity(InlineProblem problem) { int severity = problem.getSeverity(); - if (severity >= HighlightSeverity.ERROR.myVal && - settingsState.getAdditionalErrorSeverities().stream().anyMatch(s -> s == severity) - ) { - problem.setSeverity(HighlightSeverity.ERROR.myVal); + for (int additionalSeverity : settingsState.getAdditionalErrorSeverities()) { + if (additionalSeverity == severity) { + problem.setSeverity(HighlightSeverity.ERROR.myVal); + return; + } } - else if (severity >= HighlightSeverity.WARNING.myVal && - settingsState.getAdditionalWarningSeverities().stream().anyMatch(s -> s == severity) - ) { - problem.setSeverity(HighlightSeverity.WARNING.myVal); + + for (int additionalSeverity : settingsState.getAdditionalWarningSeverities()) { + if (additionalSeverity == severity) { + problem.setSeverity(HighlightSeverity.WARNING.myVal); + return; + } } - else if (severity >= HighlightSeverity.WEAK_WARNING.myVal && - settingsState.getAdditionalWeakWarningSeverities().stream().anyMatch(s -> s == severity) - ) { - problem.setSeverity(HighlightSeverity.WEAK_WARNING.myVal); + + for (int additionalSeverity : settingsState.getAdditionalWeakWarningSeverities()) { + if (additionalSeverity == severity) { + problem.setSeverity(HighlightSeverity.WEAK_WARNING.myVal); + return; + } } - else if (severity >= HighlightSeverity.INFORMATION.myVal && - settingsState.getAdditionalInfoSeverities().stream().anyMatch(s -> s == severity) - ) { - problem.setSeverity(HighlightSeverity.INFORMATION.myVal); + + for (int additionalSeverity : settingsState.getAdditionalInfoSeverities()) { + if (additionalSeverity == severity) { + problem.setSeverity(HighlightSeverity.INFO.myVal); + return; + } } } diff --git a/src/main/java/org/overengineer/inlineproblems/listeners/MarkupModelProblemListener.java b/src/main/java/org/overengineer/inlineproblems/listeners/MarkupModelProblemListener.java index f9e26b6..b8ae1c1 100644 --- a/src/main/java/org/overengineer/inlineproblems/listeners/MarkupModelProblemListener.java +++ b/src/main/java/org/overengineer/inlineproblems/listeners/MarkupModelProblemListener.java @@ -168,6 +168,9 @@ private void handleEvent(EventType type, @NotNull RangeHighlighterEx highlighter } problemManager.applyCustomSeverity(newProblem); + if (problemManager.shouldProblemBeIgnored(newProblem.getSeverity())) { + return; + } switch (type) { case ADD: From 07adfa218c0f396d88550d0123434e1da2382d09 Mon Sep 17 00:00:00 2001 From: 0verEngineer Date: Wed, 24 May 2023 19:47:30 +0200 Subject: [PATCH 13/14] Update CHANGELOG.md and makes activeProblems thread save --- CHANGELOG.md | 3 +++ .../java/org/overengineer/inlineproblems/ProblemManager.java | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8d4dee6..66b4138 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ - Some performance improvements - Description for the listeners in the settings - Configurable delay for the manual scan listener +- Support for new EAP versions ### Changed - HighlightProblemListener is now deprecated @@ -18,6 +19,8 @@ ### Fixed - Some possible null pointer exceptions - invokeLater queuing issue of MarkupModelListener if used with the only one problem per line feature +- Cache of activeProblems is now thread safe +- CustomSeverity bugs that leads to useless problem updates ## [0.4.2] diff --git a/src/main/java/org/overengineer/inlineproblems/ProblemManager.java b/src/main/java/org/overengineer/inlineproblems/ProblemManager.java index 5ea4903..fd99b27 100644 --- a/src/main/java/org/overengineer/inlineproblems/ProblemManager.java +++ b/src/main/java/org/overengineer/inlineproblems/ProblemManager.java @@ -32,7 +32,7 @@ public void removeProblem(InlineProblem problem) { inlineDrawer.undrawErrorLineHighlight(problem); inlineDrawer.undrawInlineProblemLabel(problem); - if (!activeProblems.remove(problem)) { + if (!Collections.synchronizedList(activeProblems).remove(problem)) { logger.warn("Removal of problem failed, resetting"); resetForEditor(problem.getTextEditor().getEditor()); return; @@ -73,7 +73,7 @@ private void addProblemPrivate(InlineProblem problem) { inlineDrawer.drawProblemLabel(problem, drawDetails); inlineDrawer.drawProblemLineHighlight(problem, drawDetails); - activeProblems.add(problem); + Collections.synchronizedList(activeProblems).add(problem); } public boolean shouldProblemBeIgnored(int severity) { From ce8442a6bc2f28338416d806c19fade7f9f8e150 Mon Sep 17 00:00:00 2001 From: 0verEngineer Date: Wed, 24 May 2023 22:36:16 +0200 Subject: [PATCH 14/14] Undeprecate HighlightProblemListener, adds a MergingUpdateQueue to the markup model scan --- CHANGELOG.md | 1 - .../DocumentMarkupModelScanner.java | 60 ++++++++++++++----- .../listeners/HighlightProblemListener.java | 5 +- .../listeners/MarkupModelProblemListener.java | 2 +- .../settings/SettingsComponent.java | 8 +-- 5 files changed, 52 insertions(+), 24 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 66b4138..94cb945 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,7 +13,6 @@ - Support for new EAP versions ### Changed -- HighlightProblemListener is now deprecated - MarkupModelListener is now the default listener ### Fixed diff --git a/src/main/java/org/overengineer/inlineproblems/DocumentMarkupModelScanner.java b/src/main/java/org/overengineer/inlineproblems/DocumentMarkupModelScanner.java index ea51e91..e100492 100644 --- a/src/main/java/org/overengineer/inlineproblems/DocumentMarkupModelScanner.java +++ b/src/main/java/org/overengineer/inlineproblems/DocumentMarkupModelScanner.java @@ -1,6 +1,7 @@ package org.overengineer.inlineproblems; import com.intellij.codeInsight.daemon.impl.HighlightInfo; +import com.intellij.openapi.Disposable; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.editor.Document; @@ -10,7 +11,10 @@ import com.intellij.openapi.fileEditor.FileEditorManager; import com.intellij.openapi.fileEditor.TextEditor; import com.intellij.openapi.project.ProjectManager; +import com.intellij.openapi.util.Disposer; import com.intellij.util.concurrency.AppExecutorUtil; +import com.intellij.util.ui.update.MergingUpdateQueue; +import com.intellij.util.ui.update.Update; import org.overengineer.inlineproblems.entities.InlineProblem; import org.overengineer.inlineproblems.entities.enums.Listener; import org.overengineer.inlineproblems.listeners.HighlightProblemListener; @@ -23,7 +27,7 @@ import java.util.concurrent.TimeUnit; -public class DocumentMarkupModelScanner { +public class DocumentMarkupModelScanner implements Disposable { private final ProblemManager problemManager = ApplicationManager.getApplication().getService(ProblemManager.class); private final Logger logger = Logger.getInstance(DocumentMarkupModelScanner.class); @@ -32,18 +36,25 @@ public class DocumentMarkupModelScanner { private static DocumentMarkupModelScanner instance; + private final MergingUpdateQueue mergingUpdateQueue; + private ScheduledFuture scheduledFuture; public static final String NAME = "ManualScanner"; - public static DocumentMarkupModelScanner getInstance() { - if (instance == null) - instance = new DocumentMarkupModelScanner(); - - return instance; - } - private DocumentMarkupModelScanner() { + Disposer.register(problemManager, this); + + mergingUpdateQueue = new MergingUpdateQueue( + "DocumentMarkupModelScannerQueue", + 10, + true, + null, + this, + null, + true + ); + SettingsState settingsState = SettingsState.getInstance(); if (settingsState.getEnabledListener() == Listener.MANUAL_SCANNING) { delayMilliseconds = settingsState.getManualScannerDelay(); @@ -52,6 +63,18 @@ private DocumentMarkupModelScanner() { createAndStartScheduledFuture(); } + public static DocumentMarkupModelScanner getInstance() { + if (instance == null) + instance = new DocumentMarkupModelScanner(); + + return instance; + } + + @Override + public void dispose() { + mergingUpdateQueue.cancelAllUpdates(); + } + public void scanForProblemsManually() { ProjectManager projectManager = ProjectManager.getInstanceIfCreated(); @@ -78,18 +101,27 @@ public void scanForProblemsManually() { } } + /** + * This function is queued in the mergingUpdateQueue because it is called frequently, this can be multiple times per + * millisecond if the HighlightProblemListener is used. + */ public void scanForProblemsManuallyInTextEditor(TextEditor textEditor) { if (textEditor.getFile() == null) { return; } - List problems = getProblemsInEditor(textEditor); + mergingUpdateQueue.queue(new Update("scan") { + @Override + public void run() { + List problems = getProblemsInEditor(textEditor); - problemManager.updateFromNewActiveProblemsForProjectAndFile( - problems, - textEditor.getEditor().getProject(), - textEditor.getFile().getPath() - ); + problemManager.updateFromNewActiveProblemsForProjectAndFile( + problems, + textEditor.getEditor().getProject(), + textEditor.getFile().getPath() + ); + } + }); } private List getProblemsInEditor(TextEditor textEditor) { diff --git a/src/main/java/org/overengineer/inlineproblems/listeners/HighlightProblemListener.java b/src/main/java/org/overengineer/inlineproblems/listeners/HighlightProblemListener.java index b3d7f15..6e92b60 100644 --- a/src/main/java/org/overengineer/inlineproblems/listeners/HighlightProblemListener.java +++ b/src/main/java/org/overengineer/inlineproblems/listeners/HighlightProblemListener.java @@ -17,7 +17,7 @@ public class HighlightProblemListener implements HighlightInfoFilter { private final DocumentMarkupModelScanner markupModelScanner = DocumentMarkupModelScanner.getInstance(); private final SettingsState settingsState = SettingsState.getInstance(); - public static final String NAME = "HighlightProblemListener (Deprecated)"; + public static final String NAME = "HighlightProblemListener"; public static final int ADDITIONAL_MANUAL_SCAN_DELAY_MILLIS = 2000; @Override @@ -28,9 +28,6 @@ public boolean accept(@NotNull HighlightInfo highlightInfo, @Nullable PsiFile fi if (file == null || !file.isValid()) return true; - // The HighlightProblemListener is deprecated because the accept function is called a lot of times per second - // and the invokeLater queues the invocations, so this is often called before handleAccept is finished. - // invokeAndWait also doesn't work because it can cause a deadlock. if (!file.getProject().isDisposed()) { ApplicationManager.getApplication().invokeLater(() -> handleAccept(file)); } diff --git a/src/main/java/org/overengineer/inlineproblems/listeners/MarkupModelProblemListener.java b/src/main/java/org/overengineer/inlineproblems/listeners/MarkupModelProblemListener.java index b8ae1c1..5b0c646 100644 --- a/src/main/java/org/overengineer/inlineproblems/listeners/MarkupModelProblemListener.java +++ b/src/main/java/org/overengineer/inlineproblems/listeners/MarkupModelProblemListener.java @@ -30,7 +30,7 @@ public class MarkupModelProblemListener implements MarkupModelListener { private static final List disposables = new ArrayList<>(); - public static final String NAME = "MarkupModelListener"; + public static final String NAME = "MarkupModelListener (default)"; private enum EventType { ADD, REMOVE, CHANGE diff --git a/src/main/java/org/overengineer/inlineproblems/settings/SettingsComponent.java b/src/main/java/org/overengineer/inlineproblems/settings/SettingsComponent.java index 0f327fb..894cf3d 100644 --- a/src/main/java/org/overengineer/inlineproblems/settings/SettingsComponent.java +++ b/src/main/java/org/overengineer/inlineproblems/settings/SettingsComponent.java @@ -136,10 +136,10 @@ public SettingsComponent() { .addSeparator() .addComponent(new JBLabel("General")) .addLabeledComponent(new JBLabel("Enabled problem listener"), enabledListener) - .addTooltip("- MarkupModelListener: Called after addition of a RangeHighlighter to a file. Faster on large files, slower on small ones") - .addTooltip("- ManualScanner: Scans the DocumentMarkupModel for all highlighters at a fixed delay") - .addTooltip("- HighlightProblemListener (DEPRECATED): Faster on small to medium sized files, slower on large ones.") - .addTooltip(" Called way to often and can cause freezes. If you want similar performance use the ManualScanner instead") + .addTooltip("- MarkupModelListener (default): Called after addition of a RangeHighlighter to a file. Faster on large files, slower on small ones") + .addTooltip("- HighlightProblemListener: Faster on small to medium sized files, slower on large ones. Called very often and can cause slowdowns.") + .addTooltip("- ManualScanner: Scans the DocumentMarkupModel for all highlighters at a fixed delay, uses the same logic ") + .addTooltip(" as HighlightProblemListener but can help with slowdowns on big files.") .addLabeledComponent(new JBLabel("ManualScanner delay in milliseconds"), manualScannerDelay) .addTooltip("Delay between manual scans, only used when ManualScanner is enabled") .addComponent(forceErrorsInSameLine, 0)