Added simple live templates: fm, sout & serr.
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<templateSet group="Kotlin">
|
||||
<template resource-bundle="org.jetbrains.jet.plugin.JetBundle" key="livetemplate.description.fm"
|
||||
name="fm" toReformat="true" toShortenFQNames="true" value="fun main(args : Array<String>) { $END$ }">
|
||||
<context>
|
||||
<option name="KOTLIN" value="true" />
|
||||
</context>
|
||||
</template>
|
||||
<template resource-bundle="org.jetbrains.jet.plugin.JetBundle" key="livetemplate.description.sout"
|
||||
name="sout" toReformat="true"
|
||||
ShortenFQNames="true" value="println($END$)">
|
||||
<context>
|
||||
<option name="KOTLIN" value="true" />
|
||||
</context>
|
||||
</template>
|
||||
<template resource-bundle="org.jetbrains.jet.plugin.JetBundle" key="livetemplate.description.serr"
|
||||
name="serr" toReformat="true" toShortenFQNames="true" value="System.out?.println($END$)">
|
||||
<context>
|
||||
<option name="KOTLIN" value="true" />
|
||||
</context>
|
||||
</template>
|
||||
</templateSet>
|
||||
@@ -65,6 +65,9 @@
|
||||
<completion.contributor language="jet" implementationClass="org.jetbrains.jet.plugin.completion.JetKeywordCompletionContributor"/>
|
||||
<completion.contributor language="jet" implementationClass="org.jetbrains.jet.plugin.completion.JetCompletionContributor"/>
|
||||
|
||||
<liveTemplateContext implementation="org.jetbrains.jet.plugin.liveTemplates.JetTemplateContextType"/>
|
||||
<defaultLiveTemplatesProvider implementation="org.jetbrains.jet.plugin.liveTemplates.JetLiveTemplatesProvider"/>
|
||||
|
||||
<annotator language="jet" implementationClass="org.jetbrains.jet.plugin.annotations.SoftKeywordsAnnotator"/>
|
||||
<annotator language="jet" implementationClass="org.jetbrains.jet.plugin.annotations.LabelsAnnotator"/>
|
||||
<annotator language="jet" implementationClass="org.jetbrains.jet.plugin.annotations.JetPsiChecker"/>
|
||||
|
||||
@@ -25,4 +25,8 @@ replace.cast.with.static.assert=Replace a cast with a static assert
|
||||
replace.with.dot.call=Replace with dot call
|
||||
replace.with.safe.call=Replace with safe call
|
||||
change.to.backing.field=Change reference to backing field
|
||||
implement.members=Implement members
|
||||
implement.members=Implement members
|
||||
|
||||
livetemplate.description.fm=main() function
|
||||
livetemplate.description.sout=Prints a string to System.out
|
||||
livetemplate.description.serr=Prints a string to System.err
|
||||
@@ -0,0 +1,19 @@
|
||||
package org.jetbrains.jet.plugin.liveTemplates;
|
||||
|
||||
import com.intellij.codeInsight.template.impl.DefaultLiveTemplatesProvider;
|
||||
|
||||
/**
|
||||
* @author Evgeny Gerashchenko
|
||||
* @since 1/27/12
|
||||
*/
|
||||
public class JetLiveTemplatesProvider implements DefaultLiveTemplatesProvider {
|
||||
@Override
|
||||
public String[] getDefaultLiveTemplateFiles() {
|
||||
return new String[]{"liveTemplates/Kotlin"};
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getHiddenLiveTemplateFiles() {
|
||||
return new String[0];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package org.jetbrains.jet.plugin.liveTemplates;
|
||||
|
||||
import com.intellij.codeInsight.template.EverywhereContextType;
|
||||
import com.intellij.codeInsight.template.TemplateContextType;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.psi.util.PsiUtilBase;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.plugin.JetLanguage;
|
||||
|
||||
/**
|
||||
* @author Evgeny Gerashchenko
|
||||
* @since 1/27/12
|
||||
*/
|
||||
public class JetTemplateContextType extends TemplateContextType {
|
||||
public JetTemplateContextType() {
|
||||
super("KOTLIN", "Kotlin", EverywhereContextType.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInContext(@NotNull PsiFile file, int offset) {
|
||||
return PsiUtilBase.getLanguageAtOffset(file, offset).isKindOf(JetLanguage.INSTANCE);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user