mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
This allows building sourcekitd and swift-refactor with `SWIFT_BUILD_SWIFT_SYNTAX=NO`. In these builds, the `relatedidents` and `find-syntactic-rename-ranges` requests will always return an error.
45 lines
1.6 KiB
Swift
45 lines
1.6 KiB
Swift
public struct Outer {
|
|
@propertyWrapper
|
|
public struct InnerWrapper<T> {
|
|
public var wrappedValue: T
|
|
public /*init:def*/init(initialValue: T) {
|
|
self.wrappedValue = initialValue
|
|
}
|
|
public /*body:def*/init(first: Int, body: () -> T) {
|
|
self.wrappedValue = body()
|
|
}
|
|
}
|
|
}
|
|
|
|
var globalInt: Int { return 17 }
|
|
public struct HasWrappers {
|
|
@Outer.InnerWrapper
|
|
public var x: Int = globalInt
|
|
|
|
@Outer . /*body:call*/InnerWrapper(first: 20, body: { globalInt })
|
|
public var y: Int
|
|
|
|
@Outer . /*body:call*/InnerWrapper(first: 10, body: {
|
|
struct Inner {
|
|
@Outer . /*init:call*/InnerWrapper(initialValue: globalInt)
|
|
var x: Int
|
|
}
|
|
return Inner().x + globalInt
|
|
})
|
|
public var z: Int
|
|
}
|
|
|
|
func uses() {
|
|
_ = Outer . /*body:call*/InnerWrapper(first: 42, body: { 45 })
|
|
_ = Outer . /*init:call*/InnerWrapper(initialValue: 0)
|
|
}
|
|
|
|
|
|
// REQUIRES: swift_swift_parser
|
|
// RUN: %empty-directory(%t.result)
|
|
// RUN: %empty-directory(%t.ranges)
|
|
// RUN: %refactor -find-rename-ranges -source-filename %s -pos="init" -is-function-like -old-name "init(initialValue:)" >> %t.ranges/property-wrapper-init.swift
|
|
// RUN: %refactor -find-rename-ranges -source-filename %s -pos="body" -is-function-like -old-name "init(first:body:)" >> %t.ranges/property-wrapper-body.swift
|
|
// RUN: diff -u %S/Outputs/property-wrapper-init/init.swift.expected %t.ranges/property-wrapper-init.swift
|
|
// RUN: diff -u %S/Outputs/property-wrapper-init/body.swift.expected %t.ranges/property-wrapper-body.swift
|