mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[jps] don't clear JPS extension cache every time when running test without initialized Application
Some tests don't initialize Application at all, but have JpsIdePluginManagerImpl in classpath. Before the change cleanupExtensionCache cleared caches on every invocation leading to noticeable performance degradation. Now the cache is cleared only one time when Application become available. GitOrigin-RevId: 0cd69a7488df6aa0f0ee4a4efce355307b482651
This commit is contained in:
committed by
intellij-monorepo-bot
parent
25a6e732c3
commit
a6988d0088
@@ -85,10 +85,6 @@ public class JpsServiceManagerImpl extends JpsServiceManager {
|
||||
private boolean cleanupExtensionCache() {
|
||||
JpsPluginManager manager = myPluginManager;
|
||||
if (manager != null) {
|
||||
if (!manager.isFullyLoaded()) {
|
||||
myExtensions.clear();
|
||||
return true;
|
||||
}
|
||||
int stamp = manager.getModificationStamp();
|
||||
if (myModificationStamp.getAndSet(stamp) != stamp) {
|
||||
myExtensions.clear();
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
// 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.jps.impl;
|
||||
|
||||
import com.intellij.openapi.application.Application;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.extensions.*;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.module.ModuleManager;
|
||||
@@ -42,14 +44,15 @@ public final class JpsIdePluginManagerImpl extends JpsPluginManager {
|
||||
private final boolean myFullyLoaded;
|
||||
|
||||
public JpsIdePluginManagerImpl() {
|
||||
ExtensionsArea rootArea = Extensions.getRootArea();
|
||||
myFullyLoaded = rootArea != null;
|
||||
Application application = ApplicationManager.getApplication();
|
||||
myFullyLoaded = application != null;
|
||||
if (!myFullyLoaded) {
|
||||
//this may happen e.g. in tests if some test is executed before Application is initialized; in that case the created instance won't be cached
|
||||
//and will be reinitialized next time
|
||||
return;
|
||||
}
|
||||
|
||||
ExtensionsArea rootArea = application.getExtensionArea();
|
||||
//todo[nik] get rid of this check: currently this class is used in intellij.platform.jps.build tests instead of JpsPluginManagerImpl because intellij.platform.ide.impl module is added to classpath via testFramework
|
||||
if (rootArea.hasExtensionPoint(JpsPluginBean.EP_NAME)) {
|
||||
final Ref<Boolean> initial = new Ref<>(Boolean.TRUE);
|
||||
@@ -241,6 +244,9 @@ public final class JpsIdePluginManagerImpl extends JpsPluginManager {
|
||||
|
||||
@Override
|
||||
public int getModificationStamp() {
|
||||
if (!myFullyLoaded && myModificationStamp.get() == 0 && ApplicationManager.getApplication() != null) {
|
||||
myModificationStamp.compareAndSet(0, 1);
|
||||
}
|
||||
return myModificationStamp.get();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user