github.com/powerman/golang-tools@v0.1.11-0.20220410185822-5ad214d8d803/internal/lsp/testdata/extract/extract_method/extract_basic.go.golden (about) 1 -- functionextraction_extract_basic_13_2 -- 2 package extract 3 4 type A struct { 5 x int 6 y int 7 } 8 9 func (a *A) XLessThanYP() bool { 10 return a.x < a.y //@extractmethod("return", "a.y"),extractfunc("return", "a.y") 11 } 12 13 func (a *A) AddP() int { 14 sum := newFunction(a) //@extractmethod("sum", "a.y"),extractfunc("sum", "a.y") 15 return sum //@extractmethod("return", "sum"),extractfunc("return", "sum") 16 } 17 18 func newFunction(a *A) int { 19 sum := a.x + a.y 20 return sum 21 } 22 23 func (a A) XLessThanY() bool { 24 return a.x < a.y //@extractmethod("return", "a.y"),extractfunc("return", "a.y") 25 } 26 27 func (a A) Add() int { 28 sum := a.x + a.y //@extractmethod("sum", "a.y"),extractfunc("sum", "a.y") 29 return sum //@extractmethod("return", "sum"),extractfunc("return", "sum") 30 } 31 32 -- functionextraction_extract_basic_14_2 -- 33 package extract 34 35 type A struct { 36 x int 37 y int 38 } 39 40 func (a *A) XLessThanYP() bool { 41 return a.x < a.y //@extractmethod("return", "a.y"),extractfunc("return", "a.y") 42 } 43 44 func (a *A) AddP() int { 45 sum := a.x + a.y //@extractmethod("sum", "a.y"),extractfunc("sum", "a.y") 46 return newFunction(sum) //@extractmethod("return", "sum"),extractfunc("return", "sum") 47 } 48 49 func newFunction(sum int) int { 50 return sum 51 } 52 53 func (a A) XLessThanY() bool { 54 return a.x < a.y //@extractmethod("return", "a.y"),extractfunc("return", "a.y") 55 } 56 57 func (a A) Add() int { 58 sum := a.x + a.y //@extractmethod("sum", "a.y"),extractfunc("sum", "a.y") 59 return sum //@extractmethod("return", "sum"),extractfunc("return", "sum") 60 } 61 62 -- functionextraction_extract_basic_18_2 -- 63 package extract 64 65 type A struct { 66 x int 67 y int 68 } 69 70 func (a *A) XLessThanYP() bool { 71 return a.x < a.y //@extractmethod("return", "a.y"),extractfunc("return", "a.y") 72 } 73 74 func (a *A) AddP() int { 75 sum := a.x + a.y //@extractmethod("sum", "a.y"),extractfunc("sum", "a.y") 76 return sum //@extractmethod("return", "sum"),extractfunc("return", "sum") 77 } 78 79 func (a A) XLessThanY() bool { 80 return newFunction(a) //@extractmethod("return", "a.y"),extractfunc("return", "a.y") 81 } 82 83 func newFunction(a A) bool { 84 return a.x < a.y 85 } 86 87 func (a A) Add() int { 88 sum := a.x + a.y //@extractmethod("sum", "a.y"),extractfunc("sum", "a.y") 89 return sum //@extractmethod("return", "sum"),extractfunc("return", "sum") 90 } 91 92 -- functionextraction_extract_basic_22_2 -- 93 package extract 94 95 type A struct { 96 x int 97 y int 98 } 99 100 func (a *A) XLessThanYP() bool { 101 return a.x < a.y //@extractmethod("return", "a.y"),extractfunc("return", "a.y") 102 } 103 104 func (a *A) AddP() int { 105 sum := a.x + a.y //@extractmethod("sum", "a.y"),extractfunc("sum", "a.y") 106 return sum //@extractmethod("return", "sum"),extractfunc("return", "sum") 107 } 108 109 func (a A) XLessThanY() bool { 110 return a.x < a.y //@extractmethod("return", "a.y"),extractfunc("return", "a.y") 111 } 112 113 func (a A) Add() int { 114 sum := newFunction(a) //@extractmethod("sum", "a.y"),extractfunc("sum", "a.y") 115 return sum //@extractmethod("return", "sum"),extractfunc("return", "sum") 116 } 117 118 func newFunction(a A) int { 119 sum := a.x + a.y 120 return sum 121 } 122 123 -- functionextraction_extract_basic_23_2 -- 124 package extract 125 126 type A struct { 127 x int 128 y int 129 } 130 131 func (a *A) XLessThanYP() bool { 132 return a.x < a.y //@extractmethod("return", "a.y"),extractfunc("return", "a.y") 133 } 134 135 func (a *A) AddP() int { 136 sum := a.x + a.y //@extractmethod("sum", "a.y"),extractfunc("sum", "a.y") 137 return sum //@extractmethod("return", "sum"),extractfunc("return", "sum") 138 } 139 140 func (a A) XLessThanY() bool { 141 return a.x < a.y //@extractmethod("return", "a.y"),extractfunc("return", "a.y") 142 } 143 144 func (a A) Add() int { 145 sum := a.x + a.y //@extractmethod("sum", "a.y"),extractfunc("sum", "a.y") 146 return newFunction(sum) //@extractmethod("return", "sum"),extractfunc("return", "sum") 147 } 148 149 func newFunction(sum int) int { 150 return sum 151 } 152 153 -- functionextraction_extract_basic_9_2 -- 154 package extract 155 156 type A struct { 157 x int 158 y int 159 } 160 161 func (a *A) XLessThanYP() bool { 162 return newFunction(a) //@extractmethod("return", "a.y"),extractfunc("return", "a.y") 163 } 164 165 func newFunction(a *A) bool { 166 return a.x < a.y 167 } 168 169 func (a *A) AddP() int { 170 sum := a.x + a.y //@extractmethod("sum", "a.y"),extractfunc("sum", "a.y") 171 return sum //@extractmethod("return", "sum"),extractfunc("return", "sum") 172 } 173 174 func (a A) XLessThanY() bool { 175 return a.x < a.y //@extractmethod("return", "a.y"),extractfunc("return", "a.y") 176 } 177 178 func (a A) Add() int { 179 sum := a.x + a.y //@extractmethod("sum", "a.y"),extractfunc("sum", "a.y") 180 return sum //@extractmethod("return", "sum"),extractfunc("return", "sum") 181 } 182 183 -- functionextraction_extract_method_13_2 -- 184 package extract 185 186 type A struct { 187 x int 188 y int 189 } 190 191 func (a *A) XLessThanYP() bool { 192 return a.x < a.y //@extractmethod("return", "a.y"),extractfunc("return", "a.y") 193 } 194 195 func (a *A) AddP() int { 196 sum := newFunction(a) //@extractmethod("sum", "a.y"),extractfunc("sum", "a.y") 197 return sum //@extractmethod("return", "sum"),extractfunc("return", "sum") 198 } 199 200 func newFunction(a *A) int { 201 sum := a.x + a.y 202 return sum 203 } 204 205 func (a A) XLessThanY() bool { 206 return a.x < a.y //@extractmethod("return", "a.y"),extractfunc("return", "a.y") 207 } 208 209 func (a A) Add() int { 210 sum := a.x + a.y //@extractmethod("sum", "a.y"),extractfunc("sum", "a.y") 211 return sum //@extractmethod("return", "sum"),extractfunc("return", "sum") 212 } 213 214 -- functionextraction_extract_method_14_2 -- 215 package extract 216 217 type A struct { 218 x int 219 y int 220 } 221 222 func (a *A) XLessThanYP() bool { 223 return a.x < a.y //@extractmethod("return", "a.y"),extractfunc("return", "a.y") 224 } 225 226 func (a *A) AddP() int { 227 sum := a.x + a.y //@extractmethod("sum", "a.y"),extractfunc("sum", "a.y") 228 return newFunction(sum) //@extractmethod("return", "sum"),extractfunc("return", "sum") 229 } 230 231 func newFunction(sum int) int { 232 return sum 233 } 234 235 func (a A) XLessThanY() bool { 236 return a.x < a.y //@extractmethod("return", "a.y"),extractfunc("return", "a.y") 237 } 238 239 func (a A) Add() int { 240 sum := a.x + a.y //@extractmethod("sum", "a.y"),extractfunc("sum", "a.y") 241 return sum //@extractmethod("return", "sum"),extractfunc("return", "sum") 242 } 243 244 -- functionextraction_extract_method_18_2 -- 245 package extract 246 247 type A struct { 248 x int 249 y int 250 } 251 252 func (a *A) XLessThanYP() bool { 253 return a.x < a.y //@extractmethod("return", "a.y"),extractfunc("return", "a.y") 254 } 255 256 func (a *A) AddP() int { 257 sum := a.x + a.y //@extractmethod("sum", "a.y"),extractfunc("sum", "a.y") 258 return sum //@extractmethod("return", "sum"),extractfunc("return", "sum") 259 } 260 261 func (a A) XLessThanY() bool { 262 return newFunction(a) //@extractmethod("return", "a.y"),extractfunc("return", "a.y") 263 } 264 265 func newFunction(a A) bool { 266 return a.x < a.y 267 } 268 269 func (a A) Add() int { 270 sum := a.x + a.y //@extractmethod("sum", "a.y"),extractfunc("sum", "a.y") 271 return sum //@extractmethod("return", "sum"),extractfunc("return", "sum") 272 } 273 274 -- functionextraction_extract_method_22_2 -- 275 package extract 276 277 type A struct { 278 x int 279 y int 280 } 281 282 func (a *A) XLessThanYP() bool { 283 return a.x < a.y //@extractmethod("return", "a.y"),extractfunc("return", "a.y") 284 } 285 286 func (a *A) AddP() int { 287 sum := a.x + a.y //@extractmethod("sum", "a.y"),extractfunc("sum", "a.y") 288 return sum //@extractmethod("return", "sum"),extractfunc("return", "sum") 289 } 290 291 func (a A) XLessThanY() bool { 292 return a.x < a.y //@extractmethod("return", "a.y"),extractfunc("return", "a.y") 293 } 294 295 func (a A) Add() int { 296 sum := newFunction(a) //@extractmethod("sum", "a.y"),extractfunc("sum", "a.y") 297 return sum //@extractmethod("return", "sum"),extractfunc("return", "sum") 298 } 299 300 func newFunction(a A) int { 301 sum := a.x + a.y 302 return sum 303 } 304 305 -- functionextraction_extract_method_23_2 -- 306 package extract 307 308 type A struct { 309 x int 310 y int 311 } 312 313 func (a *A) XLessThanYP() bool { 314 return a.x < a.y //@extractmethod("return", "a.y"),extractfunc("return", "a.y") 315 } 316 317 func (a *A) AddP() int { 318 sum := a.x + a.y //@extractmethod("sum", "a.y"),extractfunc("sum", "a.y") 319 return sum //@extractmethod("return", "sum"),extractfunc("return", "sum") 320 } 321 322 func (a A) XLessThanY() bool { 323 return a.x < a.y //@extractmethod("return", "a.y"),extractfunc("return", "a.y") 324 } 325 326 func (a A) Add() int { 327 sum := a.x + a.y //@extractmethod("sum", "a.y"),extractfunc("sum", "a.y") 328 return newFunction(sum) //@extractmethod("return", "sum"),extractfunc("return", "sum") 329 } 330 331 func newFunction(sum int) int { 332 return sum 333 } 334 335 -- functionextraction_extract_method_9_2 -- 336 package extract 337 338 type A struct { 339 x int 340 y int 341 } 342 343 func (a *A) XLessThanYP() bool { 344 return newFunction(a) //@extractmethod("return", "a.y"),extractfunc("return", "a.y") 345 } 346 347 func newFunction(a *A) bool { 348 return a.x < a.y 349 } 350 351 func (a *A) AddP() int { 352 sum := a.x + a.y //@extractmethod("sum", "a.y"),extractfunc("sum", "a.y") 353 return sum //@extractmethod("return", "sum"),extractfunc("return", "sum") 354 } 355 356 func (a A) XLessThanY() bool { 357 return a.x < a.y //@extractmethod("return", "a.y"),extractfunc("return", "a.y") 358 } 359 360 func (a A) Add() int { 361 sum := a.x + a.y //@extractmethod("sum", "a.y"),extractfunc("sum", "a.y") 362 return sum //@extractmethod("return", "sum"),extractfunc("return", "sum") 363 } 364 365 -- methodextraction_extract_basic_13_2 -- 366 package extract 367 368 type A struct { 369 x int 370 y int 371 } 372 373 func (a *A) XLessThanYP() bool { 374 return a.x < a.y //@extractmethod("return", "a.y"),extractfunc("return", "a.y") 375 } 376 377 func (a *A) AddP() int { 378 sum := a.newMethod() //@extractmethod("sum", "a.y"),extractfunc("sum", "a.y") 379 return sum //@extractmethod("return", "sum"),extractfunc("return", "sum") 380 } 381 382 func (a *A) newMethod() int { 383 sum := a.x + a.y 384 return sum 385 } 386 387 func (a A) XLessThanY() bool { 388 return a.x < a.y //@extractmethod("return", "a.y"),extractfunc("return", "a.y") 389 } 390 391 func (a A) Add() int { 392 sum := a.x + a.y //@extractmethod("sum", "a.y"),extractfunc("sum", "a.y") 393 return sum //@extractmethod("return", "sum"),extractfunc("return", "sum") 394 } 395 396 -- methodextraction_extract_basic_14_2 -- 397 package extract 398 399 type A struct { 400 x int 401 y int 402 } 403 404 func (a *A) XLessThanYP() bool { 405 return a.x < a.y //@extractmethod("return", "a.y"),extractfunc("return", "a.y") 406 } 407 408 func (a *A) AddP() int { 409 sum := a.x + a.y //@extractmethod("sum", "a.y"),extractfunc("sum", "a.y") 410 return a.newMethod(sum) //@extractmethod("return", "sum"),extractfunc("return", "sum") 411 } 412 413 func (*A) newMethod(sum int) int { 414 return sum 415 } 416 417 func (a A) XLessThanY() bool { 418 return a.x < a.y //@extractmethod("return", "a.y"),extractfunc("return", "a.y") 419 } 420 421 func (a A) Add() int { 422 sum := a.x + a.y //@extractmethod("sum", "a.y"),extractfunc("sum", "a.y") 423 return sum //@extractmethod("return", "sum"),extractfunc("return", "sum") 424 } 425 426 -- methodextraction_extract_basic_18_2 -- 427 package extract 428 429 type A struct { 430 x int 431 y int 432 } 433 434 func (a *A) XLessThanYP() bool { 435 return a.x < a.y //@extractmethod("return", "a.y"),extractfunc("return", "a.y") 436 } 437 438 func (a *A) AddP() int { 439 sum := a.x + a.y //@extractmethod("sum", "a.y"),extractfunc("sum", "a.y") 440 return sum //@extractmethod("return", "sum"),extractfunc("return", "sum") 441 } 442 443 func (a A) XLessThanY() bool { 444 return a.newMethod() //@extractmethod("return", "a.y"),extractfunc("return", "a.y") 445 } 446 447 func (a A) newMethod() bool { 448 return a.x < a.y 449 } 450 451 func (a A) Add() int { 452 sum := a.x + a.y //@extractmethod("sum", "a.y"),extractfunc("sum", "a.y") 453 return sum //@extractmethod("return", "sum"),extractfunc("return", "sum") 454 } 455 456 -- methodextraction_extract_basic_22_2 -- 457 package extract 458 459 type A struct { 460 x int 461 y int 462 } 463 464 func (a *A) XLessThanYP() bool { 465 return a.x < a.y //@extractmethod("return", "a.y"),extractfunc("return", "a.y") 466 } 467 468 func (a *A) AddP() int { 469 sum := a.x + a.y //@extractmethod("sum", "a.y"),extractfunc("sum", "a.y") 470 return sum //@extractmethod("return", "sum"),extractfunc("return", "sum") 471 } 472 473 func (a A) XLessThanY() bool { 474 return a.x < a.y //@extractmethod("return", "a.y"),extractfunc("return", "a.y") 475 } 476 477 func (a A) Add() int { 478 sum := a.newMethod() //@extractmethod("sum", "a.y"),extractfunc("sum", "a.y") 479 return sum //@extractmethod("return", "sum"),extractfunc("return", "sum") 480 } 481 482 func (a A) newMethod() int { 483 sum := a.x + a.y 484 return sum 485 } 486 487 -- methodextraction_extract_basic_23_2 -- 488 package extract 489 490 type A struct { 491 x int 492 y int 493 } 494 495 func (a *A) XLessThanYP() bool { 496 return a.x < a.y //@extractmethod("return", "a.y"),extractfunc("return", "a.y") 497 } 498 499 func (a *A) AddP() int { 500 sum := a.x + a.y //@extractmethod("sum", "a.y"),extractfunc("sum", "a.y") 501 return sum //@extractmethod("return", "sum"),extractfunc("return", "sum") 502 } 503 504 func (a A) XLessThanY() bool { 505 return a.x < a.y //@extractmethod("return", "a.y"),extractfunc("return", "a.y") 506 } 507 508 func (a A) Add() int { 509 sum := a.x + a.y //@extractmethod("sum", "a.y"),extractfunc("sum", "a.y") 510 return a.newMethod(sum) //@extractmethod("return", "sum"),extractfunc("return", "sum") 511 } 512 513 func (A) newMethod(sum int) int { 514 return sum 515 } 516 517 -- methodextraction_extract_basic_9_2 -- 518 package extract 519 520 type A struct { 521 x int 522 y int 523 } 524 525 func (a *A) XLessThanYP() bool { 526 return a.newMethod() //@extractmethod("return", "a.y"),extractfunc("return", "a.y") 527 } 528 529 func (a *A) newMethod() bool { 530 return a.x < a.y 531 } 532 533 func (a *A) AddP() int { 534 sum := a.x + a.y //@extractmethod("sum", "a.y"),extractfunc("sum", "a.y") 535 return sum //@extractmethod("return", "sum"),extractfunc("return", "sum") 536 } 537 538 func (a A) XLessThanY() bool { 539 return a.x < a.y //@extractmethod("return", "a.y"),extractfunc("return", "a.y") 540 } 541 542 func (a A) Add() int { 543 sum := a.x + a.y //@extractmethod("sum", "a.y"),extractfunc("sum", "a.y") 544 return sum //@extractmethod("return", "sum"),extractfunc("return", "sum") 545 } 546 547 -- methodextraction_extract_method_13_2 -- 548 package extract 549 550 type A struct { 551 x int 552 y int 553 } 554 555 func (a *A) XLessThanYP() bool { 556 return a.x < a.y //@extractmethod("return", "a.y"),extractfunc("return", "a.y") 557 } 558 559 func (a *A) AddP() int { 560 sum := a.newMethod() //@extractmethod("sum", "a.y"),extractfunc("sum", "a.y") 561 return sum //@extractmethod("return", "sum"),extractfunc("return", "sum") 562 } 563 564 func (a *A) newMethod() int { 565 sum := a.x + a.y 566 return sum 567 } 568 569 func (a A) XLessThanY() bool { 570 return a.x < a.y //@extractmethod("return", "a.y"),extractfunc("return", "a.y") 571 } 572 573 func (a A) Add() int { 574 sum := a.x + a.y //@extractmethod("sum", "a.y"),extractfunc("sum", "a.y") 575 return sum //@extractmethod("return", "sum"),extractfunc("return", "sum") 576 } 577 578 -- methodextraction_extract_method_14_2 -- 579 package extract 580 581 type A struct { 582 x int 583 y int 584 } 585 586 func (a *A) XLessThanYP() bool { 587 return a.x < a.y //@extractmethod("return", "a.y"),extractfunc("return", "a.y") 588 } 589 590 func (a *A) AddP() int { 591 sum := a.x + a.y //@extractmethod("sum", "a.y"),extractfunc("sum", "a.y") 592 return a.newMethod(sum) //@extractmethod("return", "sum"),extractfunc("return", "sum") 593 } 594 595 func (*A) newMethod(sum int) int { 596 return sum 597 } 598 599 func (a A) XLessThanY() bool { 600 return a.x < a.y //@extractmethod("return", "a.y"),extractfunc("return", "a.y") 601 } 602 603 func (a A) Add() int { 604 sum := a.x + a.y //@extractmethod("sum", "a.y"),extractfunc("sum", "a.y") 605 return sum //@extractmethod("return", "sum"),extractfunc("return", "sum") 606 } 607 608 -- methodextraction_extract_method_18_2 -- 609 package extract 610 611 type A struct { 612 x int 613 y int 614 } 615 616 func (a *A) XLessThanYP() bool { 617 return a.x < a.y //@extractmethod("return", "a.y"),extractfunc("return", "a.y") 618 } 619 620 func (a *A) AddP() int { 621 sum := a.x + a.y //@extractmethod("sum", "a.y"),extractfunc("sum", "a.y") 622 return sum //@extractmethod("return", "sum"),extractfunc("return", "sum") 623 } 624 625 func (a A) XLessThanY() bool { 626 return a.newMethod() //@extractmethod("return", "a.y"),extractfunc("return", "a.y") 627 } 628 629 func (a A) newMethod() bool { 630 return a.x < a.y 631 } 632 633 func (a A) Add() int { 634 sum := a.x + a.y //@extractmethod("sum", "a.y"),extractfunc("sum", "a.y") 635 return sum //@extractmethod("return", "sum"),extractfunc("return", "sum") 636 } 637 638 -- methodextraction_extract_method_22_2 -- 639 package extract 640 641 type A struct { 642 x int 643 y int 644 } 645 646 func (a *A) XLessThanYP() bool { 647 return a.x < a.y //@extractmethod("return", "a.y"),extractfunc("return", "a.y") 648 } 649 650 func (a *A) AddP() int { 651 sum := a.x + a.y //@extractmethod("sum", "a.y"),extractfunc("sum", "a.y") 652 return sum //@extractmethod("return", "sum"),extractfunc("return", "sum") 653 } 654 655 func (a A) XLessThanY() bool { 656 return a.x < a.y //@extractmethod("return", "a.y"),extractfunc("return", "a.y") 657 } 658 659 func (a A) Add() int { 660 sum := a.newMethod() //@extractmethod("sum", "a.y"),extractfunc("sum", "a.y") 661 return sum //@extractmethod("return", "sum"),extractfunc("return", "sum") 662 } 663 664 func (a A) newMethod() int { 665 sum := a.x + a.y 666 return sum 667 } 668 669 -- methodextraction_extract_method_23_2 -- 670 package extract 671 672 type A struct { 673 x int 674 y int 675 } 676 677 func (a *A) XLessThanYP() bool { 678 return a.x < a.y //@extractmethod("return", "a.y"),extractfunc("return", "a.y") 679 } 680 681 func (a *A) AddP() int { 682 sum := a.x + a.y //@extractmethod("sum", "a.y"),extractfunc("sum", "a.y") 683 return sum //@extractmethod("return", "sum"),extractfunc("return", "sum") 684 } 685 686 func (a A) XLessThanY() bool { 687 return a.x < a.y //@extractmethod("return", "a.y"),extractfunc("return", "a.y") 688 } 689 690 func (a A) Add() int { 691 sum := a.x + a.y //@extractmethod("sum", "a.y"),extractfunc("sum", "a.y") 692 return a.newMethod(sum) //@extractmethod("return", "sum"),extractfunc("return", "sum") 693 } 694 695 func (A) newMethod(sum int) int { 696 return sum 697 } 698 699 -- methodextraction_extract_method_9_2 -- 700 package extract 701 702 type A struct { 703 x int 704 y int 705 } 706 707 func (a *A) XLessThanYP() bool { 708 return a.newMethod() //@extractmethod("return", "a.y"),extractfunc("return", "a.y") 709 } 710 711 func (a *A) newMethod() bool { 712 return a.x < a.y 713 } 714 715 func (a *A) AddP() int { 716 sum := a.x + a.y //@extractmethod("sum", "a.y"),extractfunc("sum", "a.y") 717 return sum //@extractmethod("return", "sum"),extractfunc("return", "sum") 718 } 719 720 func (a A) XLessThanY() bool { 721 return a.x < a.y //@extractmethod("return", "a.y"),extractfunc("return", "a.y") 722 } 723 724 func (a A) Add() int { 725 sum := a.x + a.y //@extractmethod("sum", "a.y"),extractfunc("sum", "a.y") 726 return sum //@extractmethod("return", "sum"),extractfunc("return", "sum") 727 } 728