Introduce live templates for main without arguments #KT-27461 Fixed
This commit is contained in:
+24
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
* 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.liveTemplates.macro
|
||||
|
||||
import com.intellij.codeInsight.template.Expression
|
||||
import com.intellij.codeInsight.template.ExpressionContext
|
||||
import com.intellij.codeInsight.template.Result
|
||||
import com.intellij.codeInsight.template.TextResult
|
||||
import org.jetbrains.kotlin.config.LanguageFeature
|
||||
import org.jetbrains.kotlin.idea.project.languageVersionSettings
|
||||
|
||||
class KotlinMainArgumentsMacro : KotlinMacro() {
|
||||
override fun getName() = "kotlinMainArguments"
|
||||
override fun getPresentableName() = "kotlinMainArguments()"
|
||||
|
||||
override fun calculateResult(params: Array<Expression>, context: ExpressionContext): Result? {
|
||||
val languageVersionSettings = context.psiElementAtStartOffset?.languageVersionSettings ?: return null
|
||||
if (languageVersionSettings.supportsFeature(LanguageFeature.ExtendedMainConvention)) return TextResult("")
|
||||
return TextResult("args: Array<String>")
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -1,3 +1,3 @@
|
||||
fun main(args: Array<String>) {
|
||||
fun main() {
|
||||
<caret>
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fun main(args: Array<String>) {
|
||||
<caret>
|
||||
}
|
||||
+1
@@ -0,0 +1 @@
|
||||
<caret>
|
||||
+4
@@ -72,6 +72,10 @@ class LiveTemplatesTest : KotlinLightCodeInsightFixtureTestCase() {
|
||||
paremeterless()
|
||||
}
|
||||
|
||||
fun testMaina() {
|
||||
paremeterless()
|
||||
}
|
||||
|
||||
fun testSoutv() {
|
||||
start()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user