diff --git a/platform/ide-core/src/com/intellij/notification/NotificationAction.java b/platform/ide-core/src/com/intellij/notification/NotificationAction.java index 353feb12b526..5f887e218786 100644 --- a/platform/ide-core/src/com/intellij/notification/NotificationAction.java +++ b/platform/ide-core/src/com/intellij/notification/NotificationAction.java @@ -1,4 +1,4 @@ -// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. +// Copyright 2000-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. package com.intellij.notification; import com.intellij.internal.statistic.collectors.fus.actions.persistence.ActionIdProvider; @@ -7,7 +7,6 @@ import com.intellij.openapi.actionSystem.AnAction; import com.intellij.openapi.actionSystem.AnActionEvent; import com.intellij.openapi.project.DumbAwareAction; import org.jetbrains.annotations.ApiStatus; -import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -65,9 +64,11 @@ public abstract class NotificationAction extends DumbAwareAction { return new Simple(text, action, true, action, null); } - public static @NotNull NotificationAction createSimple(@NotNull @NotificationContent String text, - @NotNull @NonNls String actionId, - @NotNull Runnable action) { + public static @NotNull NotificationAction createSimple( + @NotNull @NotificationContent String text, + @NotNull String actionId, + @NotNull Runnable action + ) { return new Simple(text, (event, notification) -> action.run(), false, action, actionId); } diff --git a/platform/platform-impl/src/com/intellij/openapi/fileChooser/actions/GotoDesktopDirAction.java b/platform/platform-impl/src/com/intellij/openapi/fileChooser/actions/GotoDesktopDirAction.java index 61ed5126c3fc..55ab8761c34a 100644 --- a/platform/platform-impl/src/com/intellij/openapi/fileChooser/actions/GotoDesktopDirAction.java +++ b/platform/platform-impl/src/com/intellij/openapi/fileChooser/actions/GotoDesktopDirAction.java @@ -14,10 +14,12 @@ import com.intellij.openapi.util.NullableLazyValue; import com.intellij.openapi.vfs.LocalFileSystem; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.ui.mac.foundation.Foundation; -import com.intellij.ui.mac.foundation.ID; import com.intellij.util.SystemProperties; import com.intellij.util.system.OS; -import com.sun.jna.platform.win32.*; +import com.sun.jna.platform.win32.Shell32; +import com.sun.jna.platform.win32.ShlObj; +import com.sun.jna.platform.win32.WinDef; +import com.sun.jna.platform.win32.WinError; import org.jetbrains.annotations.NotNull; import java.nio.file.Files; @@ -28,24 +30,24 @@ import static com.intellij.openapi.util.NullableLazyValue.lazyNullable; final class GotoDesktopDirAction extends FileChooserAction implements LightEditCompatible { private final NullableLazyValue myDesktopPath = lazyNullable(() -> { - Path path = getDesktopDirectory(); + var path = getDesktopDirectory(); return Files.isDirectory(path) ? path : null; }); private final NullableLazyValue myDesktopDirectory = lazyNullable(() -> { - Path path = myDesktopPath.getValue(); + var path = myDesktopPath.getValue(); return path != null ? LocalFileSystem.getInstance().findFileByNioFile(path) : null; }); @Override protected void update(@NotNull FileChooserPanel panel, @NotNull AnActionEvent e) { - Path path = myDesktopPath.getValue(); + var path = myDesktopPath.getValue(); e.getPresentation().setEnabled(path != null); } @Override protected void actionPerformed(@NotNull FileChooserPanel panel, @NotNull AnActionEvent e) { - Path path = myDesktopPath.getValue(); + var path = myDesktopPath.getValue(); if (path != null) { panel.load(path); } @@ -53,13 +55,13 @@ final class GotoDesktopDirAction extends FileChooserAction implements LightEditC @Override protected void update(@NotNull FileSystemTree tree, @NotNull AnActionEvent e) { - VirtualFile dir = myDesktopDirectory.getValue(); + var dir = myDesktopDirectory.getValue(); e.getPresentation().setEnabled(dir != null && tree.isUnderRoots(dir)); } @Override protected void actionPerformed(@NotNull FileSystemTree tree, @NotNull AnActionEvent e) { - VirtualFile dir = myDesktopDirectory.getValue(); + var dir = myDesktopDirectory.getValue(); if (dir != null) { tree.select(dir, () -> tree.expand(dir, null)); } @@ -67,24 +69,24 @@ final class GotoDesktopDirAction extends FileChooserAction implements LightEditC private static Path getDesktopDirectory() { if (OS.CURRENT == OS.Windows && JnaLoader.isLoaded()) { - char[] path = new char[WinDef.MAX_PATH]; - WinNT.HRESULT res = Shell32.INSTANCE.SHGetFolderPath(null, ShlObj.CSIDL_DESKTOP, null, ShlObj.SHGFP_TYPE_CURRENT, path); + var path = new char[WinDef.MAX_PATH]; + var res = Shell32.INSTANCE.SHGetFolderPath(null, ShlObj.CSIDL_DESKTOP, null, ShlObj.SHGFP_TYPE_CURRENT, path); if (WinError.S_OK.equals(res)) { - int len = 0; + var len = 0; while (len < path.length && path[len] != 0) len++; return Path.of(new String(path, 0, len)); } } else if (OS.CURRENT == OS.macOS && JnaLoader.isLoaded()) { - ID manager = Foundation.invoke(Foundation.getObjcClass("NSFileManager"), "defaultManager"); - ID url = Foundation.invoke(manager, "URLForDirectory:inDomain:appropriateForURL:create:error:", - 12 /*NSDesktopDirectory*/, 1 /*NSUserDomainMask*/, null, false, null); - String path = Foundation.toStringViaUTF8(Foundation.invoke(url, "path")); + var manager = Foundation.invoke(Foundation.getObjcClass("NSFileManager"), "defaultManager"); + var selector = "URLForDirectory:inDomain:appropriateForURL:create:error:"; + var url = Foundation.invoke(manager, selector, 12 /*NSDesktopDirectory*/, 1 /*NSUserDomainMask*/, null, false, null); + var path = Foundation.toStringViaUTF8(Foundation.invoke(url, "path")); if (path != null) { return Path.of(path); } } - else if (PathEnvironmentVariableUtil.isOnPath("xdg-user-dir")) { + else if (OS.isGenericUnix() && PathEnvironmentVariableUtil.isOnPath("xdg-user-dir")) { var path = ExecUtil.execAndReadLine(new GeneralCommandLine("xdg-user-dir", "DESKTOP")); if (path != null && !path.isBlank()) { try {