@@ -2464,21 +2464,32 @@ extension SourceKitLSPServer {
24642464 guard let index = await workspaceForDocument ( uri: req. textDocument. uri) ? . index ( checkedFor: . deletedFiles) else {
24652465 return nil
24662466 }
2467- let usrs =
2468- symbols
2469- . filter {
2470- // Only include references to type. For example, we don't want to find the type hierarchy of a constructor when
2471- // starting the type hierarchy on `Foo()``.
2472- switch $0. kind {
2473- case . class, . enum, . interface, . struct: return true
2474- default : return false
2475- }
2467+ let usrs = symbols. filter {
2468+ // Only include references to type. For example, we don't want to find the type hierarchy of a constructor when
2469+ // starting the type hierarchy on `Foo()`.
2470+ // Consider a symbol a class if its kind is `nil`, eg. for a symbol returned by clang's SymbolInfo, which
2471+ // doesn't support the `kind` field.
2472+ switch $0. kind {
2473+ case . class, . enum, . interface, . struct, nil : return true
2474+ default : return false
24762475 }
2477- . compactMap ( \. usr)
2476+ } . compactMap ( \. usr)
2477+
24782478 let typeHierarchyItems = usrs. compactMap { ( usr) -> TypeHierarchyItem ? in
24792479 guard let info = index. primaryDefinitionOrDeclarationOccurrence ( ofUSR: usr) else {
24802480 return nil
24812481 }
2482+ // Filter symbols based on their kind in the index since the filter on the symbol info response might have
2483+ // returned `nil` for the kind, preventing us from doing any filtering there.
2484+ switch info. symbol. kind {
2485+ case . unknown, . macro, . function, . variable, . field, . enumConstant, . instanceMethod, . classMethod, . staticMethod,
2486+ . instanceProperty, . classProperty, . staticProperty, . constructor, . destructor, . conversionFunction, . parameter,
2487+ . concept, . commentTag:
2488+ return nil
2489+ case . module, . namespace, . namespaceAlias, . enum, . struct, . class, . protocol, . extension, . union, . typealias,
2490+ . using:
2491+ break
2492+ }
24822493 return self . indexToLSPTypeHierarchyItem (
24832494 definition: info,
24842495 moduleName: info. location. moduleName,
0 commit comments