@@ -245,7 +245,7 @@ func (s *JavaCallListener) EnterCreator(ctx *parser.CreatorContext) {
245
245
246
246
func buildCreatedCall (createdName string , ctx * parser.CreatorContext ) {
247
247
method := methodMap [getMethodMapName (currentMethod )]
248
- fullType := warpTargetFullType (createdName )
248
+ fullType , _ := warpTargetFullType (createdName )
249
249
250
250
startLine := ctx .GetStart ().GetLine ()
251
251
startLinePosition := ctx .GetStart ().GetColumn ()
@@ -254,7 +254,7 @@ func buildCreatedCall(createdName string, ctx *parser.CreatorContext) {
254
254
255
255
jMethodCall := & models.JMethodCall {
256
256
Package : removeTarget (fullType ),
257
- Type : "Creator " ,
257
+ Type : "creator " ,
258
258
Class : createdName ,
259
259
MethodName : "" ,
260
260
StartLine : startLine ,
@@ -281,7 +281,7 @@ func (s *JavaCallListener) EnterMethodCall(ctx *parser.MethodCallContext) {
281
281
stopLine := ctx .GetStop ().GetLine ()
282
282
stopLinePosition := startLinePosition + len (callee )
283
283
284
- fullType := warpTargetFullType (targetType )
284
+ fullType , callType := warpTargetFullType (targetType )
285
285
if targetType == "super" {
286
286
targetType = currentClzExtend
287
287
}
@@ -293,7 +293,7 @@ func (s *JavaCallListener) EnterMethodCall(ctx *parser.MethodCallContext) {
293
293
targetType = currentClz
294
294
}
295
295
296
- jMethodCall = & models.JMethodCall {removeTarget (fullType ), "" , targetType , callee , startLine , startLinePosition , stopLine , stopLinePosition }
296
+ jMethodCall = & models.JMethodCall {removeTarget (fullType ), callType , targetType , callee , startLine , startLinePosition , stopLine , stopLinePosition }
297
297
} else {
298
298
if ctx .GetText () == targetType {
299
299
methodName := ctx .IDENTIFIER ().GetText ()
@@ -306,14 +306,14 @@ func (s *JavaCallListener) EnterMethodCall(ctx *parser.MethodCallContext) {
306
306
clz = ""
307
307
}
308
308
}
309
- jMethodCall = & models.JMethodCall {pkg , "" , clz , methodName , startLine , startLinePosition , stopLine , stopLinePosition }
309
+ jMethodCall = & models.JMethodCall {pkg , callType , clz , methodName , startLine , startLinePosition , stopLine , stopLinePosition }
310
310
} else {
311
311
methodName := ctx .IDENTIFIER ().GetText ()
312
312
targetType = buildSpecificTarget (targetType )
313
313
314
314
targetType = buildMethodNameForBuilder (ctx , targetType )
315
315
316
- jMethodCall = & models.JMethodCall {currentPkg , "NEEDFIX" , targetType , methodName , startLine , startLinePosition , stopLine , stopLinePosition }
316
+ jMethodCall = & models.JMethodCall {currentPkg , callType , targetType , methodName , startLine , startLinePosition , stopLine , stopLinePosition }
317
317
}
318
318
}
319
319
@@ -374,7 +374,7 @@ func (s *JavaCallListener) EnterExpression(ctx *parser.ExpressionContext) {
374
374
methodName := ctx .IDENTIFIER ().GetText ()
375
375
targetType := parseTargetType (text )
376
376
377
- fullType := warpTargetFullType (targetType )
377
+ fullType , _ := warpTargetFullType (targetType )
378
378
379
379
startLine := ctx .GetStart ().GetLine ()
380
380
startLinePosition := ctx .GetStart ().GetColumn ()
@@ -424,9 +424,11 @@ func parseTargetType(targetCtx string) string {
424
424
return targetType
425
425
}
426
426
427
- func warpTargetFullType (targetType string ) string {
427
+ func warpTargetFullType (targetType string ) (string , string ) {
428
+ callType := ""
428
429
if strings .EqualFold (currentClz , targetType ) {
429
- return currentPkg + "." + targetType
430
+ callType = "self"
431
+ return currentPkg + "." + targetType , ""
430
432
}
431
433
432
434
// TODO: update for array
@@ -437,30 +439,34 @@ func warpTargetFullType(targetType string) string {
437
439
if pureTargetType != "" {
438
440
for _ , imp := range imports {
439
441
if strings .HasSuffix (imp , pureTargetType ) {
440
- return imp
442
+ callType = "chain"
443
+ return imp , callType
441
444
}
442
445
}
443
446
}
444
447
445
448
//maybe the same package
446
449
for _ , clz := range clzs {
447
450
if strings .HasSuffix (clz , "." + pureTargetType ) {
448
- return clz
451
+ callType = "same package"
452
+ return clz , callType
449
453
}
450
454
}
451
455
452
456
//1. current package, 2. import by *
453
457
if pureTargetType == "super" {
454
458
for _ , imp := range imports {
455
459
if strings .HasSuffix (imp , currentClzExtend ) {
456
- return imp
460
+ callType = "super"
461
+ return imp , callType
457
462
}
458
463
}
459
464
}
460
465
461
466
if _ , ok := identMap [currentPkg + "." + targetType ]; ok {
462
- return currentPkg + "." + targetType
467
+ callType = "same package 2"
468
+ return currentPkg + "." + targetType , callType
463
469
}
464
470
465
- return ""
471
+ return "" , callType
466
472
}
0 commit comments