(message)
| 360 | """nest def is api, return by locals()""" |
| 361 | |
| 362 | def build_initialize(message): |
| 363 | rootUri = message["params"]["rootUri"] |
| 364 | root_path = os.path.abspath(os.path.expanduser(uri2filepath(rootUri))) |
| 365 | cache_path = os.path.join( |
| 366 | os.path.expanduser("~/Library/Caches/xcode-build-server"), |
| 367 | root_path.replace("/", "-"), |
| 368 | ) |
| 369 | bspVersion = message["params"]["bspVersion"] |
| 370 | |
| 371 | state = State( |
| 372 | root_path, cache_path, new_version=version_compare("2.2.0", bspVersion) <= 0 |
| 373 | ) |
| 374 | global shared_state |
| 375 | if shared_state: |
| 376 | logger.warn("already initialized!!") |
| 377 | else: |
| 378 | shared_state = state |
| 379 | |
| 380 | # FIXME: currently indexStorePath can't change dynamicly. have to restart server. |
| 381 | # though it rarely changes.. need to watch sourcekit-lsp implementation |
| 382 | indexStorePath = state.indexStorePath |
| 383 | if not indexStorePath: |
| 384 | indexStorePath = f"{cache_path}/indexStorePath" |
| 385 | |
| 386 | indexStorePathHash = hashlib.md5(indexStorePath.encode("utf-8")).hexdigest() |
| 387 | # database should unique to a indexStorePath |
| 388 | indexDatabasePath = f"{cache_path}/indexDatabasePath-{indexStorePathHash}" |
| 389 | |
| 390 | return { |
| 391 | "jsonrpc": "2.0", |
| 392 | "id": message["id"], |
| 393 | "result": { |
| 394 | "displayName": "xcode build server", |
| 395 | "version": VERSION, |
| 396 | "bspVersion": "2.2.0", |
| 397 | "rootUri": rootUri, |
| 398 | "capabilities": { |
| 399 | "languageIds": ["c", "cpp", "objective-c", "objective-cpp", "swift"] |
| 400 | }, |
| 401 | "data": { |
| 402 | "indexDatabasePath": indexDatabasePath, |
| 403 | "indexStorePath": indexStorePath, |
| 404 | "sourceKitOptionsProvider": True, |
| 405 | }, |
| 406 | "dataKind": "sourceKit", |
| 407 | }, |
| 408 | } |
| 409 | |
| 410 | def build_initialized(message): |
| 411 | shared_state.start_observe_changes() |
nothing calls this directly
no test coverage detected