You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Since Xcode uses absolute paths for its arguments, this is only easily reproducible in sourcekit-lsp.
Steps to reproduce:
Build sourcekit-lsp from my fork which changes sourcekit-lsp's build arguments to use relative path handling; you could probably do the same for Xcode's SPM integration.
Open the swift-llbuild2 checkout using an editor hooked up to your custom sourcekit-lsp (and make sure it's using the same toolchain you used to build the swift-llbuild2) and make sure you've set SOURCEKIT_LOGGING=3 to enable sourcekit logging.
Observe from the sourcekit logs that the first code completion isn't reusing the AST context. If you do a subsequent code completion within 5 seconds, it will reuse the AST context, if you wait longer than 5 seconds, the next code completion will not reuse the AST context.
The text was updated successfully, but these errors were encountered:
Environment
Tested with Xcode 12 - 12.3 beta 1
Additional Detail from JIRA
md5: 6816508ed1745e3c1d975ea58cbcece3
Issue Description:
Sourcekitd's AST reuse for code completion appears to be fragile when relative paths and/or -working-dir arguments are being used.
When this issues appears, code completion shows incrementality/AST reuse (visible by setting SOURCEKIT_LOGGING=3 and checking for the reusingastcontext flag in the sourcekit code completion reply) for ~5 seconds or so, and then loses incrementality, making something in this method the likely cause (https://github.com/apple/swift/blob/c9dbef61b2122277e42d450f34ec0f3be4fcea95/lib/IDE/CompletionInstance.cpp#L235).
Since Xcode uses absolute paths for its arguments, this is only easily reproducible in sourcekit-lsp.
Steps to reproduce:
Build sourcekit-lsp from my fork which changes sourcekit-lsp's build arguments to use relative path handling; you could probably do the same for Xcode's SPM integration.
Checkout and build https://github.com/apple/swift-llbuild2 using swift build
Open the swift-llbuild2 checkout using an editor hooked up to your custom sourcekit-lsp (and make sure it's using the same toolchain you used to build the swift-llbuild2) and make sure you've set SOURCEKIT_LOGGING=3 to enable sourcekit logging.
Navigate to https://github.com/apple/swift-llbuild2/blob/85b95bcd53b499af567d9b85cb5cdfe72b78fbbc/Sources/llbuild2/Core/Engine.swift#L55 and trigger code completion by copying and pasting "self" and then typing .
Observe from the sourcekit logs that the first code completion isn't reusing the AST context. If you do a subsequent code completion within 5 seconds, it will reuse the AST context, if you wait longer than 5 seconds, the next code completion will not reuse the AST context.
The text was updated successfully, but these errors were encountered: