From 66b1e9b6e5faaed0fb868f1a3d543801b2290af4 Mon Sep 17 00:00:00 2001 From: Mikhail Pyltsin Date: Wed, 14 May 2025 15:52:57 +0200 Subject: [PATCH] [java-import] IDEA-369199 Preserve module imports even if they are not used - fixed inconsistency GitOrigin-RevId: 610b42d224f7733de0ca9e250ffc1dfcff5d75fd --- java/java-psi-api/src/com/intellij/psi/util/ImportsUtil.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/java/java-psi-api/src/com/intellij/psi/util/ImportsUtil.java b/java/java-psi-api/src/com/intellij/psi/util/ImportsUtil.java index 1dfb9538f5e0..9b533201b2cd 100644 --- a/java/java-psi-api/src/com/intellij/psi/util/ImportsUtil.java +++ b/java/java-psi-api/src/com/intellij/psi/util/ImportsUtil.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.psi.util; import com.intellij.openapi.project.Project; @@ -99,7 +99,7 @@ public final class ImportsUtil { * @return a list of implicit import statements associated with the given Java file. */ public static List getAllImplicitImports(@NotNull PsiJavaFile file) { - return CachedValuesManager.getProjectPsiDependentCache(file, javaFile -> { + List cache = CachedValuesManager.getProjectPsiDependentCache(file, javaFile -> { List results = new ArrayList<>(); Project project = javaFile.getProject(); PsiElementFactory factory = PsiElementFactory.getInstance(project); @@ -112,5 +112,6 @@ public final class ImportsUtil { } return results; }); + return new ArrayList<>(cache); } }