cleanup: arguments of confirmLoadingUntrustedProject
authorSergei Vorobyov <sergey.vorobyov@jetbrains.com>
Wed, 3 Mar 2021 16:52:36 +0000 (19:52 +0300)
committerintellij-monorepo-bot <intellij-monorepo-bot-no-reply@jetbrains.com>
Wed, 3 Mar 2021 20:14:18 +0000 (20:14 +0000)
replaced redundant constant lambda parameter

GitOrigin-RevId: 103b38f1b48c7c6d55cd9be6cdb982f169e6c674

platform/external-system-impl/src/com/intellij/openapi/externalSystem/autoimport/AutoImportProjectTracker.kt
platform/external-system-impl/src/com/intellij/openapi/externalSystem/util/ExternalSystemUtil.java
plugins/maven/src/main/java/org/jetbrains/idea/maven/execution/MavenRunConfigurationType.java
plugins/maven/src/main/java/org/jetbrains/idea/maven/utils/MavenUtil.java

index d450a19e88b3b4c5ef3ea5b404c3997427067238..52d90fc707a6f98aa0a21e03a82f3cadfa05f0f9 100644 (file)
@@ -140,7 +140,7 @@ class AutoImportProjectTracker(private val project: Project) : ExternalSystemPro
 
     val systemIds = projectsToReload.map { it.projectAware.projectId.systemId }.toSet().toTypedArray()
     val isFirstLoad = ThreeState.UNSURE == project.getTrustedState()
-    ExternalSystemUtil.confirmLoadingUntrustedProject(project, { isFirstLoad }, *systemIds)
+    ExternalSystemUtil.confirmLoadingUntrustedProject(project, isFirstLoad, *systemIds)
 
     for (projectData in projectsToReload) {
       LOG.debug("${projectData.projectAware.projectId.readableName}: Project reload")
index 982bc84bd2d27d7819a27732fcaa538f587b5c23..4df1fd0e22bcc98699d528de8c11a3cc45594db3 100644 (file)
@@ -368,7 +368,7 @@ public final class ExternalSystemUtil {
     ApplicationManager.getApplication().invokeAndWait(FileDocumentManager.getInstance()::saveAllDocuments);
 
     boolean isFirstLoad = ThreeState.UNSURE.equals(TrustedProjects.getTrustedState(project));
-    boolean isTrustedProject = confirmLoadingUntrustedProject(project, () -> isFirstLoad, externalSystemId);
+    boolean isTrustedProject = confirmLoadingUntrustedProject(project, isFirstLoad, externalSystemId);
 
     if (!isPreviewMode && !isTrustedProject) {
       LOG.debug("Skip " + externalSystemId + " load, because project is not trusted");
@@ -679,36 +679,56 @@ public final class ExternalSystemUtil {
     }
   }
 
+  @Deprecated
+  @SuppressWarnings({"MissingDeprecatedAnnotation", "DeprecatedIsStillUsed"})
   public static boolean confirmLoadingUntrustedProject(
     @NotNull Project project,
+    @NotNull Supplier<Boolean> confirmation,
     ProjectSystemId... systemIds
   ) {
-    return confirmLoadingUntrustedProject(project, () -> true, systemIds);
+    return confirmLoadingUntrustedProject(project, confirmation.get(), Arrays.asList(systemIds));
   }
 
+  @Deprecated
+  @SuppressWarnings({"MissingDeprecatedAnnotation", "DeprecatedIsStillUsed"})
   public static boolean confirmLoadingUntrustedProject(
     @NotNull Project project,
+    @NotNull Supplier<Boolean> confirmation,
     @NotNull Collection<ProjectSystemId> systemIds
   ) {
-    return confirmLoadingUntrustedProject(project, () -> true, systemIds);
+    return confirmLoadingUntrustedProject(project, confirmation.get(), systemIds);
   }
 
   public static boolean confirmLoadingUntrustedProject(
     @NotNull Project project,
-    @NotNull Supplier<Boolean> confirmation,
     ProjectSystemId... systemIds
   ) {
-    return confirmLoadingUntrustedProject(project, confirmation, Arrays.asList(systemIds));
+    return confirmLoadingUntrustedProject(project, true, systemIds);
   }
 
   public static boolean confirmLoadingUntrustedProject(
     @NotNull Project project,
-    @NotNull Supplier<Boolean> confirmation,
+    @NotNull Collection<ProjectSystemId> systemIds
+  ) {
+    return confirmLoadingUntrustedProject(project, true, systemIds);
+  }
+
+  public static boolean confirmLoadingUntrustedProject(
+    @NotNull Project project,
+    boolean askConfirmation,
+    ProjectSystemId... systemIds
+  ) {
+    return confirmLoadingUntrustedProject(project, askConfirmation, Arrays.asList(systemIds));
+  }
+
+  public static boolean confirmLoadingUntrustedProject(
+    @NotNull Project project,
+    boolean askConfirmation,
     @NotNull Collection<ProjectSystemId> systemIds
   ) {
     String systemsPresentation = StringUtil.join(systemIds, it -> it.getReadableName(), ", ");
     return TrustedProjects.isTrusted(project) || project.isDefault() || executesTrustedCodeOnly(systemIds) ||
-           confirmation.get() && TrustedProjects.confirmLoadingUntrustedProject(
+           askConfirmation && TrustedProjects.confirmLoadingUntrustedProject(
              project,
              ExternalSystemBundle.message("untrusted.project.notification.title", systemsPresentation, systemIds.size()),
              ExternalSystemBundle.message("untrusted.project.notification.text", systemsPresentation, systemIds.size()),
index 889a87ac9ebb6b222a6a8645c5049fd6c2c771ef..938f54377c636febc7294f637bbe214dda9aec83 100644 (file)
@@ -163,7 +163,7 @@ public final class MavenRunConfigurationType implements ConfigurationType {
                                       @Nullable ProgramRunner.Callback callback,
                                       boolean isDelegateBuild) {
 
-    if (!ExternalSystemUtil.confirmLoadingUntrustedProject(project, Collections.singletonList(MavenUtil.SYSTEM_ID))) {
+    if (!ExternalSystemUtil.confirmLoadingUntrustedProject(project, MavenUtil.SYSTEM_ID)) {
       MavenUtil.showError(project,
                           RunnerBundle.message("notification.title.failed.to.execute.maven.goal"),
                           RunnerBundle.message("notification.project.is.untrusted"));
index fafacf7f32c4e239009b9ba576b9f7027ca1ee67..24f13bf3363a9db5430c4f0ade76964fbd09dac4 100644 (file)
@@ -1055,7 +1055,7 @@ public class MavenUtil {
   }
 
   public static boolean isProjectTrustedEnoughToImport(Project project, boolean askConfirmation) {
-    return ExternalSystemUtil.confirmLoadingUntrustedProject(project, () -> askConfirmation, SYSTEM_ID);
+    return ExternalSystemUtil.confirmLoadingUntrustedProject(project, askConfirmation, SYSTEM_ID);
   }
 
   public static void restartMavenConnectors(Project project) {