Postfix templates: added serr and souf templates

This commit is contained in:
Alexander Zolotov
2018-06-27 14:48:07 +03:00
parent 6c66dbbdd0
commit 2f149fa165
8 changed files with 87 additions and 15 deletions

View File

@@ -37,6 +37,8 @@ public class JavaPostfixTemplateProvider implements PostfixTemplateProvider {
new ForDescendingPostfixTemplate(this),
new WhileStatementPostfixTemplate(this),
new SoutPostfixTemplate(this),
new SerrPostfixTemplate(this),
new SoufPostfixTemplate(this),
new SoutvPostfixTemplate(this),
new ReturnStatementPostfixTemplate(this),
new OptionalPostfixTemplate(this),

View File

@@ -0,0 +1,24 @@
// 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.postfix.templates.editable.JavaEditablePostfixTemplate;
import com.intellij.codeInsight.template.postfix.templates.editable.JavaPostfixTemplateExpressionCondition;
import com.intellij.pom.java.LanguageLevel;
import org.jetbrains.annotations.NotNull;
import java.util.Collections;
public class SerrPostfixTemplate extends JavaEditablePostfixTemplate {
public SerrPostfixTemplate(@NotNull JavaPostfixTemplateProvider provider) {
super("serr",
"System.err.println($EXPR$);$END$",
"System.err.println(expr)",
Collections.singleton(new JavaPostfixTemplateExpressionCondition.JavaPostfixTemplateNonVoidExpressionCondition()),
LanguageLevel.JDK_1_3, true, provider);
}
@Override
public boolean isBuiltin() {
return true;
}
}

View File

@@ -0,0 +1,24 @@
// 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.postfix.templates.editable.JavaEditablePostfixTemplate;
import com.intellij.codeInsight.template.postfix.templates.editable.JavaPostfixTemplateExpressionCondition;
import com.intellij.pom.java.LanguageLevel;
import org.jetbrains.annotations.NotNull;
import java.util.Collections;
public class SoufPostfixTemplate extends JavaEditablePostfixTemplate {
public SoufPostfixTemplate(@NotNull JavaPostfixTemplateProvider provider) {
super("souf",
"System.out.printf(\"$END$\", $EXPR$);",
"System.out.printf(\"\", expr)",
Collections.singleton(new JavaPostfixTemplateExpressionCondition.JavaPostfixTemplateNonVoidExpressionCondition()),
LanguageLevel.JDK_1_3, true, provider);
}
@Override
public boolean isBuiltin() {
return true;
}
}

View File

@@ -0,0 +1,7 @@
package templates;
public class Foo {
void m(boolean b, int value) {
b.serr<caret>
}
}

View File

@@ -0,0 +1,7 @@
package templates;
public class Foo {
void m(boolean b, int value) {
System.err.println(b);<caret>
}
}

View File

@@ -0,0 +1,7 @@
package templates;
public class Foo {
void m(boolean b, int value) {
b.souf<caret>
}
}

View File

@@ -0,0 +1,7 @@
package templates;
public class Foo {
void m(boolean b, int value) {
System.out.printf("<caret>", b);
}
}

View File

@@ -1,18 +1,4 @@
/*
* Copyright 2000-2017 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// 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;
@@ -28,6 +14,14 @@ public class SoutPostfixTemplateTest extends PostfixTemplateTestCase {
doTest();
}
public void testSerr() {
doTest();
}
public void testSouf() {
doTest();
}
public void testVoid() {
doTest();
}