Minor: fix tests
This commit is contained in:
@@ -27,7 +27,8 @@ import com.intellij.psi.search.GlobalSearchScope
|
||||
import org.jetbrains.kotlin.idea.KotlinFileType
|
||||
import org.jetbrains.kotlin.idea.configuration.ui.notifications.ConfigureKotlinNotification
|
||||
import org.jetbrains.kotlin.idea.util.projectStructure.allModules
|
||||
import org.jetbrains.kotlin.idea.versions.hasKotlinRuntimeMarkerClass
|
||||
import org.jetbrains.kotlin.idea.versions.getKotlinJsRuntimeMarkerClass
|
||||
import org.jetbrains.kotlin.idea.versions.getKotlinJvmRuntimeMarkerClass
|
||||
import org.jetbrains.kotlin.utils.ifEmpty
|
||||
|
||||
data class RepositoryDescription(val id: String, val name: String, val url: String, val isSnapshot: Boolean)
|
||||
@@ -123,9 +124,19 @@ fun getNonConfiguredModules(project: Project, excludeModules: Collection<Module>
|
||||
}
|
||||
}
|
||||
|
||||
fun hasKotlinRuntimeInScope(module: Module): Boolean {
|
||||
fun hasKotlinJvmOrJsRuntimeInScope(module: Module): Boolean {
|
||||
val scope = module.getModuleWithDependenciesAndLibrariesScope(hasKotlinFilesOnlyInTests(module))
|
||||
return hasKotlinRuntimeMarkerClass(module.project, scope)
|
||||
return getKotlinJvmRuntimeMarkerClass(module.project, scope) != null || getKotlinJsRuntimeMarkerClass(module.project, scope) != null
|
||||
}
|
||||
|
||||
fun hasKotlinJvmRuntimeInScope(module: Module): Boolean {
|
||||
val scope = module.getModuleWithDependenciesAndLibrariesScope(hasKotlinFilesOnlyInTests(module))
|
||||
return getKotlinJvmRuntimeMarkerClass(module.project, scope) != null
|
||||
}
|
||||
|
||||
fun hasKotlinJsRuntimeInScope(module: Module): Boolean {
|
||||
val scope = module.getModuleWithDependenciesAndLibrariesScope(hasKotlinFilesOnlyInTests(module))
|
||||
return getKotlinJsRuntimeMarkerClass(module.project, scope) != null
|
||||
}
|
||||
|
||||
fun hasKotlinFilesOnlyInTests(module: Module): Boolean {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2015 JetBrains s.r.o.
|
||||
* Copyright 2010-2016 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.
|
||||
@@ -20,7 +20,6 @@ import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.idea.maven.dom.model.MavenDomPlugin;
|
||||
import org.jetbrains.kotlin.idea.project.ProjectStructureUtil;
|
||||
import org.jetbrains.kotlin.resolve.TargetPlatform;
|
||||
import org.jetbrains.kotlin.resolve.jvm.platform.JvmPlatform;
|
||||
|
||||
@@ -35,7 +34,7 @@ public class KotlinJavaMavenConfigurator extends KotlinMavenConfigurator {
|
||||
|
||||
@Override
|
||||
protected boolean isKotlinModule(@NotNull Module module) {
|
||||
return ConfigureKotlinInProjectUtilsKt.hasKotlinRuntimeInScope(module);
|
||||
return ConfigureKotlinInProjectUtilsKt.hasKotlinJvmRuntimeInScope(module);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -37,7 +37,7 @@ public class KotlinJavaModuleConfigurator extends KotlinWithLibraryConfigurator
|
||||
|
||||
@Override
|
||||
public boolean isConfigured(@NotNull Module module) {
|
||||
return ConfigureKotlinInProjectUtilsKt.hasKotlinRuntimeInScope(module);
|
||||
return ConfigureKotlinInProjectUtilsKt.hasKotlinJvmRuntimeInScope(module);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -107,7 +107,7 @@ public class KotlinJavaModuleConfigurator extends KotlinWithLibraryConfigurator
|
||||
}
|
||||
|
||||
LibraryScope scope = new LibraryScope(project, library);
|
||||
return KotlinRuntimeLibraryUtilKt.hasKotlinRuntimeMarkerClass(project, scope);
|
||||
return KotlinRuntimeLibraryUtilKt.getKotlinJvmRuntimeMarkerClass(project, scope) != null;
|
||||
}
|
||||
|
||||
KotlinJavaModuleConfigurator() {
|
||||
|
||||
+2
-3
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2015 JetBrains s.r.o.
|
||||
* Copyright 2010-2016 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.
|
||||
@@ -20,7 +20,6 @@ import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.idea.maven.dom.model.MavenDomPlugin;
|
||||
import org.jetbrains.kotlin.idea.project.ProjectStructureUtil;
|
||||
import org.jetbrains.kotlin.js.resolve.JsPlatform;
|
||||
import org.jetbrains.kotlin.resolve.TargetPlatform;
|
||||
|
||||
@@ -38,7 +37,7 @@ public class KotlinJavascriptMavenConfigurator extends KotlinMavenConfigurator {
|
||||
|
||||
@Override
|
||||
protected boolean isKotlinModule(@NotNull Module module) {
|
||||
return ProjectStructureUtil.isJsKotlinModule(module);
|
||||
return ConfigureKotlinInProjectUtilsKt.hasKotlinJsRuntimeInScope(module);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2015 JetBrains s.r.o.
|
||||
* Copyright 2010-2016 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.
|
||||
@@ -23,7 +23,6 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.kotlin.idea.framework.JSLibraryStdDescription;
|
||||
import org.jetbrains.kotlin.idea.framework.KotlinLibraryUtilKt;
|
||||
import org.jetbrains.kotlin.idea.project.ProjectStructureUtil;
|
||||
import org.jetbrains.kotlin.js.JavaScript;
|
||||
import org.jetbrains.kotlin.js.resolve.JsPlatform;
|
||||
import org.jetbrains.kotlin.resolve.TargetPlatform;
|
||||
@@ -53,7 +52,7 @@ public class KotlinJsModuleConfigurator extends KotlinWithLibraryConfigurator {
|
||||
|
||||
@Override
|
||||
public boolean isConfigured(@NotNull Module module) {
|
||||
return ProjectStructureUtil.isJsKotlinModule(module);
|
||||
return ConfigureKotlinInProjectUtilsKt.hasKotlinJsRuntimeInScope(module);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2015 JetBrains s.r.o.
|
||||
* Copyright 2010-2016 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.
|
||||
@@ -77,7 +77,7 @@ class KotlinSetupEnvironmentNotificationProvider(
|
||||
return createSetupSdkPanel(myProject, psiFile)
|
||||
}
|
||||
|
||||
if (!hasKotlinRuntimeInScope(module) &&
|
||||
if (!hasKotlinJvmOrJsRuntimeInScope(module) &&
|
||||
UnsupportedAbiVersionNotificationPanelProvider.collectBadRoots(module).isEmpty()) {
|
||||
return createKotlinNotConfiguredPanel(module)
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2015 JetBrains s.r.o.
|
||||
* Copyright 2010-2016 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.
|
||||
@@ -70,7 +70,7 @@ public abstract class KotlinWithGradleConfigurator implements KotlinProjectConfi
|
||||
|
||||
@Override
|
||||
public boolean isConfigured(@NotNull Module module) {
|
||||
if (ConfigureKotlinInProjectUtilsKt.hasKotlinRuntimeInScope(module)) {
|
||||
if (ConfigureKotlinInProjectUtilsKt.hasKotlinJvmRuntimeInScope(module)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -32,6 +32,7 @@ import com.intellij.openapi.util.text.StringUtil
|
||||
import com.intellij.openapi.vfs.JarFileSystem
|
||||
import com.intellij.openapi.vfs.VirtualFile
|
||||
import com.intellij.psi.JavaPsiFacade
|
||||
import com.intellij.psi.PsiClass
|
||||
import com.intellij.psi.search.GlobalSearchScope
|
||||
import com.intellij.util.PathUtil.getLocalFile
|
||||
import com.intellij.util.PathUtil.getLocalPath
|
||||
@@ -258,16 +259,18 @@ fun showRuntimeJarNotFoundDialog(project: Project, jarName: String) {
|
||||
"No Runtime Found")
|
||||
}
|
||||
|
||||
fun hasKotlinRuntimeMarkerClass(project: Project, scope: GlobalSearchScope): Boolean {
|
||||
fun getKotlinJvmRuntimeMarkerClass(project: Project, scope: GlobalSearchScope): PsiClass? {
|
||||
return runReadAction {
|
||||
project.runWithAlternativeResolveEnabled {
|
||||
getKotlinJvmRuntimeMarkerClass(project, scope) != null || getKotlinJsRuntimeMarkerClass(project, scope) != null
|
||||
JavaPsiFacade.getInstance(project).findClass(KotlinBuiltIns.FQ_NAMES.unit.asString(), scope)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun getKotlinJvmRuntimeMarkerClass(project: Project, scope: GlobalSearchScope) =
|
||||
JavaPsiFacade.getInstance(project).findClass(KotlinBuiltIns.FQ_NAMES.unit.asString(), scope)
|
||||
|
||||
private fun getKotlinJsRuntimeMarkerClass(project: Project, scope: GlobalSearchScope) =
|
||||
JsVirtualFileFinderFactory.SERVICE.getInstance(project).create(scope).findVirtualFileWithHeader(ClassId.topLevel(KotlinBuiltIns.FQ_NAMES.unit.toSafe()))
|
||||
fun getKotlinJsRuntimeMarkerClass(project: Project, scope: GlobalSearchScope): VirtualFile? {
|
||||
return runReadAction {
|
||||
project.runWithAlternativeResolveEnabled {
|
||||
JsVirtualFileFinderFactory.SERVICE.getInstance(project).create(scope).findVirtualFileWithHeader(ClassId.topLevel(KotlinBuiltIns.FQ_NAMES.unit.toSafe()))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+3
-3
@@ -54,14 +54,14 @@ fun box(): String {
|
||||
assertEquals(7, js("j /= 2"), "/=")
|
||||
assertEquals(1, js("j %= 2"), "%=")
|
||||
|
||||
assertEquals(Unit, js("(void 0)"), "void")
|
||||
assertEquals(undefined, js("(void 0)"), "void")
|
||||
assertEquals(true, js("'key' in {'key': 10}"), "in")
|
||||
assertEquals("string", js("typeof 'str'"), "typeof")
|
||||
assertEquals(A(2), js("new _.foo.A(2)"), "new")
|
||||
assertEquals(true, js("new String('str') instanceof String"), "instanceof")
|
||||
|
||||
var s: Any = js("({key: 10})")
|
||||
assertEquals(Unit, js("delete s.key, s.key"), "delete")
|
||||
assertEquals(undefined, js("delete s.key, s.key"), "delete")
|
||||
|
||||
return "OK"
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user