mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Postfix templates: added soutv postfix template (IDEA-194685)
This commit is contained in:
+2
@@ -37,6 +37,7 @@ public class JavaPostfixTemplateProvider implements PostfixTemplateProvider {
|
||||
new ForDescendingPostfixTemplate(this),
|
||||
new WhileStatementPostfixTemplate(this),
|
||||
new SoutPostfixTemplate(this),
|
||||
new SoutvPostfixTemplate(this),
|
||||
new ReturnStatementPostfixTemplate(this),
|
||||
new OptionalPostfixTemplate(this),
|
||||
new ForeachPostfixTemplate("iter", this),
|
||||
@@ -134,6 +135,7 @@ public class JavaPostfixTemplateProvider implements PostfixTemplateProvider {
|
||||
// cannot be editable until there is no UI for editing template variables
|
||||
!(templateToEdit instanceof ForIndexedPostfixTemplate) &&
|
||||
!(templateToEdit instanceof ForeachPostfixTemplate) &&
|
||||
!(templateToEdit instanceof SoutvPostfixTemplate) &&
|
||||
!(templateToEdit instanceof ArgumentPostfixTemplate) &&
|
||||
!(templateToEdit instanceof OptionalPostfixTemplate)) {
|
||||
JavaPostfixTemplateEditor editor = new JavaPostfixTemplateEditor(this);
|
||||
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
// Copyright 2000-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 file.
|
||||
package com.intellij.codeInsight.template.postfix.templates;
|
||||
|
||||
import com.intellij.codeInsight.template.Template;
|
||||
import com.intellij.codeInsight.template.postfix.templates.editable.JavaEditablePostfixTemplate;
|
||||
import com.intellij.codeInsight.template.postfix.templates.editable.JavaPostfixTemplateExpressionCondition;
|
||||
import com.intellij.pom.java.LanguageLevel;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
public class SoutvPostfixTemplate extends JavaEditablePostfixTemplate {
|
||||
public SoutvPostfixTemplate(@NotNull JavaPostfixTemplateProvider provider) {
|
||||
super("soutv",
|
||||
"System.out.println(\"$EXPR_COPY$ = \" + $EXPR$);$END$",
|
||||
"System.out.println(expr)",
|
||||
Collections.singleton(new JavaPostfixTemplateExpressionCondition.JavaPostfixTemplateNonVoidExpressionCondition()),
|
||||
LanguageLevel.JDK_1_3, true, provider);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addTemplateVariables(@NotNull PsiElement element, @NotNull Template template) {
|
||||
super.addTemplateVariables(element, template);
|
||||
template.addVariable("EXPR_COPY", "escapeString(EXPR)", null, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBuiltin() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
public class Foo {
|
||||
void m() {
|
||||
5.soutv<caret>
|
||||
}
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
public class Foo {
|
||||
void m() {
|
||||
System.out.println("5 = " + 5);<caret>
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package templates;
|
||||
|
||||
public class Foo {
|
||||
void m(boolean b, int value) {
|
||||
b.soutv<caret>
|
||||
}
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
package templates;
|
||||
|
||||
public class Foo {
|
||||
void m(boolean b, int value) {
|
||||
System.out.println("b = " + b);<caret>
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
public class Foo {
|
||||
void m() {
|
||||
"hello".soutv<caret>
|
||||
}
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
public class Foo {
|
||||
void m() {
|
||||
System.out.println("\"hello\" = " + "hello");<caret>
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package templates;
|
||||
|
||||
public class Foo {
|
||||
void m(boolean b, int value) {
|
||||
m().soutv<caret>
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package templates;
|
||||
|
||||
public class Foo {
|
||||
void m(boolean b, int value) {
|
||||
m().soutv <caret>
|
||||
}
|
||||
}
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
// Copyright 2000-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 file.
|
||||
package com.intellij.java.codeInsight.template.postfix.templates;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class SoutvPostfixTemplateTest extends PostfixTemplateTestCase {
|
||||
@NotNull
|
||||
@Override
|
||||
protected String getSuffix() {
|
||||
return "soutv";
|
||||
}
|
||||
|
||||
public void testPrimitive() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testVoid() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testSimple() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testString() {
|
||||
doTest();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user