|
1 | 1 | // script
|
2 | 2 | use coref::java::*
|
| 3 | + |
3 | 4 | schema ECGNode extends ElementParent {}
|
4 | 5 |
|
5 | 6 | impl ECGNode {
|
@@ -460,6 +461,196 @@ impl ECGNode {
|
460 | 461 | }
|
461 | 462 | }
|
462 | 463 |
|
| 464 | + pub fn getAnAncestorCDDependedNode(self, type: string, direction: string) -> ECGNode { |
| 465 | + for (e in ECGNode(__all_data__), c in Callable(__all_data__), r in ReferenceExpression(__all_data__)) { |
| 466 | + if (type = "CD") { |
| 467 | + if (self.key_eq(c) || (self.key_eq(r.getDefinition()) && r.getEnclosingCallable() = c)) { |
| 468 | + for (e2 in Method(__all_data__), c_caller in c.getAnAncestorCaller()) { |
| 469 | + if (e2.key_eq(c_caller) && direction = "Depended" && e.key_eq(e2)) { |
| 470 | + return e |
| 471 | + } |
| 472 | + } |
| 473 | + } |
| 474 | + } |
| 475 | + } |
| 476 | + } |
| 477 | + |
| 478 | + pub fn getECGDependsNode(self, type: string, direction: string) -> ECGNode { |
| 479 | + for (e in ECGNode(__all_data__)) { |
| 480 | + if (e = self.getCDDependsNode(type, direction)) { |
| 481 | + return e |
| 482 | + } |
| 483 | + if (e = self.getDDDependsNode(type, direction)) { |
| 484 | + return e |
| 485 | + } |
| 486 | + } |
| 487 | + } |
| 488 | + |
| 489 | + pub fn getCDDependsNode(self, type: string, direction: string) -> ECGNode { |
| 490 | + for (e in ECGNode(__all_data__), |
| 491 | + c in Callable(__all_data__), |
| 492 | + r in ReferenceExpression(__all_data__)) { |
| 493 | + if (self.key_eq(c)) { |
| 494 | + if (type = "CD") { |
| 495 | + for (e1 in c.getCallee()) { |
| 496 | + if (direction = "Depends") { |
| 497 | + if (e.key_eq(e1)) { |
| 498 | + return e |
| 499 | + } |
| 500 | + } |
| 501 | + } |
| 502 | + } |
| 503 | + } |
| 504 | + for (v in Variable(__all_data__)) { |
| 505 | + if (self.key_eq(v)) { |
| 506 | + if (v.key_eq(r.getDefinition())) { |
| 507 | + if (c = r.getEnclosingCallable()) { |
| 508 | + if (type = "CD") { |
| 509 | + for (e1 in c.getCallee()) { |
| 510 | + if (direction = "Depends") { |
| 511 | + if (e.key_eq(e1)) { |
| 512 | + return e |
| 513 | + } |
| 514 | + } |
| 515 | + } |
| 516 | + } |
| 517 | + } |
| 518 | + } |
| 519 | + } |
| 520 | + } |
| 521 | + } |
| 522 | + } |
| 523 | + |
| 524 | + pub fn getDDDependsNode(self, type: string, direction: string) -> ECGNode { |
| 525 | + for (e1 in ECGNode(__all_data__)) { |
| 526 | + for (r in ReturnStatement(__all_data__), |
| 527 | + c in Method(__all_data__), |
| 528 | + e in Expression(__all_data__)) { |
| 529 | + if (e.key_eq(e1)) { |
| 530 | + if (self.key_eq(c)) { |
| 531 | + if (c.key_eq(r.getEnclosingCallable())) { |
| 532 | + if (e = r.getResult()) { |
| 533 | + if (direction = "Depends") { |
| 534 | + if (type = "DD") { |
| 535 | + return e1 |
| 536 | + } |
| 537 | + } |
| 538 | + } |
| 539 | + } |
| 540 | + } |
| 541 | + } |
| 542 | + } |
| 543 | + for (e in Callable(__all_data__), |
| 544 | + c in Field(__all_data__), |
| 545 | + r in ReferenceExpression(__all_data__)) { |
| 546 | + if (e.key_eq(e1)) { |
| 547 | + if (self.key_eq(c)) { |
| 548 | + if (c.key_eq(r.getDefinition())) { |
| 549 | + if (e = r.getEnclosingCallable()) { |
| 550 | + if (direction = "Depends") { |
| 551 | + if (type = "DD") { |
| 552 | + return e1 |
| 553 | + } |
| 554 | + } |
| 555 | + } |
| 556 | + } |
| 557 | + } |
| 558 | + } |
| 559 | + } |
| 560 | + for (e in Callable(__all_data__), |
| 561 | + c in EnumConstant(__all_data__), |
| 562 | + r in ReferenceExpression(__all_data__)) { |
| 563 | + if (e.key_eq(e1)) { |
| 564 | + if (self.key_eq(c)) { |
| 565 | + if (c.key_eq(r.getDefinition())) { |
| 566 | + if (e = r.getEnclosingCallable()) { |
| 567 | + if (direction = "Depends") { |
| 568 | + if (type = "DD") { |
| 569 | + return e1 |
| 570 | + } |
| 571 | + } |
| 572 | + } |
| 573 | + } |
| 574 | + } |
| 575 | + } |
| 576 | + } |
| 577 | + for (n in string::__undetermined_all__()) { |
| 578 | + for (e in LombokField(__all_data__), |
| 579 | + c in CallExpression(__all_data__)) { |
| 580 | + if (e.key_eq(e1)) { |
| 581 | + if (self.key_eq(c)) { |
| 582 | + if (e = c.getLombokField()) { |
| 583 | + let (tmp = CallExpression(__all_data__).find(e)) { |
| 584 | + if (!isDirectCall(tmp)) { |
| 585 | + if (n = c.getMethodName()) { |
| 586 | + if (!n.matches("get.*")) { |
| 587 | + if (direction = "Depends") { |
| 588 | + if (type = "DD") { |
| 589 | + return e1 |
| 590 | + } |
| 591 | + } |
| 592 | + } |
| 593 | + } |
| 594 | + } |
| 595 | + } |
| 596 | + } |
| 597 | + } |
| 598 | + } |
| 599 | + } |
| 600 | + } |
| 601 | + } |
| 602 | + } |
| 603 | + |
| 604 | + pub fn getAnAncestorCDDependsNode(self, type: string, direction: string) -> ECGNode { |
| 605 | + for (e in ECGNode(__all_data__), |
| 606 | + c in Callable(__all_data__), |
| 607 | + r in ReferenceExpression(__all_data__)) { |
| 608 | + if (type = "CD") { |
| 609 | + if (self.key_eq(c)) { |
| 610 | + for (e1 in c.getAnAncestorCallee()) { |
| 611 | + if (direction = "Depends") { |
| 612 | + if (e.key_eq(e1)) { |
| 613 | + return e |
| 614 | + } |
| 615 | + } |
| 616 | + } |
| 617 | + } |
| 618 | + if (self.key_eq(r.getDefinition())) { |
| 619 | + if (c = r.getEnclosingCallable()) { |
| 620 | + for (e1 in c.getAnAncestorCallee()) { |
| 621 | + if (direction = "Depends") { |
| 622 | + if (e.key_eq(e1)) { |
| 623 | + return e |
| 624 | + } |
| 625 | + } |
| 626 | + } |
| 627 | + } |
| 628 | + } |
| 629 | + } |
| 630 | + } |
| 631 | + } |
| 632 | + |
| 633 | + pub fn getPath(self) -> string { |
| 634 | + for (line in int::__undetermined_all__(), |
| 635 | + t in string::__undetermined_all__(), |
| 636 | + path in string::__undetermined_all__(), |
| 637 | + info in string::__undetermined_all__()) { |
| 638 | + for (l in coref::java::Location(__all_data__)) { |
| 639 | + if (l = self.getLocation()) { |
| 640 | + if (path = l.getFile().getRelativePath()) { |
| 641 | + if (line = l.getStartLineNumber()) { |
| 642 | + if (t = line.to_string()) { |
| 643 | + if (info = path + ":" + t) { |
| 644 | + return info |
| 645 | + } |
| 646 | + } |
| 647 | + } |
| 648 | + } |
| 649 | + } |
| 650 | + } |
| 651 | + } |
| 652 | + } |
| 653 | + |
463 | 654 | fn tmp_0(n: string) -> bool {
|
464 | 655 | if (n.matches("get.*")) {
|
465 | 656 | return true
|
|
0 commit comments