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); } }