mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[SR-511][Parse] Add 'associatedtype' keyword and fixit
Adds an associatedtype keyword to the parser tokens, and accepts either typealias or associatedtype to create an AssociatedTypeDecl, warning that the former is deprecated. The ASTPrinter now emits associatedtype for AssociatedTypeDecls. Separated AssociatedType from TypeAlias as two different kinds of CodeCompletionDeclKinds. This part probably doesn’t turn out to be absolutely necessary currently, but it is nice cleanup from formerly specifically glomming the two together. And then many, many changes to tests. The actual new tests for the fixits is at the end of Generics/associated_types.swift.
This commit is contained in:
@@ -115,6 +115,8 @@ static UIdent KindDeclExtensionStruct("source.lang.swift.decl.extension.struct")
|
||||
static UIdent KindDeclExtensionClass("source.lang.swift.decl.extension.class");
|
||||
static UIdent KindDeclExtensionEnum("source.lang.swift.decl.extension.enum");
|
||||
static UIdent KindDeclExtensionProtocol("source.lang.swift.decl.extension.protocol");
|
||||
static UIdent KindDeclAssociatedType("source.lang.swift.decl.associatedtype");
|
||||
static UIdent KindRefAssociatedType("source.lang.swift.ref.associatedtype");
|
||||
static UIdent KindDeclTypeAlias("source.lang.swift.decl.typealias");
|
||||
static UIdent KindRefTypeAlias("source.lang.swift.ref.typealias");
|
||||
static UIdent KindDeclGenericTypeParam("source.lang.swift.decl.generic_type_param");
|
||||
@@ -163,7 +165,7 @@ public:
|
||||
UIdent visitVarDecl(const VarDecl *D);
|
||||
UIdent visitExtensionDecl(const ExtensionDecl *D);
|
||||
UIdent visitAssociatedTypeDecl(const AssociatedTypeDecl *D) {
|
||||
return IsRef ? KindRefTypeAlias : KindDeclTypeAlias;
|
||||
return IsRef ? KindRefAssociatedType : KindDeclAssociatedType;
|
||||
}
|
||||
|
||||
#define UID_FOR(CLASS) \
|
||||
@@ -312,6 +314,7 @@ UIdent SwiftLangSupport::getUIDForCodeCompletionDeclKind(
|
||||
case CodeCompletionDeclKind::Enum: return KindRefEnum;
|
||||
case CodeCompletionDeclKind::EnumElement: return KindRefEnumElement;
|
||||
case CodeCompletionDeclKind::Protocol: return KindRefProtocol;
|
||||
case CodeCompletionDeclKind::AssociatedType: return KindRefAssociatedType;
|
||||
case CodeCompletionDeclKind::TypeAlias: return KindRefTypeAlias;
|
||||
case CodeCompletionDeclKind::GenericTypeParam: return KindRefGenericTypeParam;
|
||||
case CodeCompletionDeclKind::Constructor: return KindRefConstructor;
|
||||
@@ -337,6 +340,7 @@ UIdent SwiftLangSupport::getUIDForCodeCompletionDeclKind(
|
||||
case CodeCompletionDeclKind::Enum: return KindDeclEnum;
|
||||
case CodeCompletionDeclKind::EnumElement: return KindDeclEnumElement;
|
||||
case CodeCompletionDeclKind::Protocol: return KindDeclProtocol;
|
||||
case CodeCompletionDeclKind::AssociatedType: return KindDeclAssociatedType;
|
||||
case CodeCompletionDeclKind::TypeAlias: return KindDeclTypeAlias;
|
||||
case CodeCompletionDeclKind::GenericTypeParam: return KindDeclGenericTypeParam;
|
||||
case CodeCompletionDeclKind::Constructor: return KindDeclConstructor;
|
||||
|
||||
Reference in New Issue
Block a user