mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Fixes missing Xcode "Quick Help" for enum values as switch case patterns
This commit is contained in:
@@ -310,6 +310,10 @@ bool SemaAnnotator::walkToTypeReprPost(TypeRepr *T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::pair<bool, Pattern *> SemaAnnotator::walkToPatternPre(Pattern *P) {
|
std::pair<bool, Pattern *> SemaAnnotator::walkToPatternPre(Pattern *P) {
|
||||||
|
if (auto *EP = dyn_cast<EnumElementPattern>(P)) {
|
||||||
|
return { passReference(EP->getElementDecl(), EP->getType(), DeclNameLoc(EP->getLoc())), P };
|
||||||
|
}
|
||||||
|
|
||||||
auto *TP = dyn_cast<TypedPattern>(P);
|
auto *TP = dyn_cast<TypedPattern>(P);
|
||||||
if (!TP || !TP->isPropagatedType())
|
if (!TP || !TP->isPropagatedType())
|
||||||
return { true, P };
|
return { true, P };
|
||||||
|
|||||||
21
test/SourceKit/Indexing/index_enum_case.swift
Normal file
21
test/SourceKit/Indexing/index_enum_case.swift
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
// RUN: %sourcekitd-test -req=index %s -- -serialize-diagnostics -serialize-diagnostics-path %t.dia %s | %sed_clean > %t.response
|
||||||
|
// RUN: diff -u %s.response %t.response
|
||||||
|
|
||||||
|
public enum E {
|
||||||
|
|
||||||
|
case one, two(a: String), three
|
||||||
|
|
||||||
|
var text: String {
|
||||||
|
switch self {
|
||||||
|
case .one:
|
||||||
|
return "one"
|
||||||
|
case .two(let a):
|
||||||
|
return a
|
||||||
|
case .three:
|
||||||
|
return "three"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
let e: E = .two(a:"String")
|
||||||
133
test/SourceKit/Indexing/index_enum_case.swift.response
Normal file
133
test/SourceKit/Indexing/index_enum_case.swift.response
Normal file
@@ -0,0 +1,133 @@
|
|||||||
|
{
|
||||||
|
key.hash: <hash>,
|
||||||
|
key.dependencies: [
|
||||||
|
{
|
||||||
|
key.kind: source.lang.swift.import.module.swift,
|
||||||
|
key.name: "Swift",
|
||||||
|
key.filepath: Swift.swiftmodule,
|
||||||
|
key.hash: <hash>,
|
||||||
|
key.is_system: 1
|
||||||
|
}
|
||||||
|
],
|
||||||
|
key.entities: [
|
||||||
|
{
|
||||||
|
key.kind: source.lang.swift.decl.enum,
|
||||||
|
key.name: "E",
|
||||||
|
key.usr: "s:O15index_enum_case1E",
|
||||||
|
key.line: 4,
|
||||||
|
key.column: 13,
|
||||||
|
key.entities: [
|
||||||
|
{
|
||||||
|
key.kind: source.lang.swift.decl.enumelement,
|
||||||
|
key.name: "one",
|
||||||
|
key.usr: "s:FO15index_enum_case1E3oneFMS0_S0_",
|
||||||
|
key.line: 6,
|
||||||
|
key.column: 10
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key.kind: source.lang.swift.decl.enumelement,
|
||||||
|
key.name: "two",
|
||||||
|
key.usr: "s:FO15index_enum_case1E3twoFMS0_FT1aSS_S0_",
|
||||||
|
key.line: 6,
|
||||||
|
key.column: 15,
|
||||||
|
key.entities: [
|
||||||
|
{
|
||||||
|
key.kind: source.lang.swift.ref.struct,
|
||||||
|
key.name: "String",
|
||||||
|
key.usr: "s:SS",
|
||||||
|
key.line: 6,
|
||||||
|
key.column: 22
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key.kind: source.lang.swift.decl.enumelement,
|
||||||
|
key.name: "three",
|
||||||
|
key.usr: "s:FO15index_enum_case1E5threeFMS0_S0_",
|
||||||
|
key.line: 6,
|
||||||
|
key.column: 31
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key.kind: source.lang.swift.decl.var.instance,
|
||||||
|
key.name: "text",
|
||||||
|
key.usr: "s:vO15index_enum_case1E4textSS",
|
||||||
|
key.line: 8,
|
||||||
|
key.column: 9,
|
||||||
|
key.entities: [
|
||||||
|
{
|
||||||
|
key.kind: source.lang.swift.decl.function.accessor.getter,
|
||||||
|
key.usr: "s:FO15index_enum_case1Eg4textSS",
|
||||||
|
key.line: 8,
|
||||||
|
key.column: 22,
|
||||||
|
key.entities: [
|
||||||
|
{
|
||||||
|
key.kind: source.lang.swift.ref.enumelement,
|
||||||
|
key.name: "one",
|
||||||
|
key.usr: "s:FO15index_enum_case1E3oneFMS0_S0_",
|
||||||
|
key.line: 10,
|
||||||
|
key.column: 15
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key.kind: source.lang.swift.ref.enumelement,
|
||||||
|
key.name: "two",
|
||||||
|
key.usr: "s:FO15index_enum_case1E3twoFMS0_FT1aSS_S0_",
|
||||||
|
key.line: 12,
|
||||||
|
key.column: 15
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key.kind: source.lang.swift.ref.enumelement,
|
||||||
|
key.name: "three",
|
||||||
|
key.usr: "s:FO15index_enum_case1E5threeFMS0_S0_",
|
||||||
|
key.line: 14,
|
||||||
|
key.column: 15
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key.kind: source.lang.swift.ref.struct,
|
||||||
|
key.name: "String",
|
||||||
|
key.usr: "s:SS",
|
||||||
|
key.line: 8,
|
||||||
|
key.column: 15
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key.kind: source.lang.swift.decl.var.global,
|
||||||
|
key.name: "e",
|
||||||
|
key.usr: "s:v15index_enum_case1eOS_1E",
|
||||||
|
key.line: 21,
|
||||||
|
key.column: 5,
|
||||||
|
key.entities: [
|
||||||
|
{
|
||||||
|
key.kind: source.lang.swift.decl.function.accessor.getter,
|
||||||
|
key.usr: "s:F15index_enum_caseg1eOS_1E",
|
||||||
|
key.line: 21,
|
||||||
|
key.column: 5
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key.kind: source.lang.swift.decl.function.accessor.setter,
|
||||||
|
key.usr: "s:F15index_enum_cases1eOS_1E",
|
||||||
|
key.line: 21,
|
||||||
|
key.column: 5
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key.kind: source.lang.swift.ref.enum,
|
||||||
|
key.name: "E",
|
||||||
|
key.usr: "s:O15index_enum_case1E",
|
||||||
|
key.line: 21,
|
||||||
|
key.column: 8
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key.kind: source.lang.swift.ref.enumelement,
|
||||||
|
key.name: "two",
|
||||||
|
key.usr: "s:FO15index_enum_case1E3twoFMS0_FT1aSS_S0_",
|
||||||
|
key.line: 21,
|
||||||
|
key.column: 13
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user