Commit fe804b3
authored
feat(resolver): resolve super.method() dispatch via class expression + static block + field def (#1399)
* feat(resolver): resolve super.method() dispatch via class expression + static block + field def
- Add `(class name: ...)` query patterns for JS/TS class expressions so that
`return class Foo extends Bar { ... }` records the extends relationship in
ctx.classes — previously only class_declaration was captured, leaving class
expressions invisible to resolveThisDispatch.
- Add `class_static_block` → `ClassName.<static>` synthetic method definition
in both query path (extractClassMembersWalk) and walk path (walkJavaScriptNode).
Calls inside `static { super.f(); }` blocks are now attributed to a method-kind
node so the CHA parents map can resolve `super.f()` to the parent class.
- Add `field_definition`/`public_field_definition` → `ClassName.fieldName` method
definition when the field value is an arrow function or function expression.
`static f = () => { ... }` becomes a resolvable `A.f` node so
`resolveThisDispatch` can emit the `B.<static> → A.f` edge.
- Mirror all three changes in the native Rust extractor for parity.
- Add 6 parser unit tests and import Jelly micro-test fixtures for super,
super2, super3, super4, super5 as ground-truth benchmarks.
Benchmark result: super fixture 31% → 38% recall (B.<static> → A.f now resolved).
docs check acknowledged
Closes #1377
* fix(extractor): guard handleFieldDef to only emit callable field definitions (#1399)
Impact: 2 functions changed, 18 affected
* fix(extractor): remove unreachable duplicate match arms in Rust match_js_node (#1399)
The PR moved class_static_block and field_definition earlier in the match block
(lines 771/773) but left identical arms below (lines 786/787) as dead code.
Removing them eliminates Rust unreachable_patterns warnings.1 parent 0754216 commit fe804b3
5 files changed
Lines changed: 107 additions & 63 deletions
File tree
- crates/codegraph-core/src/extractors
- src/extractors
- tests
- benchmarks/resolution/fixtures/jelly-micro
- classes
- super
- parsers
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
763 | 763 | | |
764 | 764 | | |
765 | 765 | | |
766 | | - | |
| 766 | + | |
| 767 | + | |
| 768 | + | |
767 | 769 | | |
768 | 770 | | |
| 771 | + | |
769 | 772 | | |
| 773 | + | |
770 | 774 | | |
771 | 775 | | |
772 | 776 | | |
| |||
776 | 780 | | |
777 | 781 | | |
778 | 782 | | |
779 | | - | |
780 | | - | |
781 | | - | |
782 | | - | |
783 | | - | |
784 | 783 | | |
785 | 784 | | |
786 | 785 | | |
| |||
864 | 863 | | |
865 | 864 | | |
866 | 865 | | |
| 866 | + | |
| 867 | + | |
| 868 | + | |
| 869 | + | |
| 870 | + | |
| 871 | + | |
| 872 | + | |
| 873 | + | |
| 874 | + | |
| 875 | + | |
| 876 | + | |
| 877 | + | |
| 878 | + | |
| 879 | + | |
| 880 | + | |
| 881 | + | |
| 882 | + | |
| 883 | + | |
| 884 | + | |
| 885 | + | |
| 886 | + | |
| 887 | + | |
| 888 | + | |
867 | 889 | | |
868 | 890 | | |
869 | 891 | | |
| |||
881 | 903 | | |
882 | 904 | | |
883 | 905 | | |
884 | | - | |
| 906 | + | |
| 907 | + | |
| 908 | + | |
| 909 | + | |
| 910 | + | |
| 911 | + | |
885 | 912 | | |
886 | 913 | | |
887 | 914 | | |
| |||
897 | 924 | | |
898 | 925 | | |
899 | 926 | | |
900 | | - | |
901 | | - | |
902 | | - | |
903 | | - | |
904 | | - | |
905 | | - | |
906 | | - | |
907 | | - | |
908 | | - | |
909 | | - | |
910 | | - | |
911 | | - | |
912 | | - | |
913 | | - | |
914 | | - | |
915 | | - | |
916 | | - | |
917 | 927 | | |
918 | 928 | | |
919 | 929 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
738 | 738 | | |
739 | 739 | | |
740 | 740 | | |
| 741 | + | |
| 742 | + | |
| 743 | + | |
| 744 | + | |
| 745 | + | |
| 746 | + | |
| 747 | + | |
741 | 748 | | |
742 | 749 | | |
743 | 750 | | |
| |||
769 | 776 | | |
770 | 777 | | |
771 | 778 | | |
772 | | - | |
773 | | - | |
774 | | - | |
775 | | - | |
776 | | - | |
777 | | - | |
778 | | - | |
779 | 779 | | |
780 | 780 | | |
781 | 781 | | |
| |||
843 | 843 | | |
844 | 844 | | |
845 | 845 | | |
| 846 | + | |
| 847 | + | |
| 848 | + | |
| 849 | + | |
| 850 | + | |
| 851 | + | |
| 852 | + | |
| 853 | + | |
| 854 | + | |
| 855 | + | |
| 856 | + | |
| 857 | + | |
| 858 | + | |
| 859 | + | |
| 860 | + | |
| 861 | + | |
| 862 | + | |
| 863 | + | |
| 864 | + | |
| 865 | + | |
| 866 | + | |
| 867 | + | |
| 868 | + | |
| 869 | + | |
846 | 870 | | |
847 | 871 | | |
848 | 872 | | |
849 | 873 | | |
| 874 | + | |
| 875 | + | |
| 876 | + | |
| 877 | + | |
850 | 878 | | |
| 879 | + | |
| 880 | + | |
| 881 | + | |
| 882 | + | |
| 883 | + | |
| 884 | + | |
851 | 885 | | |
852 | 886 | | |
853 | | - | |
| 887 | + | |
| 888 | + | |
| 889 | + | |
| 890 | + | |
854 | 891 | | |
855 | 892 | | |
856 | 893 | | |
| 894 | + | |
| 895 | + | |
| 896 | + | |
857 | 897 | | |
858 | 898 | | |
859 | | - | |
860 | | - | |
861 | | - | |
862 | | - | |
863 | | - | |
864 | | - | |
865 | | - | |
866 | | - | |
867 | | - | |
868 | | - | |
869 | | - | |
870 | | - | |
871 | | - | |
872 | | - | |
873 | | - | |
874 | | - | |
875 | | - | |
876 | | - | |
| 899 | + | |
| 900 | + | |
877 | 901 | | |
878 | | - | |
| 902 | + | |
879 | 903 | | |
880 | 904 | | |
881 | 905 | | |
| |||
Lines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
366 | 366 | | |
367 | 367 | | |
368 | 368 | | |
369 | | - | |
| 369 | + | |
370 | 370 | | |
371 | 371 | | |
372 | 372 | | |
| |||
378 | 378 | | |
379 | 379 | | |
380 | 380 | | |
381 | | - | |
| 381 | + | |
382 | 382 | | |
383 | 383 | | |
384 | 384 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
78 | 78 | | |
79 | 79 | | |
80 | 80 | | |
81 | | - | |
| 81 | + | |
82 | 82 | | |
83 | 83 | | |
84 | 84 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
99 | 99 | | |
100 | 100 | | |
101 | 101 | | |
102 | | - | |
| 102 | + | |
103 | 103 | | |
104 | 104 | | |
105 | 105 | | |
106 | 106 | | |
107 | 107 | | |
108 | | - | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
109 | 115 | | |
110 | | - | |
| 116 | + | |
| 117 | + | |
111 | 118 | | |
112 | 119 | | |
113 | 120 | | |
| 121 | + | |
| 122 | + | |
114 | 123 | | |
115 | 124 | | |
116 | 125 | | |
| |||
1166 | 1175 | | |
1167 | 1176 | | |
1168 | 1177 | | |
1169 | | - | |
| 1178 | + | |
1170 | 1179 | | |
1171 | | - | |
1172 | | - | |
1173 | | - | |
| 1180 | + | |
| 1181 | + | |
| 1182 | + | |
| 1183 | + | |
1174 | 1184 | | |
1175 | 1185 | | |
1176 | | - | |
| 1186 | + | |
1177 | 1187 | | |
1178 | | - | |
| 1188 | + | |
1179 | 1189 | | |
1180 | 1190 | | |
1181 | 1191 | | |
| |||
0 commit comments