Allow KtPsiFactory#createModifierList to create fun modifier
#KTIJ-16332
This commit is contained in:
committed by
teamcity
parent
a742c126c2
commit
26d4e02b7c
@@ -354,7 +354,7 @@ class KtPsiFactory @JvmOverloads constructor(private val project: Project, val m
|
||||
}
|
||||
|
||||
fun createModifierList(@NonNls text: String): KtModifierList {
|
||||
return createProperty("$text val x").modifierList!!
|
||||
return createClass("$text interface x").modifierList!!
|
||||
}
|
||||
|
||||
fun createEmptyModifierList() = createModifierList(KtTokens.PRIVATE_KEYWORD).apply { firstChild.delete() }
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
* 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.psi
|
||||
|
||||
import org.jetbrains.kotlin.cli.jvm.compiler.EnvironmentConfigFiles
|
||||
import org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment
|
||||
import org.jetbrains.kotlin.lexer.KtTokens
|
||||
import org.jetbrains.kotlin.test.KotlinTestUtils
|
||||
import org.jetbrains.kotlin.test.KotlinTestWithEnvironment
|
||||
import org.junit.Assert
|
||||
|
||||
class KtPsiFactoryTest : KotlinTestWithEnvironment() {
|
||||
fun testCreateModifierList() {
|
||||
val psiFactory = KtPsiFactory(project)
|
||||
KtTokens.MODIFIER_KEYWORDS_ARRAY.forEach {
|
||||
val modifier = psiFactory.createModifierList(it)
|
||||
Assert.assertTrue(modifier.hasModifier(it))
|
||||
}
|
||||
}
|
||||
|
||||
override fun createEnvironment(): KotlinCoreEnvironment {
|
||||
return KotlinCoreEnvironment.createForTests(
|
||||
testRootDisposable, KotlinTestUtils.newConfiguration(), EnvironmentConfigFiles.JVM_CONFIG_FILES
|
||||
)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user