From c5dd40ef6fa0b1e532798e6ec3d304906d6e27df Mon Sep 17 00:00:00 2001 From: Roman Shevchenko Date: Wed, 18 Sep 2024 18:55:49 +0200 Subject: [PATCH] Cleanup (dead code; suppressions; typos; formatting) GitOrigin-RevId: e588ffc8f225b7e451be7e03525cfe3e9bc5a19e --- .../impl/UpdateCheckerService.java | 15 ++-- .../impl/UpdateSettingsConfigurable.kt | 7 +- ...aseJetBrainsExternalProductResourceUrls.kt | 2 +- .../src/com/intellij/ui/LicensingFacade.java | 74 ++++++++----------- .../src/com/intellij/driver/client/Driver.kt | 38 ++++------ 5 files changed, 56 insertions(+), 80 deletions(-) diff --git a/platform/platform-impl/src/com/intellij/openapi/updateSettings/impl/UpdateCheckerService.java b/platform/platform-impl/src/com/intellij/openapi/updateSettings/impl/UpdateCheckerService.java index 3b2aebeb032c..c641d9665f23 100644 --- a/platform/platform-impl/src/com/intellij/openapi/updateSettings/impl/UpdateCheckerService.java +++ b/platform/platform-impl/src/com/intellij/openapi/updateSettings/impl/UpdateCheckerService.java @@ -25,7 +25,6 @@ import com.intellij.openapi.util.text.HtmlChunk; import com.intellij.openapi.util.text.StringUtil; import com.intellij.platform.ide.customization.ExternalProductResourceUrls; import com.intellij.ui.ExperimentalUI; -import com.intellij.util.SystemProperties; import com.intellij.util.Url; import com.intellij.util.concurrency.AppExecutorUtil; import com.intellij.util.text.DateFormatUtil; @@ -41,9 +40,9 @@ import java.nio.file.Files; import java.nio.file.Path; import java.util.*; import java.util.concurrent.ScheduledFuture; -import java.util.concurrent.TimeUnit; import static java.lang.Math.max; +import static java.util.concurrent.TimeUnit.*; @ApiStatus.Internal class UpdateCheckerService { @@ -55,9 +54,7 @@ class UpdateCheckerService { private static final Logger LOG = Logger.getInstance(UpdateCheckerService.class); - private static final long CHECK_INTERVAL_MS = TimeUnit.MINUTES.toMillis( - SystemProperties.getLongProperty("ide.updates.check.interval.minutes", TimeUnit.DAYS.toMinutes(1)) - ); + private static final long CHECK_INTERVAL_MS = MINUTES.toMillis(Long.getLong("ide.updates.check.interval.minutes", DAYS.toMinutes(1))); private static final String ERROR_LOG_FILE_NAME = "idea_updater_error.log"; // must be equal to 'com.intellij.updater.Runner.ERROR_LOG_FILE_NAME' private static final String PREVIOUS_BUILD_NUMBER_PROPERTY = "ide.updates.previous.build.number"; private static final String OLD_DIRECTORIES_SCAN_SCHEDULED = "ide.updates.old.dirs.scan.scheduled"; @@ -142,7 +139,7 @@ class UpdateCheckerService { } private void queueNextCheck(long delay) { - myScheduledCheck = AppExecutorUtil.getAppScheduledExecutorService().schedule(() -> checkUpdates(), delay, TimeUnit.MILLISECONDS); + myScheduledCheck = AppExecutorUtil.getAppScheduledExecutorService().schedule(() -> checkUpdates(), delay, MILLISECONDS); } private void checkUpdates() { @@ -333,7 +330,7 @@ class UpdateCheckerService { static void deleteOldApplicationDirectories() { PropertiesComponent propertyService = PropertiesComponent.getInstance(); if (ConfigImportHelper.isConfigImported()) { - long scheduledAt = System.currentTimeMillis() + TimeUnit.DAYS.toMillis(OLD_DIRECTORIES_SCAN_DELAY_DAYS); + long scheduledAt = System.currentTimeMillis() + DAYS.toMillis(OLD_DIRECTORIES_SCAN_DELAY_DAYS); LOG.info("scheduling old directories scan after " + DateFormatUtil.formatDateTime(scheduledAt)); propertyService.setValue(OLD_DIRECTORIES_SCAN_SCHEDULED, Long.toString(scheduledAt)); OldDirectoryCleaner.Stats.scheduled(); @@ -341,9 +338,9 @@ class UpdateCheckerService { else { long scheduledAt = propertyService.getLong(OLD_DIRECTORIES_SCAN_SCHEDULED, 0L), now; if (scheduledAt != 0 && (now = System.currentTimeMillis()) >= scheduledAt) { - OldDirectoryCleaner.Stats.started((int)TimeUnit.MILLISECONDS.toDays(now - scheduledAt) + OLD_DIRECTORIES_SCAN_DELAY_DAYS); + OldDirectoryCleaner.Stats.started((int)MILLISECONDS.toDays(now - scheduledAt) + OLD_DIRECTORIES_SCAN_DELAY_DAYS); LOG.info("starting old directories scan"); - long expireAfter = now - TimeUnit.DAYS.toMillis(OLD_DIRECTORIES_SHELF_LIFE_DAYS); + long expireAfter = now - DAYS.toMillis(OLD_DIRECTORIES_SHELF_LIFE_DAYS); new OldDirectoryCleaner(expireAfter).seekAndDestroy(null, null); propertyService.unsetValue(OLD_DIRECTORIES_SCAN_SCHEDULED); diff --git a/platform/platform-impl/src/com/intellij/openapi/updateSettings/impl/UpdateSettingsConfigurable.kt b/platform/platform-impl/src/com/intellij/openapi/updateSettings/impl/UpdateSettingsConfigurable.kt index cbd20d0fd329..d36a507558e1 100644 --- a/platform/platform-impl/src/com/intellij/openapi/updateSettings/impl/UpdateSettingsConfigurable.kt +++ b/platform/platform-impl/src/com/intellij/openapi/updateSettings/impl/UpdateSettingsConfigurable.kt @@ -150,11 +150,8 @@ class UpdateSettingsConfigurable @JvmOverloads constructor (private val checkNow onApply { val isEnabled = settings.isCheckNeeded || settings.isPluginsCheckNeeded if (isEnabled != wasEnabled) { - if (isEnabled) { - UpdateCheckerService.getInstance().queueNextCheck() - } - else { - UpdateCheckerService.getInstance().cancelChecks() + UpdateCheckerService.getInstance().apply { + if (isEnabled) queueNextCheck() else cancelChecks() } wasEnabled = isEnabled } diff --git a/platform/platform-impl/src/com/intellij/platform/ide/impl/customization/BaseJetBrainsExternalProductResourceUrls.kt b/platform/platform-impl/src/com/intellij/platform/ide/impl/customization/BaseJetBrainsExternalProductResourceUrls.kt index 1fed3e9bdcc9..59ea6084bc4e 100644 --- a/platform/platform-impl/src/com/intellij/platform/ide/impl/customization/BaseJetBrainsExternalProductResourceUrls.kt +++ b/platform/platform-impl/src/com/intellij/platform/ide/impl/customization/BaseJetBrainsExternalProductResourceUrls.kt @@ -21,7 +21,7 @@ abstract class BaseJetBrainsExternalProductResourceUrls : ExternalProductResourc abstract val basePatchDownloadUrl: Url /** - * Returns ID of YouTrack Project which will be used by the "Submit a Bug Report" action. + * Returns ID of YouTrack project which will be used by the "Submit a Bug Report" action. */ abstract val youtrackProjectId: String diff --git a/platform/platform-impl/src/com/intellij/ui/LicensingFacade.java b/platform/platform-impl/src/com/intellij/ui/LicensingFacade.java index 9c7292df5503..2b7f518cb88f 100644 --- a/platform/platform-impl/src/com/intellij/ui/LicensingFacade.java +++ b/platform/platform-impl/src/com/intellij/ui/LicensingFacade.java @@ -6,7 +6,6 @@ import com.google.gson.GsonBuilder; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.application.PermanentInstallationID; import com.intellij.openapi.util.NlsSafe; -import com.intellij.util.messages.MessageBus; import com.intellij.util.messages.Topic; import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; @@ -28,23 +27,26 @@ public final class LicensingFacade { public String metadata; @SuppressWarnings("StaticNonFinalField") public static volatile boolean isUnusedSignalled; - - /** - * @deprecated Use {@link #getInstance()} instead. - */ - @Deprecated + /** @deprecated Use {@link #getInstance()} instead */ + @Deprecated(forRemoval = true) + @SuppressWarnings("StaticNonFinalField") public static volatile LicensingFacade INSTANCE; + public boolean ai_enabled; public String subType; public static @Nullable LicensingFacade getInstance() { return INSTANCE; } - @ApiStatus.Internal - public static void setInstance(@Nullable LicensingFacade instance) { - INSTANCE = instance; - final MessageBus messageBus = ApplicationManager.getApplication().getMessageBus(); - messageBus.syncPublisher(LicenseStateListener.TOPIC).licenseStateChanged(instance); + /** + * @param productCode the product code to look up the expiration date for + * @return the expiration date for the specified product as it is hard-coded in the license. + * Normally, there is the last day when the license is still valid. + * {@code null} value is returned if expiration date is not applicable for the product or the license has not been obtained. + */ + public @Nullable Date getExpirationDate(String productCode) { + final Map result = expirationDates; + return result != null? result.get(productCode) : null; } public @Nullable String getLicensedToMessage() { @@ -82,36 +84,24 @@ public final class LicensingFacade { } /** - * @param productCode the product code to lookup the expiration date for - * @return the expiration date for the specified product as it is hard-coded in the license. - * Normally the is the last day when the license is still valid. - * null value is returned if expiration date is not applicable for the product, or the licence has net been obtained - */ - public @Nullable Date getExpirationDate(String productCode) { - final Map result = expirationDates; - return result != null? result.get(productCode) : null; - } - - /** - * @return a "confirmation stamp" string describing the license obtained by the licensing subsystem for the product with the given productCode. - * returns null, if no license is currently obtained for the product. - * - * A confirmation stamp is structured according to the following rules: - *
-   *  confirmationStamp := key:'license-key' | stamp:'license-server-stamp' | eval:'eval-key'
-   *  

- * licenseKey := 'licenseId'-'licenseJsonBase64'-'signatureBase64'-'certificateBase64'
- * the signed part is licenseJson - *

- * license-server-stamp := 'timestampLong':'machineId':'signatureType':'signatureBase64':'certificateBase64'[:'intermediate-certificateBase64'] - *
- * the signed part is 'timestampLong':'machineId'
- * machineId should be the same as {@link PermanentInstallationID#get()} returns - *

- * eval-key := 'expiration-date-long' - * - * @see JetBrains Marketplace online documentation for more information - *
+ * @return a "confirmation stamp" string describing the license obtained by the licensing subsystem for the product + * with the given productCode, or {@code null} if no license is currently obtained for the product. + *

+ * A confirmation stamp is structured according to the following rules: + *

+   *   confirmationStamp := key:'license-key' | stamp:'license-server-stamp' | eval:'eval-key'
+   *   
+ * licenseKey := 'licenseId'-'licenseJsonBase64'-'signatureBase64'-'certificateBase64'
+ * the signed part is licenseJson + *
+ * license-server-stamp := 'timestampLong':'machineId':'signatureType':'signatureBase64':'certificateBase64'[:'intermediate-certificateBase64']
+ * the signed part is 'timestampLong':'machineId'
+ * machineId should be the same as {@link PermanentInstallationID#get()} returns + *
+ * eval-key := 'expiration-date-long' + *
+ * @see + * JetBrains Marketplace online documentation for more information */ public @Nullable String getConfirmationStamp(String productCode) { final Map result = confirmationStamps; @@ -156,4 +146,4 @@ public final class LicensingFacade { @NotNull Topic TOPIC = new Topic<>(LicenseStateListener.class); void licenseStateChanged(@Nullable LicensingFacade newState); } -} \ No newline at end of file +} diff --git a/platform/remote-driver/client/src/com/intellij/driver/client/Driver.kt b/platform/remote-driver/client/src/com/intellij/driver/client/Driver.kt index cef1c0d217f1..00b8a576abcc 100644 --- a/platform/remote-driver/client/src/com/intellij/driver/client/Driver.kt +++ b/platform/remote-driver/client/src/com/intellij/driver/client/Driver.kt @@ -77,8 +77,8 @@ interface Driver : AutoCloseable { /** * Forcefully exits the application. - * Don't use directly in tests, instead use [com.intellij.ide.starter.driver.engine.BackgroundRun.closeIdeAndWait], otherwise - * test on RemDev won't work since client and not host will be closed. + * Don't use directly in tests, instead use `com.intellij.ide.starter.driver.engine.BackgroundRun.closeIdeAndWait`, + * otherwise remote dev tests won't work since the client and not the host will be closed. */ fun exitApplication() @@ -111,9 +111,7 @@ interface Driver : AutoCloseable { /** * @return proxy reference for a newly created remote object */ - fun new(clazz: KClass, vararg args: Any?): T { - return new(clazz, *args, rdTarget = RdTarget.DEFAULT) - } + fun new(clazz: KClass, vararg args: Any?): T = new(clazz, *args, rdTarget = RdTarget.DEFAULT) fun new(clazz: KClass, vararg args: Any?, rdTarget: RdTarget = RdTarget.DEFAULT): T @@ -125,15 +123,16 @@ interface Driver : AutoCloseable { /** * Runs the block with the specified dispatcher and lock semantics. */ - fun withContext(dispatcher: OnDispatcher = OnDispatcher.DEFAULT, - semantics: LockSemantics = LockSemantics.NO_LOCK, - code: Driver.() -> T): T + fun withContext( + dispatcher: OnDispatcher = OnDispatcher.DEFAULT, + semantics: LockSemantics = LockSemantics.NO_LOCK, + code: Driver.() -> T + ): T /** * Runs the block that requires a read action with the specified dispatcher. */ - fun withReadAction(dispatcher: OnDispatcher = OnDispatcher.DEFAULT, - code: Driver.() -> T): T + fun withReadAction(dispatcher: OnDispatcher = OnDispatcher.DEFAULT, code: Driver.() -> T): T /** * Runs the block that requires a write action. @@ -147,34 +146,27 @@ interface Driver : AutoCloseable { */ @JvmStatic @Contract(pure = true) - fun create(host: JmxHost? = JmxHost(null, null, "localhost:7777"), isRemoteIdeMode: Boolean = false): Driver { - return DriverImpl(host, isRemoteIdeMode) - } + fun create(host: JmxHost? = JmxHost(null, null, "localhost:7777"), isRemoteIdeMode: Boolean = false): Driver = + DriverImpl(host, isRemoteIdeMode) } } /** - * Remote reference to a Project. + * Remote reference to a project. */ interface ProjectRef : PolymorphRef /** * @return new remote proxy for a [Remote] application service interface */ -inline fun Driver.service(rdTarget: RdTarget = RdTarget.DEFAULT): T { - return service(T::class, rdTarget) -} +inline fun Driver.service(rdTarget: RdTarget = RdTarget.DEFAULT): T = service(T::class, rdTarget) /** * @return new remote proxy for a [Remote] application service interface */ -inline fun Driver.service(project: ProjectRef, rdTarget: RdTarget = RdTarget.DEFAULT): T { - return service(T::class, project, rdTarget) -} +inline fun Driver.service(project: ProjectRef, rdTarget: RdTarget = RdTarget.DEFAULT): T = service(T::class, project, rdTarget) /** * @return new remote proxy for a utility class or a class with static methods */ -inline fun Driver.utility(rdTarget: RdTarget = RdTarget.DEFAULT): T { - return utility(T::class, rdTarget) -} +inline fun Driver.utility(rdTarget: RdTarget = RdTarget.DEFAULT): T = utility(T::class, rdTarget)