[SourceKit] DocInfo: Update the UIdent for synthesized extensions to respect the synthesized targets instead of the original extended types.

This commit is contained in:
Xi Ge
2016-03-31 18:11:14 -07:00
parent 7cb49d7f4b
commit 8afcf65fa2
5 changed files with 41 additions and 21 deletions

View File

@@ -6582,7 +6582,7 @@ var FooSubUnnamedEnumeratorA1: Int { get }
] ]
}, },
{ {
key.kind: source.lang.swift.decl.extension.struct, key.kind: source.lang.swift.decl.extension.enum,
key.offset: 1733, key.offset: 1733,
key.length: 91, key.length: 91,
key.conforms: [ key.conforms: [
@@ -6618,7 +6618,7 @@ var FooSubUnnamedEnumeratorA1: Int { get }
] ]
}, },
{ {
key.kind: source.lang.swift.decl.extension.struct, key.kind: source.lang.swift.decl.extension.enum,
key.offset: 1826, key.offset: 1826,
key.length: 96, key.length: 96,
key.conforms: [ key.conforms: [
@@ -6654,7 +6654,7 @@ var FooSubUnnamedEnumeratorA1: Int { get }
] ]
}, },
{ {
key.kind: source.lang.swift.decl.extension.struct, key.kind: source.lang.swift.decl.extension.enum,
key.offset: 1924, key.offset: 1924,
key.length: 76, key.length: 76,
key.conforms: [ key.conforms: [
@@ -6690,7 +6690,7 @@ var FooSubUnnamedEnumeratorA1: Int { get }
] ]
}, },
{ {
key.kind: source.lang.swift.decl.extension.struct, key.kind: source.lang.swift.decl.extension.enum,
key.offset: 2002, key.offset: 2002,
key.length: 201, key.length: 201,
key.conforms: [ key.conforms: [
@@ -6813,7 +6813,7 @@ var FooSubUnnamedEnumeratorA1: Int { get }
] ]
}, },
{ {
key.kind: source.lang.swift.decl.extension.struct, key.kind: source.lang.swift.decl.extension.enum,
key.offset: 2205, key.offset: 2205,
key.length: 48, key.length: 48,
key.conforms: [ key.conforms: [
@@ -6830,7 +6830,7 @@ var FooSubUnnamedEnumeratorA1: Int { get }
} }
}, },
{ {
key.kind: source.lang.swift.decl.extension.struct, key.kind: source.lang.swift.decl.extension.enum,
key.offset: 2255, key.offset: 2255,
key.length: 91, key.length: 91,
key.conforms: [ key.conforms: [
@@ -6866,7 +6866,7 @@ var FooSubUnnamedEnumeratorA1: Int { get }
] ]
}, },
{ {
key.kind: source.lang.swift.decl.extension.struct, key.kind: source.lang.swift.decl.extension.enum,
key.offset: 2348, key.offset: 2348,
key.length: 129, key.length: 129,
key.conforms: [ key.conforms: [
@@ -6901,7 +6901,7 @@ var FooSubUnnamedEnumeratorA1: Int { get }
] ]
}, },
{ {
key.kind: source.lang.swift.decl.extension.struct, key.kind: source.lang.swift.decl.extension.enum,
key.offset: 2479, key.offset: 2479,
key.length: 43, key.length: 43,
key.conforms: [ key.conforms: [
@@ -6981,7 +6981,7 @@ var FooSubUnnamedEnumeratorA1: Int { get }
] ]
}, },
{ {
key.kind: source.lang.swift.decl.extension.protocol, key.kind: source.lang.swift.decl.extension.struct,
key.doc.full_as_xml: "<Other><Name></Name><Declaration>extension FooRuncingOptions</Declaration><Abstract><Para><codeVoice>OptionSet</codeVoice> requirements for which default implementations are supplied.</Para></Abstract><Discussion><Note><Para>A type conforming to <codeVoice>OptionSet</codeVoice> can implement any of these initializers or methods, and those implementations will be used in lieu of these defaults.</Para></Note></Discussion></Other>", key.doc.full_as_xml: "<Other><Name></Name><Declaration>extension FooRuncingOptions</Declaration><Abstract><Para><codeVoice>OptionSet</codeVoice> requirements for which default implementations are supplied.</Para></Abstract><Discussion><Note><Para>A type conforming to <codeVoice>OptionSet</codeVoice> can implement any of these initializers or methods, and those implementations will be used in lieu of these defaults.</Para></Note></Discussion></Other>",
key.offset: 2710, key.offset: 2710,
key.length: 158, key.length: 158,
@@ -7051,7 +7051,7 @@ var FooSubUnnamedEnumeratorA1: Int { get }
] ]
}, },
{ {
key.kind: source.lang.swift.decl.extension.protocol, key.kind: source.lang.swift.decl.extension.struct,
key.generic_requirements: [ key.generic_requirements: [
{ {
key.description: "Element == Self" key.description: "Element == Self"
@@ -7126,7 +7126,7 @@ var FooSubUnnamedEnumeratorA1: Int { get }
] ]
}, },
{ {
key.kind: source.lang.swift.decl.extension.protocol, key.kind: source.lang.swift.decl.extension.struct,
key.generic_requirements: [ key.generic_requirements: [
{ {
key.description: "RawValue : BitwiseOperations" key.description: "RawValue : BitwiseOperations"
@@ -7211,7 +7211,7 @@ var FooSubUnnamedEnumeratorA1: Int { get }
] ]
}, },
{ {
key.kind: source.lang.swift.decl.extension.protocol, key.kind: source.lang.swift.decl.extension.struct,
key.doc.full_as_xml: "<Other><Name></Name><Declaration>extension FooRuncingOptions</Declaration><Abstract><Para><codeVoice>SetAlgebra</codeVoice> requirements for which default implementations are supplied.</Para></Abstract><Discussion><Note><Para>A type conforming to <codeVoice>SetAlgebra</codeVoice> can implement any of these initializers or methods, and those implementations will be used in lieu of these defaults.</Para></Note></Discussion></Other>", key.doc.full_as_xml: "<Other><Name></Name><Declaration>extension FooRuncingOptions</Declaration><Abstract><Para><codeVoice>SetAlgebra</codeVoice> requirements for which default implementations are supplied.</Para></Abstract><Discussion><Note><Para>A type conforming to <codeVoice>SetAlgebra</codeVoice> can implement any of these initializers or methods, and those implementations will be used in lieu of these defaults.</Para></Note></Discussion></Other>",
key.offset: 3247, key.offset: 3247,
key.length: 744, key.length: 744,

View File

@@ -2670,7 +2670,7 @@ func genfoo<T1 : Prot, T2 : cake.C1 where T1.Element == Int, T2.Element == T1.El
] ]
}, },
{ {
key.kind: source.lang.swift.decl.extension.struct, key.kind: source.lang.swift.decl.extension.enum,
key.offset: 1242, key.offset: 1242,
key.length: 83, key.length: 83,
key.conforms: [ key.conforms: [
@@ -2706,7 +2706,7 @@ func genfoo<T1 : Prot, T2 : cake.C1 where T1.Element == Int, T2.Element == T1.El
] ]
}, },
{ {
key.kind: source.lang.swift.decl.extension.struct, key.kind: source.lang.swift.decl.extension.enum,
key.offset: 1327, key.offset: 1327,
key.length: 188, key.length: 188,
key.conforms: [ key.conforms: [
@@ -2829,7 +2829,7 @@ func genfoo<T1 : Prot, T2 : cake.C1 where T1.Element == Int, T2.Element == T1.El
] ]
}, },
{ {
key.kind: source.lang.swift.decl.extension.struct, key.kind: source.lang.swift.decl.extension.enum,
key.offset: 1517, key.offset: 1517,
key.length: 63, key.length: 63,
key.conforms: [ key.conforms: [
@@ -2865,7 +2865,7 @@ func genfoo<T1 : Prot, T2 : cake.C1 where T1.Element == Int, T2.Element == T1.El
] ]
}, },
{ {
key.kind: source.lang.swift.decl.extension.struct, key.kind: source.lang.swift.decl.extension.enum,
key.offset: 1582, key.offset: 1582,
key.length: 35, key.length: 35,
key.conforms: [ key.conforms: [
@@ -2882,7 +2882,7 @@ func genfoo<T1 : Prot, T2 : cake.C1 where T1.Element == Int, T2.Element == T1.El
} }
}, },
{ {
key.kind: source.lang.swift.decl.extension.struct, key.kind: source.lang.swift.decl.extension.enum,
key.offset: 1619, key.offset: 1619,
key.length: 78, key.length: 78,
key.conforms: [ key.conforms: [
@@ -2918,7 +2918,7 @@ func genfoo<T1 : Prot, T2 : cake.C1 where T1.Element == Int, T2.Element == T1.El
] ]
}, },
{ {
key.kind: source.lang.swift.decl.extension.struct, key.kind: source.lang.swift.decl.extension.enum,
key.offset: 1699, key.offset: 1699,
key.length: 78, key.length: 78,
key.conforms: [ key.conforms: [
@@ -2954,7 +2954,7 @@ func genfoo<T1 : Prot, T2 : cake.C1 where T1.Element == Int, T2.Element == T1.El
] ]
}, },
{ {
key.kind: source.lang.swift.decl.extension.struct, key.kind: source.lang.swift.decl.extension.enum,
key.offset: 1779, key.offset: 1779,
key.length: 116, key.length: 116,
key.conforms: [ key.conforms: [
@@ -2989,7 +2989,7 @@ func genfoo<T1 : Prot, T2 : cake.C1 where T1.Element == Int, T2.Element == T1.El
] ]
}, },
{ {
key.kind: source.lang.swift.decl.extension.struct, key.kind: source.lang.swift.decl.extension.enum,
key.offset: 1897, key.offset: 1897,
key.length: 30, key.length: 30,
key.conforms: [ key.conforms: [

View File

@@ -300,7 +300,11 @@ static bool initDocEntityInfo(const Decl *D, const Decl *SynthesizedTarget,
return false; return false;
} }
Info.Kind = SwiftLangSupport::getUIDForDecl(D, IsRef); if (IsSynthesizedExtension)
Info.Kind = SwiftLangSupport::getUIDForExtensionOfDecl(SynthesizedTarget);
else
Info.Kind = SwiftLangSupport::getUIDForDecl(D, IsRef);
if (Info.Kind.isInvalid()) if (Info.Kind.isInvalid())
return true; return true;
if (const ValueDecl *VD = dyn_cast<ValueDecl>(D)) { if (const ValueDecl *VD = dyn_cast<ValueDecl>(D)) {

View File

@@ -277,6 +277,21 @@ UIdent SwiftLangSupport::getUIDForDecl(const Decl *D, bool IsRef) {
return UIdentVisitor(IsRef).visit(const_cast<Decl*>(D)); return UIdentVisitor(IsRef).visit(const_cast<Decl*>(D));
} }
UIdent SwiftLangSupport::getUIDForExtensionOfDecl(const Decl *D) {
switch (D->getKind()) {
case swift::DeclKind::Struct:
return KindDeclExtensionStruct;
case swift::DeclKind::Enum:
return KindDeclExtensionEnum;
case swift::DeclKind::Class:
return KindDeclExtensionClass;
case swift::DeclKind::Protocol:
return KindDeclExtensionProtocol;
default:
llvm_unreachable("cannot have extension.");
}
}
UIdent SwiftLangSupport::getUIDForLocalVar(bool IsRef) { UIdent SwiftLangSupport::getUIDForLocalVar(bool IsRef) {
return IsRef ? KindRefVarLocal : KindDeclVarLocal; return IsRef ? KindRefVarLocal : KindDeclVarLocal;
} }

View File

@@ -231,6 +231,7 @@ public:
static SourceKit::UIdent getUIDForDecl(const swift::Decl *D, static SourceKit::UIdent getUIDForDecl(const swift::Decl *D,
bool IsRef = false); bool IsRef = false);
static SourceKit::UIdent getUIDForExtensionOfDecl(const swift::Decl *D);
static SourceKit::UIdent getUIDForLocalVar(bool IsRef = false); static SourceKit::UIdent getUIDForLocalVar(bool IsRef = false);
static SourceKit::UIdent getUIDForCodeCompletionDeclKind( static SourceKit::UIdent getUIDForCodeCompletionDeclKind(
swift::ide::CodeCompletionDeclKind Kind, bool IsRef = false); swift::ide::CodeCompletionDeclKind Kind, bool IsRef = false);