Skip to content

Commit 340a181

Browse files
committed
Replace deprecated IDE APIs in the IDEA plugin
The marketplace verifier flagged three calls against 2026.3. PluginManager.getPlugin is both deprecated and internal, so PluginManager.getInstance().findEnabledPlugin takes over, and PluginDescriptor.getPath gives way to getPluginPath. TrustedProjects.isTrusted stays: the class it points to, com.intellij.ide.trustedProjects.TrustedProjects, is @ApiStatus.Internal — worse for a plugin to call than an experimental one.
1 parent 3f6c827 commit 340a181

2 files changed

Lines changed: 7 additions & 4 deletions

File tree

‎open-java-format-idea-plugin/src/main/java/com/palantir/javaformat/intellij/FormatterProvider.java‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,11 @@ final class FormatterProvider {
4949
private final LoadingCache<FormatterCacheKey, Optional<FormatterService>> implementationCache =
5050
Caffeine.newBuilder().maximumSize(1).build(FormatterProvider::createFormatter);
5151

52-
@SuppressWarnings("for-rollout:deprecation")
5352
static IdeaPluginDescriptor getPluginDescriptor() {
5453
return Preconditions.checkNotNull(
55-
PluginManager.getPlugin(PluginId.getId(PLUGIN_ID)), "Couldn't find our own plugin: %s", PLUGIN_ID);
54+
PluginManager.getInstance().findEnabledPlugin(PluginId.getId(PLUGIN_ID)),
55+
"Couldn't find our own plugin: %s",
56+
PLUGIN_ID);
5657
}
5758

5859
Optional<FormatterService> get(Project project, PalantirJavaFormatSettings settings) {
@@ -89,8 +90,7 @@ private static List<Path> getProvidedImplementationUrls(List<URI> implementation
8990
private static List<Path> getBundledImplementationUrls() {
9091
// Load from the jars bundled with the plugin.
9192
IdeaPluginDescriptor ourPlugin = getPluginDescriptor();
92-
@SuppressWarnings("for-rollout:deprecation")
93-
Path implDir = ourPlugin.getPath().toPath().resolve("impl");
93+
Path implDir = ourPlugin.getPluginPath().resolve("impl");
9494
log.debug("Using open-java-format implementation bundled with plugin: {}", implDir);
9595
return listDirAsUrlsUnchecked(implDir);
9696
}

‎open-java-format-idea-plugin/src/main/java/com/palantir/javaformat/intellij/PalantirJavaFormatFormattingService.java‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@ class PalantirJavaFormatFormattingService extends AsyncDocumentFormattingService
4747
@Override
4848
protected FormattingTask createFormattingTask(@NotNull AsyncFormattingRequest request) {
4949
Project project = request.getContext().getProject();
50+
// The marketplace verifier reports this class as experimental, and newer IDEs also deprecate it. It stays:
51+
// its replacement, com.intellij.ide.trustedProjects.TrustedProjects, is @ApiStatus.Internal — a worse thing
52+
// for a plugin to call.
5053
if (!TrustedProjects.isTrusted(project)) {
5154
logger.warn("open-java-format: skipping formatting for untrusted project: " + project.getName());
5255
request.onError(

0 commit comments

Comments
 (0)