Skip to content

Commit

Permalink
Update status message when the current module has no source roots
Browse files Browse the repository at this point in the history
  • Loading branch information
jshiell committed Jun 5, 2023
1 parent fc8dfb3 commit c96c4af
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import com.intellij.openapi.wm.ToolWindow;
import com.intellij.util.ThrowableRunnable;
import org.infernus.idea.checkstyle.model.ScanScope;
import org.infernus.idea.checkstyle.toolwindow.CheckStyleToolWindowPanel;
import org.jetbrains.annotations.NotNull;

import static org.infernus.idea.checkstyle.actions.ToolWindowAccess.toolWindow;
Expand All @@ -27,6 +28,7 @@ public final void actionPerformed(final @NotNull AnActionEvent event) {
project(event).ifPresent(project -> {
try {
final ToolWindow toolWindow = toolWindow(project);
CheckStyleToolWindowPanel checkStyleToolWindowPanel = CheckStyleToolWindowPanel.panelFor(project);

final VirtualFile[] selectedFiles
= FileEditorManager.getInstance(project).getSelectedFiles();
Expand All @@ -38,16 +40,16 @@ public final void actionPerformed(final @NotNull AnActionEvent event) {
final Module module = ModuleUtil.findModuleForFile(
selectedFiles[0], project);
if (module == null) {
setProgressText(toolWindow, "plugin.status.in-progress.no-module");
if (checkStyleToolWindowPanel != null) {
checkStyleToolWindowPanel.displayWarningResult("plugin.status.in-progress.no-module");
}
return;
}

final ScanScope scope = configurationManager(project).getCurrent().getScanScope();

toolWindow.activate(() -> {
try {
setProgressText(toolWindow, "plugin.status.in-progress.module");

ThrowableRunnable<RuntimeException> scanAction = null;
if (scope == ScanScope.Everything) {
scanAction = new ScanAllFilesInModuleTask(module, getSelectedOverride(toolWindow));
Expand All @@ -57,9 +59,12 @@ public final void actionPerformed(final @NotNull AnActionEvent event) {
if (moduleSourceRoots.length > 0) {
scanAction = new ScanAllGivenFilesTask(project, moduleSourceRoots,
getSelectedOverride(toolWindow));
} else if (checkStyleToolWindowPanel != null) {
checkStyleToolWindowPanel.displayWarningResult("plugin.status.in-progress.no-module-source-roots");
}
}
if (scanAction != null) {
setProgressText(toolWindow, "plugin.status.in-progress.module");
ReadAction.run(scanAction);
}
} catch (Throwable e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ plugin.status.in-progress.module=Scanning current module...
plugin.status.in-progress.no-file=No file is open for editing
plugin.status.in-progress.no-modified-files=There are no modified files in the current changelist
plugin.status.in-progress.no-module=The current file being edited does not belong to a module
plugin.status.in-progress.no-module-source-roots=The current module has no source roots
plugin.status.in-progress.project=Scanning current project...
plugin.status.in-progress.out-of-scope=Scan was skipped as file is out of scope
plugin.status.aborted=Check was aborted
Expand Down

0 comments on commit c96c4af

Please sign in to comment.