[SLC] SymbolLightClassForEnumEntry: improve implementation
^KT-54051 ^KT-50241
This commit is contained in:
committed by
Space Team
parent
5f20c10185
commit
a7fae5fd99
+16
-20
@@ -1,17 +1,6 @@
|
||||
/*
|
||||
* Copyright 2010-2017 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-2022 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.asJava
|
||||
@@ -22,7 +11,11 @@ import org.jetbrains.kotlin.asJava.finder.JavaElementFinder
|
||||
import org.jetbrains.kotlin.checkers.KotlinMultiFileTestWithJava
|
||||
import org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.test.*
|
||||
import org.jetbrains.kotlin.psi.KtEnumEntry
|
||||
import org.jetbrains.kotlin.test.Directives
|
||||
import org.jetbrains.kotlin.test.InTextDirectivesUtils
|
||||
import org.jetbrains.kotlin.test.KotlinBaseTest
|
||||
import org.jetbrains.kotlin.test.KotlinTestUtils
|
||||
import org.jetbrains.kotlin.util.KotlinFrontEndException
|
||||
import org.junit.Assert
|
||||
import java.io.File
|
||||
@@ -63,14 +56,17 @@ abstract class AbstractCompilerLightClassTest : KotlinMultiFileTestWithJava<Kotl
|
||||
KotlinTestUtils.resolveAllKotlinFiles(environment)
|
||||
}
|
||||
|
||||
val lightCLassForScript = KotlinAsJavaSupport
|
||||
.getInstance(environment.project)
|
||||
.getScriptClasses(FqName(fqname), GlobalSearchScope.allScope(environment.project))
|
||||
val searchScope = GlobalSearchScope.allScope(environment.project)
|
||||
val kotlinAsJavaSupport = KotlinAsJavaSupport.getInstance(environment.project)
|
||||
val lightClassForScript = kotlinAsJavaSupport
|
||||
.getScriptClasses(FqName(fqname), searchScope)
|
||||
.firstOrNull()
|
||||
|
||||
return lightCLassForScript ?: JavaElementFinder
|
||||
.getInstance(environment.project)
|
||||
.findClass(fqname, GlobalSearchScope.allScope(environment.project))
|
||||
return lightClassForScript
|
||||
?: JavaElementFinder.getInstance(environment.project).findClass(fqname, searchScope)
|
||||
?: kotlinAsJavaSupport.findClassOrObjectDeclarations(FqName(fqname), searchScope).firstOrNull {
|
||||
it is KtEnumEntry // JavaElementFinder will ignore enum entry
|
||||
}?.toLightClass()
|
||||
}
|
||||
|
||||
private fun assertException(shouldOccur: Boolean, klass: Class<out Throwable>, f: () -> Unit) {
|
||||
|
||||
Reference in New Issue
Block a user