mirror of
https://github.com/safishamsi/graphify.git
synced 2026-07-13 10:57:13 +00:00
ad7015262b
The Swift `enum_entry` handler in `_swift_extra_walk` iterated the entry's children only for the `simple_identifier` case name (emitting a `case_of` edge) and never descended into the sibling `enum_type_parameters` node, where associated-value types live (`enum_type_parameters -> user_type -> type_identifier`). As a result `case started(Session)` silently dropped the `Event -> Session` type reference. Descend into each `enum_type_parameters` child after emitting `case_of`, run `_swift_collect_type_refs` over its named children, and emit a `references` edge from the enum node to each collected type (context `type`, or `generic_arg` for generic roles), guarding target != enum node. Mirrors the existing Swift property/parameter/return-type emit style. Fixture: add `case failed(Config)` to `NetworkError` in sample.swift. Test: assert (`NetworkError`, `Config`) in references(context=type).
84 lines
1.4 KiB
Swift
84 lines
1.4 KiB
Swift
import Foundation
|
|
import UIKit
|
|
|
|
protocol Processor {
|
|
func process() -> [String]
|
|
}
|
|
|
|
protocol Loggable {
|
|
func log()
|
|
}
|
|
|
|
class BaseProcessor {}
|
|
|
|
class Result<T> {}
|
|
|
|
class DataProcessor: BaseProcessor, Processor {
|
|
private var items: [String] = []
|
|
var current: Result<DataProcessor> = Result<DataProcessor>()
|
|
|
|
init() {}
|
|
|
|
deinit {}
|
|
|
|
func addItem(_ item: String) {
|
|
items.append(item)
|
|
}
|
|
|
|
func process() -> [String] {
|
|
return validate(items)
|
|
}
|
|
|
|
func run(input: DataProcessor) -> Result<DataProcessor> {
|
|
return current
|
|
}
|
|
|
|
private func validate(_ data: [String]) -> [String] {
|
|
return data.filter { !$0.isEmpty }
|
|
}
|
|
}
|
|
|
|
struct Config {
|
|
let baseUrl: String
|
|
let timeout: Int
|
|
|
|
subscript(key: String) -> String? {
|
|
return nil
|
|
}
|
|
}
|
|
|
|
enum NetworkError {
|
|
case timeout
|
|
case connectionFailed
|
|
case unauthorized
|
|
case failed(Config)
|
|
|
|
func describe() -> String {
|
|
return "error"
|
|
}
|
|
}
|
|
|
|
actor CacheManager {
|
|
private var store: [String: String] = [:]
|
|
|
|
func get(_ key: String) -> String? {
|
|
return store[key]
|
|
}
|
|
}
|
|
|
|
extension DataProcessor: Loggable {
|
|
func log() {
|
|
print("logging")
|
|
}
|
|
}
|
|
|
|
extension Config {
|
|
func isValid() -> Bool {
|
|
return !baseUrl.isEmpty
|
|
}
|
|
}
|
|
|
|
func createProcessor() -> DataProcessor {
|
|
return DataProcessor()
|
|
}
|