Implement light classes for Kotlin scripts
This commit is contained in:
@@ -33,7 +33,7 @@ object LightClassTestCommon {
|
||||
expectedFile: File,
|
||||
testDataFile: File,
|
||||
findLightClass: (String) -> PsiClass?,
|
||||
normalizeText: (String) -> String = { it }
|
||||
normalizeText: (String) -> String
|
||||
) {
|
||||
val text = FileUtil.loadFile(testDataFile, true)
|
||||
val matcher = SUBJECT_FQ_NAME_PATTERN.matcher(text)
|
||||
@@ -57,8 +57,8 @@ object LightClassTestCommon {
|
||||
|
||||
val buffer = StringBuilder()
|
||||
(delegate as ClsElementImpl).appendMirrorText(0, buffer)
|
||||
val actual = normalizeText(buffer.toString())
|
||||
return actual
|
||||
|
||||
return normalizeText(buffer.toString())
|
||||
}
|
||||
|
||||
// Actual text for light class is generated with ClsElementImpl.appendMirrorText() that can find empty DefaultImpl inner class in stubs
|
||||
|
||||
+2
-2
@@ -81,7 +81,7 @@ public abstract class KotlinMultiFileTestWithJava<M, F> extends KtUsefulTestCase
|
||||
CollectionsKt.plus(Collections.singletonList(KotlinTestUtils.getAnnotationsJar()), getExtraClasspath()),
|
||||
isJavaSourceRootNeeded() ? Collections.singletonList(javaFilesDir) : Collections.emptyList()
|
||||
);
|
||||
configuration.add(JVMConfigurationKeys.SCRIPT_DEFINITIONS, StandardScriptDefinition.INSTANCE);
|
||||
configuration.add(JVMConfigurationKeys.SCRIPT_DEFINITIONS, StandardScriptDefinition.INSTANCE);
|
||||
if (isKotlinSourceRootNeeded()) {
|
||||
ContentRootsKt.addKotlinSourceRoot(configuration, kotlinSourceRoot.getPath());
|
||||
}
|
||||
@@ -157,7 +157,7 @@ public abstract class KotlinMultiFileTestWithJava<M, F> extends KtUsefulTestCase
|
||||
writeSourceFile(fileName, text, javaFilesDir);
|
||||
}
|
||||
|
||||
if (fileName.endsWith(".kt") && kotlinSourceRoot != null) {
|
||||
if ((fileName.endsWith(".kt") || fileName.endsWith(".kts")) && kotlinSourceRoot != null) {
|
||||
writeSourceFile(fileName, text, kotlinSourceRoot);
|
||||
}
|
||||
|
||||
|
||||
@@ -563,7 +563,7 @@ public class KotlinTestUtils {
|
||||
else {
|
||||
//noinspection ConstantConditions
|
||||
for (File childFile : file.listFiles()) {
|
||||
if (childFile.getName().endsWith(".kt")) {
|
||||
if (childFile.getName().endsWith(".kt") || childFile.getName().endsWith(".kts")) {
|
||||
ktFiles.add(loadJetFile(environment.getProject(), childFile));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user