Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@
<h3 align="center">InlineProblems</h3>

<!-- Plugin description -->
Plugin to show problems like errors and warnings inside the text editor (inline) for IDEs based on the IntelliJ Platform, inspired by Error Lens and InlineError
Plugin to show problems like errors and warnings inside the text editor (inline) for IDEs based on the IntelliJ Platform, inspired by Error Lens and InlineError.

You can turn this plugin on and off by the keyboard shortcut `alt+u`.
<!-- Plugin description end -->

<p align="center">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,24 +84,24 @@

if (projectManager != null) {
List<InlineProblem> problems = new ArrayList<>();
if (settingsState.isEnableInlineProblem())
for (var project : projectManager.getOpenProjects()) {
if (!project.isInitialized() || project.isDisposed())
continue;

for (var project : projectManager.getOpenProjects()) {
if (!project.isInitialized() || project.isDisposed())
continue;
FileEditorManager fileEditorManager = FileEditorManager.getInstance(project);
for (var editor : fileEditorManager.getAllEditors()) {

FileEditorManager fileEditorManager = FileEditorManager.getInstance(project);
for (var editor : fileEditorManager.getAllEditors()) {
if (editor.getFile() == null || FileNameUtil.ignoreFile(editor.getFile().getName())) {
continue;
}

if (editor.getFile() == null || FileNameUtil.ignoreFile(editor.getFile().getName())) {
continue;
}

if (editor instanceof TextEditor) {
var textEditor = (TextEditor) editor;
problems.addAll(getProblemsInEditor(textEditor));
if (editor instanceof TextEditor) {
var textEditor = (TextEditor) editor;
problems.addAll(getProblemsInEditor(textEditor));
}
}
}
}

problemManager.updateFromNewActiveProblems(problems);
}
Expand All @@ -119,7 +119,7 @@
mergingUpdateQueue.queue(new Update("scan") {
@Override
public void run() {
List<InlineProblem> problems = getProblemsInEditor(textEditor);
List<InlineProblem> problems = settingsState.isEnableInlineProblem() ? List.of() : getProblemsInEditor(textEditor);

problemManager.updateFromNewActiveProblemsForProjectAndFile(
problems,
Expand Down Expand Up @@ -158,8 +158,7 @@
!highlightInfo.getDescription().isEmpty() &&
problemTextBeginningFilterList.stream()
.noneMatch(f -> highlightInfo.getDescription().stripLeading().toLowerCase().startsWith(f.toLowerCase())) &&
fileEndOffset >= highlightInfo.getStartOffset()
;
fileEndOffset >= highlightInfo.getStartOffset();
}

return false;
Expand All @@ -169,7 +168,7 @@

InlineProblem newProblem = new InlineProblem(
document.getLineNumber(highlightInfo.getStartOffset()),
textEditor.getFile().getPath(),

Check warning on line 171 in src/main/java/org/overengineer/inlineproblems/DocumentMarkupModelScanner.java

View workflow job for this annotation

GitHub Actions / Inspect code

Nullability and data flow problems

Method invocation `getPath` may produce `NullPointerException`
highlightInfo,
textEditor,
h,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package org.overengineer.inlineproblems.actions;

import com.intellij.notification.NotificationType;
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.application.ApplicationManager;
import org.jetbrains.annotations.NotNull;
import org.overengineer.inlineproblems.DocumentMarkupModelScanner;
import org.overengineer.inlineproblems.Notifier;
import org.overengineer.inlineproblems.bundles.SettingsBundle;
import org.overengineer.inlineproblems.settings.SettingsState;

public class EnableInlineProblemsAction extends AnAction {

@Override
public void actionPerformed(@NotNull AnActionEvent anActionEvent) {
SettingsState settingsState = SettingsState.getInstance();
if (settingsState.isEnableInlineProblemsNotifications()) {
Notifier.notify(SettingsBundle.message(
settingsState.isEnableInlineProblem()
? "settings.enableInlineProblem.disabled"
: "settings.enableInlineProblem.enabled"),
NotificationType.INFORMATION,
anActionEvent.getProject()
);
}
settingsState.setEnableInlineProblem(!settingsState.isEnableInlineProblem());
ApplicationManager.getApplication().invokeAndWait(DocumentMarkupModelScanner.getInstance()::scanForProblemsManually);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package org.overengineer.inlineproblems.actions;

import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
import org.jetbrains.annotations.NotNull;
import org.overengineer.inlineproblems.settings.SettingsState;

public class ShowErrorsAction extends AnAction {
@Override
public void actionPerformed(@NotNull AnActionEvent anActionEvent) {
SettingsState settingsState = SettingsState.getInstance();
settingsState.setShowErrors(!settingsState.isShowErrors());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package org.overengineer.inlineproblems.actions;

import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
import org.jetbrains.annotations.NotNull;
import org.overengineer.inlineproblems.settings.SettingsState;

public class ShowInfosAction extends AnAction {
@Override
public void actionPerformed(@NotNull AnActionEvent anActionEvent) {
SettingsState settingsState = SettingsState.getInstance();
settingsState.setShowInfos(!settingsState.isShowInfos());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package org.overengineer.inlineproblems.actions;

import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
import org.jetbrains.annotations.NotNull;
import org.overengineer.inlineproblems.settings.SettingsState;

public class ShowWarningsAction extends AnAction {
@Override
public void actionPerformed(@NotNull AnActionEvent anActionEvent) {
SettingsState settingsState = SettingsState.getInstance();
settingsState.setShowWarnings(!settingsState.isShowWarnings());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package org.overengineer.inlineproblems.actions;

import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
import org.jetbrains.annotations.NotNull;
import org.overengineer.inlineproblems.settings.SettingsState;

public class ShowWeakWarningsAction extends AnAction {
@Override
public void actionPerformed(@NotNull AnActionEvent anActionEvent) {
SettingsState settingsState = SettingsState.getInstance();
settingsState.setShowWeakWarnings(!settingsState.isShowWeakWarnings());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ public static void disposeAll() {
}

private void handleEvent(EventType type, @NotNull RangeHighlighterEx highlighter) {
if (!settingsState.isEnableInlineProblem())
return;

if (settingsState.getEnabledListener() != Listener.MARKUP_MODEL_LISTENER)
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ public class SettingsComponent {
private final ColorPanel infoLabelBackgroundColor = new ColorPanel();
private final ColorPanel infoHighlightColor = new ColorPanel();

private final JBCheckBox enableInlineProblem = new JBCheckBox(SettingsBundle.message("settings.enableInlineProblem"));
private final JBCheckBox enableInlineProblemsNotifications = new JBCheckBox(SettingsBundle.message("settings.enableInlineProblemsNotifications"));

private final JBCheckBox forceErrorsInSameLine = new JBCheckBox(SettingsBundle.message("settings.forceProblemsInOneLine"));
private final JBCheckBox drawBoxesAroundProblemLabels = new JBCheckBox(SettingsBundle.message("settings.drawBoxesAroundProblemLabels"));
private final JBCheckBox roundedCornerBoxes = new JBCheckBox(SettingsBundle.message("settings.roundedCornerBoxes"));
Expand Down Expand Up @@ -115,6 +118,9 @@ public SettingsComponent() {
infoLabelBackgroundColor.setSelectedColor(settingsState.getInfoBackgroundColor());
infoHighlightColor.setSelectedColor(settingsState.getInfoHighlightColor());

enableInlineProblem.setSelected(settingsState.isEnableInlineProblem());
enableInlineProblemsNotifications.setSelected(settingsState.isEnableInlineProblemsNotifications());

forceErrorsInSameLine.setSelected(settingsState.isForceProblemsInSameLine());
drawBoxesAroundProblemLabels.setSelected(settingsState.isDrawBoxesAroundErrorLabels());
roundedCornerBoxes.setSelected(settingsState.isRoundedCornerBoxes());
Expand Down Expand Up @@ -152,6 +158,8 @@ public SettingsComponent() {

settingsPanel = FormBuilder.createFormBuilder()
.addComponent(new JBLabel(SettingsBundle.message("settings.submenu.label")))
.addComponent(enableInlineProblem, 0)
.addComponent(enableInlineProblemsNotifications, 0)
.addComponent(drawBoxesAroundProblemLabels, 0)
.addComponent(roundedCornerBoxes, 0)
.addComponent(fillProblemLabels, 0)
Expand Down Expand Up @@ -231,6 +239,22 @@ public void setForceErrorsInSameLine(final boolean isSelected) {
forceErrorsInSameLine.setSelected(isSelected);
}

public boolean isEnableInlineProblem() {
return enableInlineProblem.isSelected();
}

public void setEnableInlineProblem(final boolean isSelected) {
enableInlineProblem.setSelected(isSelected);
}

public boolean isEnableInlineProblemsNotifications() {
return enableInlineProblemsNotifications.isSelected();
}

public void setEnableInlineProblemsNotifications(final boolean isSelected) {
enableInlineProblemsNotifications.setSelected(isSelected);
}

public boolean getDrawBoxesAroundProblemLabels() {
return drawBoxesAroundProblemLabels.isSelected();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ public class SettingsConfigurable implements Configurable {

private final ListenerManager listenerManager = ListenerManager.getInstance();

SettingsConfigurable() {}
SettingsConfigurable() {
}

@Override
@NlsContexts.ConfigurableName
Expand All @@ -42,6 +43,7 @@ public boolean isModified() {
SettingsState state = SettingsState.getInstance();

boolean oldStateEqualsNewState = state.isForceProblemsInSameLine() == settingsComponent.isForceErrorsInSameLine() &&
state.isEnableInlineProblem() == settingsComponent.isEnableInlineProblem() &&
state.isDrawBoxesAroundErrorLabels() == settingsComponent.getDrawBoxesAroundProblemLabels() &&
state.isRoundedCornerBoxes() == settingsComponent.isRoundedCornerBoxes() &&
state.isUseEditorFont() == settingsComponent.isUseEditorFont() &&
Expand Down Expand Up @@ -133,6 +135,9 @@ public void apply() {
state.setInfoBackgroundColor(settingsComponent.getInfoLabelBackgroundColor());
state.setInfoHighlightColor(settingsComponent.getInfoHighlightColor());

state.setEnableInlineProblem(settingsComponent.isEnableInlineProblem());
state.setEnableInlineProblemsNotifications(settingsComponent.isEnableInlineProblemsNotifications());

state.setForceProblemsInSameLine(settingsComponent.isForceErrorsInSameLine());
state.setDrawBoxesAroundErrorLabels(settingsComponent.getDrawBoxesAroundProblemLabels());
state.setRoundedCornerBoxes(settingsComponent.isRoundedCornerBoxes());
Expand Down Expand Up @@ -204,6 +209,9 @@ public void reset() {
settingsComponent.setInfoLabelBackgroundColor(state.getInfoBackgroundColor());
settingsComponent.setInfoHighlightColor(state.getInfoHighlightColor());

settingsComponent.setEnableInlineProblem(state.isEnableInlineProblem());
settingsComponent.setEnableInlineProblemsNotifications(state.isEnableInlineProblemsNotifications());

settingsComponent.setForceErrorsInSameLine(state.isForceProblemsInSameLine());
settingsComponent.setDrawBoxesAroundProblemLabels(state.isDrawBoxesAroundErrorLabels());
settingsComponent.setRoundedCornerBoxes(state.isRoundedCornerBoxes());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ public class SettingsState implements PersistentStateComponent<SettingsState> {
private boolean highlightInfos = false;
private boolean showInfosInGutter = false;
private boolean clickableContext = false;
private boolean enableInlineProblem = true;
private boolean enableInlineProblemsNotifications = false;

/**
* Colors renamed from '<NAME>Color' to '<NAME>Col' to solve
Expand Down
41 changes: 33 additions & 8 deletions src/main/resources/META-INF/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,23 +19,48 @@
<!-- Extension points defined by the plugin.
Read more: https://plugins.jetbrains.com/docs/intellij/plugin-extension-points.html -->
<extensions defaultExtensionNs="com.intellij">
<applicationConfigurable parentId="appearance" instance="org.overengineer.inlineproblems.settings.SettingsConfigurable"
<applicationConfigurable parentId="appearance"
instance="org.overengineer.inlineproblems.settings.SettingsConfigurable"
id="org.overengineer.inlineproblems.settings.SettingsConfigurable"
displayName="InlineProblems"/>
key="application.configurable.InlineProblems"/>
<applicationService serviceImplementation="org.overengineer.inlineproblems.settings.SettingsState"/>
<applicationService serviceImplementation="org.overengineer.inlineproblems.ProblemManager"/>
<daemon.highlightInfoFilter implementation="org.overengineer.inlineproblems.listeners.HighlightProblemListener" id="org.overengineer.inlineproblems.listeners.HighlightProblemListener" />
<daemon.highlightInfoFilter implementation="org.overengineer.inlineproblems.listeners.HighlightProblemListener"
id="org.overengineer.inlineproblems.listeners.HighlightProblemListener"/>

<postStartupActivity implementation="org.overengineer.inlineproblems.ProjectStartupActivity" />
<notificationGroup id="InlineProblems" displayType="BALLOON"/>
<postStartupActivity implementation="org.overengineer.inlineproblems.ProjectStartupActivity"/>
<notificationGroup id="InlineProblems" displayType="BALLOON" bundle="messages.SettingsBundle"
key="notification.group.InlineProblems"/>
</extensions>

<actions>
<action class="org.overengineer.inlineproblems.actions.EnableInlineProblemsAction"
id="org.overengineer.inlineproblems.actions.EnableInlineProblemsAction">
<keyboard-shortcut first-keystroke="alt u" keymap="$default"/>
</action>
<action class="org.overengineer.inlineproblems.actions.ShowErrorsAction"
id="org.overengineer.inlineproblems.actions.ShowErrorsAction"
/>
<action class="org.overengineer.inlineproblems.actions.ShowWarningsAction"
id="org.overengineer.inlineproblems.actions.ShowWarningsAction"
/>
<action class="org.overengineer.inlineproblems.actions.ShowWeakWarningsAction"
id="org.overengineer.inlineproblems.actions.ShowWeakWarningsAction"
/>
<action class="org.overengineer.inlineproblems.actions.ShowInfosAction"
id="org.overengineer.inlineproblems.actions.ShowInfosAction"
/>
</actions>

<projectListeners>
<listener class="org.overengineer.inlineproblems.listeners.FileEditorListener" topic="com.intellij.openapi.fileEditor.FileEditorManagerListener" />
<listener class="org.overengineer.inlineproblems.listeners.FileEditorListener"
topic="com.intellij.openapi.fileEditor.FileEditorManagerListener"/>
</projectListeners>

<applicationListeners>
<listener class="org.overengineer.inlineproblems.listeners.PluginListener" topic="com.intellij.ide.plugins.DynamicPluginListener" />
<listener class="org.overengineer.inlineproblems.listeners.ProjectCloseListener" topic="com.intellij.openapi.project.ProjectManagerListener" />
<listener class="org.overengineer.inlineproblems.listeners.PluginListener"
topic="com.intellij.ide.plugins.DynamicPluginListener"/>
<listener class="org.overengineer.inlineproblems.listeners.ProjectCloseListener"
topic="com.intellij.openapi.project.ProjectManagerListener"/>
</applicationListeners>
</idea-plugin>
18 changes: 17 additions & 1 deletion src/main/resources/messages/SettingsBundle_en.properties
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,20 @@ settings.useEditorFont=Use editor font instead of tooltip font
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
settings.enableClickableContext=Enable clickable inline problems for IDE context actions
settings.enableClickableContext=Enable clickable inline problems for IDE context actions
settings.enableInlineProblem=Enable inlineProblems
settings.enableInlineProblemsNotifications=Enable InlineProblems notifications
settings.enableInlineProblem.enabled=Enabling inlineProblems
settings.enableInlineProblem.disabled=Disabling inlineProblems
# suppress inspection "UnusedProperty"
action.org.overengineer.inlineproblems.actions.EnableInlineProblemsAction.text=Enable inline Problems
# suppress inspection "UnusedProperty"
action.org.overengineer.inlineproblems.actions.ShowErrorsAction.text=Show Errors
# suppress inspection "UnusedProperty"
action.org.overengineer.inlineproblems.actions.ShowWarningsAction.text=Show Warnings
# suppress inspection "UnusedProperty"
action.org.overengineer.inlineproblems.actions.ShowWeakWarningsAction.text=Show Weak Warnings
# suppress inspection "UnusedProperty"
action.org.overengineer.inlineproblems.actions.ShowInfosAction.text=Show Infos
notification.group.InlineProblems=InlineProblems
application.configurable.InlineProblems=InlineProblems
17 changes: 16 additions & 1 deletion src/main/resources/messages/SettingsBundle_zh_CN.properties
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,19 @@ settings.useEditorFont=\u4F7F\u7528\u7F16\u8F91\u5668\u5B57\u4F53\u800C\u4E0D\u6
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
settings.enableClickableContext=Enable clickable inline problems for IDE context actions
settings.enableClickableContext=Enable clickable inline problems for IDE context actions
settings.enableInlineProblem=Enable inlineProblems
settings.enableInlineProblem.enabled=Enabling inlineProblems
settings.enableInlineProblem.disabled=Disabling inlineProblems
# suppress inspection "UnusedProperty"
action.org.overengineer.inlineproblems.actions.EnableInlineProblemsAction.text=Enable inline Problems
# suppress inspection "UnusedProperty"
action.org.overengineer.inlineproblems.actions.ShowErrorsAction.text=Show Errors
# suppress inspection "UnusedProperty"
action.org.overengineer.inlineproblems.actions.ShowWarningsAction.text=Show Warnings
# suppress inspection "UnusedProperty"
action.org.overengineer.inlineproblems.actions.ShowWeakWarningsAction.text=Show Weak Warnings
# suppress inspection "UnusedProperty"
action.org.overengineer.inlineproblems.actions.ShowInfosAction.text=Show Infos
notification.group.InlineProblems=InlineProblems
application.configurable.InlineProblems=InlineProblems
Loading