Commit b67ac6b
fix property and accessor locations using PSI
K1 IrProperty.startOffset includes leading modifiers (private, abstract,
lateinit, annotations) in the span start; K2 already starts at val/var.
Walk the PSI tree from p.startOffset to the enclosing KtProperty, then
use valOrVarKeyword.startOffset as the declaration start. This yields a
consistent location spanning val/var through the end of the full property
declaration (including explicit getter/setter bodies) in both K1 and K2.
The PSI-based location is restricted to unspecialised extractions
(classTypeArgsIncludingOuterClasses.isNullOrEmpty()). Specialised generic
instances (e.g. C<String>.prop) continue to use the binary whole-file
location returned by getLocation(p, typeArgs), preserving the existing
behaviour that keeps them absent from fromSource() queries.
Synthesised accessors (DEFAULT_PROPERTY_ACCESSOR origin) represent the
entire property declaration, so they now share the property's location
via accessorOverride(). Explicit getter/setter bodies keep their own
independently computed location.
The visibility merge in extractFunction is extended to accept an
overriddenAttributes parameter from the caller; the internal fake-override
visibility adjustment (DescriptorVisibilities.PUBLIC for Java binary Object
methods) is merged with any caller-supplied attributes so that neither
overrides the other silently.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>1 parent 4f8ea3d commit b67ac6b
4 files changed
Lines changed: 93 additions & 28 deletions
File tree
- java
- kotlin-extractor/src/main/kotlin
- ql/test-kotlin1/library-tests
- comments
- modifiers
- properties
Lines changed: 73 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1748 | 1748 | | |
1749 | 1749 | | |
1750 | 1750 | | |
1751 | | - | |
| 1751 | + | |
| 1752 | + | |
1752 | 1753 | | |
1753 | 1754 | | |
1754 | 1755 | | |
| |||
1766 | 1767 | | |
1767 | 1768 | | |
1768 | 1769 | | |
1769 | | - | |
| 1770 | + | |
1770 | 1771 | | |
| 1772 | + | |
| 1773 | + | |
| 1774 | + | |
| 1775 | + | |
| 1776 | + | |
| 1777 | + | |
| 1778 | + | |
| 1779 | + | |
| 1780 | + | |
| 1781 | + | |
1771 | 1782 | | |
1772 | 1783 | | |
1773 | 1784 | | |
| |||
1776 | 1787 | | |
1777 | 1788 | | |
1778 | 1789 | | |
1779 | | - | |
| 1790 | + | |
1780 | 1791 | | |
1781 | 1792 | | |
1782 | 1793 | | |
| |||
2659 | 2670 | | |
2660 | 2671 | | |
2661 | 2672 | | |
| 2673 | + | |
| 2674 | + | |
| 2675 | + | |
2662 | 2676 | | |
2663 | | - | |
2664 | | - | |
| 2677 | + | |
| 2678 | + | |
| 2679 | + | |
| 2680 | + | |
2665 | 2681 | | |
2666 | 2682 | | |
2667 | 2683 | | |
2668 | 2684 | | |
2669 | 2685 | | |
2670 | 2686 | | |
2671 | 2687 | | |
| 2688 | + | |
| 2689 | + | |
| 2690 | + | |
| 2691 | + | |
| 2692 | + | |
| 2693 | + | |
| 2694 | + | |
2672 | 2695 | | |
2673 | 2696 | | |
2674 | 2697 | | |
| |||
2682 | 2705 | | |
2683 | 2706 | | |
2684 | 2707 | | |
2685 | | - | |
| 2708 | + | |
| 2709 | + | |
2686 | 2710 | | |
2687 | 2711 | | |
2688 | 2712 | | |
| |||
2712 | 2736 | | |
2713 | 2737 | | |
2714 | 2738 | | |
2715 | | - | |
| 2739 | + | |
| 2740 | + | |
2716 | 2741 | | |
2717 | 2742 | | |
2718 | 2743 | | |
| |||
2931 | 2956 | | |
2932 | 2957 | | |
2933 | 2958 | | |
| 2959 | + | |
| 2960 | + | |
| 2961 | + | |
| 2962 | + | |
| 2963 | + | |
| 2964 | + | |
| 2965 | + | |
| 2966 | + | |
| 2967 | + | |
| 2968 | + | |
| 2969 | + | |
| 2970 | + | |
| 2971 | + | |
| 2972 | + | |
| 2973 | + | |
| 2974 | + | |
| 2975 | + | |
| 2976 | + | |
| 2977 | + | |
| 2978 | + | |
| 2979 | + | |
| 2980 | + | |
| 2981 | + | |
| 2982 | + | |
| 2983 | + | |
| 2984 | + | |
| 2985 | + | |
| 2986 | + | |
| 2987 | + | |
| 2988 | + | |
| 2989 | + | |
| 2990 | + | |
| 2991 | + | |
| 2992 | + | |
| 2993 | + | |
| 2994 | + | |
| 2995 | + | |
| 2996 | + | |
| 2997 | + | |
| 2998 | + | |
2934 | 2999 | | |
2935 | 3000 | | |
2936 | 3001 | | |
| |||
2957 | 3022 | | |
2958 | 3023 | | |
2959 | 3024 | | |
2960 | | - | |
| 3025 | + | |
2961 | 3026 | | |
2962 | 3027 | | |
2963 | 3028 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
22 | | - | |
23 | 22 | | |
| 23 | + | |
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
| |||
Lines changed: 6 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
| 5 | + | |
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
| 10 | + | |
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
15 | | - | |
| 15 | + | |
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| |||
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
28 | | - | |
| 28 | + | |
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
| |||
76 | 76 | | |
77 | 77 | | |
78 | 78 | | |
79 | | - | |
80 | | - | |
81 | 79 | | |
82 | 80 | | |
83 | 81 | | |
84 | 82 | | |
| 83 | + | |
| 84 | + | |
85 | 85 | | |
86 | 86 | | |
87 | 87 | | |
Lines changed: 13 additions & 13 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | | - | |
| 7 | + | |
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
13 | | - | |
14 | | - | |
15 | | - | |
16 | | - | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
20 | | - | |
21 | | - | |
22 | | - | |
23 | | - | |
24 | | - | |
25 | | - | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
29 | | - | |
30 | | - | |
| 29 | + | |
| 30 | + | |
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
| |||
0 commit comments