diff --git a/mojo/core/src/main/java/com/perl5/lang/mojolicious/idea/actions/InstallMojoliciousAction.java b/mojo/core/src/main/java/com/perl5/lang/mojolicious/idea/actions/InstallMojoliciousAction.java index 58e59bc6d9..7fbf80aab4 100644 --- a/mojo/core/src/main/java/com/perl5/lang/mojolicious/idea/actions/InstallMojoliciousAction.java +++ b/mojo/core/src/main/java/com/perl5/lang/mojolicious/idea/actions/InstallMojoliciousAction.java @@ -22,7 +22,6 @@ import com.perl5.lang.mojolicious.MojoIcons; import com.perl5.lang.mojolicious.MojoUtil; import com.perl5.lang.perl.adapters.PackageManagerAdapter; -import com.perl5.lang.perl.adapters.PackageManagerAdapterFactory; import com.perl5.lang.perl.idea.actions.PerlActionBase; import com.perl5.lang.perl.idea.project.PerlProjectManager; import org.jetbrains.annotations.NotNull; diff --git a/plugin/core/src/main/java/com/perl5/lang/perl/adapters/PackageManagerAdapter.java b/plugin/core/src/main/java/com/perl5/lang/perl/adapters/PackageManagerAdapter.java index 4b1d74ce2e..2b7fbfff09 100644 --- a/plugin/core/src/main/java/com/perl5/lang/perl/adapters/PackageManagerAdapter.java +++ b/plugin/core/src/main/java/com/perl5/lang/perl/adapters/PackageManagerAdapter.java @@ -117,8 +117,8 @@ private void doInstall(@NotNull Collection packageNames, @Nullable Runna .withProcessListener(new ProcessAdapter() { @Override public void processTerminated(@NotNull ProcessEvent event) { - PerlRunUtil.refreshSdkDirs(mySdk, myProject, ()->{ - if( event.getExitCode() == 0 && callback != null){ + PerlRunUtil.refreshSdkDirs(mySdk, myProject, () -> { + if (event.getExitCode() == 0 && callback != null) { callback.run(); } }); diff --git a/plugin/core/src/main/java/com/perl5/lang/perl/idea/findusages/PerlHighlightUsagesHandlerFactory.java b/plugin/core/src/main/java/com/perl5/lang/perl/idea/findusages/PerlHighlightUsagesHandlerFactory.java index d7edd79598..37db202981 100644 --- a/plugin/core/src/main/java/com/perl5/lang/perl/idea/findusages/PerlHighlightUsagesHandlerFactory.java +++ b/plugin/core/src/main/java/com/perl5/lang/perl/idea/findusages/PerlHighlightUsagesHandlerFactory.java @@ -44,7 +44,7 @@ public class PerlHighlightUsagesHandlerFactory implements HighlightUsagesHandler @Override public @Nullable HighlightUsagesHandlerBase createHighlightUsagesHandler(@NotNull Editor editor, @NotNull PsiFile file) { - if( !file.isValid()){ + if (!file.isValid()) { return null; } Project project = file.getProject(); diff --git a/plugin/core/src/main/java/com/perl5/lang/perl/idea/project/PerlNamesCache.java b/plugin/core/src/main/java/com/perl5/lang/perl/idea/project/PerlNamesCache.java index 2cde87f5a4..de778f7373 100644 --- a/plugin/core/src/main/java/com/perl5/lang/perl/idea/project/PerlNamesCache.java +++ b/plugin/core/src/main/java/com/perl5/lang/perl/idea/project/PerlNamesCache.java @@ -110,7 +110,7 @@ public void propertyChanged(@NotNull PsiTreeChangeEvent event) { } private void queueUpdate() { - if(!myProject.isDefault()){ + if (!myProject.isDefault()) { myQueue.queue(Update.create(this, this::doUpdateSingleThread)); } } @@ -182,7 +182,7 @@ public void forceCacheUpdate() { } @TestOnly - public void cleanCache(){ + public void cleanCache() { myKnownSubs = Collections.emptySet(); myKnownNamespaces = Collections.emptySet(); } diff --git a/plugin/core/src/main/java/com/perl5/lang/perl/idea/run/GenericPerlProgramRunner.java b/plugin/core/src/main/java/com/perl5/lang/perl/idea/run/GenericPerlProgramRunner.java index ac3e64ea50..b7714423f5 100644 --- a/plugin/core/src/main/java/com/perl5/lang/perl/idea/run/GenericPerlProgramRunner.java +++ b/plugin/core/src/main/java/com/perl5/lang/perl/idea/run/GenericPerlProgramRunner.java @@ -39,6 +39,7 @@ public abstract class GenericPerlProgramRunner implements ProgramRunner { private static final Logger LOG = Logger.getInstance(GenericPerlProgramRunner.class); + protected abstract @Nullable PerlRunProfileState createState(@NotNull ExecutionEnvironment executionEnvironment) throws ExecutionException; @@ -55,7 +56,8 @@ public final void execute(@NotNull ExecutionEnvironment environment) throws Exec /** * Handles missing modules by prompting the user to install them, and then installing them * using the package manager adapter. Executes the environment after the installation is complete. - * @param environment the execution environment + * + * @param environment the execution environment * @param missingModules a list of missing modules * @return true iff invoker should not call run configuration itself, because it's going to be handled by the callback */ @@ -67,18 +69,19 @@ private boolean handleMissingModules(@NotNull ExecutionEnvironment environment, } var request = Messages.showYesNoDialog( project, - PerlBundle.message("dialog.message.are.missing.in.would.you.like.to.install", missingModules.stream().sorted().collect(Collectors.joining(", "))), + PerlBundle.message("dialog.message.are.missing.in.would.you.like.to.install", + missingModules.stream().sorted().collect(Collectors.joining(", "))), PerlBundle.message("dialog.title.missing.modules"), Messages.getQuestionIcon()); if (request != Messages.YES) { return false; } var packageManagerAdapter = PackageManagerAdapterFactory.create(sdk, project); - packageManagerAdapter.install(missingModules, ()->{ + packageManagerAdapter.install(missingModules, () -> { if (project.isDisposed()) { return; } - ApplicationManager.getApplication().invokeLater(()-> { + ApplicationManager.getApplication().invokeLater(() -> { try { doExecute(environment); } @@ -90,19 +93,20 @@ private boolean handleMissingModules(@NotNull ExecutionEnvironment environment, return true; } - private List getMissingModules(@NotNull ExecutionEnvironment environment){ + private List getMissingModules(@NotNull ExecutionEnvironment environment) { var project = environment.getProject(); return ContainerUtil.filter(getRequiredModules(environment), - it-> PerlPackageUtil.getPackageVirtualFileByPackageName(project, it) == null); + it -> PerlPackageUtil.getPackageVirtualFileByPackageName(project, it) == null); } /** * Returns a modifiable set of required modules for the given execution environment. * By default, the set is obtained from the "Required modules" field of the run configuration. + * * @param environment the execution environment * @return a modifiable set of required modules */ - protected Set getRequiredModules(@NotNull ExecutionEnvironment environment){ + protected Set getRequiredModules(@NotNull ExecutionEnvironment environment) { var runProfile = environment.getRunProfile(); return runProfile instanceof GenericPerlRunConfiguration perlRunConfiguration ? new HashSet<>(perlRunConfiguration.getRequiredModulesList()) diff --git a/plugin/core/src/main/java/com/perl5/lang/perl/util/PerlRunUtil.java b/plugin/core/src/main/java/com/perl5/lang/perl/util/PerlRunUtil.java index 93e53cdeac..e00c441ee0 100644 --- a/plugin/core/src/main/java/com/perl5/lang/perl/util/PerlRunUtil.java +++ b/plugin/core/src/main/java/com/perl5/lang/perl/util/PerlRunUtil.java @@ -574,7 +574,7 @@ public void run(@NotNull ProgressIndicator indicator) { } }); } - if( callback != null){ + if (callback != null) { callback.run(); } if (ourTestSdkRefreshSemaphore != null) { @@ -589,8 +589,8 @@ public void run(@NotNull ProgressIndicator indicator) { * Asynchronously refreshes directories of the provided sdk. * This method sets up sdk paths and rescans the roots of the project to ensure that all changes are accounted for. * - * @param sdk The sdk to refresh. - * @param project The project associated with the sdk. + * @param sdk The sdk to refresh. + * @param project The project associated with the sdk. * @param callback A callback function to execute after the sdk is refreshed (optional). */ public static void refreshSdkDirs(@Nullable Sdk sdk, @Nullable Project project) { diff --git a/plugin/cpan/src/main/java/com/perl5/lang/perl/cpan/action/PerlInstallPackagesWithCpanAction.java b/plugin/cpan/src/main/java/com/perl5/lang/perl/cpan/action/PerlInstallPackagesWithCpanAction.java index 86c8ead7b8..0023913aa1 100644 --- a/plugin/cpan/src/main/java/com/perl5/lang/perl/cpan/action/PerlInstallPackagesWithCpanAction.java +++ b/plugin/cpan/src/main/java/com/perl5/lang/perl/cpan/action/PerlInstallPackagesWithCpanAction.java @@ -17,8 +17,8 @@ package com.perl5.lang.perl.cpan.action; import com.intellij.openapi.actionSystem.AnActionEvent; -import com.perl5.lang.perl.cpan.adapter.CpanAdapter; import com.perl5.lang.perl.adapters.PackageManagerAdapter; +import com.perl5.lang.perl.cpan.adapter.CpanAdapter; import com.perl5.lang.perl.idea.actions.PerlInstallPackageActionBase; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; diff --git a/plugin/cpan/src/main/java/com/perl5/lang/perl/cpan/adapter/CpanAdapter.java b/plugin/cpan/src/main/java/com/perl5/lang/perl/cpan/adapter/CpanAdapter.java index 4c113e2a33..cce28a51f6 100644 --- a/plugin/cpan/src/main/java/com/perl5/lang/perl/cpan/adapter/CpanAdapter.java +++ b/plugin/cpan/src/main/java/com/perl5/lang/perl/cpan/adapter/CpanAdapter.java @@ -58,7 +58,7 @@ public CpanAdapter(@NotNull Sdk sdk, @Nullable Project project) { @Override protected @NotNull List getInstallParameters(@NotNull Collection packageNames, boolean suppressTests) { var result = super.getInstallParameters(packageNames, suppressTests); - return suppressTests ? ContainerUtil.prepend(result, NO_TEST_ARGUMENT): result; + return suppressTests ? ContainerUtil.prepend(result, NO_TEST_ARGUMENT) : result; } @Contract("null->null") diff --git a/plugin/cpanminus/src/main/java/com/perl5/lang/perl/cpanminus/action/PerlInstallPackagesWithCpanminusAction.java b/plugin/cpanminus/src/main/java/com/perl5/lang/perl/cpanminus/action/PerlInstallPackagesWithCpanminusAction.java index 5cb6d969c1..3ca575f916 100644 --- a/plugin/cpanminus/src/main/java/com/perl5/lang/perl/cpanminus/action/PerlInstallPackagesWithCpanminusAction.java +++ b/plugin/cpanminus/src/main/java/com/perl5/lang/perl/cpanminus/action/PerlInstallPackagesWithCpanminusAction.java @@ -17,8 +17,8 @@ package com.perl5.lang.perl.cpanminus.action; import com.intellij.openapi.actionSystem.AnActionEvent; -import com.perl5.lang.perl.cpanminus.adapter.CpanminusAdapter; import com.perl5.lang.perl.adapters.PackageManagerAdapter; +import com.perl5.lang.perl.cpanminus.adapter.CpanminusAdapter; import com.perl5.lang.perl.idea.actions.PerlInstallPackageActionBase; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; diff --git a/plugin/cpanminus/src/main/java/com/perl5/lang/perl/cpanminus/adapter/CpanminusAdapter.java b/plugin/cpanminus/src/main/java/com/perl5/lang/perl/cpanminus/adapter/CpanminusAdapter.java index 5996cb9d99..0c6da62f20 100644 --- a/plugin/cpanminus/src/main/java/com/perl5/lang/perl/cpanminus/adapter/CpanminusAdapter.java +++ b/plugin/cpanminus/src/main/java/com/perl5/lang/perl/cpanminus/adapter/CpanminusAdapter.java @@ -60,7 +60,7 @@ private CpanminusAdapter(@NotNull Sdk sdk, @Nullable Project project) { protected @NotNull List getInstallParameters(@NotNull Collection packageNames, boolean suppressTests) { var result = new ArrayList(); result.add("-v"); - if( suppressTests){ + if (suppressTests) { result.add(NO_TEST_ARGUMENT); } result.addAll(super.getInstallParameters(packageNames, suppressTests)); @@ -85,11 +85,11 @@ public static boolean isAvailable(@Nullable Project project) { public static final class Factory implements PackageManagerAdapterFactory { @Override public @Nullable CpanminusAdapter createAdapter(@NotNull Sdk sdk, @Nullable Project project) { - return isAvailable(project) ? new CpanminusAdapter(sdk, project): null; + return isAvailable(project) ? new CpanminusAdapter(sdk, project) : null; } @VisibleForTesting - public static @NotNull Factory getInstance(){ + public static @NotNull Factory getInstance() { return PackageManagerAdapterFactory.findInstance(Factory.class); } } diff --git a/plugin/src/test/java/runAnything/PerlRunAnythingCpanmProviderTest.java b/plugin/src/test/java/runAnything/PerlRunAnythingCpanmProviderTest.java index fe7e37fd18..c9f26a2377 100644 --- a/plugin/src/test/java/runAnything/PerlRunAnythingCpanmProviderTest.java +++ b/plugin/src/test/java/runAnything/PerlRunAnythingCpanmProviderTest.java @@ -22,6 +22,7 @@ import com.perl5.lang.perl.cpanminus.runAnything.PerlCpanminusRunAnythingProvider; import org.jetbrains.annotations.NotNull; import org.junit.Test; + public class PerlRunAnythingCpanmProviderTest extends PerlLightTestCase { @Override protected String getBaseDataPath() { @@ -29,97 +30,97 @@ protected String getBaseDataPath() { } @Test - public void testHelpGroup() {doTestRunAnythingHelpGroup(new PerlCpanminusRunAnythingHelpGroup());} + public void testHelpGroup() { doTestRunAnythingHelpGroup(new PerlCpanminusRunAnythingHelpGroup()); } @Test - public void testCpanmTestMore() {doTest("cpanm Test::More");} + public void testCpanmTestMore() { doTest("cpanm Test::More"); } @Test - public void testEmpty() {doTest("");} + public void testEmpty() { doTest(""); } @Test - public void testCpanm() {doTest("cpanm");} + public void testCpanm() { doTest("cpanm"); } @Test - public void testOptionQuiet() {doTest("cpanm --quiet");} + public void testOptionQuiet() { doTest("cpanm --quiet"); } @Test - public void testOptionNotest() {doTest("cpanm --notest");} + public void testOptionNotest() { doTest("cpanm --notest"); } @Test - public void testOptionVerbose() {doTest("cpanm --verbose");} + public void testOptionVerbose() { doTest("cpanm --verbose"); } @Test - public void testOptionInteractive() {doTest("cpanm --interactive");} + public void testOptionInteractive() { doTest("cpanm --interactive"); } @Test - public void testOptionForce() {doTest("cpanm --force");} + public void testOptionForce() { doTest("cpanm --force"); } @Test - public void testOptionTestOnly() {doTest("cpanm --test-only");} + public void testOptionTestOnly() { doTest("cpanm --test-only"); } @Test - public void testOptionSudo() {doTest("cpanm --sudo");} + public void testOptionSudo() { doTest("cpanm --sudo"); } @Test - public void testOptionInstalldeps() {doTest("cpanm --installdeps");} + public void testOptionInstalldeps() { doTest("cpanm --installdeps"); } @Test - public void testOptionShowdeps() {doTest("cpanm --showdeps");} + public void testOptionShowdeps() { doTest("cpanm --showdeps"); } @Test - public void testOptionReinstall() {doTest("cpanm --reinstall");} + public void testOptionReinstall() { doTest("cpanm --reinstall"); } @Test - public void testOptionMirror() {doTest("cpanm --mirror");} + public void testOptionMirror() { doTest("cpanm --mirror"); } @Test - public void testOptionMirrorOnly() {doTest("cpanm --mirror-only");} + public void testOptionMirrorOnly() { doTest("cpanm --mirror-only"); } @Test - public void testOptionFrom() {doTest("cpanm --from");} + public void testOptionFrom() { doTest("cpanm --from"); } @Test - public void testOptionPrompt() {doTest("cpanm --prompt");} + public void testOptionPrompt() { doTest("cpanm --prompt"); } @Test - public void testOptionLocalLib() {doTest("cpanm --local-lib");} + public void testOptionLocalLib() { doTest("cpanm --local-lib"); } @Test - public void testOptionLocalLibContained() {doTest("cpanm --local-lib-contained");} + public void testOptionLocalLibContained() { doTest("cpanm --local-lib-contained"); } @Test - public void testOptionSelfContained() {doTest("cpanm --self-contained");} + public void testOptionSelfContained() { doTest("cpanm --self-contained"); } @Test - public void testOptionAutoCleanup() {doTest("cpanm --auto-cleanup");} + public void testOptionAutoCleanup() { doTest("cpanm --auto-cleanup"); } @Test - public void testCommandUninstall() {doTest("cpanm --uninstall");} + public void testCommandUninstall() { doTest("cpanm --uninstall"); } @Test - public void testCommandSelfUpgrade() {doTest("cpanm --self-upgrade");} + public void testCommandSelfUpgrade() { doTest("cpanm --self-upgrade"); } @Test - public void testCommandHelp() {doTest("cpanm --help");} + public void testCommandHelp() { doTest("cpanm --help"); } @Test - public void testCommandHelpVersion() {doTest("cpanm --help --version");} + public void testCommandHelpVersion() { doTest("cpanm --help --version"); } @Test - public void testCommandHelpUninstall() {doTest("cpanm --help --uninstall");} + public void testCommandHelpUninstall() { doTest("cpanm --help --uninstall"); } @Test - public void testCommandLook() {doTest("cpanm --look");} + public void testCommandLook() { doTest("cpanm --look"); } @Test - public void testCommandVersion() {doTest("cpanm --version");} + public void testCommandVersion() { doTest("cpanm --version"); } @Test - public void testCommandInfo() {doTest("cpanm --info");} + public void testCommandInfo() { doTest("cpanm --info"); } @Test - public void testCommandDot() {doTest("cpanm .");} + public void testCommandDot() { doTest("cpanm ."); } private void doTest(@NotNull String pattern) { diff --git a/plugin/src/testFixtures/java/base/PerlPlatformTestCase.java b/plugin/src/testFixtures/java/base/PerlPlatformTestCase.java index 705ecb169f..2c342c4dc9 100644 --- a/plugin/src/testFixtures/java/base/PerlPlatformTestCase.java +++ b/plugin/src/testFixtures/java/base/PerlPlatformTestCase.java @@ -62,8 +62,8 @@ import com.intellij.util.containers.ContainerUtil; import com.intellij.util.ui.UIUtil; import com.intellij.util.ui.tree.TreeUtil; -import com.perl5.lang.perl.cpan.adapter.CpanAdapter; import com.perl5.lang.perl.adapters.PackageManagerAdapter; +import com.perl5.lang.perl.cpan.adapter.CpanAdapter; import com.perl5.lang.perl.cpanminus.adapter.CpanminusAdapter; import com.perl5.lang.perl.idea.project.PerlProjectDirectoriesConfigurator; import com.perl5.lang.perl.idea.project.PerlProjectManager; @@ -563,7 +563,7 @@ protected void assertPackageNotExists(@NotNull PsiFile contextPsiFile, @NotNull contextPsiFile, packageName, (sdk, callback) -> { var adapter = Objects.requireNonNull(CpanAdapter.Factory.getInstance().createAdapter(sdk, getProject())); - return PackageManagerAdapter.createInstallAction(adapter,List.of("-M", "www.cpan.org", packageName), callback); + return PackageManagerAdapter.createInstallAction(adapter, List.of("-M", "www.cpan.org", packageName), callback); } ); }