@@ -1667,7 +1667,7 @@ extension SourceKitServer {
1667
1667
symbols: [ SymbolDetails ] ,
1668
1668
index: IndexStoreDB ? ,
1669
1669
useLocalFallback: Bool = false ,
1670
- extractOccurrences: ( String , IndexStoreDB ) -> [ SymbolOccurrence ]
1670
+ extractOccurrences: ( SymbolDetails , IndexStoreDB ) -> [ SymbolOccurrence ]
1671
1671
) -> [ ( occurrence: SymbolOccurrence ? , location: Location ) ] {
1672
1672
guard let symbol = symbols. first else {
1673
1673
return [ ]
@@ -1680,11 +1680,11 @@ extension SourceKitServer {
1680
1680
fallback = [ ]
1681
1681
}
1682
1682
1683
- guard let usr = symbol . usr , let index = index else {
1683
+ guard let index = index else {
1684
1684
return fallback
1685
1685
}
1686
1686
1687
- let occurs = extractOccurrences ( usr , index)
1687
+ let occurs = extractOccurrences ( symbol , index)
1688
1688
let resolved = occurs. compactMap { occur in
1689
1689
indexToLSPLocation ( occur. location) . map {
1690
1690
( occurrence: occur, location: $0)
@@ -1725,12 +1725,18 @@ extension SourceKitServer {
1725
1725
}
1726
1726
1727
1727
let resolved = self . extractIndexedOccurrences ( symbols: symbols, index: index, useLocalFallback: true ) {
1728
- ( usr, index) in
1728
+ ( symbolDetails, index) in
1729
+ guard let usr = symbolDetails. usr else { return [ ] }
1729
1730
logger. info ( " performing indexed jump-to-def with usr \( usr) " )
1730
1731
var occurs = index. occurrences ( ofUSR: usr, roles: [ . definition] )
1731
1732
if occurs. isEmpty {
1732
1733
occurs = index. occurrences ( ofUSR: usr, roles: [ . declaration] )
1733
1734
}
1735
+ if symbolDetails. isDynamic {
1736
+ occurs += occurs. flatMap {
1737
+ index. occurrences ( relatedToUSR: $0. symbol. usr, roles: . overrideOf)
1738
+ }
1739
+ }
1734
1740
return occurs
1735
1741
}
1736
1742
@@ -1783,7 +1789,8 @@ extension SourceKitServer {
1783
1789
)
1784
1790
)
1785
1791
let index = await self . workspaceForDocument ( uri: req. textDocument. uri) ? . index
1786
- let extractedResult = self . extractIndexedOccurrences ( symbols: symbols, index: index) { ( usr, index) in
1792
+ let extractedResult = self . extractIndexedOccurrences ( symbols: symbols, index: index) { ( symbolDetails, index) in
1793
+ guard let usr = symbolDetails. usr else { return [ ] }
1787
1794
var occurs = index. occurrences ( ofUSR: usr, roles: . baseOf)
1788
1795
if occurs. isEmpty {
1789
1796
occurs = index. occurrences ( relatedToUSR: usr, roles: . overrideOf)
@@ -1806,7 +1813,8 @@ extension SourceKitServer {
1806
1813
)
1807
1814
)
1808
1815
let index = await self . workspaceForDocument ( uri: req. textDocument. uri) ? . index
1809
- let extractedResult = self . extractIndexedOccurrences ( symbols: symbols, index: index) { ( usr, index) in
1816
+ let extractedResult = self . extractIndexedOccurrences ( symbols: symbols, index: index) { ( symbolDetails, index) in
1817
+ guard let usr = symbolDetails. usr else { return [ ] }
1810
1818
logger. info ( " performing indexed jump-to-def with usr \( usr) " )
1811
1819
var roles : SymbolRole = [ . reference]
1812
1820
if req. context. includeDeclaration {
@@ -1852,8 +1860,9 @@ extension SourceKitServer {
1852
1860
)
1853
1861
let index = await self . workspaceForDocument ( uri: req. textDocument. uri) ? . index
1854
1862
// For call hierarchy preparation we only locate the definition
1855
- let extractedResult = self . extractIndexedOccurrences ( symbols: symbols, index: index) { ( usr, index) in
1856
- index. occurrences ( ofUSR: usr, roles: [ . definition, . declaration] )
1863
+ let extractedResult = self . extractIndexedOccurrences ( symbols: symbols, index: index) { ( symbolDetails, index) in
1864
+ guard let usr = symbolDetails. usr else { return [ ] }
1865
+ return index. occurrences ( ofUSR: usr, roles: [ . definition, . declaration] )
1857
1866
}
1858
1867
return extractedResult. compactMap { info -> CallHierarchyItem ? in
1859
1868
guard let occurrence = info. occurrence else {
@@ -2009,8 +2018,9 @@ extension SourceKitServer {
2009
2018
guard let index = await self . workspaceForDocument ( uri: req. textDocument. uri) ? . index else {
2010
2019
return [ ]
2011
2020
}
2012
- let extractedResult = self . extractIndexedOccurrences ( symbols: symbols, index: index) { ( usr, index) in
2013
- index. occurrences ( ofUSR: usr, roles: [ . definition, . declaration] )
2021
+ let extractedResult = self . extractIndexedOccurrences ( symbols: symbols, index: index) { ( symbolDetails, index) in
2022
+ guard let usr = symbolDetails. usr else { return [ ] }
2023
+ return index. occurrences ( ofUSR: usr, roles: [ . definition, . declaration] )
2014
2024
}
2015
2025
return extractedResult. compactMap { info -> TypeHierarchyItem ? in
2016
2026
guard let occurrence = info. occurrence else {
0 commit comments