Skip to content

Change sourcekitd_* functions to public #488

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions Source/SourceKittenFramework/Request.swift
Original file line number Diff line number Diff line change
Expand Up @@ -489,18 +489,23 @@ extension String {

let joinedParameters = parameters.map({ $0.replacingOccurrences(of: "!", with: "?") }).joined(separator: ", ")
let joinedReturnTypes = returnTypes.map({ $0.replacingOccurrences(of: "!", with: "?") }).joined(separator: ", ")
let lhs = "internal let \(name): @convention(c) (\(joinedParameters)) -> (\(joinedReturnTypes))"
let lhs = "let \(name): @convention(c) (\(joinedParameters)) -> (\(joinedReturnTypes))"
let rhs = "library.load(symbol: \"\(name)\")"
return "\(lhs) = \(rhs)".replacingOccurrences(of: "SourceKittenFramework.", with: "")
}
}
}

internal func libraryWrapperForModule(_ module: String, loadPath: String, linuxPath: String?, spmModule: String, compilerArguments: [String]) throws -> String {
internal func libraryWrapperForModule(_ module: String, // swiftlint:disable:this function_parameter_count
accessControlLevel: String,
loadPath: String,
linuxPath: String?,
spmModule: String,
compilerArguments: [String]) throws -> String {
let sourceKitResponse = try interfaceForModule(module, compilerArguments: compilerArguments)
let substructure = SwiftDocKey.getSubstructure(Structure(sourceKitResponse: sourceKitResponse).dictionary)!.map({ $0 as! [String: SourceKitRepresentable] })
let source = sourceKitResponse["key.sourcetext"] as! String
let freeFunctions = source.extractFreeFunctions(inSubstructure: substructure)
let freeFunctions = source.extractFreeFunctions(inSubstructure: substructure).map { "\(accessControlLevel) \($0)" }
let spmImport = "#if SWIFT_PACKAGE\nimport \(spmModule)\n#endif\n"
let library: String
if let linuxPath = linuxPath {
Expand Down
Loading