Skip to content

Commit c8eb68a

Browse files
committed
Allow to extract function literal
1 parent 95c8aeb commit c8eb68a

File tree

4 files changed

+12
-1
lines changed

4 files changed

+12
-1
lines changed

src/com/goide/inspections/GoInspectionUtil.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ private GoInspectionUtil() {}
3131
public static int getExpressionResultCount(GoExpression call) {
3232
if (call instanceof GoLiteral || call instanceof GoStringLiteral || call instanceof GoBinaryExpr ||
3333
call instanceof GoUnaryExpr && ((GoUnaryExpr)call).getSendChannel() == null || call instanceof GoBuiltinCallExpr ||
34-
call instanceof GoCompositeLit || call instanceof GoIndexOrSliceExpr) {
34+
call instanceof GoCompositeLit || call instanceof GoIndexOrSliceExpr || call instanceof GoFunctionLit) {
3535
return 1;
3636
}
3737
if (call instanceof GoParenthesesExpr) {
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package a
2+
3+
func a(s string) {
4+
i := func(int, int) {}
5+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package a
2+
3+
func a(s string) {
4+
fun<caret>c(int, int) {}
5+
}

tests/com/goide/refactor/GoIntroduceVariableTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ private void doFailureTest(String msg) {
6060
public void testDoNotSuggestKeywordBasedOnType() { doTest(); }
6161
public void testDoNotSuggestKeywordBasedOnCallName() { doTest(); }
6262
public void testDoNotSuggestNameEqualsToType() { doTest(); }
63+
public void testExtractFunctionLiteral() { doTest(); }
6364

6465
public void testExtractSingleExpressionStatement_1() { doTest(); }
6566
public void testExtractSingleExpressionStatement_2() { doTest(); }

0 commit comments

Comments
 (0)