[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:
gregomni
2016-01-13 15:05:26 -08:00
parent e711d5e427
commit 2b2e9dc80e
73 changed files with 468 additions and 414 deletions

View File

@@ -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;