diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/project/Platform.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/project/Platform.kt index 22216fece81..866609586fa 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/project/Platform.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/project/Platform.kt @@ -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 + }