|
1 | 1 | package software.xdev.saveactions.core.action; |
2 | 2 |
|
3 | | -import software.xdev.saveactions.core.service.SaveActionsService; |
4 | | -import software.xdev.saveactions.core.service.SaveActionsServiceManager; |
| 3 | +import static java.util.Collections.synchronizedSet; |
| 4 | +import static software.xdev.saveactions.core.ExecutionMode.batch; |
| 5 | +import static software.xdev.saveactions.model.Action.activateOnBatch; |
| 6 | + |
| 7 | +import java.util.HashSet; |
| 8 | +import java.util.Set; |
| 9 | + |
| 10 | +import org.jetbrains.annotations.NotNull; |
| 11 | + |
5 | 12 | import com.intellij.analysis.AnalysisScope; |
6 | 13 | import com.intellij.analysis.BaseAnalysisAction; |
7 | 14 | import com.intellij.openapi.diagnostic.Logger; |
8 | 15 | import com.intellij.openapi.project.Project; |
9 | 16 | import com.intellij.psi.PsiElementVisitor; |
10 | 17 | import com.intellij.psi.PsiFile; |
11 | | -import org.jetbrains.annotations.NotNull; |
12 | | -import software.xdev.saveactions.model.Action; |
13 | 18 |
|
14 | | -import java.util.HashSet; |
15 | | -import java.util.Set; |
| 19 | +import software.xdev.saveactions.core.service.SaveActionsService; |
| 20 | +import software.xdev.saveactions.core.service.SaveActionsServiceManager; |
| 21 | +import software.xdev.saveactions.model.Action; |
16 | 22 |
|
17 | | -import static software.xdev.saveactions.core.ExecutionMode.batch; |
18 | | -import static software.xdev.saveactions.model.Action.activateOnBatch; |
19 | | -import static java.util.Collections.synchronizedSet; |
20 | 23 |
|
21 | 24 | /** |
22 | | - * This action runs the save actions on the given scope of files, only if property |
23 | | - * {@link Action#activateOnShortcut} is enabled. The user is asked for the scope using a standard |
24 | | - * IDEA dialog. It delegates to {@link SaveActionsService}. Originally based on |
25 | | - * {@link com.intellij.codeInspection.inferNullity.InferNullityAnnotationsAction}. |
| 25 | + * This action runs the save actions on the given scope of files, only if property {@link Action#activateOnShortcut} is |
| 26 | + * enabled. The user is asked for the scope using a standard IDEA dialog. It delegates to {@link SaveActionsService}. |
| 27 | + * Originally based on {@link com.intellij.codeInspection.inferNullity.InferNullityAnnotationsAction}. |
26 | 28 | * |
27 | 29 | * @author markiewb |
28 | 30 | * @see SaveActionsServiceManager |
29 | 31 | */ |
30 | | -public class BatchAction extends BaseAnalysisAction { |
31 | | - |
32 | | - private static final Logger LOGGER = Logger.getInstance(SaveActionsService.class); |
33 | | - private static final String COMPONENT_NAME = "Save Actions"; |
34 | | - |
35 | | - public BatchAction() { |
36 | | - super(COMPONENT_NAME, COMPONENT_NAME); |
37 | | - } |
38 | | - |
39 | | - @Override |
40 | | - protected void analyze(@NotNull Project project, @NotNull AnalysisScope scope) { |
41 | | - LOGGER.info("[+] Start BatchAction#analyze with project " + project + " and scope " + scope); |
42 | | - Set<PsiFile> psiFiles = synchronizedSet(new HashSet<>()); |
43 | | - scope.accept(new PsiElementVisitor() { |
44 | | - @Override |
45 | | - public void visitFile(PsiFile psiFile) { |
46 | | - super.visitFile(psiFile); |
47 | | - psiFiles.add(psiFile); |
48 | | - } |
49 | | - }); |
50 | | - SaveActionsServiceManager.getService().guardedProcessPsiFiles(project, psiFiles, activateOnBatch, batch); |
51 | | - LOGGER.info("End BatchAction#analyze processed " + psiFiles.size() + " files"); |
52 | | - } |
53 | | - |
| 32 | +public class BatchAction extends BaseAnalysisAction |
| 33 | +{ |
| 34 | + private static final Logger LOGGER = Logger.getInstance(SaveActionsService.class); |
| 35 | + private static final String COMPONENT_NAME = "Save Actions"; |
| 36 | + |
| 37 | + public BatchAction() |
| 38 | + { |
| 39 | + super(COMPONENT_NAME, COMPONENT_NAME); |
| 40 | + } |
| 41 | + |
| 42 | + @Override |
| 43 | + protected void analyze(@NotNull final Project project, @NotNull final AnalysisScope scope) |
| 44 | + { |
| 45 | + LOGGER.info("[+] Start BatchAction#analyze with project " + project + " and scope " + scope); |
| 46 | + final Set<PsiFile> psiFiles = synchronizedSet(new HashSet<>()); |
| 47 | + scope.accept(new PsiElementVisitor() |
| 48 | + { |
| 49 | + @Override |
| 50 | + public void visitFile(final PsiFile psiFile) |
| 51 | + { |
| 52 | + super.visitFile(psiFile); |
| 53 | + psiFiles.add(psiFile); |
| 54 | + } |
| 55 | + }); |
| 56 | + SaveActionsServiceManager.getService().guardedProcessPsiFiles(project, psiFiles, activateOnBatch, batch); |
| 57 | + LOGGER.info("End BatchAction#analyze processed " + psiFiles.size() + " files"); |
| 58 | + } |
54 | 59 | } |
0 commit comments