Skip to content

Commit

Permalink
Migrate FindBugsCompileAfterHook and PluginSuggestion from services t…
Browse files Browse the repository at this point in the history
…o simple classes
  • Loading branch information
jqyp committed Jul 7, 2020
1 parent e4dfbc0 commit aaa4a58
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;

public class FindBugsCompileAfterHookService {
public class FindBugsCompileAfterHook {

private static final int DEFAULT_DELAY_MS = 30000;
private static final int DELAY_MS = StringUtil.parseInt(System.getProperty("idea.findbugs.autoanalyze.delaymillis", String.valueOf(DEFAULT_DELAY_MS)), DEFAULT_DELAY_MS);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,27 +40,22 @@
import java.util.HashSet;
import java.util.Set;

public final class PluginSuggestionService {
public final class PluginSuggestion {

private static final String NOTIFICATION_GROUP_ID_PLUGIN_SUGGESTION = "SpotBugs: Plugin Suggestion";
private static final NotificationGroup NOTIFICATION_GROUP_PLUGIN_SUGGESTION = new NotificationGroup(NOTIFICATION_GROUP_ID_PLUGIN_SUGGESTION, NotificationDisplayType.STICKY_BALLOON, false);
private final Project myProject;

public PluginSuggestionService(@NotNull final Project project) {
myProject = project;
}

public void suggestPlugins() {
final ProjectSettings settings = ProjectSettings.getInstance(myProject);
public static void suggestPlugins(@NotNull final Project project) {
final ProjectSettings settings = ProjectSettings.getInstance(project);
if (!NotificationUtil.isGroupEnabled(NOTIFICATION_GROUP_ID_PLUGIN_SUGGESTION)) {
return;
}
if (isAndroidFindbugsPluginEnabled(settings)) {
return;
}
final Set<Suggestion> suggestions = collectSuggestions(myProject, settings);
final Set<Suggestion> suggestions = collectSuggestions(project, settings);
if (!suggestions.isEmpty()) {
showSuggestions(myProject, suggestions);
showSuggestions(project, suggestions);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public ProjectOpenCloseListener() {
public void compilationFinished(final boolean aborted, final int errors, final int warnings, final @NotNull CompileContext compileContext) {
// note that this is not invoked when auto make trigger compilation
if (!aborted && errors == 0) {
FindBugsCompileAfterHookService.initWorker(compileContext);
FindBugsCompileAfterHook.initWorker(compileContext);
}
}

Expand All @@ -56,12 +56,11 @@ public void fileGenerated(final String s) {
@Override
public void projectOpened(@NotNull Project project) {
CompilerManager.getInstance(project).addCompilationStatusListener(compilationStatusListener);
if (FindBugsCompileAfterHookService.isAfterAutoMakeEnabled(project)) {
FindBugsCompileAfterHookService.setAnalyzeAfterAutomake(project, true);
if (FindBugsCompileAfterHook.isAfterAutoMakeEnabled(project)) {
FindBugsCompileAfterHook.setAnalyzeAfterAutomake(project, true);
}

PluginSuggestionService pluginSuggestionService = project.getService(PluginSuggestionService.class);
pluginSuggestionService.suggestPlugins();
PluginSuggestion.suggestPlugins(project);
new RFilerFilterSuggestion(project).suggest();

LegacyProjectSettingsConverter.convertSettings(project);
Expand All @@ -70,6 +69,6 @@ public void projectOpened(@NotNull Project project) {
@Override
public void projectClosed(@NotNull Project project) {
CompilerManager.getInstance(project).removeCompilationStatusListener(compilationStatusListener);
FindBugsCompileAfterHookService.setAnalyzeAfterAutomake(project, false);
FindBugsCompileAfterHook.setAnalyzeAfterAutomake(project, false);
}
}
2 changes: 0 additions & 2 deletions src/main/resources/META-INF/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,6 @@
displayName="SpotBugs"/>
<checkinHandlerFactory implementation="org.jetbrains.plugins.spotbugs.core.CheckinHandlerFactoryImpl"/>
<projectService serviceImplementation="org.jetbrains.plugins.spotbugs.core.ProblemCacheService"/>
<projectService serviceImplementation="org.jetbrains.plugins.spotbugs.core.PluginSuggestionService"/>
<projectService serviceImplementation="org.jetbrains.plugins.spotbugs.core.FindBugsCompileAfterHookService"/>
</extensions>
<extensions defaultExtensionNs="com.intellij">
<errorHandler implementation="org.jetbrains.plugins.spotbugs.core.ErrorReportSubmitterImpl"/>
Expand Down

0 comments on commit aaa4a58

Please sign in to comment.