Skip to content

Commit

Permalink
#2664 Re-formatted code
Browse files Browse the repository at this point in the history
Formatting on commit was disabled for some reason
  • Loading branch information
hurricup committed Sep 30, 2023
1 parent faa0115 commit 6451355
Show file tree
Hide file tree
Showing 12 changed files with 59 additions and 55 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,8 @@ private void doInstall(@NotNull Collection<String> 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();
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
}
Expand Down Expand Up @@ -182,7 +182,7 @@ public void forceCacheUpdate() {
}

@TestOnly
public void cleanCache(){
public void cleanCache() {
myKnownSubs = Collections.emptySet();
myKnownNamespaces = Collections.emptySet();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@

public abstract class GenericPerlProgramRunner implements ProgramRunner<RunnerSettings> {
private static final Logger LOG = Logger.getInstance(GenericPerlProgramRunner.class);

protected abstract @Nullable PerlRunProfileState createState(@NotNull ExecutionEnvironment executionEnvironment) throws
ExecutionException;

Expand All @@ -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
*/
Expand All @@ -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);
}
Expand All @@ -90,19 +93,20 @@ private boolean handleMissingModules(@NotNull ExecutionEnvironment environment,
return true;
}

private List<String> getMissingModules(@NotNull ExecutionEnvironment environment){
private List<String> 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<String> getRequiredModules(@NotNull ExecutionEnvironment environment){
protected Set<String> getRequiredModules(@NotNull ExecutionEnvironment environment) {
var runProfile = environment.getRunProfile();
return runProfile instanceof GenericPerlRunConfiguration perlRunConfiguration
? new HashSet<>(perlRunConfiguration.getRequiredModulesList())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -574,7 +574,7 @@ public void run(@NotNull ProgressIndicator indicator) {
}
});
}
if( callback != null){
if (callback != null) {
callback.run();
}
if (ourTestSdkRefreshSemaphore != null) {
Expand All @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public CpanAdapter(@NotNull Sdk sdk, @Nullable Project project) {
@Override
protected @NotNull List<String> getInstallParameters(@NotNull Collection<String> 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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ private CpanminusAdapter(@NotNull Sdk sdk, @Nullable Project project) {
protected @NotNull List<String> getInstallParameters(@NotNull Collection<String> packageNames, boolean suppressTests) {
var result = new ArrayList<String>();
result.add("-v");
if( suppressTests){
if (suppressTests) {
result.add(NO_TEST_ARGUMENT);
}
result.addAll(super.getInstallParameters(packageNames, suppressTests));
Expand All @@ -85,11 +85,11 @@ public static boolean isAvailable(@Nullable Project project) {
public static final class Factory implements PackageManagerAdapterFactory<CpanminusAdapter> {
@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);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,104 +22,105 @@
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() {
return "runAnything/perl/cpanm";
}

@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) {
Expand Down
4 changes: 2 additions & 2 deletions plugin/src/testFixtures/java/base/PerlPlatformTestCase.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
);
}
Expand Down

0 comments on commit 6451355

Please sign in to comment.