Build: Workaround scripting dependencies on full Idea

This commit is contained in:
Vyacheslav Gerasimov
2019-06-13 18:11:27 +03:00
parent 5a39c637c2
commit 0514437fba
2 changed files with 9 additions and 1 deletions
@@ -20,6 +20,9 @@ dependencies {
compileOnly(intellijCoreDep()) { includeJars("intellij-core") }
compileOnly(intellijDep()) { includeJars("asm-all", rootProject = rootProject) }
// FIXME: drop after removing references to LocalFileSystem they don't exist in intellij-core
compileOnly(intellijDep()) { includeJars("platform-api") }
testCompile(project(":compiler:frontend"))
testCompile(project(":compiler:plugin-api"))
testCompile(project(":compiler:util"))
@@ -6,15 +6,20 @@
package org.jetbrains.kotlin.scripting.definitions
import com.intellij.ide.highlighter.JavaClassFileType
import com.intellij.openapi.application.runReadAction
import com.intellij.openapi.application.ApplicationManager
import com.intellij.openapi.fileTypes.FileTypeRegistry
import com.intellij.openapi.project.Project
import com.intellij.openapi.util.Computable
import com.intellij.openapi.vfs.VirtualFile
import com.intellij.psi.PsiFile
import com.intellij.psi.PsiManager
import org.jetbrains.kotlin.idea.KotlinFileType
import org.jetbrains.kotlin.psi.KtFile
inline fun <T> runReadAction(crossinline runnable: () -> T): T {
return ApplicationManager.getApplication().runReadAction(Computable { runnable() })
}
fun PsiFile.findScriptDefinition(): ScriptDefinition? {
// Do not use psiFile.script, see comments in findScriptDefinition
if (this !is KtFile/* || this.script == null*/) return null