diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 0000000..0e718df --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1,15 @@ +# These are supported funding model platforms + +github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] +patreon: # Replace with a single Patreon username +open_collective: # Replace with a single Open Collective username +ko_fi: overengineer44 +tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel +community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry +liberapay: # Replace with a single Liberapay username +issuehunt: # Replace with a single IssueHunt username +lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry +polar: # Replace with a single Polar username +buy_me_a_coffee: # Replace with a single Buy Me a Coffee username +thanks_dev: # Replace with a single thanks.dev username +custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 6b85c2c..5c640af 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -58,7 +58,7 @@ jobs: # Setup Gradle - name: Setup Gradle - uses: gradle/actions/setup-gradle@v3 + uses: gradle/actions/setup-gradle@v4 with: gradle-home-cache-cleanup: true @@ -122,7 +122,7 @@ jobs: # Setup Gradle - name: Setup Gradle - uses: gradle/actions/setup-gradle@v3 + uses: gradle/actions/setup-gradle@v4 with: gradle-home-cache-cleanup: true @@ -175,7 +175,7 @@ jobs: # Run Qodana inspections - name: Qodana - Code Inspection - uses: JetBrains/qodana-action@v2023.3.1 + uses: JetBrains/qodana-action@v2024.2 with: cache-default-branch-only: true @@ -206,7 +206,7 @@ jobs: # Setup Gradle - name: Setup Gradle - uses: gradle/actions/setup-gradle@v3 + uses: gradle/actions/setup-gradle@v4 with: gradle-home-cache-cleanup: true @@ -219,7 +219,7 @@ jobs: # Run Verify Plugin task and IntelliJ Plugin Verifier tool - name: Run Plugin Verification tasks - run: ./gradlew runPluginVerifier -Dplugin.verifier.home.dir=${{ needs.build.outputs.pluginVerifierHomeDir }} + run: ./gradlew verifyPlugin -Dplugin.verifier.home.dir=${{ needs.build.outputs.pluginVerifierHomeDir }} # Collect Plugin Verifier Result - name: Collect Plugin Verifier Result diff --git a/CHANGELOG.md b/CHANGELOG.md index 7fe39d3..cd17397 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,11 @@ ## [Unreleased] +## [0.5.6] +### Changed +- Added 2 settings options to disable HTML stripping and XML unescaping +### Fixed +- Generics in error messages were stripped because of the HTML stripping ## [0.5.5] ### Changed diff --git a/gradle.properties b/gradle.properties index 30981ca..9d215b8 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.5.5 +pluginVersion = 0.5.6 # Supported build number ranges and IntelliJ Platform versions -> https://plugins.jetbrains.com/docs/intellij/build-number-ranges.html pluginSinceBuild = 212.5 diff --git a/src/main/java/org/overengineer/inlineproblems/DocumentMarkupModelScanner.java b/src/main/java/org/overengineer/inlineproblems/DocumentMarkupModelScanner.java index 0f80415..004cec8 100644 --- a/src/main/java/org/overengineer/inlineproblems/DocumentMarkupModelScanner.java +++ b/src/main/java/org/overengineer/inlineproblems/DocumentMarkupModelScanner.java @@ -30,6 +30,7 @@ public class DocumentMarkupModelScanner implements Disposable { private final ProblemManager problemManager = ApplicationManager.getApplication().getService(ProblemManager.class); + private final SettingsState settingsState; private final Logger logger = Logger.getInstance(DocumentMarkupModelScanner.class); @@ -46,6 +47,8 @@ public class DocumentMarkupModelScanner implements Disposable { private DocumentMarkupModelScanner() { Disposer.register(problemManager, this); + settingsState = SettingsState.getInstance(); + mergingUpdateQueue = new MergingUpdateQueue( "DocumentMarkupModelScannerQueue", 10, @@ -169,7 +172,8 @@ private List getProblemsInEditor(TextEditor textEditor) { textEditor.getFile().getPath(), highlightInfo, textEditor, - h + h, + settingsState ); problemManager.applyCustomSeverity(newProblem); diff --git a/src/main/java/org/overengineer/inlineproblems/definitions/RegexPattern.java b/src/main/java/org/overengineer/inlineproblems/definitions/RegexPattern.java new file mode 100644 index 0000000..733450d --- /dev/null +++ b/src/main/java/org/overengineer/inlineproblems/definitions/RegexPattern.java @@ -0,0 +1,7 @@ +package org.overengineer.inlineproblems.definitions; + +import java.util.regex.Pattern; + +public class RegexPattern { + public static final Pattern HTML_TAG_PATTERN = Pattern.compile("]*)?>"); +} diff --git a/src/main/java/org/overengineer/inlineproblems/entities/InlineProblem.java b/src/main/java/org/overengineer/inlineproblems/entities/InlineProblem.java index bc0d6bc..c377223 100644 --- a/src/main/java/org/overengineer/inlineproblems/entities/InlineProblem.java +++ b/src/main/java/org/overengineer/inlineproblems/entities/InlineProblem.java @@ -8,7 +8,8 @@ import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.Setter; - +import org.overengineer.inlineproblems.definitions.RegexPattern; +import org.overengineer.inlineproblems.settings.SettingsState; @Getter @Setter @@ -17,6 +18,7 @@ public class InlineProblem { // The line the problem first appeared private final int line; + @Setter private int severity; // If two problems with the same text occur in the same line only one will be shown @@ -49,13 +51,14 @@ public InlineProblem( String filePath, HighlightInfo highlightInfo, TextEditor textEditor, - RangeHighlighter rangeHighlighter + RangeHighlighter rangeHighlighter, + SettingsState settingsState ) { String usedText = highlightInfo.getDescription(); if (usedText == null) usedText = ""; else - usedText = getTextWithoutHtmlOrXml(usedText.stripLeading()); + usedText = getTextWithHtmlStrippingAndXmlUnescaping(usedText.stripLeading(), settingsState); this.line = line; this.text = usedText; @@ -72,16 +75,21 @@ public InlineProblem( this.actualEndOffset = highlightInfo.getActualEndOffset() -1; } - public void setSeverity(int severity) { - this.severity = severity; - } - - private String getTextWithoutHtmlOrXml(String text) { - if (text.contains("<")) + private String getTextWithHtmlStrippingAndXmlUnescaping(String text, SettingsState settingsState) { + if ( + settingsState.isEnableHtmlStripping() && + text.contains("<") && + RegexPattern.HTML_TAG_PATTERN.matcher(text).find() + ) { text = StringUtil.stripHtml(text, " "); + } - if (text.contains("&")) + if ( + settingsState.isEnableHtmlStripping() && + text.contains("&") + ) { text = StringUtil.unescapeXmlEntities(text); + } return text; } diff --git a/src/main/java/org/overengineer/inlineproblems/listeners/MarkupModelProblemListener.java b/src/main/java/org/overengineer/inlineproblems/listeners/MarkupModelProblemListener.java index 655a7b4..66c2776 100644 --- a/src/main/java/org/overengineer/inlineproblems/listeners/MarkupModelProblemListener.java +++ b/src/main/java/org/overengineer/inlineproblems/listeners/MarkupModelProblemListener.java @@ -144,7 +144,8 @@ private void handleEvent(EventType type, @NotNull RangeHighlighterEx highlighter textEditor.getFile().getPath(), highlightInfo, textEditor, - highlighter + highlighter, + settingsState ); if (type == EventType.CHANGE || type == EventType.REMOVE) { diff --git a/src/main/java/org/overengineer/inlineproblems/settings/SettingsComponent.java b/src/main/java/org/overengineer/inlineproblems/settings/SettingsComponent.java index ff747b7..ca45b5e 100644 --- a/src/main/java/org/overengineer/inlineproblems/settings/SettingsComponent.java +++ b/src/main/java/org/overengineer/inlineproblems/settings/SettingsComponent.java @@ -61,6 +61,8 @@ public class SettingsComponent { private final JBCheckBox useEditorFont = new JBCheckBox(SettingsBundle.message("settings.useEditorFont")); private final JBCheckBox showOnlyHighestSeverityPerLine = new JBCheckBox(SettingsBundle.message("settings.showOnlyHighestPerLine")); + private final JBCheckBox enableHtmlStripping = new JBCheckBox(SettingsBundle.message("settings.enableHtmlStripping")); + private final JBCheckBox enableXmlUnescaping = new JBCheckBox(SettingsBundle.message("settings.enableXmlUnescaping")); private final JFormattedTextField inlayFontSizeDeltaText; private final JFormattedTextField manualScannerDelay; private final JBCheckBox fillProblemLabels = new JBCheckBox(SettingsBundle.message("settings.fillProblemLabels")); @@ -164,6 +166,8 @@ public SettingsComponent() { .addComponent(forceErrorsInSameLine, 0) .addComponent(useEditorFont, 0) .addComponent(showOnlyHighestSeverityPerLine, 0) + .addComponent(enableHtmlStripping, 0) + .addComponent(enableXmlUnescaping, 0) .addLabeledComponent(new JBLabel(SettingsBundle.message("settings.inlaySizeDelta")), inlayFontSizeDeltaText) .addTooltip(SettingsBundle.message("settings.inlaySizeDeltaTooltip")) .addLabeledComponent(new JLabel(SettingsBundle.message("settings.problemFilterListLabel")), problemFilterList) @@ -247,6 +251,14 @@ public boolean isShowOnlyHighestSeverityPerLine() { return showOnlyHighestSeverityPerLine.isSelected(); } + public boolean isEnableHtmlStripping() { + return enableHtmlStripping.isSelected(); + } + + public boolean isEnableXmlUnescaping() { + return enableXmlUnescaping.isSelected(); + } + public int getInlayFontSizeDelta() { int val = 0; // Convert the String @@ -273,6 +285,14 @@ public void setShowOnlyHighestSeverityPerLine(boolean isSelected) { showOnlyHighestSeverityPerLine.setSelected(isSelected); } + public void setEnableHtmlStripping(boolean isSelected) { + enableHtmlStripping.setSelected(isSelected); + } + + public void setEnableXmlUnescaping(boolean isSelected) { + enableXmlUnescaping.setSelected(isSelected); + } + public boolean isFillProblemLabels() { return fillProblemLabels.isSelected(); } diff --git a/src/main/java/org/overengineer/inlineproblems/settings/SettingsConfigurable.java b/src/main/java/org/overengineer/inlineproblems/settings/SettingsConfigurable.java index af60cad..276d653 100644 --- a/src/main/java/org/overengineer/inlineproblems/settings/SettingsConfigurable.java +++ b/src/main/java/org/overengineer/inlineproblems/settings/SettingsConfigurable.java @@ -46,6 +46,8 @@ public boolean isModified() { state.isRoundedCornerBoxes() == settingsComponent.isRoundedCornerBoxes() && state.isUseEditorFont() == settingsComponent.isUseEditorFont() && state.isShowOnlyHighestSeverityPerLine() == settingsComponent.isShowOnlyHighestSeverityPerLine() && + state.isEnableHtmlStripping() == settingsComponent.isEnableHtmlStripping() && + state.isEnableXmlUnescaping() == settingsComponent.isEnableXmlUnescaping() && state.getInlayFontSizeDelta() == settingsComponent.getInlayFontSizeDelta() && state.isFillProblemLabels() == settingsComponent.isFillProblemLabels() && state.isBoldProblemLabels() == settingsComponent.isBoldProblemLabels() && @@ -135,6 +137,8 @@ public void apply() { state.setRoundedCornerBoxes(settingsComponent.isRoundedCornerBoxes()); state.setUseEditorFont(settingsComponent.isUseEditorFont()); state.setShowOnlyHighestSeverityPerLine(settingsComponent.isShowOnlyHighestSeverityPerLine()); + state.setEnableHtmlStripping(settingsComponent.isEnableHtmlStripping()); + state.setEnableXmlUnescaping(settingsComponent.isEnableXmlUnescaping()); state.setInlayFontSizeDelta(settingsComponent.getInlayFontSizeDelta()); state.setFillProblemLabels(settingsComponent.isFillProblemLabels()); state.setBoldProblemLabels(settingsComponent.isBoldProblemLabels()); @@ -203,6 +207,8 @@ public void reset() { settingsComponent.setRoundedCornerBoxes(state.isRoundedCornerBoxes()); settingsComponent.setUseEditorFont(state.isUseEditorFont()); settingsComponent.setShowOnlyHighestSeverityPerLine(state.isShowOnlyHighestSeverityPerLine()); + settingsComponent.setEnableHtmlStripping(state.isEnableHtmlStripping()); + settingsComponent.setEnableXmlUnescaping(state.isEnableXmlUnescaping()); settingsComponent.setInlayFontSizeDelta(state.getInlayFontSizeDelta()); settingsComponent.setFillProblemLabels(state.isFillProblemLabels()); settingsComponent.setBoldProblemLabels(state.isBoldProblemLabels()); diff --git a/src/main/java/org/overengineer/inlineproblems/settings/SettingsState.java b/src/main/java/org/overengineer/inlineproblems/settings/SettingsState.java index 57923ed..b8ba8d6 100644 --- a/src/main/java/org/overengineer/inlineproblems/settings/SettingsState.java +++ b/src/main/java/org/overengineer/inlineproblems/settings/SettingsState.java @@ -104,6 +104,8 @@ public class SettingsState implements PersistentStateComponent { private List additionalInfoSeverities = new ArrayList<>(); private boolean showOnlyHighestSeverityPerLine = false; + private boolean enableHtmlStripping = true; + private boolean enableXmlUnescaping = true; // migration booleans private boolean highlightProblemListenerDeprecateMigrationDone = false; diff --git a/src/main/resources/messages/SettingsBundle_en.properties b/src/main/resources/messages/SettingsBundle_en.properties index 90809ee..f1a04b5 100644 --- a/src/main/resources/messages/SettingsBundle_en.properties +++ b/src/main/resources/messages/SettingsBundle_en.properties @@ -50,4 +50,6 @@ settings.infoLineHighlightColor=Info line highlight color: settings.additionalSeveritiesInfoDesc=Semicolon separated list of additional info severities e.g. '10, 100' settings.forceProblemsInOneLine=Force problems in the same line even if they are too long to fit settings.useEditorFont=Use editor font instead of tooltip font -settings.showOnlyHighestPerLine=Show only the problem with the highest severity per line \ No newline at end of file +settings.showOnlyHighestPerLine=Show only the problem with the highest severity per line +settings.enableHtmlStripping=Enable stripping of HTML in the messages +settings.enableXmlUnescaping=Enable unescaping of XML in the messages \ No newline at end of file diff --git a/src/main/resources/messages/SettingsBundle_zh_CN.properties b/src/main/resources/messages/SettingsBundle_zh_CN.properties index c74d3fa..0737999 100644 --- a/src/main/resources/messages/SettingsBundle_zh_CN.properties +++ b/src/main/resources/messages/SettingsBundle_zh_CN.properties @@ -48,4 +48,6 @@ settings.infoLineHighlightColor=\u4FE1\u606F\u884C\u7A81\u51FA\u663E\u793A\u989C settings.additionalSeveritiesInfoDesc=\u9644\u52A0\u4FE1\u606F\u4E25\u91CD\u6027\u7684\u7528\u5206\u53F7\u5206\u9694\u7684\u5217\u8868\uFF0C\u4F8B\u5982 '10, 100' settings.forceProblemsInOneLine=\u5F3A\u5236\u5728\u540C\u4E00\u884C\u663E\u793A\u95EE\u9898\uFF0C\u5373\u4F7F\u5B83\u4EEC\u592A\u957F\u800C\u65E0\u6CD5\u9002\u5E94 settings.useEditorFont=\u4F7F\u7528\u7F16\u8F91\u5668\u5B57\u4F53\u800C\u4E0D\u662F\u63D0\u793A\u5B57\u4F53 -settings.showOnlyHighestPerLine=\u4ec5\u663e\u793a\u6bcf\u884c\u4e2d\u6700\u4e25\u91cd\u7684\u95ee\u9898 \ No newline at end of file +settings.showOnlyHighestPerLine=\u4ec5\u663e\u793a\u6bcf\u884c\u4e2d\u6700\u4e25\u91cd\u7684\u95ee\u9898 +settings.enableHtmlStripping=Enable stripping of HTML in the messages +settings.enableXmlUnescaping=Enable unescaping of XML in the messages