Workaround for added @NotNull annotation on ProjectFileIndex.getInstance()
This commit is contained in:
@@ -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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -16,8 +16,10 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.idea.project
|
package org.jetbrains.kotlin.idea.project
|
||||||
|
|
||||||
|
import com.intellij.openapi.components.ServiceManager
|
||||||
import com.intellij.openapi.module.Module
|
import com.intellij.openapi.module.Module
|
||||||
import com.intellij.openapi.module.ModuleUtilCore
|
import com.intellij.openapi.module.ModuleUtilCore
|
||||||
|
import com.intellij.openapi.roots.ProjectFileIndex
|
||||||
import com.sampullara.cli.Argument
|
import com.sampullara.cli.Argument
|
||||||
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
|
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
|
||||||
import org.jetbrains.kotlin.cli.common.arguments.CommonCompilerArguments
|
import org.jetbrains.kotlin.cli.common.arguments.CommonCompilerArguments
|
||||||
@@ -54,4 +56,9 @@ val Module.languageVersionSettings: LanguageVersionSettings
|
|||||||
}
|
}
|
||||||
|
|
||||||
val KtElement.languageVersionSettings: LanguageVersionSettings
|
val KtElement.languageVersionSettings: LanguageVersionSettings
|
||||||
get() = ModuleUtilCore.findModuleForPsiElement(this)?.languageVersionSettings ?: LanguageVersionSettingsImpl.DEFAULT
|
get() {
|
||||||
|
if (ServiceManager.getService(ProjectFileIndex::class.java) == null) {
|
||||||
|
return LanguageVersionSettingsImpl.DEFAULT
|
||||||
|
}
|
||||||
|
return ModuleUtilCore.findModuleForPsiElement(this)?.languageVersionSettings ?: LanguageVersionSettingsImpl.DEFAULT
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user