mirror of
https://github.com/apple/sourcekit-lsp.git
synced 2026-03-02 18:23:24 +01:00
Merge pull request #100 from gmittert/SourceKitModuleWindows
Fixup SourceKit module on Windows
This commit is contained in:
@@ -169,8 +169,13 @@ public final class SourceKitServer: LanguageServer {
|
||||
return nil
|
||||
}
|
||||
|
||||
#if os(Windows)
|
||||
let pid: Int = unsafeBitCast(GetCurrentProcess(), to: Int.self)
|
||||
#else
|
||||
let pid: Int = Int(getpid())
|
||||
#endif
|
||||
let resp = try service.sendSync(InitializeRequest(
|
||||
processId: Int(getpid()),
|
||||
processId: pid,
|
||||
rootPath: nil,
|
||||
rootURL: (workspace?.rootPath).map { URL(fileURLWithPath: $0.pathString) },
|
||||
initializationOptions: InitializationOptions(),
|
||||
|
||||
@@ -42,7 +42,11 @@ final class SwiftSourceKitFramework {
|
||||
|
||||
init(dylib path: AbsolutePath) throws {
|
||||
self.path = path
|
||||
#if os(Windows)
|
||||
self.dylib = try dlopen(path.pathString, mode: [])
|
||||
#else
|
||||
self.dylib = try dlopen(path.pathString, mode: [.lazy, .local, .first, .deepBind])
|
||||
#endif
|
||||
|
||||
func dlsym_required<T>(_ handle: DLHandle, symbol: String) throws -> T {
|
||||
guard let sym: T = dlsym(handle, symbol: symbol) else {
|
||||
@@ -54,7 +58,7 @@ final class SwiftSourceKitFramework {
|
||||
// Workaround rdar://problem/43656704 by not constructing the value directly.
|
||||
// self.api = sourcekitd_functions_t(
|
||||
let ptr = UnsafeMutablePointer<sourcekitd_functions_t>.allocate(capacity: 1)
|
||||
bzero(UnsafeMutableRawPointer(ptr), MemoryLayout<sourcekitd_functions_t>.stride)
|
||||
memset(UnsafeMutableRawPointer(ptr), 0, MemoryLayout<sourcekitd_functions_t>.stride)
|
||||
var api = ptr.pointee
|
||||
ptr.deallocate()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user