Files
swift-mirror/test/SourceKit/CursorInfo/cursor_init.swift
Ben Barham 3ea9bed415 [SourceKit/CursorInfo] Add constructor to call results
Cursor info for a constructor would previously give the cursor info for
the containing type only. It now also adds cursor info for the
constructor itself in a "secondary_symbols" field.

Refactor `passCursorInfoForDecl` to use a single allocator rather than
keeping track of positions in a buffer and assigning everything at the
end of the function.

Refactor the various available refactoring gathering functions to take a
SmallVectorImpl and to not copy strings where they don't need to.

Resolves rdar://75385556
2021-03-30 13:23:59 +10:00

32 lines
1.0 KiB
Swift

struct A {
init(arg: Int) {}
init(arg: Bool) {}
}
func test() {
_ = A(arg: 1)
_ = A(arg: true)
}
// RUN: %sourcekitd-test -req=cursor -pos=7:7 %s -- %s | %FileCheck -check-prefix=CHECK-INT %s
// CHECK-INT: source.lang.swift.ref.struct
// CHECK-INT: s:11cursor_init1AV
// CHECK-INT: SECONDARY SYMBOLS BEGIN
// CHECK-INT-NEXT: source.lang.swift.ref.function.constructor {{[^|]*}}
// CHECK-INT-NEXT: init(arg:)
// CHECK-INT-NEXT: s:11cursor_init1AV3argACSi_tcfc
// CHECK-INT-NEXT: source.lang.swift
// CHECK-INT: -----
// CHECK-INT-NEXT: SECONDARY SYMBOLS END
// RUN: %sourcekitd-test -req=cursor -pos=8:7 %s -- %s | %FileCheck -check-prefix=CHECK-BOOL %s
// CHECK-BOOL: source.lang.swift.ref.struct
// CHECK-BOOL: s:11cursor_init1AV
// CHECK-BOOL: SECONDARY SYMBOLS BEGIN
// CHECK-BOOL-NEXT: source.lang.swift.ref.function.constructor {{[^|]*}}
// CHECK-BOOL-NEXT: init(arg:)
// CHECK-BOOL-NEXT: s:11cursor_init1AV3argACSb_tcfc
// CHECK-BOOL-NEXT: source.lang.swift
// CHECK-BOOL: -----
// CHECK-BOOL-NEXT: SECONDARY SYMBOLS END