diff --git a/compiler/psi/src/org/jetbrains/kotlin/psi/KtCodeFragment.kt b/compiler/psi/src/org/jetbrains/kotlin/psi/KtCodeFragment.kt index 441bab2372e40..1b60c903ad064 100644 --- a/compiler/psi/src/org/jetbrains/kotlin/psi/KtCodeFragment.kt +++ b/compiler/psi/src/org/jetbrains/kotlin/psi/KtCodeFragment.kt @@ -1,17 +1,6 @@ /* - * Copyright 2010-2015 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 2010-2024 JetBrains s.r.o. and Kotlin Programming Language contributors. + * 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.psi @@ -29,6 +18,7 @@ import com.intellij.psi.tree.IElementType import com.intellij.testFramework.LightVirtualFile import com.intellij.util.messages.Topic import org.jetbrains.kotlin.idea.KotlinFileType +import org.jetbrains.kotlin.psi.KtCodeFragment.Companion.IMPORT_SEPARATOR import org.jetbrains.kotlin.psi.psiUtil.getElementTextWithContext abstract class KtCodeFragment( @@ -198,6 +188,9 @@ abstract class KtCodeFragment( return null } + override val importList: KtImportList? + get() = importsAsImportList() + override val importLists: List get() = listOfNotNull(importsAsImportList()) diff --git a/compiler/psi/src/org/jetbrains/kotlin/psi/KtCommonFile.kt b/compiler/psi/src/org/jetbrains/kotlin/psi/KtCommonFile.kt index 9bb85dd83f850..246a73a381946 100644 --- a/compiler/psi/src/org/jetbrains/kotlin/psi/KtCommonFile.kt +++ b/compiler/psi/src/org/jetbrains/kotlin/psi/KtCommonFile.kt @@ -51,8 +51,8 @@ open class KtCommonFile(viewProvider: FileViewProvider, val isCompiled: Boolean) @Volatile private var pathCached: String? = null - val importList: KtImportList? - get() = importLists.firstOrNull() + open val importList: KtImportList? + get() = findChildByTypeOrClass(KtStubElementTypes.IMPORT_LIST, KtImportList::class.java) @Volatile private var hasImportAlias: Boolean? = null