LoadingPhase -> LoadingState

GitOrigin-RevId: eedb0614859333f1bc027a7de2016e6c18bb3f12
This commit is contained in:
Vladimir Krivosheev
2019-09-21 07:43:29 +00:00
committed by intellij-monorepo-bot
parent bf99c40fbe
commit d60bc3d3a1
32 changed files with 130 additions and 129 deletions
@@ -1,7 +1,7 @@
// Copyright 2000-2019 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.
package com.intellij.psi.tree;
import com.intellij.diagnostic.LoadingPhase;
import com.intellij.diagnostic.LoadingState;
import com.intellij.lang.Language;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.util.text.StringUtil;
@@ -88,7 +88,7 @@ public class IElementType {
this(debugName, language, true);
if (!(this instanceof IFileElementType)) {
LoadingPhase.COMPONENT_LOADED.assertAtLeast();
LoadingState.COMPONENTS_LOADED.checkOccurred();
}
}
@@ -68,7 +68,7 @@ public final class PerformanceWatcher implements Disposable {
@NotNull
public static PerformanceWatcher getInstance() {
LoadingPhase.CONFIGURATION_STORE_INITIALIZED.assertAtLeast();
LoadingState.CONFIGURATION_STORE_INITIALIZED.checkOccurred();
return ServiceManager.getService(PerformanceWatcher.class);
}
@@ -229,7 +229,7 @@ public final class PerformanceWatcher implements Disposable {
myLastDumpTime = currentMillis;
if (myFreezeStart == 0) {
myFreezeStart = myLastEdtAlive;
myFreezeDuringStartup = !LoadingPhase.isStartupComplete();
myFreezeDuringStartup = !LoadingState.INDEXING_FINISHED.isOccurred();
getPublisher().uiFreezeStarted();
}
dumpThreads();
@@ -2,7 +2,7 @@
package com.intellij.openapi.application;
import com.google.common.base.MoreObjects;
import com.intellij.diagnostic.LoadingPhase;
import com.intellij.diagnostic.LoadingState;
import com.intellij.diagnostic.StartUpMeasurer;
import com.intellij.ide.plugins.PluginManagerCore;
import com.intellij.ide.plugins.cl.PluginClassLoader;
@@ -251,7 +251,7 @@ public class TransactionGuardImpl extends TransactionGuard {
}
private static boolean areAssertionsEnabled() {
return LoadingPhase.COMPONENT_LOADED.isComplete() && Registry.is("ide.require.transaction.for.model.changes", false);
return LoadingState.COMPONENTS_LOADED.isOccurred() && Registry.is("ide.require.transaction.for.model.changes", false);
}
@Override
@@ -1,7 +1,7 @@
// Copyright 2000-2019 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.
package com.intellij.ide.ui
import com.intellij.diagnostic.LoadingPhase
import com.intellij.diagnostic.LoadingState
import com.intellij.openapi.Disposable
import com.intellij.openapi.application.ApplicationManager
import com.intellij.openapi.components.PersistentStateComponent
@@ -419,7 +419,7 @@ class UISettings constructor(private val notRoamableOptions: NotRoamableUiSettin
get() {
var result = cachedInstance
if (result == null) {
LoadingPhase.CONFIGURATION_STORE_INITIALIZED.assertAtLeast()
LoadingState.CONFIGURATION_STORE_INITIALIZED.checkOccurred()
result = ApplicationManager.getApplication().getService(UISettings::class.java)!!
cachedInstance = result
}
@@ -430,7 +430,7 @@ class UISettings constructor(private val notRoamableOptions: NotRoamableUiSettin
val instanceOrNull: UISettings?
get() {
val result = cachedInstance
if (result == null && LoadingPhase.CONFIGURATION_STORE_INITIALIZED.isComplete) {
if (result == null && LoadingState.CONFIGURATION_STORE_INITIALIZED.isOccurred) {
return instance
}
return result
@@ -464,7 +464,7 @@ class UISettings constructor(private val notRoamableOptions: NotRoamableUiSettin
g as Graphics2D
g.setRenderingHint(RenderingHints.KEY_TEXT_LCD_CONTRAST, UIUtil.getLcdContrastValue())
if (LoadingPhase.CONFIGURATION_STORE_INITIALIZED.isComplete && ApplicationManager.getApplication() == null) {
if (LoadingState.CONFIGURATION_STORE_INITIALIZED.isOccurred && ApplicationManager.getApplication() == null) {
// cannot use services while Application has not been loaded yet, so let's apply the default hints
GraphicsUtil.applyRenderingHints(g)
return
@@ -1,7 +1,7 @@
// Copyright 2000-2019 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.
package com.intellij.openapi.application;
import com.intellij.diagnostic.LoadingPhase;
import com.intellij.diagnostic.LoadingState;
import com.intellij.ide.util.PropertiesComponent;
import com.intellij.openapi.components.Service;
import com.intellij.openapi.components.ServiceManager;
@@ -30,7 +30,7 @@ public final class Experiments {
}
public boolean isFeatureEnabled(@NotNull String featureId) {
if (!LoadingPhase.COMPONENT_REGISTERED.isComplete()) {
if (!LoadingState.COMPONENTS_REGISTERED.isOccurred()) {
return false;
}
@@ -66,7 +66,7 @@ public final class Experiments {
@Nullable
private static ExperimentalFeature getFeatureById(@NotNull String featureId) {
if (!LoadingPhase.COMPONENT_REGISTERED.isComplete()) {
if (!LoadingState.COMPONENTS_REGISTERED.isOccurred()) {
return null;
}
return EP_NAME.findFirstSafe(feature -> feature.id.equals(featureId));
@@ -1,7 +1,7 @@
// Copyright 2000-2019 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.
package com.intellij.openapi.keymap;
import com.intellij.diagnostic.LoadingPhase;
import com.intellij.diagnostic.LoadingState;
import com.intellij.openapi.Disposable;
import com.intellij.openapi.application.Application;
import com.intellij.openapi.application.ApplicationManager;
@@ -26,7 +26,7 @@ public abstract class KeymapManager {
public static KeymapManager getInstance() {
Application application = ApplicationManager.getApplication();
if (application == null || !LoadingPhase.CONFIGURATION_STORE_INITIALIZED.isComplete()) {
if (application == null || !LoadingState.CONFIGURATION_STORE_INITIALIZED.isOccurred()) {
return null;
}
@@ -1,7 +1,7 @@
// Copyright 2000-2019 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.
package com.intellij.openapi.wm;
import com.intellij.diagnostic.LoadingPhase;
import com.intellij.diagnostic.LoadingState;
import com.intellij.openapi.actionSystem.CommonDataKeys;
import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.application.Application;
@@ -217,7 +217,7 @@ public abstract class IdeFocusManager implements FocusRequestor {
IdeFocusManager focusManager = null;
Application app = ApplicationManager.getApplication();
if (app != null && LoadingPhase.COMPONENT_REGISTERED.isComplete()) {
if (app != null && LoadingState.COMPONENTS_REGISTERED.isOccurred()) {
focusManager = app.getComponent(IdeFocusManager.class);
}
@@ -39,7 +39,7 @@ public class DialogAppender extends AppenderSkeleton {
return; // the dialog appender doesn't deal with non-critical errors and is meaningless when there is no frame to show an error icon
}
if (LoadingPhase.COMPONENT_LOADED.isComplete()) {
if (LoadingState.COMPONENTS_LOADED.isOccurred()) {
LoggingEvent queued;
while ((queued = myEarlyEvents.poll()) != null) queueAppend(queued);
queueAppend(event);
@@ -49,7 +49,7 @@ open class GcPauseWatcher {
}
protected open fun recordGcPauseTime(name: String, currPauseDuration: Long) {
if (!LoadingPhase.isStartupComplete()) {
if (StartUpMeasurer.isEnabled()) {
StartUpMeasurer.addCompletedActivity(StartUpMeasurer.getCurrentTime() - TimeUnit.MILLISECONDS.toNanos(currPauseDuration), Integer.toString(counter.incrementAndGet()), ActivityCategory.GC, null)
}
}
@@ -1,7 +1,7 @@
// Copyright 2000-2019 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.
package com.intellij.ide;
import com.intellij.diagnostic.LoadingPhase;
import com.intellij.diagnostic.LoadingState;
import com.intellij.diagnostic.PerformanceWatcher;
import com.intellij.ide.actions.MaximizeActiveDialogAction;
import com.intellij.ide.dnd.DnDManager;
@@ -347,7 +347,7 @@ public final class IdeEventQueue extends EventQueue {
return true;
}
if (LoadingPhase.COMPONENT_LOADED.isComplete()) {
if (LoadingState.COMPONENTS_LOADED.isOccurred()) {
ourAppIsLoaded = true;
return true;
}
@@ -553,7 +553,7 @@ public final class IdeEventQueue extends EventQueue {
@Nullable
private static PerformanceWatcher obtainPerformanceWatcher() {
PerformanceWatcher watcher = ourPerformanceWatcher;
if (watcher == null && LoadingPhase.CONFIGURATION_STORE_INITIALIZED.isComplete()) {
if (watcher == null && LoadingState.CONFIGURATION_STORE_INITIALIZED.isOccurred()) {
Application app = ApplicationManager.getApplication();
if (app != null && !app.isDisposed()) {
watcher = PerformanceWatcher.getInstance();
@@ -1,7 +1,7 @@
// Copyright 2000-2019 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.
package com.intellij.ide.plugins;
import com.intellij.diagnostic.LoadingPhase;
import com.intellij.diagnostic.LoadingState;
import com.intellij.openapi.components.Service;
import com.intellij.openapi.components.ServiceManager;
import com.intellij.openapi.extensions.PluginId;
@@ -23,7 +23,7 @@ import java.util.Set;
public final class InstalledPluginsState {
@Nullable
public static InstalledPluginsState getInstanceIfLoaded() {
return LoadingPhase.COMPONENT_LOADED.isComplete() ? getInstance() : null;
return LoadingState.COMPONENTS_LOADED.isOccurred() ? getInstance() : null;
}
public static InstalledPluginsState getInstance() {
@@ -415,7 +415,7 @@ fun initConfigurationStore(app: ApplicationImpl, configPath: String?) {
// we set it after beforeApplicationLoaded call, because app store can depend on stream provider state
app.stateStore.setPath(effectiveConfigPath)
LoadingPhase.setCurrentPhase(LoadingPhase.CONFIGURATION_STORE_INITIALIZED)
StartUpMeasurer.setCurrentState(LoadingState.CONFIGURATION_STORE_INITIALIZED)
activity.end()
}
@@ -4,7 +4,7 @@ package com.intellij.idea;
import com.intellij.Patches;
import com.intellij.concurrency.IdeaForkJoinWorkerThreadFactory;
import com.intellij.diagnostic.Activity;
import com.intellij.diagnostic.LoadingPhase;
import com.intellij.diagnostic.LoadingState;
import com.intellij.diagnostic.StartUpMeasurer;
import com.intellij.ide.CliResult;
import com.intellij.ide.IdeEventQueue;
@@ -68,7 +68,7 @@ import java.util.concurrent.*;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.function.Function;
import static com.intellij.diagnostic.LoadingPhase.LAF_INITIALIZED;
import static com.intellij.diagnostic.LoadingState.LAF_INITIALIZED;
import static java.nio.file.attribute.PosixFilePermission.*;
public final class StartupUtil {
@@ -139,7 +139,7 @@ public final class StartupUtil {
}
public static void prepareApp(@NotNull String[] args, @NotNull String mainClass) throws Exception {
LoadingPhase.setStrictMode();
LoadingState.setStrictMode();
Activity activity = StartUpMeasurer.startMainActivity("ForkJoin CommonPool configuration");
IdeaForkJoinWorkerThreadFactory.setupForkJoinCommonPool(Main.isHeadless(args));
@@ -277,7 +277,7 @@ public final class StartupUtil {
}
future.complete(null);
LoadingPhase.setCurrentPhase(LAF_INITIALIZED);
StartUpMeasurer.setCurrentState(LAF_INITIALIZED);
if (Main.isHeadless()) {
return;
@@ -3,7 +3,7 @@ package com.intellij.notification.impl;
import com.intellij.application.Topics;
import com.intellij.codeInsight.hint.TooltipController;
import com.intellij.diagnostic.LoadingPhase;
import com.intellij.diagnostic.LoadingState;
import com.intellij.icons.AllIcons;
import com.intellij.ide.DataManager;
import com.intellij.ide.FrameStateListener;
@@ -138,7 +138,7 @@ public final class NotificationsManagerImpl extends NotificationsManager {
}
private static void showNotification(@NotNull final Notification notification, @Nullable final Project project) {
if (!LoadingPhase.COMPONENT_LOADED.isComplete()) {
if (!LoadingState.COMPONENTS_LOADED.isOccurred()) {
ApplicationManager.getApplication().invokeLater(() -> showNotification(notification, project), ModalityState.current());
return;
}
@@ -1,7 +1,7 @@
// Copyright 2000-2019 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.
package com.intellij.openapi.application.ex;
import com.intellij.diagnostic.LoadingPhase;
import com.intellij.diagnostic.LoadingState;
import com.intellij.openapi.application.ApplicationManager;
import org.jetbrains.annotations.ApiStatus;
@@ -11,11 +11,11 @@ public final class ApplicationManagerEx extends ApplicationManager {
}
/**
* @deprecated Use {@code LoadingPhase.COMPONENT_LOADED.isComplete()}.
* @deprecated Use {@code LoadingState.COMPONENTS_LOADED.isOccurred()}.
*/
@Deprecated
@ApiStatus.ScheduledForRemoval
public static boolean isAppLoaded() {
return LoadingPhase.COMPONENT_LOADED.isComplete();
return LoadingState.COMPONENTS_LOADED.isOccurred();
}
}
@@ -336,7 +336,7 @@ public class ApplicationImpl extends PlatformComponentManagerImpl implements App
else {
ProgressManager.getInstance().runProcess(() -> createComponents(indicator), indicator);
}
LoadingPhase.setCurrentPhase(LoadingPhase.COMPONENT_LOADED);
StartUpMeasurer.setCurrentState(LoadingState.COMPONENTS_LOADED);
}
finally {
token.finish();
@@ -1,7 +1,7 @@
// Copyright 2000-2019 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.
package com.intellij.openapi.application.impl;
import com.intellij.diagnostic.LoadingPhase;
import com.intellij.diagnostic.LoadingState;
import com.intellij.ide.IdeEventQueue;
import com.intellij.openapi.Disposable;
import com.intellij.openapi.application.*;
@@ -206,7 +206,7 @@ public class LaterInvocator {
ourModalityStack.push(appendedState);
}
TransactionGuardImpl guard = LoadingPhase.COMPONENT_LOADED.isComplete() ? (TransactionGuardImpl)TransactionGuard.getInstance() : null;
TransactionGuardImpl guard = LoadingState.COMPONENTS_LOADED.isOccurred() ? (TransactionGuardImpl)TransactionGuard.getInstance() : null;
if (guard != null) {
guard.enteredModality(appendedState);
}
@@ -6,7 +6,7 @@ import com.intellij.configurationStore.BundledSchemeEP;
import com.intellij.configurationStore.LazySchemeProcessor;
import com.intellij.configurationStore.SchemeDataHolder;
import com.intellij.configurationStore.SchemeExtensionProvider;
import com.intellij.diagnostic.LoadingPhase;
import com.intellij.diagnostic.LoadingState;
import com.intellij.ide.WelcomeWizardUtil;
import com.intellij.ide.ui.LafManager;
import com.intellij.ide.ui.UITheme;
@@ -366,7 +366,7 @@ public final class EditorColorsManagerImpl extends EditorColorsManager implement
@Override
public void setGlobalScheme(@Nullable EditorColorsScheme scheme) {
boolean notify = LoadingPhase.COMPONENT_LOADED.isComplete();
boolean notify = LoadingState.COMPONENTS_LOADED.isOccurred();
mySchemeManager.setCurrent(scheme == null ? getDefaultScheme() : scheme, notify);
}
@@ -2,7 +2,8 @@
package com.intellij.openapi.project;
import com.google.common.annotations.VisibleForTesting;
import com.intellij.diagnostic.LoadingPhase;
import com.intellij.diagnostic.LoadingState;
import com.intellij.diagnostic.StartUpMeasurer;
import com.intellij.diagnostic.ThreadDumper;
import com.intellij.ide.IdeBundle;
import com.intellij.ide.file.BatchFileChangeListener;
@@ -350,7 +351,7 @@ public class DumbServiceImpl extends DumbService implements Disposable, Modifica
}
}
LoadingPhase.compareAndSet(LoadingPhase.PROJECT_OPENED, LoadingPhase.INDEXING_FINISHED);
StartUpMeasurer.compareAndSetCurrentState(LoadingState.PROJECT_OPENED, LoadingState.INDEXING_FINISHED);
myDumbEnterTrace = null;
myDumbStart = null;
@@ -477,10 +477,10 @@ public class ProjectManagerImpl extends ProjectManagerEx implements Disposable {
StartUpMeasurer.stopPluginCostMeasurement();
}, ModalityState.NON_MODAL, project.getDisposedOrDisposeInProgress());
ApplicationManager.getApplication().invokeLater(() -> {
LoadingPhase.compareAndSet(LoadingPhase.COMPONENT_LOADED,
DumbService.isDumb(project)
? LoadingPhase.PROJECT_OPENED
: LoadingPhase.INDEXING_FINISHED);
LoadingState phase = DumbService.isDumb(project)
? LoadingState.PROJECT_OPENED
: LoadingState.INDEXING_FINISHED;
StartUpMeasurer.compareAndSetCurrentState(LoadingState.COMPONENTS_LOADED, phase);
if (!project.isDisposedOrDisposeInProgress()) {
startupManager.scheduleBackgroundPostStartupActivities();
@@ -1,7 +1,7 @@
// Copyright 2000-2019 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.
package com.intellij.openapi.vfs.newvfs;
import com.intellij.diagnostic.LoadingPhase;
import com.intellij.diagnostic.LoadingState;
import com.intellij.internal.statistic.DelayedIdeActivity;
import com.intellij.openapi.application.Application;
import com.intellij.openapi.application.ApplicationManager;
@@ -19,7 +19,7 @@ import org.jetbrains.annotations.NotNull;
final class RefreshProgress extends ProgressIndicatorBase {
@NotNull
public static ProgressIndicator create(@NotNull String message) {
Application app = LoadingPhase.COMPONENT_LOADED.isComplete() ? ApplicationManager.getApplication() : null;
Application app = LoadingState.COMPONENTS_LOADED.isOccurred() ? ApplicationManager.getApplication() : null;
return app == null || app.isUnitTestMode() ? new EmptyProgressIndicator() : new RefreshProgress(message);
}
@@ -1,7 +1,7 @@
// Copyright 2000-2019 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.
package com.intellij.openapi.wm.impl;
import com.intellij.diagnostic.LoadingPhase;
import com.intellij.diagnostic.LoadingState;
import com.intellij.ide.ui.UISettings;
import com.intellij.openapi.actionSystem.DataProvider;
import com.intellij.openapi.project.Project;
@@ -100,7 +100,7 @@ public final class IdeFrameImpl extends JFrame implements IdeFrame, DataProvider
@Override
public void setExtendedState(int state) {
// do not load FrameInfoHelper class
if (LoadingPhase.COMPONENT_REGISTERED.isComplete() && getExtendedState() == Frame.NORMAL && FrameInfoHelper.isMaximized(state)) {
if (LoadingState.COMPONENTS_REGISTERED.isOccurred() && getExtendedState() == Frame.NORMAL && FrameInfoHelper.isMaximized(state)) {
getRootPane().putClientProperty(NORMAL_STATE_BOUNDS, getBounds());
}
super.setExtendedState(state);
@@ -108,7 +108,7 @@ public final class IdeFrameImpl extends JFrame implements IdeFrame, DataProvider
@Override
public void paint(@NotNull Graphics g) {
if (LoadingPhase.COMPONENT_REGISTERED.isComplete()) {
if (LoadingState.COMPONENTS_REGISTERED.isOccurred()) {
UISettings.setupAntialiasing(g);
}
@@ -2,7 +2,7 @@
package com.intellij.ui.mac;
import com.apple.eawt.Application;
import com.intellij.diagnostic.LoadingPhase;
import com.intellij.diagnostic.LoadingState;
import com.intellij.ide.DataManager;
import com.intellij.ide.actions.AboutAction;
import com.intellij.ide.actions.ShowSettingsAction;
@@ -69,7 +69,7 @@ public final class MacOSApplicationProvider {
application.setOpenFileHandler(event -> {
List<File> files = event.getFiles();
if (files.isEmpty()) return;
if (LoadingPhase.COMPONENT_LOADED.isComplete()) {
if (LoadingState.COMPONENTS_LOADED.isOccurred()) {
Project project = getProject(false);
submit("OpenFile", () -> ProjectUtil.tryOpenFileList(project, files, "MacMenu"));
}
@@ -1,7 +1,7 @@
// Copyright 2000-2019 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.
package com.intellij.ui.messages;
import com.intellij.diagnostic.LoadingPhase;
import com.intellij.diagnostic.LoadingState;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.*;
@@ -52,7 +52,7 @@ public class MessagesServiceImpl implements MessagesService {
try {
if (canShowMacSheetPanel() && !alwaysUseIdeaUI) {
WindowManager windowManager = LoadingPhase.COMPONENT_REGISTERED.isComplete() ? WindowManager.getInstance() : null;
WindowManager windowManager = LoadingState.COMPONENTS_REGISTERED.isOccurred() ? WindowManager.getInstance() : null;
if (windowManager != null) {
Window parentWindow = windowManager.suggestParentWindow(project);
return MacMessages.getInstance()
@@ -2,7 +2,7 @@
package com.intellij.ide.plugins;
import com.intellij.diagnostic.ImplementationConflictException;
import com.intellij.diagnostic.LoadingPhase;
import com.intellij.diagnostic.LoadingState;
import com.intellij.diagnostic.PluginException;
import com.intellij.idea.Main;
import com.intellij.openapi.application.ApplicationManager;
@@ -23,7 +23,7 @@ public final class StartupAbortedException extends RuntimeException {
}
public static void processException(@NotNull Throwable t) {
if (LoadingPhase.COMPONENT_LOADED.isComplete() && !(t instanceof StartupAbortedException)) {
if (LoadingState.COMPONENTS_LOADED.isOccurred() && !(t instanceof StartupAbortedException)) {
if (!(t instanceof ProcessCanceledException)) {
PluginManagerCore.getLogger().error(t);
}
@@ -54,7 +54,7 @@ public final class StartupAbortedException extends RuntimeException {
}
}
if (LoadingPhase.COMPONENT_REGISTERED.isComplete()) {
if (LoadingState.COMPONENTS_REGISTERED.isOccurred()) {
ImplementationConflictException conflictException = findCause(t, ImplementationConflictException.class);
if (conflictException != null) {
PluginConflictReporter pluginConflictReporter = ApplicationManager.getApplication().getService(PluginConflictReporter.class);
@@ -2,7 +2,7 @@
package com.intellij.serviceContainer
import com.intellij.diagnostic.ActivityCategory
import com.intellij.diagnostic.LoadingPhase
import com.intellij.diagnostic.LoadingState
import com.intellij.diagnostic.PluginException
import com.intellij.diagnostic.StartUpMeasurer
import com.intellij.openapi.Disposable
@@ -73,7 +73,7 @@ internal abstract class BaseComponentAdapter(internal val componentManager: Plat
}
private fun <T : Any> getInstanceUncached(componentManager: PlatformComponentManagerImpl, indicator: ProgressIndicator?): T? {
LoadingPhase.COMPONENT_REGISTERED.assertAtLeast()
LoadingState.COMPONENTS_REGISTERED.checkOccurred()
checkContainerIsActive(componentManager, indicator)
val activityCategory = if (StartUpMeasurer.isEnabled()) getActivityCategory(componentManager) else null
@@ -1,7 +1,7 @@
// Copyright 2000-2019 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.
package com.intellij.serviceContainer
import com.intellij.diagnostic.LoadingPhase
import com.intellij.diagnostic.LoadingState
import com.intellij.diagnostic.PluginException
import com.intellij.diagnostic.StartUpMeasurer
import com.intellij.ide.plugins.*
@@ -137,7 +137,7 @@ abstract class PlatformComponentManagerImpl @JvmOverloads constructor(internal v
activity = activity.endAndStart("${activityNamePrefix}extension registration")
}
val notifyListeners = LoadingPhase.PROJECT_OPENED.isComplete
val notifyListeners = LoadingState.PROJECT_OPENED.isOccurred
for (descriptor in plugins) {
descriptor.registerExtensions(extensionArea, this, notifyListeners)
}
@@ -148,8 +148,8 @@ abstract class PlatformComponentManagerImpl @JvmOverloads constructor(internal v
}
// app - phase must be set before getMessageBus()
if (picoContainer.parent == null && !LoadingPhase.PROJECT_OPENED.isComplete /* loading plugin on the fly */) {
LoadingPhase.setCurrentPhase(LoadingPhase.COMPONENT_REGISTERED)
if (picoContainer.parent == null && !LoadingState.PROJECT_OPENED.isOccurred /* loading plugin on the fly */) {
StartUpMeasurer.setCurrentState(LoadingState.COMPONENTS_REGISTERED)
}
// todo support lazy listeners for dynamically loaded plugins
@@ -254,7 +254,7 @@ abstract class PlatformComponentManagerImpl @JvmOverloads constructor(internal v
@Internal
fun initializeComponent(component: Any, serviceDescriptor: ServiceDescriptor?) {
if (serviceDescriptor == null || !(component is PathMacroManager || component is IComponentStore || component is MessageBusFactory)) {
LoadingPhase.CONFIGURATION_STORE_INITIALIZED.assertAtLeast()
LoadingState.CONFIGURATION_STORE_INITIALIZED.checkOccurred()
componentStore.initComponent(component, serviceDescriptor)
}
}
@@ -332,7 +332,7 @@ abstract class PlatformComponentManagerImpl @JvmOverloads constructor(internal v
}
private fun <T : Any> getOrCreateLightService(serviceClass: Class<T>, cache: ConcurrentMap<Class<*>, Any>): T {
LoadingPhase.COMPONENT_REGISTERED.assertAtLeast()
LoadingState.COMPONENTS_REGISTERED.checkOccurred()
@Suppress("UNCHECKED_CAST")
var result = cache.get(serviceClass) as T?
@@ -106,7 +106,7 @@ public final class ActivityImpl implements Activity {
public void end() {
assert end == 0 : "not started or already ended";
end = StartUpMeasurer.getCurrentTime();
StartUpMeasurer.add(this);
StartUpMeasurer.addActivity(this);
}
@Override
@@ -10,44 +10,36 @@ import org.jetbrains.annotations.NotNull;
import java.util.Arrays;
import java.util.Set;
import java.util.concurrent.atomic.AtomicReference;
import java.util.stream.Collectors;
@ApiStatus.Internal
public enum LoadingPhase {
public enum LoadingState {
BOOTSTRAP("bootstrap"),
LAF_INITIALIZED("LaF is initialized"),
COMPONENT_REGISTERED("app component registered"),
COMPONENTS_REGISTERED("app component registered"),
CONFIGURATION_STORE_INITIALIZED("app store initialized"),
COMPONENT_LOADED("app component loaded"),
COMPONENTS_LOADED("app component loaded"),
PROJECT_OPENED("project opened"),
INDEXING_FINISHED("indexing finished");
private final String displayName;
final String displayName;
LoadingPhase(@NotNull String displayName) {
private static boolean CHECK_LOADING_PHASE;
LoadingState(@NotNull String displayName) {
this.displayName = displayName;
}
@NotNull
private static Logger getLogger() {
return Logger.getInstance(LoadingPhase.class);
static Logger getLogger() {
return Logger.getInstance("#com.intellij.diagnostic.LoadingState");
}
private static boolean CHECK_LOADING_PHASE;
@ApiStatus.Internal
public static void setStrictMode() {
CHECK_LOADING_PHASE = true;
}
public static void setCurrentPhase(@NotNull LoadingPhase phase) {
LoadingPhase old = currentPhase.getAndSet(phase);
if (old.ordinal() > phase.ordinal()) {
getLogger().error("New phase " + phase + " cannot be earlier than old " + old);
}
logPhaseSet(phase);
}
private final static Set<Throwable> stackTraces = new THashSet<>(new TObjectHashingStrategy<Throwable>() {
@Override
public int computeHashCode(Throwable throwable) {
@@ -69,29 +61,13 @@ public enum LoadingPhase {
}
});
private final static AtomicReference<LoadingPhase> currentPhase = new AtomicReference<>(BOOTSTRAP);
public static void compareAndSet(@NotNull LoadingPhase expect, @NotNull LoadingPhase phase) {
if (currentPhase.compareAndSet(expect, phase)) {
logPhaseSet(phase);
}
}
private static void logPhaseSet(@NotNull LoadingPhase phase) {
StartUpMeasurer.addInstantEvent(phase.displayName);
if (phase.ordinal() >= CONFIGURATION_STORE_INITIALIZED.ordinal()) {
getLogger().info("Reached the loading phase " + phase);
}
}
public void assertAtLeast() {
public void checkOccurred() {
if (!CHECK_LOADING_PHASE) {
return;
}
LoadingPhase currentPhase = LoadingPhase.currentPhase.get();
if (currentPhase.ordinal() >= ordinal() || isKnownViolator()) {
LoadingState currentState = StartUpMeasurer.currentState.get();
if (currentState.ordinal() >= ordinal() || isKnownViolator()) {
return;
}
@@ -101,9 +77,9 @@ public enum LoadingPhase {
return;
}
getLogger().error("Should be called at least at the phase " + this + ", the current phase is: " + currentPhase + "\n" +
"Current violators count: " + stackTraces.size() + "\n\n",
t);
getLogger().error("Should be called at least in the state " + this + ", the current state is: " + currentState + "\n" +
"Current violators count: " + stackTraces.size() + "\n\n",
t);
}
}
@@ -117,11 +93,7 @@ public enum LoadingPhase {
return false;
}
public static boolean isStartupComplete() {
return INDEXING_FINISHED.isComplete();
}
public boolean isComplete() {
return currentPhase.get().ordinal() >= ordinal();
public boolean isOccurred() {
return StartUpMeasurer.currentState.get().ordinal() >= ordinal();
}
}
@@ -9,9 +9,12 @@ import org.jetbrains.annotations.Nullable;
import java.util.*;
import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicReference;
import java.util.function.Consumer;
public final class StartUpMeasurer {
final static AtomicReference<LoadingState> currentState = new AtomicReference<>(LoadingState.BOOTSTRAP);
public static final long MEASURE_THRESHOLD = TimeUnit.MILLISECONDS.toNanos(10);
// `what + noun` is used as scheme for name to make analyzing easier (to visually group - `components loading/initialization/etc`,
@@ -77,9 +80,13 @@ public final class StartUpMeasurer {
* Scope is not supported — reported as global.
*/
public static void addInstantEvent(@NotNull String name) {
if (!isEnabled) {
return;
}
ActivityImpl activity = new ActivityImpl(name, null);
activity.setEnd(-1);
add(activity);
addActivity(activity);
}
@NotNull
@@ -140,15 +147,36 @@ public final class StartUpMeasurer {
return duration;
}
@NotNull
public static Activity addCompletedActivity(long start, long end, @NotNull String name, @NotNull ActivityCategory category, String pluginId) {
public static void addCompletedActivity(long start, long end, @NotNull String name, @NotNull ActivityCategory category, String pluginId) {
if (!isEnabled) {
return;
}
ActivityImpl item = new ActivityImpl(name, start, /* parent = */ null, pluginId);
item.setCategory(category);
item.setEnd(end);
add(item);
return item;
addActivity(item);
}
public static void setCurrentState(@NotNull LoadingState state) {
LoadingState old = currentState.getAndSet(state);
if (old.ordinal() > state.ordinal()) {
LoadingState.getLogger().error("New state " + state + " cannot precede old " + old);
}
stateSet(state);
}
public static void compareAndSetCurrentState(@NotNull LoadingState expectedState, @NotNull LoadingState newState) {
if (currentState.compareAndSet(expectedState, newState)) {
stateSet(newState);
}
}
private static void stateSet(@NotNull LoadingState state) {
addInstantEvent(state.displayName);
}
@ApiStatus.Internal
public static void processAndClear(boolean isContinueToCollect, @NotNull Consumer<? super ActivityImpl> consumer) {
isEnabled = isContinueToCollect;
@@ -167,12 +195,11 @@ public final class StartUpMeasurer {
return startTime;
}
static void add(@NotNull ActivityImpl activity) {
if (isEnabled) {
items.add(activity);
}
static void addActivity(@NotNull ActivityImpl activity) {
items.add(activity);
}
@ApiStatus.Internal
public static void addTimings(@NotNull LinkedHashMap<String, Long> timings, @NotNull String groupName) {
if (!items.isEmpty()) {
throw new IllegalStateException("addTimings must be not called if some events were already added using API");
@@ -200,6 +227,7 @@ public final class StartUpMeasurer {
items.add(parent);
}
@ApiStatus.Internal
public static void addPluginCost(@NotNull String pluginId, @NotNull String phase, long time) {
if (!isMeasuringPluginStartupCosts()) {
return;
@@ -1,7 +1,7 @@
// Copyright 2000-2019 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.
package com.intellij.openapi.util.registry;
import com.intellij.diagnostic.LoadingPhase;
import com.intellij.diagnostic.LoadingState;
import com.intellij.util.ConcurrencyUtil;
import gnu.trove.THashMap;
import org.jdom.Element;
@@ -48,8 +48,8 @@ public final class Registry {
}
public static boolean is(@NotNull String key, boolean defaultValue) {
if (!LoadingPhase.COMPONENT_REGISTERED.isComplete()) {
LoadingPhase.LAF_INITIALIZED.assertAtLeast();
if (!LoadingState.COMPONENTS_REGISTERED.isOccurred()) {
LoadingState.LAF_INITIALIZED.checkOccurred();
return defaultValue;
}
@@ -66,8 +66,8 @@ public final class Registry {
}
public static int intValue(@NotNull String key, int defaultValue) {
if (!LoadingPhase.COMPONENT_REGISTERED.isComplete()) {
LoadingPhase.LAF_INITIALIZED.assertAtLeast();
if (!LoadingState.COMPONENTS_REGISTERED.isOccurred()) {
LoadingState.LAF_INITIALIZED.checkOccurred();
return defaultValue;
}
@@ -122,7 +122,7 @@ public final class Registry {
@NotNull
public static Registry getInstance() {
LoadingPhase.COMPONENT_REGISTERED.assertAtLeast();
LoadingState.COMPONENTS_REGISTERED.checkOccurred();
return ourInstance;
}
@@ -2,7 +2,7 @@
package com.intellij.util.ui;
import com.intellij.BundleBase;
import com.intellij.diagnostic.LoadingPhase;
import com.intellij.diagnostic.LoadingState;
import com.intellij.icons.AllIcons;
import com.intellij.openapi.Disposable;
import com.intellij.openapi.diagnostic.Logger;
@@ -80,7 +80,7 @@ import java.util.regex.Pattern;
public final class UIUtil extends StartupUiUtil {
static {
LoadingPhase.LAF_INITIALIZED.assertAtLeast();
LoadingState.LAF_INITIALIZED.checkOccurred();
}
public static final String BORDER_LINE = "<hr size=1 noshade>";