Tests for soutc, serrc; use JavaLanguage.INSTANCE.getDisplayName() for Java

Review ID: IDEA-CR-60451

GitOrigin-RevId: ea77644cd21b8d34ba4060f7c12106f290c50764
This commit is contained in:
Tagir Valeev
2020-03-23 15:07:33 +07:00
committed by intellij-monorepo-bot
parent 8e905ce4db
commit 149e5de1f7
5 changed files with 32 additions and 2 deletions

View File

@@ -80,7 +80,7 @@ public abstract class JavaCodeContextType extends TemplateContextType {
public static class Generic extends JavaCodeContextType {
public Generic() {
super("JAVA_CODE", JavaBundle.message("live.template.context.java"), EverywhereContextType.class);
super("JAVA_CODE", JavaLanguage.INSTANCE.getDisplayName(), EverywhereContextType.class);
}
@Override

View File

@@ -0,0 +1,8 @@
import java.util.List;
class Foo {
static void foo(List<String> ls) {
ls.forEach(System.out::println<caret>);
}
}

View File

@@ -0,0 +1,8 @@
import java.util.List;
class Foo {
static void foo(List<String> ls) {
ls.forEach(<caret>);
}
}

View File

@@ -229,6 +229,21 @@ class Outer {
startTemplate("soutp", "output")
checkResult()
}
void testSoutConsumerApplicability() {
for (String name : ["soutc", "serrc"]) {
TemplateImpl template = (TemplateImpl)TemplateSettings.getInstance().getTemplate(name, "output")
assert !isApplicable('class Foo {void x(){ <caret>JUNK }}', template)
assert !isApplicable('class Foo {void x(java.util.stream.IntStream is){ is.map(<caret>JUNK) }}', template)
assert isApplicable('class Foo {void x(java.util.stream.IntStream is){ is.peek(<caret>JUNK) }}', template)
}
}
void testSoutConsumer() {
configure()
startTemplate("soutc", "output")
checkResult()
}
private boolean isApplicable(String text, TemplateImpl inst) throws IOException {
myFixture.configureByText("a.java", text)

View File

@@ -1181,7 +1181,6 @@ external.annotations.roots=Annotation Roots
inspection.stream.api.migration.can.be.replaced.with.call=Can be replaced with ''{0}'' call
highlight.suppressed.warnings.choose.inspections=Choose Inspections to Highlight Suppressed Problems from
inspection.magic.constants.should.be.one.of.values=Should be one of: {0}{1,choice,0#|1# or their combination}
live.template.context.java=Java
live.template.context.consumer.function=Consumer function
live.template.context.statement=Statement
live.template.context.expression=Expression