Check if containing file is KtFile

EA-109460 - CCE: KtElementImplStub.getContainingKtFile
This commit is contained in:
Dmitry Jemerov
2017-12-28 13:02:53 +01:00
parent 4b6efe3eb0
commit 2c4180222a
@@ -1,17 +1,6 @@
/*
* Copyright 2010-2016 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
* that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.idea.decompiler.navigation
@@ -31,7 +20,9 @@ import gnu.trove.THashSet
import org.jetbrains.annotations.TestOnly
import org.jetbrains.kotlin.asJava.toLightClass
import org.jetbrains.kotlin.descriptors.CallableDescriptor
import org.jetbrains.kotlin.idea.caches.resolve.*
import org.jetbrains.kotlin.idea.caches.resolve.getBinaryLibrariesModuleInfos
import org.jetbrains.kotlin.idea.caches.resolve.getLibrarySourcesModuleInfos
import org.jetbrains.kotlin.idea.caches.resolve.resolveToDescriptorIfAny
import org.jetbrains.kotlin.idea.decompiler.navigation.MemberMatching.*
import org.jetbrains.kotlin.idea.stubindex.KotlinFullClassNameIndex
import org.jetbrains.kotlin.idea.stubindex.KotlinTopLevelFunctionFqnNameIndex
@@ -275,7 +266,8 @@ object SourceNavigationHelper {
when (navigationKind) {
SourceNavigationHelper.NavigationKind.CLASS_FILES_TO_SOURCES -> if (!from.containingKtFile.isCompiled) return from
SourceNavigationHelper.NavigationKind.SOURCES_TO_CLASS_FILES -> {
if (from.containingKtFile.isCompiled) return from
val file = from.containingFile
if (file is KtFile && file.isCompiled) return from
if (!ProjectRootsUtil.isInContent(from, false, true, false, true)) return from
if (KtPsiUtil.isLocal(from)) return from
}