GitOrigin-RevId: ab8b1f51e55964d276fcdd3fdd1f6389bb72dec2
This commit is contained in:
Vladimir Krivosheev
2023-05-12 10:24:15 +02:00
committed by intellij-monorepo-bot
parent 336a710201
commit c9a728765b
7 changed files with 59 additions and 68 deletions

View File

@@ -1,4 +1,4 @@
// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.openapi.components;
import com.intellij.openapi.util.TextRange;
@@ -37,8 +37,8 @@ public final class ExpandMacroToPathMap extends PathMacroMap {
}
for (Map.Entry<String, String> entry : myPlainMap.entrySet()) {
// when replacing macros with actual paths the replace utility may be used as always 'case-sensitive'
// for case-insensitive file systems there will be no unnecessary toLowerCase() transforms.
// when replacing macros with actual paths, the replace utility may be used as always 'case-sensitive'
// for case-insensitive file systems, there will be no unnecessary toLowerCase() transforms.
text = StringUtil.replace(text, entry.getKey(), entry.getValue(), false);
}

View File

@@ -1,4 +1,4 @@
// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.configurationStore
import com.intellij.openapi.components.PathMacroManager
@@ -6,7 +6,9 @@ import com.intellij.openapi.components.PathMacroSubstitutor
import com.intellij.openapi.components.TrackingPathMacroSubstitutor
import org.jetbrains.annotations.ApiStatus
internal fun PathMacroManager?.createTrackingSubstitutor(): TrackingPathMacroSubstitutorImpl? = if (this == null) null else TrackingPathMacroSubstitutorImpl(this)
internal fun PathMacroManager?.createTrackingSubstitutor(): TrackingPathMacroSubstitutorImpl? {
return if (this == null) null else TrackingPathMacroSubstitutorImpl(this)
}
@ApiStatus.Internal
class TrackingPathMacroSubstitutorImpl(internal val macroManager: PathMacroManager) : PathMacroSubstitutor by macroManager, TrackingPathMacroSubstitutor {

View File

@@ -1,4 +1,4 @@
// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.openapi.actionSystem;
import com.intellij.DynamicBundle;
@@ -44,51 +44,51 @@ public final class Presentation implements Cloneable {
* Defines tool tip for button at toolbar or text for element at menu
* value: String
*/
@NonNls public static final String PROP_TEXT = "text";
public static final @NonNls String PROP_TEXT = "text";
/**
* Defines tool tip for button at toolbar or text for element at menu
* that includes mnemonic suffix, like "Git(G)"
* value: String
*/
@NonNls public static final String PROP_TEXT_WITH_SUFFIX = "textWithSuffix";
public static final @NonNls String PROP_TEXT_WITH_SUFFIX = "textWithSuffix";
/**
* value: Integer
*/
@NonNls public static final String PROP_MNEMONIC_KEY = "mnemonicKey";
public static final @NonNls String PROP_MNEMONIC_KEY = "mnemonicKey";
/**
* value: Integer
*/
@NonNls public static final String PROP_MNEMONIC_INDEX = "mnemonicIndex";
public static final @NonNls String PROP_MNEMONIC_INDEX = "mnemonicIndex";
/**
* value: String
*/
@NonNls public static final String PROP_DESCRIPTION = "description";
public static final @NonNls String PROP_DESCRIPTION = "description";
/**
* value: Icon
*/
@NonNls public static final String PROP_ICON = "icon";
public static final @NonNls String PROP_ICON = "icon";
/**
* value: Icon
*/
@NonNls public static final String PROP_DISABLED_ICON = "disabledIcon";
public static final @NonNls String PROP_DISABLED_ICON = "disabledIcon";
/**
* value: Icon
*/
@NonNls public static final String PROP_SELECTED_ICON = "selectedIcon";
public static final @NonNls String PROP_SELECTED_ICON = "selectedIcon";
/**
* value: Icon
*/
@NonNls public static final String PROP_HOVERED_ICON = "hoveredIcon";
public static final @NonNls String PROP_HOVERED_ICON = "hoveredIcon";
/**
* value: Boolean
*/
@NonNls public static final String PROP_VISIBLE = "visible";
public static final @NonNls String PROP_VISIBLE = "visible";
/**
* The actual value is a Boolean.
*/
@NonNls public static final String PROP_ENABLED = "enabled";
public static final @NonNls String PROP_ENABLED = "enabled";
@NonNls public static final Key<@Nls String> PROP_VALUE = Key.create("value");
public static final @NonNls Key<@Nls String> PROP_VALUE = Key.create("value");
public static final double DEFAULT_WEIGHT = 0;
public static final double HIGHER_WEIGHT = 42;
@@ -105,7 +105,7 @@ public final class Presentation implements Cloneable {
private int myFlags = IS_ENABLED | IS_VISIBLE | IS_DISABLE_GROUP_IF_EMPTY;
private @NotNull Supplier<@ActionDescription String> myDescriptionSupplier = () -> null;
private @NotNull Supplier<? extends TextWithMnemonic> myTextWithMnemonicSupplier = () -> null;
private @NotNull Supplier<TextWithMnemonic> myTextWithMnemonicSupplier = () -> null;
private @NotNull SmartFMap<String, Object> myUserMap = SmartFMap.emptyMap();
private Icon myIcon;
@@ -196,9 +196,8 @@ public final class Presentation implements Cloneable {
setTextWithMnemonic(getTextWithMnemonic(() -> text, mayContainMnemonic));
}
@NotNull
public Supplier<TextWithMnemonic> getTextWithMnemonic(@NotNull Supplier<@Nls(capitalization = Nls.Capitalization.Title) String> text,
boolean mayContainMnemonic) {
public @NotNull Supplier<TextWithMnemonic> getTextWithMnemonic(@NotNull Supplier<@Nls(capitalization = Nls.Capitalization.Title) String> text,
boolean mayContainMnemonic) {
if (mayContainMnemonic) {
return () -> {
String s = text.get();
@@ -222,7 +221,7 @@ public final class Presentation implements Cloneable {
*
* @param textWithMnemonicSupplier text with mnemonic to set
*/
public void setTextWithMnemonic(@NotNull Supplier<? extends TextWithMnemonic> textWithMnemonicSupplier) {
public void setTextWithMnemonic(@NotNull Supplier<TextWithMnemonic> textWithMnemonicSupplier) {
String oldText = getText();
String oldTextWithSuffix = getText(true);
int oldMnemonic = getMnemonic();
@@ -254,15 +253,12 @@ public final class Presentation implements Cloneable {
/**
* @return the text with mnemonic, properly escaped, so it could be passed to {@link #setText(String)} (e.g. to copy the presentation).
*/
@ActionText
@Nullable
public String getTextWithMnemonic() {
public @ActionText @Nullable String getTextWithMnemonic() {
TextWithMnemonic textWithMnemonic = myTextWithMnemonicSupplier.get();
return textWithMnemonic == null ? null : textWithMnemonic.toString();
}
@NotNull
public Supplier<? extends TextWithMnemonic> getTextWithPossibleMnemonic() {
public @NotNull Supplier<TextWithMnemonic> getTextWithPossibleMnemonic() {
return myTextWithMnemonicSupplier;
}
@@ -310,7 +306,7 @@ public final class Presentation implements Cloneable {
return myHoveredIcon;
}
public void setHoveredIcon(@Nullable final Icon hoveredIcon) {
public void setHoveredIcon(final @Nullable Icon hoveredIcon) {
Icon old = myHoveredIcon;
myHoveredIcon = hoveredIcon;
fireObjectPropertyChange(PROP_HOVERED_ICON, old, myHoveredIcon);
@@ -528,8 +524,7 @@ public final class Presentation implements Cloneable {
}
}
@Nullable
public <T> T getClientProperty(@NotNull Key<T> key) {
public @Nullable <T> T getClientProperty(@NotNull Key<T> key) {
//noinspection unchecked
return (T)myUserMap.get(key.toString());
}
@@ -540,8 +535,7 @@ public final class Presentation implements Cloneable {
/** @deprecated Use {@link #getClientProperty(Key)} instead */
@Deprecated
@Nullable
public Object getClientProperty(@NonNls @NotNull String key) {
public @Nullable Object getClientProperty(@NonNls @NotNull String key) {
return myUserMap.get(key);
}
@@ -588,9 +582,8 @@ public final class Presentation implements Cloneable {
return BitUtil.isSet(myFlags, IS_MULTI_CHOICE);
}
@Nls
@Override
public String toString() {
public @Nls String toString() {
return getText() + " (" + myDescriptionSupplier.get() + ")";
}
}

View File

@@ -1,16 +1,19 @@
// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.diagnostic
import com.intellij.ide.util.PropertiesComponent
import com.intellij.openapi.components.Service
import com.intellij.openapi.components.service
import com.intellij.openapi.diagnostic.logger
import java.util.logging.Level
import java.util.logging.Logger
/**
* Allows to apply & persist custom log debug categories which can be turned on by user via the [com.intellij.ide.actions.DebugLogConfigureAction].
* Allows applying & persisting custom log debug categories
* which can be turned on by user via the [com.intellij.ide.actions.DebugLogConfigureAction].
* Applies these custom categories on startup.
*/
@Service(Service.Level.APP)
class DebugLogManager {
enum class DebugLogLevel { DEBUG, TRACE, ALL }
@@ -18,7 +21,7 @@ class DebugLogManager {
companion object {
@JvmStatic
fun getInstance() = service<DebugLogManager>()
fun getInstance(): DebugLogManager = service()
}
// java.util.logging keeps only weak references to loggers, so we need to store strong references to loggers we've customized to ensure
@@ -28,7 +31,7 @@ class DebugLogManager {
init {
val categories = mutableListOf<Category>()
categories.addAll(getSavedCategories())
// add categories from system properties (e.g. for tests on CI server)
// add categories from system properties (e.g., for tests on CI server)
categories.addAll(fromString(System.getProperty(LOG_DEBUG_CATEGORIES_SYSTEM_PROPERTY), DebugLogLevel.DEBUG))
categories.addAll(fromString(System.getProperty(LOG_TRACE_CATEGORIES_SYSTEM_PROPERTY), DebugLogLevel.TRACE))
categories.addAll(fromString(System.getProperty(LOG_ALL_CATEGORIES_SYSTEM_PROPERTY), DebugLogLevel.ALL))
@@ -65,13 +68,13 @@ class DebugLogManager {
}
.distinct()
.toList()
filtered.forEach {
val logger = Logger.getLogger(it)
for (name in filtered) {
val logger = Logger.getLogger(name)
logger.level = loggerLevel
customizedLoggers.add(logger)
}
if (filtered.isNotEmpty()) {
LOG.info("Set ${level.name} for the following categories: ${filtered.joinToString()}")
logger<DebugLogManager>().info("Set ${level.name} for the following categories: ${filtered.joinToString()}")
}
}
@@ -106,6 +109,4 @@ private const val LOG_TRACE_CATEGORIES = "log.trace.categories"
private const val LOG_ALL_CATEGORIES = "log.all.categories"
private const val LOG_DEBUG_CATEGORIES_SYSTEM_PROPERTY = "idea.$LOG_DEBUG_CATEGORIES"
private const val LOG_TRACE_CATEGORIES_SYSTEM_PROPERTY = "idea.$LOG_TRACE_CATEGORIES"
private const val LOG_ALL_CATEGORIES_SYSTEM_PROPERTY = "idea.$LOG_ALL_CATEGORIES"
private val LOG = logger<DebugLogManager>()
private const val LOG_ALL_CATEGORIES_SYSTEM_PROPERTY = "idea.$LOG_ALL_CATEGORIES"

View File

@@ -1,4 +1,4 @@
// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.application.options
import com.intellij.openapi.application.PathMacroContributor
@@ -50,7 +50,7 @@ open class PathMacrosImpl @JvmOverloads constructor(private val loadContributors
)
@JvmStatic
fun getInstanceEx() = getInstance() as PathMacrosImpl
fun getInstanceEx(): PathMacrosImpl = getInstance() as PathMacrosImpl
}
override fun getUserMacroNames() = macros.keys

View File

@@ -1,4 +1,4 @@
// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.application.options;
import com.intellij.openapi.application.ApplicationManager;
@@ -24,7 +24,7 @@ import java.util.Map;
* @see com.intellij.openapi.components.PathMacroManager
*/
public final class ReplacePathToMacroMap extends PathMacroMap {
private List<String> myPathsIndex = null;
private List<String> pathIndex = null;
private final Map<String, String> myMacroMap = new LinkedHashMap<>();
public static final String[] PROTOCOLS;
@@ -70,7 +70,7 @@ public final class ReplacePathToMacroMap extends PathMacroMap {
@Override
public @NotNull String substitute(@NotNull String text, boolean caseSensitive) {
for (final String path : getPathIndex()) {
for (String path : getPathIndex()) {
text = replacePathMacro(text, path, caseSensitive);
}
return text;
@@ -86,7 +86,7 @@ public final class ReplacePathToMacroMap extends PathMacroMap {
}
//check that this is complete path (ends with "/" or "!/")
// do not collapse partial paths, i.e. do not substitute "/a/b/cd" in paths like "/a/b/cdeFgh"
// do not collapse partial paths, i.e., do not substitute "/a/b/cd" in paths like "/a/b/cdeFgh"
int endOfOccurrence = path.length();
final boolean isWindowsRoot = path.endsWith(":/");
if (!isWindowsRoot &&
@@ -146,7 +146,7 @@ public final class ReplacePathToMacroMap extends PathMacroMap {
}
}
if (occurrenceOfPath < 0) {
if (newText.length() == 0) {
if (newText.isEmpty()) {
return text;
}
newText.append(text, i, text.length());
@@ -185,8 +185,8 @@ public final class ReplacePathToMacroMap extends PathMacroMap {
}
private @NotNull List<String> getPathIndex() {
if (myPathsIndex != null && myPathsIndex.size() == myMacroMap.size()) {
return myPathsIndex;
if (pathIndex != null && pathIndex.size() == myMacroMap.size()) {
return pathIndex;
}
List<Map.Entry<String, String>> entries = new ArrayList<>(myMacroMap.entrySet());
@@ -197,8 +197,8 @@ public final class ReplacePathToMacroMap extends PathMacroMap {
}
entries.sort((o1, o2) -> weights.getInt(o2.getKey()) - weights.getInt(o1.getKey()));
myPathsIndex = ContainerUtil.map(entries, entry -> entry.getKey());
return myPathsIndex;
pathIndex = ContainerUtil.map(entries, entry -> entry.getKey());
return pathIndex;
}
public boolean equals(Object obj) {
@@ -217,6 +217,6 @@ public final class ReplacePathToMacroMap extends PathMacroMap {
@Override
public String toString() {
return "macroMap: " + myMacroMap + "\n\npathsIndex: " + StringUtil.join(myPathsIndex, "\n");
return "macroMap: " + myMacroMap + "\n\npathsIndex: " + StringUtil.join(pathIndex, "\n");
}
}

View File

@@ -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-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.openapi.components;
import com.intellij.application.options.PathMacrosCollector;
@@ -41,8 +41,7 @@ public class PathMacroManager implements PathMacroSubstitutor {
myPathMacros = (PathMacrosImpl)pathMacros;
}
@NotNull
public PathMacroFilter getMacroFilter() {
public @NotNull PathMacroFilter getMacroFilter() {
return Holder.createFilter();
}
@@ -75,8 +74,7 @@ public class PathMacroManager implements PathMacroSubstitutor {
}
}
@NotNull
public ExpandMacroToPathMap getExpandMacroMap() {
public @NotNull ExpandMacroToPathMap getExpandMacroMap() {
ExpandMacroToPathMap result = new ExpandMacroToPathMap();
getPathMacros().addMacroExpands(result);
for (Map.Entry<String, String> entry : PathMacroUtil.getGlobalSystemMacros().entrySet()) {
@@ -85,8 +83,7 @@ public class PathMacroManager implements PathMacroSubstitutor {
return result;
}
@NotNull
public final synchronized ReplacePathToMacroMap getReplacePathMap() {
public final synchronized @NotNull ReplacePathToMacroMap getReplacePathMap() {
long pathMacrosModificationCount = getPathMacros().getModificationCount();
if (myReplacePathToMacroMap != null && pathMacrosModificationCount == myPathMacrosModificationCount) {
return myReplacePathToMacroMap;
@@ -97,8 +94,7 @@ public class PathMacroManager implements PathMacroSubstitutor {
return myReplacePathToMacroMap;
}
@NotNull
protected ReplacePathToMacroMap computeReplacePathMap() {
protected @NotNull ReplacePathToMacroMap computeReplacePathMap() {
ReplacePathToMacroMap result = new ReplacePathToMacroMap();
getPathMacros().addMacroReplacements(result);
for (Map.Entry<String, String> entry : PathMacroUtil.getGlobalSystemMacros().entrySet()) {
@@ -143,8 +139,7 @@ public class PathMacroManager implements PathMacroSubstitutor {
map.substitute(element, SystemInfoRt.isFileSystemCaseSensitive, recursively, Holder.createFilter());
}
@NotNull
private PathMacrosImpl getPathMacros() {
private @NotNull PathMacrosImpl getPathMacros() {
if (myPathMacros == null) {
myPathMacros = PathMacrosImpl.getInstanceEx();
}