Cleanup (dead code; suppressions; typos; formatting)

GitOrigin-RevId: e588ffc8f225b7e451be7e03525cfe3e9bc5a19e
This commit is contained in:
Roman Shevchenko
2024-09-18 18:55:49 +02:00
committed by intellij-monorepo-bot
parent e2e06928e6
commit c5dd40ef6f
5 changed files with 56 additions and 80 deletions

View File

@@ -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);

View File

@@ -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
}

View File

@@ -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

View File

@@ -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<String, Date> 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<String, Date> 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:
* <pre>
* confirmationStamp := key:'license-key' | stamp:'license-server-stamp' | eval:'eval-key'
* <br><br>
* licenseKey := 'licenseId'-'licenseJsonBase64'-'signatureBase64'-'certificateBase64' <br>
* the signed part is licenseJson
* <br><br>
* license-server-stamp := 'timestampLong':'machineId':'signatureType':'signatureBase64':'certificateBase64'[:'intermediate-certificateBase64']
* <br>
* the signed part is 'timestampLong':'machineId' <br>
* machineId should be the same as {@link PermanentInstallationID#get()} returns
* <br><br>
* eval-key := 'expiration-date-long'
*
* @see <a href="https://plugins.jetbrains.com/docs/marketplace/add-marketplace-license-verification-calls-to-the-plugin-code.html">JetBrains Marketplace online documentation</a> for more information
* </pre>
* @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.
* <p>
* A confirmation stamp is structured according to the following rules:
* <pre>
* confirmationStamp := key:'license-key' | stamp:'license-server-stamp' | eval:'eval-key'
* <br>
* licenseKey := 'licenseId'-'licenseJsonBase64'-'signatureBase64'-'certificateBase64'<br>
* the signed part is licenseJson
* <br>
* license-server-stamp := 'timestampLong':'machineId':'signatureType':'signatureBase64':'certificateBase64'[:'intermediate-certificateBase64']<br>
* the signed part is 'timestampLong':'machineId' <br>
* machineId should be the same as {@link PermanentInstallationID#get()} returns
* <br>
* eval-key := 'expiration-date-long'
* </pre>
* @see <a href="https://plugins.jetbrains.com/docs/marketplace/add-marketplace-license-verification-calls-to-the-plugin-code.html">
* JetBrains Marketplace online documentation</a> for more information
*/
public @Nullable String getConfirmationStamp(String productCode) {
final Map<String, String> result = confirmationStamps;
@@ -156,4 +146,4 @@ public final class LicensingFacade {
@NotNull Topic<LicenseStateListener> TOPIC = new Topic<>(LicenseStateListener.class);
void licenseStateChanged(@Nullable LicensingFacade newState);
}
}
}

View File

@@ -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 <T : Any> new(clazz: KClass<T>, vararg args: Any?): T {
return new(clazz, *args, rdTarget = RdTarget.DEFAULT)
}
fun <T : Any> new(clazz: KClass<T>, vararg args: Any?): T = new(clazz, *args, rdTarget = RdTarget.DEFAULT)
fun <T : Any> new(clazz: KClass<T>, 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 <T> withContext(dispatcher: OnDispatcher = OnDispatcher.DEFAULT,
semantics: LockSemantics = LockSemantics.NO_LOCK,
code: Driver.() -> T): T
fun <T> 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 <T> withReadAction(dispatcher: OnDispatcher = OnDispatcher.DEFAULT,
code: Driver.() -> T): T
fun <T> 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 <reified T : Any> Driver.service(rdTarget: RdTarget = RdTarget.DEFAULT): T {
return service(T::class, rdTarget)
}
inline fun <reified T : Any> Driver.service(rdTarget: RdTarget = RdTarget.DEFAULT): T = service(T::class, rdTarget)
/**
* @return new remote proxy for a [Remote] application service interface
*/
inline fun <reified T : Any> Driver.service(project: ProjectRef, rdTarget: RdTarget = RdTarget.DEFAULT): T {
return service(T::class, project, rdTarget)
}
inline fun <reified T : Any> 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 <reified T : Any> Driver.utility(rdTarget: RdTarget = RdTarget.DEFAULT): T {
return utility(T::class, rdTarget)
}
inline fun <reified T : Any> Driver.utility(rdTarget: RdTarget = RdTarget.DEFAULT): T = utility(T::class, rdTarget)