Workaround for added @NotNull annotation on ProjectFileIndex.getInstance()

This commit is contained in:
Dmitry Jemerov
2016-12-07 19:30:36 +03:00
parent 24c1d9f90b
commit baad540516
@@ -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.
@@ -16,8 +16,10 @@
package org.jetbrains.kotlin.idea.project
import com.intellij.openapi.components.ServiceManager
import com.intellij.openapi.module.Module
import com.intellij.openapi.module.ModuleUtilCore
import com.intellij.openapi.roots.ProjectFileIndex
import com.sampullara.cli.Argument
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
import org.jetbrains.kotlin.cli.common.arguments.CommonCompilerArguments
@@ -54,4 +56,9 @@ val Module.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
}