From 71590b67351b77432fe02b0df6e46d5b9d2fe92c Mon Sep 17 00:00:00 2001 From: Mikhail Glukhikh Date: Mon, 3 Jun 2019 12:49:26 +0300 Subject: [PATCH] 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 --- idea/resources/META-INF/plugin-common.xml | 2 ++ .../kotlin/idea/KotlinLanguageSubstitutor.kt | 22 +++++++++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 idea/src/org/jetbrains/kotlin/idea/KotlinLanguageSubstitutor.kt diff --git a/idea/resources/META-INF/plugin-common.xml b/idea/resources/META-INF/plugin-common.xml index 107b2da98f1..eef0bc80864 100644 --- a/idea/resources/META-INF/plugin-common.xml +++ b/idea/resources/META-INF/plugin-common.xml @@ -863,6 +863,8 @@ + + org.jetbrains.kotlin.idea.intentions.FoldInitializerAndIfToElvisIntention Kotlin diff --git a/idea/src/org/jetbrains/kotlin/idea/KotlinLanguageSubstitutor.kt b/idea/src/org/jetbrains/kotlin/idea/KotlinLanguageSubstitutor.kt new file mode 100644 index 00000000000..5b145296625 --- /dev/null +++ b/idea/src/org/jetbrains/kotlin/idea/KotlinLanguageSubstitutor.kt @@ -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 + } +} \ No newline at end of file