mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
groovy live templates granularity
This commit is contained in:
@@ -191,7 +191,11 @@
|
||||
<typedHandler implementation="org.jetbrains.plugins.groovy.lang.editor.actions.GroovyTypedHandler"/>
|
||||
<backspaceHandlerDelegate implementation="org.jetbrains.plugins.groovy.lang.editor.actions.GroovyBackspaceHandler"/>
|
||||
|
||||
<liveTemplateContext implementation="org.jetbrains.plugins.groovy.template.GroovyTemplateContextType"/>
|
||||
<liveTemplateContext implementation="org.jetbrains.plugins.groovy.template.GroovyTemplateContextType$Generic"/>
|
||||
<liveTemplateContext implementation="org.jetbrains.plugins.groovy.template.GroovyTemplateContextType$Expression"/>
|
||||
<liveTemplateContext implementation="org.jetbrains.plugins.groovy.template.GroovyTemplateContextType$Statement"/>
|
||||
<liveTemplateContext implementation="org.jetbrains.plugins.groovy.template.GroovyTemplateContextType$Declaration"/>
|
||||
|
||||
<liveTemplateOptionalProcessor implementation="org.jetbrains.plugins.groovy.template.GroovyShortenFQNamesProcessor"/>
|
||||
<variableTypeCalculator implementation="org.jetbrains.plugins.groovy.template.GroovyVariableTypeCalculator"/>
|
||||
|
||||
|
||||
+1
-1
@@ -250,7 +250,7 @@ public class GroovyCompletionData {
|
||||
return context.getTextRange().getStartOffset() == 0 && !(context instanceof OuterLanguageElement);
|
||||
}
|
||||
|
||||
private static boolean suggestClassInterfaceEnum(PsiElement context) {
|
||||
public static boolean suggestClassInterfaceEnum(PsiElement context) {
|
||||
if (context.getParent() != null &&
|
||||
(context.getParent() instanceof GrReferenceExpression) &&
|
||||
context.getParent().getParent() instanceof GroovyFile) {
|
||||
|
||||
+118
-4
@@ -15,16 +15,130 @@
|
||||
*/
|
||||
package org.jetbrains.plugins.groovy.template;
|
||||
|
||||
import com.intellij.codeInsight.template.FileTypeBasedContextType;
|
||||
import com.intellij.codeInsight.template.EverywhereContextType;
|
||||
import com.intellij.codeInsight.template.TemplateContextType;
|
||||
import com.intellij.openapi.fileTypes.FileType;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.psi.PsiWhiteSpace;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.intellij.psi.util.PsiUtilBase;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.plugins.groovy.GroovyFileType;
|
||||
import org.jetbrains.plugins.groovy.lang.completion.GroovyCompletionData;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrIfStatement;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.blocks.GrCodeBlock;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrCall;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrExpression;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrReferenceExpression;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrTypeDefinition;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.util.PsiUtil;
|
||||
|
||||
import static com.intellij.patterns.PsiJavaPatterns.psiElement;
|
||||
|
||||
/**
|
||||
* @author peter
|
||||
*/
|
||||
public class GroovyTemplateContextType extends FileTypeBasedContextType{
|
||||
public abstract class GroovyTemplateContextType extends TemplateContextType {
|
||||
|
||||
protected GroovyTemplateContextType() {
|
||||
super("GROOVY", "Groovy", GroovyFileType.GROOVY_FILE_TYPE);
|
||||
protected GroovyTemplateContextType(@NotNull @NonNls String id,
|
||||
@NotNull String presentableName,
|
||||
@Nullable Class<? extends TemplateContextType> baseContextType) {
|
||||
super(id, presentableName, baseContextType);
|
||||
}
|
||||
|
||||
public boolean isInContext(@NotNull final PsiFile file, final int offset) {
|
||||
if (PsiUtilBase.getLanguageAtOffset(file, offset).isKindOf(GroovyFileType.GROOVY_LANGUAGE)) {
|
||||
PsiElement element = file.findElementAt(offset);
|
||||
if (element instanceof PsiWhiteSpace) {
|
||||
return false;
|
||||
}
|
||||
return element != null && isInContext(element);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
protected abstract boolean isInContext(@NotNull PsiElement element);
|
||||
|
||||
@Override
|
||||
public boolean isInContext(@NotNull final FileType fileType) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public static class Generic extends GroovyTemplateContextType {
|
||||
public Generic() {
|
||||
super("GROOVY", "Groovy", EverywhereContextType.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isInContext(@NotNull PsiElement element) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public static class Statement extends GroovyTemplateContextType {
|
||||
public Statement() {
|
||||
super("GROOVY_STATEMENT", "Statement", Generic.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isInContext(@NotNull PsiElement element) {
|
||||
return isStatementContext(element);
|
||||
}
|
||||
|
||||
private static boolean isStatementContext(PsiElement element) {
|
||||
return Expression.isExpressionContext(element) && PsiUtil.isExpressionStatement(element.getParent());
|
||||
}
|
||||
}
|
||||
public static class Expression extends GroovyTemplateContextType {
|
||||
public Expression() {
|
||||
super("GROOVY_EXPRESSION", "Expression", Generic.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isInContext(@NotNull PsiElement element) {
|
||||
return isExpressionContext(element);
|
||||
}
|
||||
|
||||
private static boolean isExpressionContext(PsiElement element) {
|
||||
final PsiElement parent = element.getParent();
|
||||
if (!(parent instanceof GrReferenceExpression)) {
|
||||
return false;
|
||||
}
|
||||
if (((GrReferenceExpression)parent).isQualified()) {
|
||||
return false;
|
||||
}
|
||||
if (parent.getParent() instanceof GrCall) {
|
||||
return false;
|
||||
}
|
||||
if (
|
||||
psiElement().afterLeaf(
|
||||
psiElement().inside(
|
||||
psiElement(GrExpression.class).afterLeaf(
|
||||
psiElement().withText("(").withParent(GrIfStatement.class))))
|
||||
.accepts(element)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
public static class Declaration extends GroovyTemplateContextType {
|
||||
public Declaration() {
|
||||
super("GROOVY_DECLARATION", "Declaration", Generic.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isInContext(@NotNull PsiElement element) {
|
||||
if (PsiTreeUtil.getParentOfType(element, GrCodeBlock.class, false, GrTypeDefinition.class) != null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return GroovyCompletionData.suggestClassInterfaceEnum(element) || GroovyCompletionData.suggestFinalDef(element);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -7,6 +7,9 @@ package org.jetbrains.plugins.groovy.lang;
|
||||
import com.intellij.codeInsight.lookup.Lookup;
|
||||
import com.intellij.codeInsight.lookup.LookupManager;
|
||||
import com.intellij.codeInsight.lookup.impl.LookupImpl;
|
||||
import com.intellij.codeInsight.template.impl.TemplateImpl;
|
||||
import com.intellij.codeInsight.template.impl.TemplateManagerImpl;
|
||||
import com.intellij.codeInsight.template.impl.TemplateSettings;
|
||||
import com.intellij.codeInsight.template.impl.actions.ListTemplatesAction;
|
||||
import com.intellij.openapi.application.Result;
|
||||
import com.intellij.openapi.command.WriteCommandAction;
|
||||
@@ -14,6 +17,8 @@ import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase;
|
||||
import org.jetbrains.plugins.groovy.util.TestUtils;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* @author peter
|
||||
*/
|
||||
@@ -39,4 +44,39 @@ public class GroovyLiveTemplatesTest extends LightCodeInsightFixtureTestCase{
|
||||
}.execute();
|
||||
}
|
||||
|
||||
public void testGroovyStatementContext() throws Exception {
|
||||
final TemplateImpl template = TemplateSettings.getInstance().getTemplate("inst", "other");
|
||||
assertFalse(isApplicable("class Foo {{ if (a inst<caret>) }}", template));
|
||||
assertTrue(isApplicable("class Foo {{ inst<caret> }}", template));
|
||||
assertTrue(isApplicable("inst<caret>", template));
|
||||
assertFalse(isApplicable("class Foo {{ return (inst<caret>) }}", template));
|
||||
}
|
||||
|
||||
public void testGroovyExpressionContext() throws Exception {
|
||||
final TemplateImpl template = TemplateSettings.getInstance().getTemplate("lst", "other");
|
||||
assertFalse(isApplicable("class Foo {{ if (a toar<caret>) }}", template));
|
||||
assertTrue(isApplicable("class Foo {{ toar<caret> }}", template));
|
||||
assertTrue(isApplicable("xxx<caret>", template));
|
||||
assertTrue(isApplicable("<caret>xxx", template));
|
||||
assertTrue(isApplicable("class Foo {{ return (toar<caret>) }}", template));
|
||||
}
|
||||
|
||||
public void testGroovyDeclarationContext() throws Exception {
|
||||
final TemplateImpl template = TemplateSettings.getInstance().getTemplate("psvm", "other");
|
||||
assertFalse(isApplicable("class Foo {{ <caret>xxx }}", template));
|
||||
assertFalse(isApplicable("class Foo {{ toar<caret> }}", template));
|
||||
assertFalse(isApplicable("class Foo {{ if (a toar<caret>) }}", template));
|
||||
assertFalse(isApplicable("class Foo {{ return (toar<caret>) }}", template));
|
||||
assertTrue(isApplicable("class Foo { xxx<caret> }", template));
|
||||
assertTrue(isApplicable("class Foo { xxx<caret> }", template));
|
||||
assertFalse(isApplicable("class Foo { int xxx<caret> }", template));
|
||||
assertTrue(isApplicable("class Foo {}\nxxx<caret>", template));
|
||||
assertTrue(isApplicable("xxx<caret>", template));
|
||||
}
|
||||
|
||||
private boolean isApplicable(String text, TemplateImpl inst) throws IOException {
|
||||
myFixture.configureByText("a.groovy", text);
|
||||
return TemplateManagerImpl.isApplicable(myFixture.getFile(), myFixture.getEditor().getCaretModel().getOffset(), inst);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -9,8 +9,8 @@
|
||||
<context>
|
||||
<option name="JAVA_CODE" value="false" />
|
||||
<option name="JAVA_STATEMENT" value="true" />
|
||||
<option name="GROOVY" value="true" />
|
||||
<option name="ASPECTJ" value="true" />
|
||||
<option name="GROOVY" value="false" />
|
||||
<option name="GROOVY_STATEMENT" value="true" />
|
||||
</context>
|
||||
</template>
|
||||
<template name="itco" value="for($ITER_TYPE$ $ITER$ = $COLLECTION$.iterator(); $ITER$.hasNext(); ) { $ELEMENT_TYPE$ $VAR$ =$CAST$ $ITER$.next(); $END$ }"
|
||||
@@ -24,8 +24,8 @@
|
||||
<context>
|
||||
<option name="JAVA_CODE" value="false" />
|
||||
<option name="JAVA_STATEMENT" value="true" />
|
||||
<option name="GROOVY" value="true" />
|
||||
<option name="ASPECTJ" value="true" />
|
||||
<option name="GROOVY" value="false" />
|
||||
<option name="GROOVY_STATEMENT" value="true" />
|
||||
</context>
|
||||
</template>
|
||||
<template name="iten" value="while($ENUM$.hasMoreElements()){ $TYPE$ $VAR$ = $CAST$ $ENUM$.nextElement(); $END$ }"
|
||||
@@ -37,8 +37,8 @@
|
||||
<context>
|
||||
<option name="JAVA_CODE" value="false" />
|
||||
<option name="JAVA_STATEMENT" value="true" />
|
||||
<option name="GROOVY" value="true" />
|
||||
<option name="ASPECTJ" value="true" />
|
||||
<option name="GROOVY" value="false" />
|
||||
<option name="GROOVY_STATEMENT" value="true" />
|
||||
</context>
|
||||
</template>
|
||||
<template name="itit" value="while($ITER$.hasNext()){ $TYPE$ $VAR$ = $CAST$ $ITER$.next(); $END$ }"
|
||||
@@ -50,8 +50,8 @@
|
||||
<context>
|
||||
<option name="JAVA_CODE" value="false" />
|
||||
<option name="JAVA_STATEMENT" value="true" />
|
||||
<option name="GROOVY" value="true" />
|
||||
<option name="ASPECTJ" value="true" />
|
||||
<option name="GROOVY" value="false" />
|
||||
<option name="GROOVY_STATEMENT" value="true" />
|
||||
</context>
|
||||
</template>
|
||||
<template name="itli" value="for (int $INDEX$ = 0; $INDEX$ < $LIST$.size(); $INDEX$++) { $ELEMENT_TYPE$ $VAR$ = $CAST$ $LIST$.get($INDEX$); $END$ }"
|
||||
@@ -64,8 +64,8 @@
|
||||
<context>
|
||||
<option name="JAVA_CODE" value="false" />
|
||||
<option name="JAVA_STATEMENT" value="true" />
|
||||
<option name="GROOVY" value="true" />
|
||||
<option name="ASPECTJ" value="true" />
|
||||
<option name="GROOVY" value="false" />
|
||||
<option name="GROOVY_STATEMENT" value="true" />
|
||||
</context>
|
||||
</template>
|
||||
<template name="ittok" value="for (java.util.StringTokenizer $TOKENIZER$ = new java.util.StringTokenizer($STRING$); $TOKENIZER$.hasMoreTokens(); ) { String $VAR$ = $TOKENIZER_COPY$.nextToken(); $END$ } "
|
||||
@@ -77,8 +77,8 @@
|
||||
<context>
|
||||
<option name="JAVA_CODE" value="false" />
|
||||
<option name="JAVA_STATEMENT" value="true" />
|
||||
<option name="GROOVY" value="true" />
|
||||
<option name="ASPECTJ" value="true" />
|
||||
<option name="GROOVY" value="false" />
|
||||
<option name="GROOVY_STATEMENT" value="true" />
|
||||
</context>
|
||||
</template>
|
||||
<template name="itve" value="for(int $INDEX$ = 0; $INDEX$ < $VECTOR$.size(); $INDEX$++) { $ELEMENT_TYPE$ $VAR$ = $CAST$ $VECTOR$.elementAt($INDEX$); $END$ }"
|
||||
@@ -91,8 +91,8 @@
|
||||
<context>
|
||||
<option name="JAVA_CODE" value="false" />
|
||||
<option name="JAVA_STATEMENT" value="true" />
|
||||
<option name="GROOVY" value="true" />
|
||||
<option name="ASPECTJ" value="true" />
|
||||
<option name="GROOVY" value="false" />
|
||||
<option name="GROOVY_STATEMENT" value="true" />
|
||||
</context>
|
||||
</template>
|
||||
<template name="ritar" value="for(int $INDEX$ = $ARRAY$.length - 1; $INDEX$ >= 0; $INDEX$--) { $ELEMENT_TYPE$ $VAR$ = $ARRAY$[$INDEX$]; $END$ }"
|
||||
@@ -104,8 +104,8 @@
|
||||
<context>
|
||||
<option name="JAVA_CODE" value="false" />
|
||||
<option name="JAVA_STATEMENT" value="true" />
|
||||
<option name="GROOVY" value="true" />
|
||||
<option name="ASPECTJ" value="true" />
|
||||
<option name="GROOVY" value="false" />
|
||||
<option name="GROOVY_STATEMENT" value="true" />
|
||||
</context>
|
||||
</template>
|
||||
<template name="iter" value="for ($ELEMENT_TYPE$ $VAR$ : $ITERABLE_TYPE$) { $END$ }"
|
||||
|
||||
@@ -1,58 +1,58 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<templateSet group="other">
|
||||
<template resource-bundle="messages.CodeInsightBundle" key="livetemplate.description.inst"
|
||||
name="inst" toReformat="true" toShortenFQNames="true" value="if ($EXPR$ instanceof $TYPE$) { $TYPE$ $VAR1$ = ($TYPE$)$EXPR$; $END$ }">
|
||||
name="inst" toReformat="true" toShortenFQNames="true" value="if ($EXPR$ instanceof $TYPE$) { $TYPE$ $VAR1$ = ($TYPE$)$EXPR$; $END$ }">
|
||||
<variable alwaysStopAt="true" defaultValue="expr" expression="variableOfType("Object")" name="EXPR" />
|
||||
<variable alwaysStopAt="true" defaultValue="" expression=""Object"" name="TYPE" />
|
||||
<variable alwaysStopAt="true" defaultValue="" expression="suggestVariableName()" name="VAR1" />
|
||||
<context>
|
||||
<option name="JAVA_CODE" value="false" />
|
||||
<option name="JAVA_STATEMENT" value="true" />
|
||||
<option name="GROOVY" value="true" />
|
||||
<option name="ASPECTJ" value="true" />
|
||||
<option name="GROOVY" value="false" />
|
||||
<option name="GROOVY_STATEMENT" value="true" />
|
||||
</context>
|
||||
</template>
|
||||
<template resource-bundle="messages.CodeInsightBundle" key="livetemplate.description.lst"
|
||||
name="lst" toReformat="true" toShortenFQNames="true" value="$ARRAY$[$ARRAY$.length - 1]">
|
||||
name="lst" toReformat="true" toShortenFQNames="true" value="$ARRAY$[$ARRAY$.length - 1]">
|
||||
<variable alwaysStopAt="true" defaultValue="array" expression="arrayVariable()" name="ARRAY" />
|
||||
<context>
|
||||
<option name="JAVA_CODE" value="false" />
|
||||
<option name="JAVA_EXPRESSION" value="true" />
|
||||
<option name="GROOVY" value="true" />
|
||||
<option name="ASPECTJ" value="true" />
|
||||
<option name="GROOVY" value="false" />
|
||||
<option name="GROOVY_EXPRESSION" value="true" />
|
||||
</context>
|
||||
</template>
|
||||
<template resource-bundle="messages.CodeInsightBundle" key="livetemplate.description.mn"
|
||||
name="mn" toReformat="true" toShortenFQNames="true" value="$VAR$ = Math.min($VAR$, $END$);">
|
||||
name="mn" toReformat="true" toShortenFQNames="true" value="$VAR$ = Math.min($VAR$, $END$);">
|
||||
<variable alwaysStopAt="true" defaultValue="" expression="variableOfType("double")" name="VAR" />
|
||||
<context>
|
||||
<option name="JAVA_CODE" value="false" />
|
||||
<option name="JAVA_STATEMENT" value="true" />
|
||||
<option name="GROOVY" value="true" />
|
||||
<option name="ASPECTJ" value="true" />
|
||||
<option name="GROOVY" value="false" />
|
||||
<option name="GROOVY_STATEMENT" value="true" />
|
||||
</context>
|
||||
</template>
|
||||
<template resource-bundle="messages.CodeInsightBundle" key="livetemplate.description.mx"
|
||||
name="mx" toReformat="true" toShortenFQNames="true" value="$VAR$ = Math.max($VAR$, $END$);">
|
||||
name="mx" toReformat="true" toShortenFQNames="true" value="$VAR$ = Math.max($VAR$, $END$);">
|
||||
<variable alwaysStopAt="true" defaultValue="" expression="variableOfType("double")" name="VAR" />
|
||||
<context>
|
||||
<option name="JAVA_CODE" value="false" />
|
||||
<option name="JAVA_STATEMENT" value="true" />
|
||||
<option name="GROOVY" value="true" />
|
||||
<option name="ASPECTJ" value="true" />
|
||||
<option name="GROOVY" value="false" />
|
||||
<option name="GROOVY_STATEMENT" value="true" />
|
||||
</context>
|
||||
</template>
|
||||
<template resource-bundle="messages.CodeInsightBundle" key="livetemplate.description.psvm"
|
||||
name="psvm" toReformat="true" toShortenFQNames="true" value="public static void main(String[] args){ $END$ }">
|
||||
name="psvm" toReformat="true" toShortenFQNames="true" value="public static void main(String[] args){ $END$ }">
|
||||
<context>
|
||||
<option name="JAVA_CODE" value="false" />
|
||||
<option name="JAVA_DECLARATION" value="true" />
|
||||
<option name="GROOVY" value="true" />
|
||||
<option name="ASPECTJ" value="true" />
|
||||
<option name="GROOVY" value="false" />
|
||||
<option name="GROOVY_DECLARATION" value="true" />
|
||||
</context>
|
||||
</template>
|
||||
<template resource-bundle="messages.CodeInsightBundle" key="livetemplate.description.toar"
|
||||
name="toar" toReformat="true" toShortenFQNames="true" value="$COLLECTION$.toArray(new $COMPONENT_TYPE$[$COLLECTION$.size()])$END$">
|
||||
name="toar" toReformat="true" toShortenFQNames="true" value="$COLLECTION$.toArray(new $COMPONENT_TYPE$[$COLLECTION$.size()])$END$">
|
||||
<variable alwaysStopAt="true" defaultValue=""Object"" expression="componentTypeOf(expectedType())" name="COMPONENT_TYPE" />
|
||||
<variable alwaysStopAt="true" defaultValue="collection" expression="variableOfType("java.util.Collection")" name="COLLECTION" />
|
||||
<context>
|
||||
@@ -62,45 +62,45 @@
|
||||
</context>
|
||||
</template>
|
||||
<template resource-bundle="messages.CodeInsightBundle" key="livetemplate.description.lazy"
|
||||
name="lazy" value="if ($VAR$ == null) { $VAR$ = new $TYPE$($END$); }" toReformat="true" toShortenFQNames="true">
|
||||
name="lazy" value="if ($VAR$ == null) { $VAR$ = new $TYPE$($END$); }" toReformat="true" toShortenFQNames="true">
|
||||
<variable name="VAR" expression="variableOfType("java.lang.Object")" defaultValue="" alwaysStopAt="true" />
|
||||
<variable name="TYPE" expression="subtypes(typeOfVariable(VAR))" defaultValue="" alwaysStopAt="true" />
|
||||
<context>
|
||||
<option name="JAVA_CODE" value="false" />
|
||||
<option name="JAVA_STATEMENT" value="true" />
|
||||
<option name="GROOVY" value="true" />
|
||||
<option name="ASPECTJ" value="true" />
|
||||
<option name="GROOVY" value="false" />
|
||||
<option name="GROOVY_STATEMENT" value="true" />
|
||||
</context>
|
||||
</template>
|
||||
<template resource-bundle="messages.CodeInsightBundle" key="livetemplate.description.if.not.null"
|
||||
name="inn" value="if ($VAR$ != null) { $END$ }" toReformat="true" toShortenFQNames="true">
|
||||
name="inn" value="if ($VAR$ != null) { $END$ }" toReformat="true" toShortenFQNames="true">
|
||||
<variable name="VAR" expression="suggestFirstVariableName("Object")" defaultValue="var" alwaysStopAt="true" />
|
||||
<context>
|
||||
<option name="JAVA_CODE" value="false" />
|
||||
<option name="JAVA_STATEMENT" value="true" />
|
||||
<option name="GROOVY" value="true" />
|
||||
<option name="ASPECTJ" value="true" />
|
||||
<option name="GROOVY" value="false" />
|
||||
<option name="GROOVY_STATEMENT" value="true" />
|
||||
</context>
|
||||
</template>
|
||||
<template resource-bundle="messages.CodeInsightBundle" key="livetemplate.description.if.null"
|
||||
name="ifn" value="if ($VAR$ == null) { $END$ }" toReformat="true" toShortenFQNames="true">
|
||||
name="ifn" value="if ($VAR$ == null) { $END$ }" toReformat="true" toShortenFQNames="true">
|
||||
<variable name="VAR" expression="suggestFirstVariableName("Object")" defaultValue="var" alwaysStopAt="true" />
|
||||
<context>
|
||||
<option name="JAVA_CODE" value="false" />
|
||||
<option name="JAVA_STATEMENT" value="true" />
|
||||
<option name="GROOVY" value="true" />
|
||||
<option name="ASPECTJ" value="true" />
|
||||
<option name="GROOVY" value="false" />
|
||||
<option name="GROOVY_STATEMENT" value="true" />
|
||||
</context>
|
||||
</template>
|
||||
<template resource-bundle="messages.CodeInsightBundle" key="livetemplate.description.geti"
|
||||
name="geti" toReformat="true" toShortenFQNames="true" value="public static $CLASS_NAME$ getInstance() { return $VALUE$; }">
|
||||
name="geti" toReformat="true" toShortenFQNames="true" value="public static $CLASS_NAME$ getInstance() { return $VALUE$; }">
|
||||
<variable name="CLASS_NAME" expression="className" defaultValue="" alwaysStopAt="false"/>
|
||||
<variable name="VALUE" expression="variableOfType(CLASS_NAME)" defaultValue="null" alwaysStopAt="true"/>
|
||||
<context>
|
||||
<option name="JAVA_CODE" value="false" />
|
||||
<option name="JAVA_DECLARATION" value="true" />
|
||||
<option name="GROOVY" value="true" />
|
||||
<option name="ASPECTJ" value="true" />
|
||||
<option name="GROOVY" value="false" />
|
||||
<option name="GROOVY_DECLARATION" value="true" />
|
||||
</context>
|
||||
</template>
|
||||
</templateSet>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<templateSet group="output">
|
||||
<template resource-bundle="messages.CodeInsightBundle" key="livetemplate.description.serr"
|
||||
name="serr" toReformat="true" toShortenFQNames="true" value="System.err.println("$END$");">
|
||||
name="serr" toReformat="true" toShortenFQNames="true" value="System.err.println("$END$");">
|
||||
<context>
|
||||
<option name="JAVA_CODE" value="false" />
|
||||
<option name="JAVA_STATEMENT" value="true" />
|
||||
@@ -9,7 +9,7 @@
|
||||
</context>
|
||||
</template>
|
||||
<template resource-bundle="messages.CodeInsightBundle" key="livetemplate.description.sout"
|
||||
name="sout" toReformat="true" toShortenFQNames="true" value="System.out.println($END$);">
|
||||
name="sout" toReformat="true" toShortenFQNames="true" value="System.out.println($END$);">
|
||||
<context>
|
||||
<option name="JAVA_CODE" value="false" />
|
||||
<option name="JAVA_STATEMENT" value="true" />
|
||||
@@ -17,7 +17,7 @@
|
||||
</context>
|
||||
</template>
|
||||
<template resource-bundle="messages.CodeInsightBundle" key="livetemplate.description.souf"
|
||||
name="souf" toReformat="true" toShortenFQNames="true" value="System.out.printf("$END$");">
|
||||
name="souf" toReformat="true" toShortenFQNames="true" value="System.out.printf("$END$");">
|
||||
<context>
|
||||
<option name="JAVA_CODE" value="false" />
|
||||
<option name="JAVA_STATEMENT" value="true" />
|
||||
@@ -25,25 +25,25 @@
|
||||
</context>
|
||||
</template>
|
||||
<template resource-bundle="messages.CodeInsightBundle" key="livetemplate.description.soutm"
|
||||
name="soutm" toReformat="true" toShortenFQNames="true" value="System.out.println("$CLASS_NAME$.$METHOD_NAME$");">
|
||||
name="soutm" toReformat="true" toShortenFQNames="true" value="System.out.println("$CLASS_NAME$.$METHOD_NAME$");">
|
||||
<variable alwaysStopAt="false" defaultValue="" expression="className()" name="CLASS_NAME" />
|
||||
<variable alwaysStopAt="false" defaultValue="" expression="methodName()" name="METHOD_NAME" />
|
||||
<context>
|
||||
<option name="JAVA_CODE" value="false" />
|
||||
<option name="JAVA_STATEMENT" value="true" />
|
||||
<option name="GROOVY" value="true" />
|
||||
<option name="ASPECTJ" value="true" />
|
||||
<option name="GROOVY" value="false" />
|
||||
<option name="GROOVY_STATEMENT" value="true" />
|
||||
</context>
|
||||
</template>
|
||||
<template resource-bundle="messages.CodeInsightBundle" key="livetemplate.description.soutv"
|
||||
name="soutv" toReformat="true" toShortenFQNames="true" value="System.out.println("$EXPR_COPY$ = " + $EXPR$);">
|
||||
name="soutv" toReformat="true" toShortenFQNames="true" value="System.out.println("$EXPR_COPY$ = " + $EXPR$);">
|
||||
<variable alwaysStopAt="true" defaultValue=""expr"" expression="variableOfType("")" name="EXPR" />
|
||||
<variable alwaysStopAt="false" defaultValue="" expression="EXPR" name="EXPR_COPY" />
|
||||
<context>
|
||||
<option name="JAVA_CODE" value="false" />
|
||||
<option name="JAVA_STATEMENT" value="true" />
|
||||
<option name="GROOVY" value="true" />
|
||||
<option name="ASPECTJ" value="true" />
|
||||
<option name="GROOVY" value="false" />
|
||||
<option name="GROOVY_STATEMENT" value="true" />
|
||||
</context>
|
||||
</template>
|
||||
</templateSet>
|
||||
|
||||
@@ -1,50 +1,52 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<templateSet group="plain">
|
||||
<template resource-bundle="messages.CodeInsightBundle" key="livetemplate.description.st"
|
||||
name="St" toReformat="false" toShortenFQNames="true" value="String ">
|
||||
name="St" toReformat="false" toShortenFQNames="true" value="String ">
|
||||
<context>
|
||||
<option name="JAVA_CODE" value="false" />
|
||||
<option name="JAVA_STATEMENT" value="true" />
|
||||
<option name="JAVA_DECLARATION" value="true" />
|
||||
<option name="JAVA_EXPRESSION" value="true" />
|
||||
<option name="GROOVY" value="true" />
|
||||
<option name="ASPECTJ" value="true" />
|
||||
<option name="GROOVY" value="false" />
|
||||
<option name="GROOVY_STATEMENT" value="true" />
|
||||
<option name="GROOVY_DECLARATION" value="true" />
|
||||
<option name="GROOVY_EXPRESSION" value="true" />
|
||||
</context>
|
||||
</template>
|
||||
<template resource-bundle="messages.CodeInsightBundle" key="livetemplate.description.psf"
|
||||
name="psf" toReformat="false" toShortenFQNames="true" value="public static final ">
|
||||
name="psf" toReformat="false" toShortenFQNames="true" value="public static final ">
|
||||
<context>
|
||||
<option name="JAVA_CODE" value="false" />
|
||||
<option name="JAVA_DECLARATION" value="true" />
|
||||
<option name="GROOVY" value="true" />
|
||||
<option name="ASPECTJ" value="true" />
|
||||
<option name="GROOVY" value="false" />
|
||||
<option name="GROOVY_DECLARATION" value="true" />
|
||||
</context>
|
||||
</template>
|
||||
<template resource-bundle="messages.CodeInsightBundle" key="livetemplate.description.psfi"
|
||||
name="psfi" toReformat="false" toShortenFQNames="true" value="public static final int ">
|
||||
name="psfi" toReformat="false" toShortenFQNames="true" value="public static final int ">
|
||||
<context>
|
||||
<option name="JAVA_CODE" value="false" />
|
||||
<option name="JAVA_DECLARATION" value="true" />
|
||||
<option name="GROOVY" value="true" />
|
||||
<option name="ASPECTJ" value="true" />
|
||||
<option name="GROOVY" value="false" />
|
||||
<option name="GROOVY_DECLARATION" value="true" />
|
||||
</context>
|
||||
</template>
|
||||
<template resource-bundle="messages.CodeInsightBundle" key="livetemplate.description.psfs"
|
||||
name="psfs" toReformat="false" toShortenFQNames="true" value="public static final String ">
|
||||
name="psfs" toReformat="false" toShortenFQNames="true" value="public static final String ">
|
||||
<context>
|
||||
<option name="JAVA_CODE" value="false" />
|
||||
<option name="JAVA_DECLARATION" value="true" />
|
||||
<option name="GROOVY" value="true" />
|
||||
<option name="ASPECTJ" value="true" />
|
||||
<option name="GROOVY" value="false" />
|
||||
<option name="GROOVY_DECLARATION" value="true" />
|
||||
</context>
|
||||
</template>
|
||||
<template resource-bundle="messages.CodeInsightBundle" key="livetemplate.description.thr"
|
||||
name="thr" toReformat="false" toShortenFQNames="true" value="throw new ">
|
||||
name="thr" toReformat="false" toShortenFQNames="true" value="throw new ">
|
||||
<context>
|
||||
<option name="JAVA_CODE" value="false" />
|
||||
<option name="JAVA_STATEMENT" value="true" />
|
||||
<option name="GROOVY" value="true" />
|
||||
<option name="ASPECTJ" value="true" />
|
||||
<option name="GROOVY" value="false" />
|
||||
<option name="GROOVY_DECLARATION" value="true" />
|
||||
</context>
|
||||
</template>
|
||||
</templateSet>
|
||||
|
||||
@@ -11,7 +11,8 @@
|
||||
<option name="HTML" value="false" />
|
||||
<option name="JSP" value="false" />
|
||||
<option name="COMPLETION" value="false" />
|
||||
<option name="GROOVY" value="true" />
|
||||
<option name="GROOVY" value="false" />
|
||||
<option name="GROOVY_STATEMENT" value="true" />
|
||||
<option name="OTHER" value="true" />
|
||||
</context>
|
||||
</template>
|
||||
@@ -26,7 +27,8 @@
|
||||
<option name="HTML" value="false" />
|
||||
<option name="JSP" value="false" />
|
||||
<option name="COMPLETION" value="false" />
|
||||
<option name="GROOVY" value="true" />
|
||||
<option name="GROOVY" value="false" />
|
||||
<option name="GROOVY_EXPRESSION" value="true" />
|
||||
<option name="OTHER" value="true" />
|
||||
</context>
|
||||
</template>
|
||||
|
||||
Reference in New Issue
Block a user