Files
swift-mirror/test/SourceKit/CodeComplete/complete_swift_overlay.swift
Ben Barham 15ada41a5a [SourceKit] Make sure to use overlays when reading files
Two paths missed setting up overlays:
  - `CompletionInstance` when checking files from dependencies
  - `SwiftASTManager` when reading in files that it would later replace
    all inputs with

(1) would cause the AST context not to be re-used, even though nothing
had changed. (2) caused all non-completion functionality to fail for any
symbols within files only specified by the overlay.

Resolves rdar://85508213.
2022-03-24 15:30:02 -07:00

45 lines
1.1 KiB
Swift

// RUN: %empty-directory(%t)
// RUN: split-file %s %t
// RUN: sed -e "s@NAME_DIR@%{/t:regex_replacement}/A@g" -e "s@EXTERNAL_DIR@%{/t:regex_replacement}/B@g" %t/base.yaml > %t/overlay.yaml
// RUN: %sourcekitd-test \
// RUN: -req=global-config -req-opts=completion_check_dependency_interval=0 == \
// RUN: -req=complete -pos=2:5 %t/A/a.swift -- -vfsoverlay %t/overlay.yaml %t/A/a.swift %t/A/b.swift == \
// RUN: -req=complete -pos=2:5 %t/A/a.swift -- -vfsoverlay %t/overlay.yaml %t/A/a.swift %t/A/b.swift \
// RUN: | %FileCheck %s
// CHECK-LABEL: key.results: [
// CHECK-DAG: key.name: "method()"
// CHECK: ]
// CHECK-NOT: key.reusingastcontext: 1
// CHECK-LABEL: key.results: [
// CHECK-DAG: key.name: "method()"
// CHECK: ]
// CHECK: key.reusingastcontext: 1
//--- A/a.swift
func a(b: B) {
b.
}
//--- B/b.swift
struct B {
func method() {}
}
//--- base.yaml
{
version: 0,
redirecting-with: "fallback",
use-external-names: true,
roots: [
{
type: "directory-remap",
name: "NAME_DIR",
external-contents: "EXTERNAL_DIR"
}
]
}