Added psvm synonym for main, synonym live templates added not only to completion.
#KT-1326 fixed
This commit is contained in:
@@ -169,4 +169,26 @@
|
||||
<option name="KOTLIN_NAMESPACE" value="true"/>
|
||||
</context>
|
||||
</template>
|
||||
|
||||
|
||||
<!-- Synonyms -->
|
||||
|
||||
<!-- Synonym for main -->
|
||||
<template resource-bundle="org.jetbrains.jet.plugin.JetBundle" key="livetemplate.description.main"
|
||||
name="psvm" toReformat="true" toShortenFQNames="true"
|
||||
value="fun main(args : Array<String>) { $END$ }">
|
||||
<context>
|
||||
<option name="KOTLIN_NAMESPACE" value="true" />
|
||||
</context>
|
||||
</template>
|
||||
|
||||
<!-- Synonym for anonymous -->
|
||||
<template resource-bundle="org.jetbrains.jet.plugin.JetBundle" key="livetemplate.description.anonymous"
|
||||
name="object" id="kt-object" toReformat="true" toShortenFQNames="true" value="object : $SUPERTYPE$ { $END$ }">
|
||||
<variable alwaysStopAt="true" defaultValue=""Object"" expression="anonymousSuper()" name="SUPERTYPE" />
|
||||
<context>
|
||||
<option name="KOTLIN_STATEMENT" value="true"/>
|
||||
<option name="KOTLIN_EXPRESSION" value="true"/>
|
||||
</context>
|
||||
</template>
|
||||
</templateSet>
|
||||
|
||||
-20
@@ -73,8 +73,6 @@ public class JetLiveTemplateCompletionContributor extends CompletionContributor
|
||||
for (final TemplateImpl possible : templates) {
|
||||
result.addElement(new LiveTemplateLookupElement(possible, false));
|
||||
}
|
||||
|
||||
addSynonym(templates, result, "anonymous", "object");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -97,22 +95,4 @@ public class JetLiveTemplateCompletionContributor extends CompletionContributor
|
||||
return element instanceof LiveTemplateLookupElement && ((LiveTemplateLookupElement) element).sudden;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* custom code start */
|
||||
private static void addSynonym(List<TemplateImpl> templates, @NotNull CompletionResultSet result, @NotNull String standardName, @NotNull final String synonym) {
|
||||
for (TemplateImpl t : templates) {
|
||||
if (standardName.equals(t.getKey())) {
|
||||
result.addElement(new LiveTemplateLookupElement(t, false) {
|
||||
@NotNull
|
||||
@Override
|
||||
public String getLookupString() {
|
||||
return synonym;
|
||||
}
|
||||
});
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user