implement KtFile.getClasses() in plugin (required to have coverage work, among other things)

This commit is contained in:
Dmitry Jemerov
2015-11-09 17:29:04 +01:00
parent 607f32615f
commit 1bc4420734
5 changed files with 92 additions and 1 deletions
@@ -0,0 +1,41 @@
/*
* 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.
*/
package org.jetbrains.kotlin.asJava
import com.intellij.testFramework.LightProjectDescriptor
import org.jetbrains.kotlin.idea.test.KotlinLightCodeInsightFixtureTestCase
import org.jetbrains.kotlin.idea.test.KotlinLightProjectDescriptor
import org.jetbrains.kotlin.psi.KtFile
class KtFileLightClassTest : KotlinLightCodeInsightFixtureTestCase() {
override fun getProjectDescriptor(): LightProjectDescriptor = KotlinLightProjectDescriptor.INSTANCE
fun testSimple() {
val file = myFixture.configureByText("A.kt", "class C {}\nobject O {}") as KtFile
val classes = file.classes
assertEquals(2, classes.size)
assertEquals("C", classes[0].qualifiedName)
assertEquals("O", classes[1].qualifiedName)
}
fun testFileClass() {
val file = myFixture.configureByText("A.kt", "fun f() {}") as KtFile
val classes = file.classes
assertEquals(1, classes.size)
assertEquals("AKt", classes[0].qualifiedName)
}
}