mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
The main problem that prevented us from reusing the ASTContext was that we weren’t remapping the `LocToResolve` in the temporary buffer that only contains the re-parsed function back to the original buffer. Thus `NodeFinder` couldn’t find the node that we want to get cursor info for. Getting AST reuse to work for top-level items is harder because it currently heavily relies on the `HasCodeCompletion` state being set on the parser result. I’ll try that in a follow-up PR. rdar://103251263
28 lines
1.0 KiB
Swift
28 lines
1.0 KiB
Swift
// RUN: %sourcekitd-test -req=cursor -pos=%(line + 2):7 %s -- %s == -req=cursor -pos=%(line + 3):7 %s -- %s | %FileCheck %s --check-prefix IN-FUNCTION
|
|
func foo() {
|
|
let inFunctionA = 1
|
|
let inFunctionB = "hi"
|
|
}
|
|
|
|
// IN-FUNCTION: source.lang.swift.decl.var.local
|
|
// IN-FUNCTION-NEXT: inFunctionA
|
|
// IN-FUNCTION: DID REUSE AST CONTEXT: 0
|
|
// IN-FUNCTION: source.lang.swift.decl.var.local
|
|
// IN-FUNCTION-NEXT: inFunctionB
|
|
// IN-FUNCTION: DID REUSE AST CONTEXT: 1
|
|
|
|
// RUN: %sourcekitd-test -req=cursor -pos=%(line + 3):9 %s -- %s == -req=cursor -pos=%(line + 4):9 %s -- %s | %FileCheck %s --check-prefix IN-INSTANCE-METHOD
|
|
struct MyStruct {
|
|
func test() {
|
|
let inInstanceMethod1 = 2
|
|
let inInstanceMethod2 = "hello"
|
|
}
|
|
}
|
|
|
|
// IN-INSTANCE-METHOD: source.lang.swift.decl.var.local
|
|
// IN-INSTANCE-METHOD-NEXT: inInstanceMethod1
|
|
// IN-INSTANCE-METHOD: DID REUSE AST CONTEXT: 0
|
|
// IN-INSTANCE-METHOD: source.lang.swift.decl.var.local
|
|
// IN-INSTANCE-METHOD-NEXT: inInstanceMethod2
|
|
// IN-INSTANCE-METHOD: DID REUSE AST CONTEXT: 1
|