mirror of
https://github.com/github/codeql.git
synced 2026-07-09 13:35:38 +02:00
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>