From 66118cc40e5b16c172a7dc1fac6ed4c4ce20b0ae Mon Sep 17 00:00:00 2001 From: Eugene Petrenko Date: Mon, 4 May 2020 20:01:30 +0200 Subject: [PATCH] shared-indexes: reduce nesting in the code (minor) GitOrigin-RevId: 03d9bf18f3d276672914ed79746330d7290d999a --- .../providers/JdkPortableFilePathProvider.kt | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/util/indexing/diagnostic/dump/paths/providers/JdkPortableFilePathProvider.kt b/platform/lang-impl/src/com/intellij/util/indexing/diagnostic/dump/paths/providers/JdkPortableFilePathProvider.kt index 2e19d0fac4ce..99ad03b8b9f2 100644 --- a/platform/lang-impl/src/com/intellij/util/indexing/diagnostic/dump/paths/providers/JdkPortableFilePathProvider.kt +++ b/platform/lang-impl/src/com/intellij/util/indexing/diagnostic/dump/paths/providers/JdkPortableFilePathProvider.kt @@ -1,3 +1,4 @@ +// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.util.indexing.diagnostic.dump.paths.providers import com.intellij.openapi.project.Project @@ -11,21 +12,20 @@ import com.intellij.util.indexing.diagnostic.dump.paths.PortableFilePath object JdkPortableFilePathProvider : PortableFilePathProvider { override fun getRelativePortableFilePath(project: Project, virtualFile: VirtualFile): PortableFilePath.RelativePath? { val orderEntry = LibraryUtil.findLibraryEntry(virtualFile, project) - if (orderEntry is JdkOrderEntry) { - val jdkName = orderEntry.jdkName - if (jdkName != null) { - for (rootType in listOf(OrderRootType.CLASSES, OrderRootType.SOURCES)) { - val inClassFiles = rootType == OrderRootType.CLASSES - val jdkRoots = orderEntry.getRootFiles(rootType) - for ((rootIndex, rootFile) in jdkRoots.withIndex()) { - val relativePath = VfsUtilCore.getRelativePath(virtualFile, rootFile) - if (relativePath != null) { - return PortableFilePath.RelativePath(PortableFilePath.JdkRoot(jdkName, rootIndex, inClassFiles), relativePath) - } - } - } + if (orderEntry !is JdkOrderEntry) return null + val jdkName = orderEntry.jdkName + if (jdkName == null) return null + + for (rootType in listOf(OrderRootType.CLASSES, OrderRootType.SOURCES)) { + val inClassFiles = rootType == OrderRootType.CLASSES + val jdkRoots = orderEntry.getRootFiles(rootType) + for ((rootIndex, rootFile) in jdkRoots.withIndex()) { + val relativePath = VfsUtilCore.getRelativePath(virtualFile, rootFile) + if (relativePath == null) continue + return PortableFilePath.RelativePath(PortableFilePath.JdkRoot(jdkName, rootIndex, inClassFiles), relativePath) } } + return null } -} \ No newline at end of file +}