@@ -359,7 +359,7 @@ else if (o instanceof GoCompositeLit) {
359
359
return findTypeFromTypeRef (expression );
360
360
}
361
361
else if (o instanceof GoFunctionLit ) {
362
- return new MyFunType ((GoFunctionLit )o );
362
+ return new MyFunctionType ((GoFunctionLit )o );
363
363
}
364
364
else if (o instanceof GoBuiltinCallExpr ) {
365
365
String text = ((GoBuiltinCallExpr )o ).getReferenceExpression ().getText ();
@@ -546,6 +546,9 @@ public boolean shouldGoDeeper() {
546
546
}
547
547
return new MyArrayType (type );
548
548
}
549
+ if (resolve instanceof GoSignatureOwner ) {
550
+ return new MyFunctionType ((GoSignatureOwner )resolve );
551
+ }
549
552
return type ;
550
553
}
551
554
@@ -642,6 +645,7 @@ private static GoType funcType(@Nullable GoType type) {
642
645
GoParameters parameters = result .getParameters ();
643
646
if (parameters != null ) {
644
647
List <GoParameterDeclaration > list = parameters .getParameterDeclarationList ();
648
+ if (list .size () == 1 ) return list .get (0 ).getType ();
645
649
List <GoType > types = ContainerUtil .newArrayListWithCapacity (list .size ());
646
650
for (GoParameterDeclaration declaration : list ) {
647
651
types .add (declaration .getType ());
@@ -1302,30 +1306,6 @@ public PsiElement getType(@NotNull GoTypeSpec o) {
1302
1306
return o .getSpecType ();
1303
1307
}
1304
1308
1305
- static class MyFunType extends GoLightType <GoFunctionLit > implements GoFunctionType {
1306
- protected MyFunType (@ NotNull GoFunctionLit o ) {
1307
- super (o );
1308
- }
1309
-
1310
- @ Nullable
1311
- @ Override
1312
- public GoSignature getSignature () {
1313
- return myElement .getSignature ();
1314
- }
1315
-
1316
- @ NotNull
1317
- @ Override
1318
- public PsiElement getFunc () {
1319
- return myElement .getFunc ();
1320
- }
1321
-
1322
- @ Override
1323
- public String getText () {
1324
- GoSignature signature = getSignature ();
1325
- return getFunc ().getText () + (signature != null ? signature .getText () : "" );
1326
- }
1327
- }
1328
-
1329
1309
static class MyPointerType extends GoLightType <GoType > implements GoPointerType {
1330
1310
protected MyPointerType (@ NotNull GoType o ) {
1331
1311
super (o );
@@ -1374,5 +1354,28 @@ public String toString() {
1374
1354
return "MyGoTypeList{myTypes=" + myTypes + '}' ;
1375
1355
}
1376
1356
}
1377
-
1357
+
1358
+ private static class MyFunctionType extends GoLightType <GoSignatureOwner > implements GoFunctionType {
1359
+ public MyFunctionType (@ NotNull GoSignatureOwner o ) {
1360
+ super (o );
1361
+ }
1362
+
1363
+ @ Nullable
1364
+ @ Override
1365
+ public GoSignature getSignature () {
1366
+ return myElement .getSignature ();
1367
+ }
1368
+
1369
+ @ NotNull
1370
+ @ Override
1371
+ public PsiElement getFunc () {
1372
+ return myElement instanceof GoFunctionOrMethodDeclaration ? ((GoFunctionOrMethodDeclaration )myElement ).getFunc () : myElement ;
1373
+ }
1374
+
1375
+ @ Override
1376
+ public String getText () {
1377
+ GoSignature signature = myElement .getSignature ();
1378
+ return "func " + (signature != null ? signature .getText () : "<null>" );
1379
+ }
1380
+ }
1378
1381
}
0 commit comments