mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
java: expression context for array.stream postfix template IDEA-157975
This commit is contained in:
+2
-2
@@ -20,11 +20,11 @@ import com.intellij.psi.PsiElement;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import static com.intellij.codeInsight.template.postfix.util.JavaPostfixTemplatesUtils.selectorTopmost;
|
||||
import static com.intellij.codeInsight.template.postfix.util.JavaPostfixTemplatesUtils.selectorAllExpressionsWithCurrentOffset;
|
||||
|
||||
public class StreamPostfixTemplate extends StringBasedPostfixTemplate {
|
||||
public StreamPostfixTemplate() {
|
||||
super("stream", "Arrays.stream(expr)", JavaPostfixTemplatesUtils.atLeastJava8Selector(selectorTopmost(JavaPostfixTemplatesUtils.IS_ARRAY)));
|
||||
super("stream", "Arrays.stream(expr)", JavaPostfixTemplatesUtils.atLeastJava8Selector(selectorAllExpressionsWithCurrentOffset(JavaPostfixTemplatesUtils.IS_ARRAY)));
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
package templates;
|
||||
|
||||
public class Foo {
|
||||
void m(int[] array) {
|
||||
if (array.stream<caret>) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
package templates;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
public class Foo {
|
||||
void m(int[] array) {
|
||||
if (Arrays.stream(array)) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
+5
-1
@@ -51,7 +51,11 @@ public class StreamPostfixTemplateTest extends PostfixTemplateTestCase {
|
||||
public void testSimple() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
|
||||
public void testExpressionContext() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testDoNotExpandOnJavaLess8() {
|
||||
LanguageLevelProjectExtension.getInstance(myFixture.getProject()).setLanguageLevel(LanguageLevel.JDK_1_6);
|
||||
doTest();
|
||||
|
||||
Reference in New Issue
Block a user