Code completion updates for enhanced switches (IDEA-202340)

- Support inside switch expression
- Support rule-based labels
- Support break inside expression
- Suggest 'switch' keyword in expressions
- Insert ':' or '->' depending on the switch type
This commit is contained in:
Tagir Valeev
2018-12-08 16:30:42 +07:00
parent 86e1009135
commit 6ea7ea44c2
20 changed files with 208 additions and 36 deletions
@@ -0,0 +1,8 @@
public class ConstConfig {
int test(int x) {
return switch (x) {
case 1:
if (Math.random() > 0.5) br<caret>
};
}
}
@@ -0,0 +1,8 @@
public class ConstConfig {
int test(int x) {
return switch (x) {
case 1:
if (Math.random() > 0.5) break <caret>
};
}
}
@@ -0,0 +1,9 @@
public class ConstConfig {
{
switch (a) {
case Foooo -> {}
def<caret>
}
}
}
@@ -0,0 +1,9 @@
public class ConstConfig {
{
switch (a) {
case Foooo -> {}
default -> <caret>
}
}
}
@@ -0,0 +1,11 @@
public class ConstConfig {
enum X {FOO, BAR, BAZ}
void test(X x) {
switch (x) {
case BAR -> {}
case BAZ -> {}
case FO<caret>
}
}
}
@@ -0,0 +1,11 @@
public class ConstConfig {
enum X {FOO, BAR, BAZ}
void test(X x) {
switch (x) {
case BAR -> {}
case BAZ -> {}
case FOO -> <caret>
}
}
}
@@ -0,0 +1,9 @@
public class ConstConfig {
enum X {FOO, BAR, BAZ}
void test(X x) {
switch (x) {
case BAR, FO<caret>: {}
}
}
}
@@ -0,0 +1,9 @@
public class ConstConfig {
enum X {FOO, BAR, BAZ}
void test(X x) {
switch (x) {
case BAR, FOO:<caret> {}
}
}
}
@@ -0,0 +1,9 @@
public class ConstConfig {
enum X {FOO, BAR, BAZ}
void test(X x) {
switch (x) {
case BAR, FO<caret> -> {}
}
}
}
@@ -0,0 +1,9 @@
public class ConstConfig {
enum X {FOO, BAR, BAZ}
void test(X x) {
switch (x) {
case BAR, FOO<caret> -> {}
}
}
}
@@ -0,0 +1,5 @@
public class ConstConfig {
int test(int x) {
return sw<caret>
}
}
@@ -0,0 +1,5 @@
public class ConstConfig {
int test(int x) {
return switch (<caret>)
}
}