Skip to content

Commit

Permalink
Merge branch 'fishermans-231_refactoring'
Browse files Browse the repository at this point in the history
  • Loading branch information
dubreuia committed Dec 19, 2021
2 parents 64cae21 + 61a84b0 commit 0ecbd5a
Show file tree
Hide file tree
Showing 29 changed files with 673 additions and 466 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ dependencies {
// See https://www.jetbrains.com/intellij-repository/snapshots
// See https://www.jetbrains.com/intellij-repository/releases
intellij {
version = '2021.2'
version = '2021.3'
plugins = ['java', 'coverage']
pluginName = 'Save Actions'
// Do not touch the plugin.xml file
Expand Down
15 changes: 9 additions & 6 deletions src/main/java/com/dubreuia/core/action/BatchAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,11 @@
*/
package com.dubreuia.core.action;

import com.dubreuia.core.component.SaveActionManager;
import com.dubreuia.core.service.SaveActionsService;
import com.dubreuia.core.service.SaveActionsServiceManager;
import com.intellij.analysis.AnalysisScope;
import com.intellij.analysis.BaseAnalysisAction;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.project.Project;
import com.intellij.psi.PsiElementVisitor;
import com.intellij.psi.PsiFile;
Expand All @@ -36,22 +38,23 @@
import java.util.Set;

import static com.dubreuia.core.ExecutionMode.batch;
import static com.dubreuia.core.component.Component.COMPONENT_NAME;
import static com.dubreuia.core.component.SaveActionManager.LOGGER;
import static com.dubreuia.model.Action.activateOnBatch;
import static java.util.Collections.synchronizedSet;

/**
* This action runs the save actions on the given scope of files, only if property
* {@link com.dubreuia.model.Action#activateOnShortcut} is enabled. The user is asked for the scope using a standard
* IDEA dialog. It delegates to {@link SaveActionManager}. Originally based on
* IDEA dialog. It delegates to {@link SaveActionsService}. Originally based on
* {@link com.intellij.codeInspection.inferNullity.InferNullityAnnotationsAction}.
*
* @author markiewb
* @see SaveActionManager
* @see SaveActionsServiceManager
*/
public class BatchAction extends BaseAnalysisAction {

private static final Logger LOGGER = Logger.getInstance(SaveActionsService.class);
private static final String COMPONENT_NAME = "Save Actions";

public BatchAction() {
super(COMPONENT_NAME, COMPONENT_NAME);
}
Expand All @@ -67,7 +70,7 @@ public void visitFile(PsiFile psiFile) {
psiFiles.add(psiFile);
}
});
SaveActionManager.INSTANCE.guardedProcessPsiFiles(project, psiFiles, activateOnBatch, batch);
SaveActionsServiceManager.getService().guardedProcessPsiFiles(project, psiFiles, activateOnBatch, batch);
LOGGER.info("End BatchAction#analyze processed " + psiFiles.size() + " files");
}

Expand Down
13 changes: 8 additions & 5 deletions src/main/java/com/dubreuia/core/action/ShortcutAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,11 @@

package com.dubreuia.core.action;

import com.dubreuia.core.component.SaveActionManager;
import com.dubreuia.core.service.SaveActionsService;
import com.dubreuia.core.service.SaveActionsServiceManager;
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.project.Project;
import com.intellij.psi.PsiFile;
import org.jetbrains.annotations.NotNull;
Expand All @@ -36,26 +38,27 @@
import java.util.Set;

import static com.dubreuia.core.ExecutionMode.shortcut;
import static com.dubreuia.core.component.SaveActionManager.LOGGER;
import static com.dubreuia.model.Action.activateOnShortcut;
import static com.intellij.openapi.actionSystem.CommonDataKeys.PSI_FILE;
import static java.util.Collections.singletonList;

/**
* This action runs the plugin on shortcut, only if property {@link com.dubreuia.model.Action#activateOnShortcut} is
* enabled. It delegates to {@link SaveActionManager}.
* enabled. It delegates to {@link SaveActionsService}.
*
* @see SaveActionManager
* @see SaveActionsServiceManager
*/
public class ShortcutAction extends AnAction {

private static final Logger LOGGER = Logger.getInstance(SaveActionsService.class);

@Override
public void actionPerformed(@NotNull AnActionEvent event) {
LOGGER.info("[+] Start ShortcutAction#actionPerformed with event " + event);
PsiFile psiFile = event.getData(PSI_FILE);
Project project = event.getProject();
Set<PsiFile> psiFiles = new HashSet<>(singletonList(psiFile));
SaveActionManager.INSTANCE.guardedProcessPsiFiles(project, psiFiles, activateOnShortcut, shortcut);
SaveActionsServiceManager.getService().guardedProcessPsiFiles(project, psiFiles, activateOnShortcut, shortcut);
LOGGER.info("End ShortcutAction#actionPerformed processed " + psiFiles.size() + " files");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

import com.dubreuia.model.Storage;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.ToggleAction;
import com.intellij.openapi.project.DumbAware;
import com.intellij.openapi.project.Project;

Expand All @@ -35,7 +36,7 @@
/**
* This action toggles on and off the plugin, by modifying the underlying storage.
*/
public class ToggleAction extends com.intellij.openapi.actionSystem.ToggleAction implements DumbAware {
public class ToggleAnAction extends ToggleAction implements DumbAware {

@Override
public boolean isSelected(AnActionEvent event) {
Expand Down
93 changes: 0 additions & 93 deletions src/main/java/com/dubreuia/core/component/Component.java

This file was deleted.

Loading

0 comments on commit 0ecbd5a

Please sign in to comment.