Set scratch file extension using API for IDEA 182 or higher
This commit is contained in:
@@ -0,0 +1,20 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2018 JetBrains s.r.o. 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.scratch
|
||||||
|
|
||||||
|
import com.intellij.ide.scratch.ScratchFileCreationHelper
|
||||||
|
import com.intellij.openapi.actionSystem.DataContext
|
||||||
|
import com.intellij.openapi.project.Project
|
||||||
|
import org.jetbrains.kotlin.parsing.KotlinParserDefinition
|
||||||
|
|
||||||
|
class KtScratchFileCreationHelper: ScratchFileCreationHelper() {
|
||||||
|
|
||||||
|
override fun prepareText(project: Project, context: Context, dataContext: DataContext): Boolean {
|
||||||
|
context.fileExtension = KotlinParserDefinition.STD_SCRIPT_SUFFIX
|
||||||
|
|
||||||
|
return super.prepareText(project, context, dataContext)
|
||||||
|
}
|
||||||
|
}
|
||||||
+1
-1
@@ -48,7 +48,7 @@ class ScratchFileModuleInfoProvider(val project: Project) : ProjectComponent {
|
|||||||
|
|
||||||
val ktFile = PsiManager.getInstance(project).findFile(file) as? KtFile ?: return
|
val ktFile = PsiManager.getInstance(project).findFile(file) as? KtFile ?: return
|
||||||
|
|
||||||
// Hack before api in IDEA will be introduced
|
// BUNCH: 181 scratch files are created with .kt extension
|
||||||
if (file.extension == KotlinFileType.EXTENSION) {
|
if (file.extension == KotlinFileType.EXTENSION) {
|
||||||
runWriteAction {
|
runWriteAction {
|
||||||
var newName = file.nameWithoutExtension + STD_SCRIPT_EXT
|
var newName = file.nameWithoutExtension + STD_SCRIPT_EXT
|
||||||
|
|||||||
@@ -122,6 +122,9 @@
|
|||||||
|
|
||||||
<editorNotificationProvider implementation="org.jetbrains.kotlin.idea.versions.UnsupportedAbiVersionNotificationPanelProvider"/>
|
<editorNotificationProvider implementation="org.jetbrains.kotlin.idea.versions.UnsupportedAbiVersionNotificationPanelProvider"/>
|
||||||
|
|
||||||
|
<scratch.creationHelper language="kotlin"
|
||||||
|
implementationClass="org.jetbrains.kotlin.idea.scratch.KtScratchFileCreationHelper"/>
|
||||||
|
|
||||||
<localInspection
|
<localInspection
|
||||||
groupName="Plugin DevKit"
|
groupName="Plugin DevKit"
|
||||||
shortName="IncompatibleAPI"
|
shortName="IncompatibleAPI"
|
||||||
|
|||||||
Reference in New Issue
Block a user