From 8d06affcc719bc3e68c574039c36b95dbccadf2f Mon Sep 17 00:00:00 2001 From: Vladimir Krivosheev Date: Wed, 17 Jul 2024 13:54:59 +0200 Subject: [PATCH] IJPL-158442 cleanup GitOrigin-RevId: de9a25c2a01e84aeef8bdac2eebdab34e56eaf5e --- .../src/com/intellij/util/SingleAlarm.kt | 3 +-- .../xdebugger/impl/frame/XDebugView.java | 27 +++++++++---------- 2 files changed, 13 insertions(+), 17 deletions(-) diff --git a/platform/ide-core/src/com/intellij/util/SingleAlarm.kt b/platform/ide-core/src/com/intellij/util/SingleAlarm.kt index 79f2ea97816a..054e36991d6a 100644 --- a/platform/ide-core/src/com/intellij/util/SingleAlarm.kt +++ b/platform/ide-core/src/com/intellij/util/SingleAlarm.kt @@ -34,8 +34,7 @@ private val LOG: Logger = logger() * Alarm is deprecated. * Allows scheduling a single `Runnable` instance ([task]) to be executed after a specific time interval on a specific thread. * [request] adds a request if it's not scheduled yet, i.e., it does not delay execution of the request - * [cancelAndRequest] cancels the current request and schedules a new one instead, i.e., it delays execution of the request - * + * [cancelAndRequest] cancels the current request and schedules a new one instead, i.e., it delays execution of the request. */ class SingleAlarm @Internal constructor( private val task: Runnable, diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/frame/XDebugView.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/frame/XDebugView.java index 7bdd7e3f482b..9002878c897b 100644 --- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/frame/XDebugView.java +++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/frame/XDebugView.java @@ -1,4 +1,4 @@ -// Copyright 2000-2021 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. package com.intellij.xdebugger.impl.frame; import com.intellij.execution.ui.layout.ViewContext; @@ -20,50 +20,47 @@ import java.util.EventObject; public abstract class XDebugView implements Disposable { public enum SessionEvent {PAUSED, BEFORE_RESUME, RESUMED, STOPPED, FRAME_CHANGED, SETTINGS_CHANGED} - private final SingleAlarm myClearAlarm; + private final SingleAlarm clearAlarm; private static final int VIEW_CLEAR_DELAY = 100; //ms public XDebugView() { - myClearAlarm = new SingleAlarm(() -> clear(), VIEW_CLEAR_DELAY, this); + clearAlarm = SingleAlarm.Companion.singleEdtAlarm(VIEW_CLEAR_DELAY, this, () -> clear()); } protected final void requestClear() { - if (ApplicationManager.getApplication().isUnitTestMode()) { // no delay in tests - if (!myClearAlarm.isDisposed()) { + // no delay in tests + if (ApplicationManager.getApplication().isUnitTestMode()) { + if (!clearAlarm.isDisposed()) { clear(); } } else { - myClearAlarm.cancelAndRequest(); + clearAlarm.cancelAndRequest(); } } - @Nullable - public JComponent getMainComponent() { + public @Nullable JComponent getMainComponent() { return null; } protected final void cancelClear() { - myClearAlarm.cancel(); + clearAlarm.cancel(); } protected abstract void clear(); public abstract void processSessionEvent(@NotNull SessionEvent event, @NotNull XDebugSession session); - @Nullable - protected static XDebugSession getSession(@NotNull EventObject e) { + protected static @Nullable XDebugSession getSession(@NotNull EventObject e) { Component component = e.getSource() instanceof Component ? (Component)e.getSource() : null; return component == null ? null : getSession(component); } - @Nullable - public static XDebugSession getSession(@NotNull Component component) { + public static @Nullable XDebugSession getSession(@NotNull Component component) { return getData(XDebugSession.DATA_KEY, component); } - @Nullable - public static T getData(DataKey key, @NotNull Component component) { + public static @Nullable T getData(DataKey key, @NotNull Component component) { DataContext dataContext = DataManager.getInstance().getDataContext(component); ViewContext viewContext = ViewContext.CONTEXT_KEY.getData(dataContext); ContentManager contentManager = viewContext == null ? null : viewContext.getContentManager();