Introduce Kotlin language substitutor to fix exceptions in velocity files

Related to KT-31470 (should fix the problem or at least soften it)
May be related also to KT-30977
#KT-30886 Fixed
This commit is contained in:
Mikhail Glukhikh
2019-06-03 12:49:26 +03:00
parent 37dfbb3eba
commit 71590b6735
2 changed files with 24 additions and 0 deletions
@@ -863,6 +863,8 @@
<orderEnumerationHandlerFactory implementation="org.jetbrains.kotlin.idea.roots.KotlinNonJvmOrderEnumerationHandler$Factory"/>
<lang.substitutor language="kotlin" order="last" implementationClass="org.jetbrains.kotlin.idea.KotlinLanguageSubstitutor"/>
<intentionAction>
<className>org.jetbrains.kotlin.idea.intentions.FoldInitializerAndIfToElvisIntention</className>
<category>Kotlin</category>
@@ -0,0 +1,22 @@
/*
* Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.idea
import com.intellij.lang.Language
import com.intellij.openapi.fileTypes.PlainTextLanguage
import com.intellij.openapi.project.Project
import com.intellij.openapi.vfs.VirtualFile
import com.intellij.psi.LanguageSubstitutor
class KotlinLanguageSubstitutor : LanguageSubstitutor() {
override fun getLanguage(file: VirtualFile, project: Project): Language? {
val name = file.name
if (name.endsWith(".kt.ft")) {
return PlainTextLanguage.INSTANCE
}
return null
}
}