mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-02-04 23:39:07 +07:00
reduce classloading
GitOrigin-RevId: 0388f9b068b8767e835e788fbbe4204ceab9818f
This commit is contained in:
committed by
intellij-monorepo-bot
parent
c707cc298a
commit
c763779d85
@@ -1,4 +1,4 @@
|
||||
// Copyright 2000-2020 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-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.
|
||||
package com.intellij.ide.util.frameworkSupport;
|
||||
|
||||
import com.intellij.framework.FrameworkTypeEx;
|
||||
@@ -9,7 +9,6 @@ import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.module.ModuleType;
|
||||
import com.intellij.openapi.roots.ui.configuration.FacetsProvider;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.util.graph.CachingSemiGraph;
|
||||
import com.intellij.util.graph.DFSTBuilder;
|
||||
import com.intellij.util.graph.GraphGenerator;
|
||||
@@ -81,8 +80,8 @@ public final class FrameworkSupportUtil {
|
||||
DFSTBuilder<FrameworkSupportInModuleProvider>
|
||||
builder = new DFSTBuilder<>(GraphGenerator.generate(CachingSemiGraph.cache(new ProvidersGraph(types))));
|
||||
if (!builder.isAcyclic()) {
|
||||
Pair<FrameworkSupportInModuleProvider, FrameworkSupportInModuleProvider> pair = builder.getCircularDependency();
|
||||
LOG.error("Circular dependency between types '" + pair.getFirst().getFrameworkType().getId() + "' and '" + pair.getSecond().getFrameworkType().getId() + "' was found.");
|
||||
Map.Entry<FrameworkSupportInModuleProvider, FrameworkSupportInModuleProvider> pair = builder.getCircularDependency();
|
||||
LOG.error("Circular dependency between types '" + pair.getKey().getFrameworkType().getId() + "' and '" + pair.getValue().getFrameworkType().getId() + "' was found.");
|
||||
}
|
||||
|
||||
return builder.comparator();
|
||||
|
||||
@@ -104,9 +104,9 @@ public final class JarsBuilder {
|
||||
private JarInfo @Nullable [] sortJars() {
|
||||
final DFSTBuilder<JarInfo> builder = new DFSTBuilder<>(GraphGenerator.generate(CachingSemiGraph.cache(new JarsGraph())));
|
||||
if (!builder.isAcyclic()) {
|
||||
final Pair<JarInfo, JarInfo> dependency = builder.getCircularDependency();
|
||||
String message = JpsBuildBundle.message("build.message.cannot.build.circular.dependency.found.between.0.and.1", dependency.getFirst().getPresentableDestination(),
|
||||
dependency.getSecond().getPresentableDestination());
|
||||
Map.Entry<JarInfo, JarInfo> dependency = builder.getCircularDependency();
|
||||
String message = JpsBuildBundle.message("build.message.cannot.build.circular.dependency.found.between.0.and.1", dependency.getKey().getPresentableDestination(),
|
||||
dependency.getValue().getPresentableDestination());
|
||||
myContext.processMessage(new CompilerMessage(IncArtifactBuilder.getBuilderName(), BuildMessage.Kind.ERROR, message));
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@ package com.intellij.openapi.application;
|
||||
|
||||
import com.intellij.openapi.util.JDOMUtil;
|
||||
import com.intellij.openapi.util.NlsSafe;
|
||||
import com.intellij.openapi.util.text.Strings;
|
||||
import com.intellij.util.PlatformUtils;
|
||||
import org.jdom.Element;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
@@ -11,6 +10,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.util.Locale;
|
||||
|
||||
public final class ApplicationNamesInfo {
|
||||
private final String myProductName;
|
||||
@@ -50,8 +50,7 @@ public final class ApplicationNamesInfo {
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static ApplicationNamesInfo getInstance() {
|
||||
public static @NotNull ApplicationNamesInfo getInstance() {
|
||||
ApplicationNamesInfo result = instance;
|
||||
if (result == null) {
|
||||
//noinspection SynchronizeOnThis
|
||||
@@ -106,7 +105,7 @@ public final class ApplicationNamesInfo {
|
||||
* @see #getEditionName()
|
||||
*/
|
||||
public @NlsSafe String getFullProductNameWithEdition() {
|
||||
return myEditionName != null ? myFullProductName + ' ' + myEditionName : myFullProductName;
|
||||
return myEditionName == null ? myFullProductName : myFullProductName + ' ' + myEditionName;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -122,7 +121,8 @@ public final class ApplicationNamesInfo {
|
||||
* <strong>Kept for compatibility; use {@link #getFullProductName()} instead.</strong>
|
||||
*/
|
||||
public String getLowercaseProductName() {
|
||||
return Strings.capitalize(Strings.toLowerCase(myProductName));
|
||||
String s = myProductName.toLowerCase(Locale.ENGLISH);
|
||||
return Character.isUpperCase(s.charAt(0)) ? s : Character.toUpperCase(s.charAt(0)) + s.substring(1);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -21,7 +21,6 @@ import com.intellij.openapi.util.NlsSafe;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.openapi.util.io.FileUtilRt;
|
||||
import com.intellij.openapi.util.text.HtmlChunk;
|
||||
import com.intellij.reference.SoftReference;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import com.intellij.util.ArrayUtilRt;
|
||||
import com.intellij.util.PlatformUtils;
|
||||
@@ -38,6 +37,7 @@ import java.io.*;
|
||||
import java.lang.invoke.MethodHandles;
|
||||
import java.lang.invoke.MethodType;
|
||||
import java.lang.ref.Reference;
|
||||
import java.lang.ref.SoftReference;
|
||||
import java.nio.file.*;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
@@ -210,7 +210,7 @@ public final class PluginManagerCore {
|
||||
}
|
||||
|
||||
public static void updateBrokenPlugins(Map<PluginId, Set<String>> brokenPlugins) {
|
||||
ourBrokenPluginVersions = new java.lang.ref.SoftReference<>(brokenPlugins);
|
||||
ourBrokenPluginVersions = new SoftReference<>(brokenPlugins);
|
||||
Path updatedBrokenPluginFile = getUpdatedBrokenPluginFile();
|
||||
try (DataOutputStream out = new DataOutputStream(new BufferedOutputStream(Files.newOutputStream(updatedBrokenPluginFile), 32_000))) {
|
||||
out.write(1);
|
||||
@@ -235,7 +235,7 @@ public final class PluginManagerCore {
|
||||
return Collections.emptyMap();
|
||||
}
|
||||
|
||||
Map<PluginId, Set<String>> result = SoftReference.dereference(ourBrokenPluginVersions);
|
||||
Map<PluginId, Set<String>> result = ourBrokenPluginVersions == null ? null : ourBrokenPluginVersions.get();
|
||||
if (result == null) {
|
||||
result = readBrokenPluginFile();
|
||||
ourBrokenPluginVersions = new SoftReference<>(result);
|
||||
|
||||
@@ -11,7 +11,6 @@ import com.intellij.openapi.extensions.impl.ExtensionsAreaImpl;
|
||||
import com.intellij.openapi.extensions.impl.InterfaceExtensionPoint;
|
||||
import com.intellij.openapi.util.JDOMUtil;
|
||||
import com.intellij.openapi.util.SystemInfoRt;
|
||||
import com.intellij.openapi.util.text.Strings;
|
||||
import com.intellij.util.messages.ListenerDescriptor;
|
||||
import org.jdom.Attribute;
|
||||
import org.jdom.Content;
|
||||
@@ -60,34 +59,52 @@ final class XmlReader {
|
||||
|
||||
private static @NotNull ServiceDescriptor readServiceDescriptor(@NotNull Element element) {
|
||||
ServiceDescriptor descriptor = new ServiceDescriptor();
|
||||
descriptor.serviceInterface = element.getAttributeValue("serviceInterface");
|
||||
descriptor.serviceImplementation = Strings.nullize(element.getAttributeValue("serviceImplementation"));
|
||||
descriptor.testServiceImplementation = Strings.nullize(element.getAttributeValue("testServiceImplementation"));
|
||||
descriptor.headlessImplementation = Strings.nullize(element.getAttributeValue("headlessImplementation"));
|
||||
descriptor.configurationSchemaKey = element.getAttributeValue("configurationSchemaKey");
|
||||
|
||||
String preload = element.getAttributeValue("preload");
|
||||
if (preload != null) {
|
||||
switch (preload) {
|
||||
case "true":
|
||||
descriptor.preload = ServiceDescriptor.PreloadMode.TRUE;
|
||||
for (Attribute attribute : element.getAttributes()) {
|
||||
switch (attribute.getName()) {
|
||||
case "serviceImplementation":
|
||||
descriptor.serviceImplementation = getNullifiedValue(attribute);
|
||||
break;
|
||||
case "await":
|
||||
descriptor.preload = ServiceDescriptor.PreloadMode.AWAIT;
|
||||
case "serviceInterface":
|
||||
descriptor.serviceInterface = getNullifiedValue(attribute);
|
||||
break;
|
||||
case "notHeadless":
|
||||
descriptor.preload = ServiceDescriptor.PreloadMode.NOT_HEADLESS;
|
||||
case "testServiceImplementation":
|
||||
descriptor.testServiceImplementation = getNullifiedValue(attribute);
|
||||
break;
|
||||
case "notLightEdit":
|
||||
descriptor.preload = ServiceDescriptor.PreloadMode.NOT_LIGHT_EDIT;
|
||||
case "headlessImplementation":
|
||||
descriptor.headlessImplementation = getNullifiedValue(attribute);
|
||||
break;
|
||||
default:
|
||||
LOG.error("Unknown preload mode value: " + JDOMUtil.writeElement(element));
|
||||
case "configurationSchemaKey":
|
||||
descriptor.configurationSchemaKey = attribute.getValue();
|
||||
break;
|
||||
case "overrides":
|
||||
descriptor.overrides = Boolean.parseBoolean(attribute.getValue());
|
||||
break;
|
||||
case "preload": {
|
||||
String preload = attribute.getValue();
|
||||
if (preload != null) {
|
||||
switch (preload) {
|
||||
case "true":
|
||||
descriptor.preload = ServiceDescriptor.PreloadMode.TRUE;
|
||||
break;
|
||||
case "await":
|
||||
descriptor.preload = ServiceDescriptor.PreloadMode.AWAIT;
|
||||
break;
|
||||
case "notHeadless":
|
||||
descriptor.preload = ServiceDescriptor.PreloadMode.NOT_HEADLESS;
|
||||
break;
|
||||
case "notLightEdit":
|
||||
descriptor.preload = ServiceDescriptor.PreloadMode.NOT_LIGHT_EDIT;
|
||||
break;
|
||||
default:
|
||||
LOG.error("Unknown preload mode value: " + JDOMUtil.writeElement(element));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
descriptor.overrides = Boolean.parseBoolean(element.getAttributeValue("overrides"));
|
||||
return descriptor;
|
||||
}
|
||||
|
||||
@@ -192,11 +209,10 @@ final class XmlReader {
|
||||
return;
|
||||
}
|
||||
|
||||
List<Attribute> attributes = element.getAttributes();
|
||||
for (Attribute attribute : attributes) {
|
||||
for (Attribute attribute : element.getAttributes()) {
|
||||
switch (attribute.getName()) {
|
||||
case "url":
|
||||
descriptor.url = Strings.nullize(attribute.getValue());
|
||||
descriptor.url = getNullifiedValue(attribute);
|
||||
break;
|
||||
|
||||
case "use-idea-classloader":
|
||||
@@ -216,11 +232,11 @@ final class XmlReader {
|
||||
break;
|
||||
|
||||
case "package":
|
||||
descriptor.packagePrefix = Strings.nullize(attribute.getValue());
|
||||
descriptor.packagePrefix = getNullifiedValue(attribute);
|
||||
break;
|
||||
|
||||
case "version":
|
||||
String internalVersionString = Strings.nullize(attribute.getValue());
|
||||
String internalVersionString = getNullifiedValue(attribute);
|
||||
if (internalVersionString != null) {
|
||||
try {
|
||||
Integer.parseInt(internalVersionString);
|
||||
@@ -234,6 +250,11 @@ final class XmlReader {
|
||||
}
|
||||
}
|
||||
|
||||
private static @Nullable String getNullifiedValue(Attribute attribute) {
|
||||
String v = attribute.getValue();
|
||||
return v == null || v.isEmpty() ? null : v;
|
||||
}
|
||||
|
||||
static void readDependencies(@NotNull IdeaPluginDescriptorImpl rootDescriptor,
|
||||
@NotNull IdeaPluginDescriptorImpl descriptor,
|
||||
@NotNull DescriptorListLoadingContext context,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2000-2020 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-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.
|
||||
package com.intellij.ui;
|
||||
|
||||
import com.intellij.diagnostic.StartUpMeasurer;
|
||||
@@ -11,7 +11,6 @@ import com.intellij.ui.icons.ImageDescriptor;
|
||||
import com.intellij.ui.scale.DerivedScaleType;
|
||||
import com.intellij.ui.scale.JBUIScale;
|
||||
import com.intellij.ui.scale.ScaleContext;
|
||||
import com.intellij.util.BitUtil;
|
||||
import com.intellij.util.ImageLoader;
|
||||
import com.intellij.util.ImageLoader.Dimension2DDouble;
|
||||
import com.intellij.util.SVGLoader;
|
||||
@@ -98,10 +97,10 @@ final class RasterizedImageDataLoader implements ImageDataLoader {
|
||||
|
||||
int dotIndex = path.lastIndexOf('.');
|
||||
String name = dotIndex < 0 ? path : path.substring(0, dotIndex);
|
||||
float scale = ImageLoader.adjustScaleFactor(BitUtil.isSet(flags, ImageLoader.ALLOW_FLOAT_SCALING), pixScale);
|
||||
float scale = ImageLoader.adjustScaleFactor((flags & ImageLoader.ALLOW_FLOAT_SCALING) == ImageLoader.ALLOW_FLOAT_SCALING, pixScale);
|
||||
|
||||
boolean isSvg = rasterizedCacheKey != 0;
|
||||
boolean isDark = BitUtil.isSet(flags, ImageLoader.USE_DARK);
|
||||
boolean isDark = (flags & ImageLoader.USE_DARK) == ImageLoader.USE_DARK;
|
||||
boolean isRetina = JBUIScale.isHiDPI(pixScale);
|
||||
|
||||
float imageScale;
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
// Copyright 2000-2020 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-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.
|
||||
package com.intellij.ide.ui
|
||||
|
||||
import com.intellij.openapi.components.*
|
||||
import com.intellij.openapi.util.Pair
|
||||
import com.intellij.ui.scale.JBUIScale
|
||||
import com.intellij.util.FontUtil
|
||||
import com.intellij.util.ui.UIUtil
|
||||
@@ -71,9 +70,9 @@ class NotRoamableUiOptions : BaseState() {
|
||||
var fontScale by property(0f)
|
||||
|
||||
init {
|
||||
val fontData = systemFontFaceAndSize
|
||||
fontFace = fontData.first
|
||||
fontSize = fontData.second
|
||||
val fontData = JBUIScale.getSystemFontData()
|
||||
fontFace = fontData.key
|
||||
fontSize = fontData.value
|
||||
fontScale = UISettings.defFontScale
|
||||
}
|
||||
}
|
||||
@@ -81,15 +80,12 @@ class NotRoamableUiOptions : BaseState() {
|
||||
private class FontFilter : SerializationFilter {
|
||||
override fun accepts(accessor: Accessor, bean: Any): Boolean {
|
||||
val settings = bean as NotRoamableUiOptions
|
||||
val fontData = systemFontFaceAndSize
|
||||
val fontData = JBUIScale.getSystemFontData()
|
||||
if ("fontFace" == accessor.name) {
|
||||
return fontData.first != settings.fontFace
|
||||
return fontData.key != settings.fontFace
|
||||
}
|
||||
// fontSize/fontScale should either be stored in pair or not stored at all
|
||||
// otherwise the fontSize restore logic gets broken (see loadState)
|
||||
return !(fontData.second == settings.fontSize && 1f == settings.fontScale)
|
||||
return !(fontData.value == settings.fontSize && 1f == settings.fontScale)
|
||||
}
|
||||
}
|
||||
|
||||
private val systemFontFaceAndSize: Pair<String, Int>
|
||||
get() = JBUIScale.getSystemFontData()
|
||||
}
|
||||
@@ -1,8 +1,7 @@
|
||||
// Copyright 2000-2020 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-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.
|
||||
package com.intellij.openapi.extensions;
|
||||
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.util.text.StringUtilRt;
|
||||
import com.intellij.util.graph.CachingSemiGraph;
|
||||
import com.intellij.util.graph.DFSTBuilder;
|
||||
import com.intellij.util.graph.GraphGenerator;
|
||||
@@ -62,7 +61,7 @@ public final class LoadingOrder {
|
||||
boolean first = false;
|
||||
Set<String> before = null;
|
||||
Set<String> after = null;
|
||||
for (String string : StringUtil.split(text, ORDER_RULE_SEPARATOR)) {
|
||||
for (String string : text.split(ORDER_RULE_SEPARATOR)) {
|
||||
String trimmed = string.trim();
|
||||
if (trimmed.equalsIgnoreCase(FIRST_STR)) {
|
||||
first = true;
|
||||
@@ -70,25 +69,25 @@ public final class LoadingOrder {
|
||||
else if (trimmed.equalsIgnoreCase(LAST_STR)) {
|
||||
last = true;
|
||||
}
|
||||
else if (StringUtil.startsWithIgnoreCase(trimmed, BEFORE_STR)) {
|
||||
else if (StringUtilRt.startsWithIgnoreCase(trimmed, BEFORE_STR)) {
|
||||
if (before == null) {
|
||||
before = new LinkedHashSet<>(2);
|
||||
}
|
||||
before.add(trimmed.substring(BEFORE_STR.length()).trim());
|
||||
}
|
||||
else if (StringUtil.startsWithIgnoreCase(trimmed, BEFORE_STR_OLD)) {
|
||||
else if (StringUtilRt.startsWithIgnoreCase(trimmed, BEFORE_STR_OLD)) {
|
||||
if (before == null) {
|
||||
before = new LinkedHashSet<>(2);
|
||||
}
|
||||
before.add(trimmed.substring(BEFORE_STR_OLD.length()).trim());
|
||||
}
|
||||
else if (StringUtil.startsWithIgnoreCase(trimmed, AFTER_STR)) {
|
||||
else if (StringUtilRt.startsWithIgnoreCase(trimmed, AFTER_STR)) {
|
||||
if (after == null) {
|
||||
after = new LinkedHashSet<>(2);
|
||||
}
|
||||
after.add(trimmed.substring(AFTER_STR.length()).trim());
|
||||
}
|
||||
else if (StringUtil.startsWithIgnoreCase(trimmed, AFTER_STR_OLD)) {
|
||||
else if (StringUtilRt.startsWithIgnoreCase(trimmed, AFTER_STR_OLD)) {
|
||||
if (after == null) {
|
||||
after = new LinkedHashSet<>(2);
|
||||
}
|
||||
@@ -157,7 +156,7 @@ public final class LoadingOrder {
|
||||
final Set<Orderable> hasBefore = new LinkedHashSet<>(orderable.size());
|
||||
for (Orderable o : orderable) {
|
||||
String id = o.getOrderId();
|
||||
if (StringUtil.isNotEmpty(id)) {
|
||||
if (id != null && !id.isEmpty()) {
|
||||
map.put(id, o);
|
||||
}
|
||||
LoadingOrder order = o.getOrder();
|
||||
@@ -199,7 +198,7 @@ public final class LoadingOrder {
|
||||
}
|
||||
|
||||
String id = n.getOrderId();
|
||||
if (StringUtil.isNotEmpty(id)) {
|
||||
if (id != null && !id.isEmpty()) {
|
||||
for (Orderable o : hasBefore) {
|
||||
LoadingOrder hisOrder = cachedMap.getOrDefault(o, ANY);
|
||||
if (hisOrder.myBefore.contains(id)) {
|
||||
@@ -227,8 +226,8 @@ public final class LoadingOrder {
|
||||
|
||||
DFSTBuilder<Orderable> builder = new DFSTBuilder<>(GraphGenerator.generate(CachingSemiGraph.cache(graph)));
|
||||
if (!builder.isAcyclic()) {
|
||||
Pair<Orderable, Orderable> p = Objects.requireNonNull(builder.getCircularDependency());
|
||||
throw new SortingException("Could not satisfy sorting requirements", p.first, p.second);
|
||||
Map.Entry<Orderable, Orderable> p = Objects.requireNonNull(builder.getCircularDependency());
|
||||
throw new SortingException("Could not satisfy sorting requirements", p.getKey(), p.getValue());
|
||||
}
|
||||
|
||||
orderable.sort(builder.comparator());
|
||||
|
||||
@@ -33,12 +33,13 @@ public final class ConsentOptions {
|
||||
private static final class InstanceHolder {
|
||||
static final ConsentOptions ourInstance;
|
||||
static {
|
||||
final ApplicationInfoEx appInfo = ApplicationInfoImpl.getShadowInstance();
|
||||
ApplicationInfoEx appInfo = ApplicationInfoImpl.getShadowInstance();
|
||||
Path commonDataPath = PathManager.getCommonDataPath();
|
||||
ourInstance = new ConsentOptions(new IOBackend() {
|
||||
private final Path DEFAULT_CONSENTS_FILE = PathManager.getCommonDataPath()
|
||||
private final Path DEFAULT_CONSENTS_FILE = commonDataPath
|
||||
.resolve(ApplicationNamesInfo.getInstance().getLowercaseProductName())
|
||||
.resolve("consentOptions/cached");
|
||||
private final Path CONFIRMED_CONSENTS_FILE = PathManager.getCommonDataPath().resolve("consentOptions").resolve("accepted");
|
||||
private final Path CONFIRMED_CONSENTS_FILE = commonDataPath.resolve("consentOptions/accepted");
|
||||
private final String BUNDLED_CONSENTS_PATH = getBundledResourcePath();
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,8 +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.
|
||||
// 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.
|
||||
package com.intellij.ide.ui.laf;
|
||||
|
||||
import com.intellij.icons.AllIcons;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.ui.ColoredSideBorder;
|
||||
import com.intellij.ui.TableActions;
|
||||
import com.intellij.ui.plaf.beg.*;
|
||||
@@ -14,12 +13,12 @@ import javax.swing.border.Border;
|
||||
import javax.swing.plaf.ColorUIResource;
|
||||
import javax.swing.plaf.metal.MetalLookAndFeel;
|
||||
import java.awt.*;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author Konstantin Bulenkov
|
||||
*/
|
||||
public final class IdeaLaf extends MetalLookAndFeel {
|
||||
|
||||
public static final ColorUIResource TOOLTIP_BACKGROUND_COLOR = new ColorUIResource(255, 255, 231);
|
||||
|
||||
@Override
|
||||
@@ -28,8 +27,8 @@ public final class IdeaLaf extends MetalLookAndFeel {
|
||||
LafManagerImpl.initInputMapDefaults(defaults);
|
||||
initIdeaDefaults(defaults);
|
||||
|
||||
Pair<String, Integer> systemFont = JBUIScale.getSystemFontData();
|
||||
LafManagerImpl.initFontDefaults(defaults, UIUtil.getFontWithFallback(systemFont.first, Font.PLAIN, systemFont.second));
|
||||
Map.Entry<String, Integer> systemFont = JBUIScale.getSystemFontData();
|
||||
LafManagerImpl.initFontDefaults(defaults, UIUtil.getFontWithFallback(systemFont.getKey(), Font.PLAIN, systemFont.getValue()));
|
||||
}
|
||||
|
||||
@SuppressWarnings({"HardCodedStringLiteral"})
|
||||
|
||||
@@ -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.
|
||||
// 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.
|
||||
package com.intellij.openapi.util;
|
||||
|
||||
public class EmptyRunnable implements Runnable {
|
||||
public final class EmptyRunnable implements Runnable {
|
||||
public static final Runnable INSTANCE = new EmptyRunnable();
|
||||
|
||||
public static Runnable getInstance() {
|
||||
|
||||
@@ -6,7 +6,6 @@ import com.intellij.execution.process.UnixProcessManager;
|
||||
import com.intellij.execution.process.WinProcessManager;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.util.SystemInfoRt;
|
||||
import com.intellij.openapi.util.text.StringUtilRt;
|
||||
import com.intellij.util.containers.CollectionFactory;
|
||||
import com.intellij.util.io.BaseOutputReader;
|
||||
import org.jetbrains.annotations.*;
|
||||
@@ -352,7 +351,7 @@ public final class EnvironmentUtil {
|
||||
|
||||
protected @NotNull List<String> getShellProcessCommand() {
|
||||
String shellScript = getShell();
|
||||
if (StringUtilRt.isEmptyOrSpaces(shellScript)) {
|
||||
if (shellScript == null || shellScript.isEmpty()) {
|
||||
throw new RuntimeException("empty $SHELL");
|
||||
}
|
||||
if (!Files.isExecutable(Paths.get(shellScript))) {
|
||||
@@ -481,7 +480,7 @@ public final class EnvironmentUtil {
|
||||
private static boolean checkIfLocaleAvailable(String candidateLanguageTerritory) {
|
||||
Locale[] available = Locale.getAvailableLocales();
|
||||
for (Locale l : available) {
|
||||
if (StringUtilRt.equal(l.toString(), candidateLanguageTerritory, true)) {
|
||||
if (Objects.equals(l.toString(), candidateLanguageTerritory)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,7 @@
|
||||
// Copyright 2000-2020 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-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.
|
||||
package com.intellij.util.graph;
|
||||
|
||||
import com.intellij.openapi.util.Couple;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.containers.Stack;
|
||||
import it.unimi.dsi.fastutil.ints.IntArrayList;
|
||||
import it.unimi.dsi.fastutil.ints.IntList;
|
||||
import it.unimi.dsi.fastutil.ints.IntStack;
|
||||
@@ -22,7 +19,7 @@ public final class DFSTBuilder<Node> {
|
||||
private final OutboundSemiGraph<Node> myGraph;
|
||||
private final Object2IntMap<Node> myNodeToNNumber; // node -> node number in topological order [0..size). Independent nodes are in reversed loading order (loading order is the graph.getNodes() order)
|
||||
private final Node[] myInvN; // node number in topological order [0..size) -> node
|
||||
private Couple<Node> myBackEdge;
|
||||
private Map.Entry<Node, Node> myBackEdge;
|
||||
|
||||
private Comparator<Node> myNComparator;
|
||||
private Comparator<Node> myTComparator;
|
||||
@@ -120,7 +117,7 @@ public final class DFSTBuilder<Node> {
|
||||
}
|
||||
}
|
||||
|
||||
private final Stack<Frame> frames = new Stack<>(); // recursion stack
|
||||
private final Deque<Frame> frames = new ArrayDeque<>(); // recursion stack
|
||||
private final Object2IntMap<Node> nodeIndex = new Object2IntOpenHashMap<>();
|
||||
private int dfsIndex;
|
||||
private int sccsSizeCombined;
|
||||
@@ -137,7 +134,7 @@ public final class DFSTBuilder<Node> {
|
||||
continue;
|
||||
}
|
||||
|
||||
frames.push(new Frame(i));
|
||||
frames.addLast(new Frame(i));
|
||||
List<List<Node>> sccs = new ArrayList<>();
|
||||
|
||||
strongConnect(sccs);
|
||||
@@ -152,7 +149,10 @@ public final class DFSTBuilder<Node> {
|
||||
Node rootNode = myAllNodes[i];
|
||||
int rIndex = scc.indexOf(rootNode);
|
||||
if (rIndex != -1) {
|
||||
ContainerUtil.swapElements(scc, rIndex, 0);
|
||||
Node e1 = scc.get(rIndex);
|
||||
Node e2 = scc.get(0);
|
||||
scc.set(rIndex, e2);
|
||||
scc.set(0, e1);
|
||||
}
|
||||
|
||||
for (int j = 0; j < scc.size(); j++) {
|
||||
@@ -185,7 +185,7 @@ public final class DFSTBuilder<Node> {
|
||||
int successor = -1;
|
||||
nextNode:
|
||||
while (!frames.isEmpty()) {
|
||||
Frame pair = frames.peek();
|
||||
Frame pair = frames.peekLast();
|
||||
int i = pair.nodeI;
|
||||
|
||||
// we have returned to the node
|
||||
@@ -206,18 +206,18 @@ public final class DFSTBuilder<Node> {
|
||||
while (pair.nextUnexploredIndex < pair.out.length) {
|
||||
int nextI = pair.out[pair.nextUnexploredIndex++];
|
||||
if (index[nextI] == -1) {
|
||||
frames.push(new Frame(nextI));
|
||||
frames.addLast(new Frame(nextI));
|
||||
continue nextNode;
|
||||
}
|
||||
if (isOnStack[nextI]) {
|
||||
lowLink[i] = Math.min(lowLink[i], index[nextI]);
|
||||
|
||||
if (myBackEdge == null) {
|
||||
myBackEdge = new Couple<>(myAllNodes[nextI], myAllNodes[i]);
|
||||
myBackEdge = new AbstractMap.SimpleImmutableEntry<>(myAllNodes[nextI], myAllNodes[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
frames.pop();
|
||||
frames.removeLast();
|
||||
topo.add(i);
|
||||
// we are really back, pop a scc
|
||||
if (lowLink[i] == index[i]) {
|
||||
@@ -263,7 +263,7 @@ public final class DFSTBuilder<Node> {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Couple<Node> getCircularDependency() {
|
||||
public Map.Entry<Node, Node> getCircularDependency() {
|
||||
return myBackEdge;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
// Copyright 2000-2020 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-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.
|
||||
package com.intellij.ui.scale;
|
||||
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.openapi.util.SystemInfo;
|
||||
import com.intellij.openapi.util.SystemInfoRt;
|
||||
import com.intellij.ui.JreHiDpiUtil;
|
||||
@@ -18,6 +17,8 @@ import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.beans.PropertyChangeListener;
|
||||
import java.beans.PropertyChangeSupport;
|
||||
import java.util.AbstractMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author tav
|
||||
@@ -44,10 +45,10 @@ public final class JBUIScale {
|
||||
|
||||
private JBUIScale() {}
|
||||
|
||||
private static volatile Pair<String, Integer> systemFontData;
|
||||
private static volatile Map.Entry<String, Integer> systemFontData;
|
||||
|
||||
private synchronized static @NotNull Pair<String, Integer> computeSystemFontData() {
|
||||
Pair<String, Integer> result = systemFontData;
|
||||
private synchronized static @NotNull Map.Entry<String, Integer> computeSystemFontData() {
|
||||
Map.Entry<String, Integer > result = systemFontData;
|
||||
if (result != null) {
|
||||
return result;
|
||||
}
|
||||
@@ -102,19 +103,18 @@ public final class JBUIScale {
|
||||
}
|
||||
}
|
||||
|
||||
result = new Pair<>(font.getName(), font.getSize());
|
||||
result = new AbstractMap.SimpleImmutableEntry<>(font.getName(), font.getSize());
|
||||
systemFontData = result;
|
||||
if (isScaleVerbose) {
|
||||
log.info(String.format("ourSystemFontData: %s, %d", result.first, result.second));
|
||||
log.info(String.format("ourSystemFontData: %s, %d", result.getKey(), result.getValue()));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@ApiStatus.Internal
|
||||
public static final NullableValue<Float> DEBUG_USER_SCALE_FACTOR = new NullableValue<>() {
|
||||
@Nullable
|
||||
@Override
|
||||
public Float initialize() {
|
||||
public @Nullable Float initialize() {
|
||||
String prop = System.getProperty("ide.ui.scale");
|
||||
if (prop != null) {
|
||||
try {
|
||||
@@ -158,7 +158,7 @@ public final class JBUIScale {
|
||||
return 1f;
|
||||
}
|
||||
|
||||
float result = getFontScale(getSystemFontData().getSecond());
|
||||
float result = getFontScale(getSystemFontData().getValue());
|
||||
getLogger().info("System scale factor: " + result + " (" + (JreHiDpiUtil.isJreHiDPIEnabled() ? "JRE" : "IDE") + "-managed HiDPI)");
|
||||
return result;
|
||||
});
|
||||
@@ -322,8 +322,8 @@ public final class JBUIScale {
|
||||
return discreteScale(dpi / 96f);
|
||||
}
|
||||
|
||||
public static @NotNull Pair<String, Integer> getSystemFontData() {
|
||||
Pair<String, Integer> result = systemFontData;
|
||||
public static @NotNull Map.Entry<String, Integer> getSystemFontData() {
|
||||
Map.Entry<String, Integer> result = systemFontData;
|
||||
return result == null ? computeSystemFontData() : result;
|
||||
}
|
||||
|
||||
|
||||
@@ -197,7 +197,7 @@ public final class UIUtil {
|
||||
}
|
||||
|
||||
private static final NotNullLazyValue<Boolean> X_RENDER_ACTIVE = NotNullLazyValue.atomicLazy(() -> {
|
||||
if (!SystemInfo.isXWindow) {
|
||||
if (!SystemInfoRt.isXWindow) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -452,7 +452,7 @@ public final class UIUtil {
|
||||
|
||||
@NonNls private static final String ROOT_PANE = "JRootPane.future";
|
||||
|
||||
private static final Ref<Boolean> ourRetina = Ref.create(SystemInfo.isMac ? null : false);
|
||||
private static final Ref<Boolean> ourRetina = Ref.create(SystemInfoRt.isMac ? null : false);
|
||||
|
||||
private UIUtil() {
|
||||
}
|
||||
@@ -612,9 +612,9 @@ public final class UIUtil {
|
||||
if (c < 0x20 || c == 0x7F) return false;
|
||||
|
||||
// Allow input of special characters on Windows in Persian keyboard layout using Ctrl+Shift+1..4
|
||||
if (SystemInfo.isWindows && c >= 0x200C && c <= 0x200F) return true;
|
||||
if (SystemInfoRt.isWindows && c >= 0x200C && c <= 0x200F) return true;
|
||||
|
||||
if (SystemInfo.isMac) {
|
||||
if (SystemInfoRt.isMac) {
|
||||
return !e.isMetaDown() && !e.isControlDown();
|
||||
}
|
||||
|
||||
@@ -1158,7 +1158,7 @@ public final class UIUtil {
|
||||
@Deprecated
|
||||
@ApiStatus.ScheduledForRemoval(inVersion = "2021.1")
|
||||
public static boolean isUnderAquaLookAndFeel() {
|
||||
return SystemInfo.isMac && UIManager.getLookAndFeel().getName().contains("Mac OS X");
|
||||
return SystemInfoRt.isMac && UIManager.getLookAndFeel().getName().contains("Mac OS X");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1171,12 +1171,12 @@ public final class UIUtil {
|
||||
}
|
||||
|
||||
public static boolean isUnderAquaBasedLookAndFeel() {
|
||||
return SystemInfo.isMac && (StartupUiUtil.isUnderDarcula() || isUnderIntelliJLaF());
|
||||
return SystemInfoRt.isMac && (StartupUiUtil.isUnderDarcula() || isUnderIntelliJLaF());
|
||||
}
|
||||
|
||||
public static boolean isUnderDefaultMacTheme() {
|
||||
LookAndFeel lookAndFeel = UIManager.getLookAndFeel();
|
||||
if (SystemInfo.isMac && lookAndFeel instanceof UserDataHolder) {
|
||||
if (SystemInfoRt.isMac && lookAndFeel instanceof UserDataHolder) {
|
||||
UserDataHolder dh = (UserDataHolder)lookAndFeel;
|
||||
|
||||
return Boolean.TRUE != dh.getUserData(LAF_WITH_THEME_KEY) &&
|
||||
@@ -1187,7 +1187,7 @@ public final class UIUtil {
|
||||
|
||||
public static boolean isUnderWin10LookAndFeel() {
|
||||
LookAndFeel lookAndFeel = UIManager.getLookAndFeel();
|
||||
if (SystemInfo.isWindows && lookAndFeel instanceof UserDataHolder) {
|
||||
if (SystemInfoRt.isWindows && lookAndFeel instanceof UserDataHolder) {
|
||||
UserDataHolder dh = (UserDataHolder)lookAndFeel;
|
||||
|
||||
return Boolean.TRUE != dh.getUserData(LAF_WITH_THEME_KEY) &&
|
||||
@@ -1207,11 +1207,11 @@ public final class UIUtil {
|
||||
@Deprecated
|
||||
@ApiStatus.ScheduledForRemoval(inVersion = "2021.1")
|
||||
public static boolean isUnderGTKLookAndFeel() {
|
||||
return SystemInfo.isXWindow && UIManager.getLookAndFeel().getName().contains("GTK");
|
||||
return SystemInfoRt.isXWindow && UIManager.getLookAndFeel().getName().contains("GTK");
|
||||
}
|
||||
|
||||
public static boolean isGraphite() {
|
||||
if (!SystemInfo.isMac) return false;
|
||||
if (!SystemInfoRt.isMac) return false;
|
||||
try {
|
||||
// https://developer.apple.com/library/mac/documentation/Cocoa/Reference/ApplicationKit/Classes/NSCell_Class/index.html#//apple_ref/doc/c_ref/NSGraphiteControlTint
|
||||
// NSGraphiteControlTint = 6
|
||||
@@ -1222,7 +1222,7 @@ public final class UIUtil {
|
||||
}
|
||||
|
||||
public static @NotNull Font getToolbarFont() {
|
||||
return SystemInfo.isMac ? getLabelFont(UIUtil.FontSize.SMALL) : StartupUiUtil.getLabelFont();
|
||||
return SystemInfoRt.isMac ? getLabelFont(UIUtil.FontSize.SMALL) : StartupUiUtil.getLabelFont();
|
||||
}
|
||||
|
||||
public static @NotNull Color shade(@NotNull Color c, final double factor, final double alphaFactor) {
|
||||
@@ -1287,7 +1287,7 @@ public final class UIUtil {
|
||||
}
|
||||
|
||||
public static boolean isControlKeyDown(@NotNull MouseEvent mouseEvent) {
|
||||
return SystemInfo.isMac ? mouseEvent.isMetaDown() : mouseEvent.isControlDown();
|
||||
return SystemInfoRt.isMac ? mouseEvent.isMetaDown() : mouseEvent.isControlDown();
|
||||
}
|
||||
|
||||
public static String @NotNull [] getValidFontNames(final boolean familyName) {
|
||||
@@ -1410,7 +1410,7 @@ public final class UIUtil {
|
||||
final Color bgColor,
|
||||
final Color fgColor,
|
||||
final boolean opaque) {
|
||||
if (SystemInfo.isMac && !isRetina() || SystemInfo.isLinux) {
|
||||
if (SystemInfoRt.isMac && !isRetina() || SystemInfoRt.isLinux) {
|
||||
drawAppleDottedLine(g, startX, endX, lineY, bgColor, fgColor, opaque);
|
||||
}
|
||||
else {
|
||||
@@ -1997,7 +1997,7 @@ public final class UIUtil {
|
||||
}
|
||||
|
||||
public static @NotNull Font getFontWithFallbackIfNeeded(@NotNull Font font, @NotNull String text) {
|
||||
if (!SystemInfo.isMac /* 'getFontWithFallback' does nothing on macOS */ && font.canDisplayUpTo(text) != -1) {
|
||||
if (!SystemInfoRt.isMac /* 'getFontWithFallback' does nothing on macOS */ && font.canDisplayUpTo(text) != -1) {
|
||||
return getFontWithFallback(font);
|
||||
}
|
||||
else {
|
||||
@@ -2008,7 +2008,7 @@ public final class UIUtil {
|
||||
public static @NotNull FontUIResource getFontWithFallback(@NotNull Font font) {
|
||||
// On macOS font fallback is implemented in JDK by default
|
||||
// (except for explicitly registered fonts, e.g. the fonts we bundle with IDE, for them we don't have a solution now)
|
||||
if (!SystemInfo.isMac) {
|
||||
if (!SystemInfoRt.isMac) {
|
||||
try {
|
||||
if (!FontUtilities.fontSupportsDefaultEncoding(font)) {
|
||||
font = FontUtilities.getCompositeFontUIResource(font);
|
||||
@@ -2027,7 +2027,7 @@ public final class UIUtil {
|
||||
public static @NotNull FontUIResource getFontWithFallback(@Nullable String familyName, @JdkConstants.FontStyle int style, int size) {
|
||||
// On macOS font fallback is implemented in JDK by default
|
||||
// (except for explicitly registered fonts, e.g. the fonts we bundle with IDE, for them we don't have a solution now)
|
||||
Font fontWithFallback = SystemInfo.isMac ? new Font(familyName, style, size) : new StyleContext().getFont(familyName, style, size);
|
||||
Font fontWithFallback = SystemInfoRt.isMac ? new Font(familyName, style, size) : new StyleContext().getFont(familyName, style, size);
|
||||
return fontWithFallback instanceof FontUIResource ? (FontUIResource)fontWithFallback : new FontUIResource(fontWithFallback);
|
||||
}
|
||||
|
||||
@@ -2216,7 +2216,7 @@ public final class UIUtil {
|
||||
}
|
||||
|
||||
public static void fixFormattedField(@NotNull JFormattedTextField field) {
|
||||
if (SystemInfo.isMac) {
|
||||
if (SystemInfoRt.isMac) {
|
||||
final int commandKeyMask;
|
||||
try {
|
||||
commandKeyMask = Toolkit.getDefaultToolkit().getMenuShortcutKeyMask();
|
||||
@@ -2266,7 +2266,7 @@ public final class UIUtil {
|
||||
}
|
||||
|
||||
public static boolean isToggleListSelectionEvent(@NotNull MouseEvent e) {
|
||||
return SwingUtilities.isLeftMouseButton(e) && (SystemInfo.isMac ? e.isMetaDown() : e.isControlDown()) && !e.isPopupTrigger();
|
||||
return SwingUtilities.isLeftMouseButton(e) && (SystemInfoRt.isMac ? e.isMetaDown() : e.isControlDown()) && !e.isPopupTrigger();
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@@ -2808,7 +2808,7 @@ public final class UIUtil {
|
||||
textComponent.getDocument().addDocumentListener(SET_TEXT_CHECKER);
|
||||
textComponent.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_Z, SystemInfoRt.isMac ? Event.META_MASK : Event.CTRL_MASK), "undoKeystroke");
|
||||
textComponent.getActionMap().put("undoKeystroke", UNDO_ACTION);
|
||||
textComponent.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_Z, (SystemInfo.isMac
|
||||
textComponent.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_Z, (SystemInfoRt.isMac
|
||||
? Event.META_MASK : Event.CTRL_MASK) | Event.SHIFT_MASK), "redoKeystroke");
|
||||
textComponent.getActionMap().put("redoKeystroke", REDO_ACTION);
|
||||
}
|
||||
@@ -3311,15 +3311,6 @@ public final class UIUtil {
|
||||
return getTableSelectionForeground(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated use {@link JBUIScale#getSystemFontData()}
|
||||
*/
|
||||
@Deprecated
|
||||
@ApiStatus.ScheduledForRemoval(inVersion = "2021.3")
|
||||
public static Pair<String, Integer> getSystemFontData() {
|
||||
return JBUIScale.getSystemFontData();
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated use {@link JreHiDpiUtil#isJreHiDPIEnabled()}
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user