From 2f5f6392a2770b1c49e0fc0adddafd099d74d3ac Mon Sep 17 00:00:00 2001 From: Ivan Bessonov Date: Thu, 23 Mar 2017 17:43:52 +0300 Subject: [PATCH] IDEA-167532 skip duplicated jars in retrieving of language level for files under a library source root --- .../psi/impl/JavaPsiImplementationHelperImpl.java | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/java/java-impl/src/com/intellij/psi/impl/JavaPsiImplementationHelperImpl.java b/java/java-impl/src/com/intellij/psi/impl/JavaPsiImplementationHelperImpl.java index 498eb0492185..ca02c7d1982a 100644 --- a/java/java-impl/src/com/intellij/psi/impl/JavaPsiImplementationHelperImpl.java +++ b/java/java-impl/src/com/intellij/psi/impl/JavaPsiImplementationHelperImpl.java @@ -49,9 +49,7 @@ import com.intellij.util.containers.ContainerUtil; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import java.util.List; -import java.util.Properties; -import java.util.Set; +import java.util.*; /** * @author yole @@ -170,12 +168,15 @@ public class JavaPsiImplementationHelperImpl extends JavaPsiImplementationHelper return null; } String className = virtualFile.getNameWithoutExtension(); + Set visitedRoots = ContainerUtil.newHashSet(); for (OrderEntry entry : index.getOrderEntriesForFile(virtualFile)) { for (VirtualFile rootFile : entry.getFiles(OrderRootType.CLASSES)) { - VirtualFile classFile = rootFile.findFileByRelativePath(relativePath); - PsiJavaFile javaFile = classFile == null ? null : getPsiFileInRoot(classFile, className); - if (javaFile != null) { - return javaFile.getLanguageLevel(); + if (visitedRoots.add(rootFile)) { + VirtualFile classFile = rootFile.findFileByRelativePath(relativePath); + PsiJavaFile javaFile = classFile == null ? null : getPsiFileInRoot(classFile, className); + if (javaFile != null) { + return javaFile.getLanguageLevel(); + } } } }