@@ -56,7 +56,8 @@ class CodeCompletionDiagnostics {
56
56
llvm::raw_ostream &Out, Diag<ArgTypes...> ID,
57
57
typename swift::detail::PassArgument<ArgTypes>::type... VArgs);
58
58
59
- bool getDiagnosticForDeprecated (const ValueDecl *D, const AvailableAttr *Attr,
59
+ bool getDiagnosticForDeprecated (const ValueDecl *D,
60
+ SemanticAvailableAttr Attr,
60
61
bool isSoftDeprecated,
61
62
CodeCompletionDiagnosticSeverity &severity,
62
63
llvm::raw_ostream &Out);
@@ -81,40 +82,40 @@ bool CodeCompletionDiagnostics::getDiagnostics(
81
82
}
82
83
83
84
bool CodeCompletionDiagnostics::getDiagnosticForDeprecated (
84
- const ValueDecl *D, const AvailableAttr * Attr, bool isSoftDeprecated,
85
+ const ValueDecl *D, SemanticAvailableAttr Attr, bool isSoftDeprecated,
85
86
CodeCompletionDiagnosticSeverity &severity, llvm::raw_ostream &Out) {
86
- assert (Attr);
87
-
88
87
// FIXME: Code completion doesn't offer accessors. It only emits 'VarDecl's.
89
88
// So getter/setter specific availability doesn't work in code completion.
90
89
91
- StringRef Platform = Attr-> prettyPlatformString ();
90
+ StringRef Platform = Attr. getDomain (). getNameForDiagnostics ();
92
91
llvm::VersionTuple DeprecatedVersion;
93
- if (Attr-> Deprecated )
94
- DeprecatedVersion = Attr-> Deprecated .value ();
92
+ if (Attr. getDeprecated () )
93
+ DeprecatedVersion = Attr. getDeprecated () .value ();
95
94
96
95
llvm::VersionTuple RemappedDeprecatedVersion;
97
96
if (AvailabilityInference::updateDeprecatedPlatformForFallback (
98
- Attr, Ctx, Platform, RemappedDeprecatedVersion))
97
+ Attr. getParsedAttr () , Ctx, Platform, RemappedDeprecatedVersion))
99
98
DeprecatedVersion = RemappedDeprecatedVersion;
100
99
100
+ auto Message = Attr.getMessage ();
101
+ auto NewName = Attr.getRename ();
101
102
if (!isSoftDeprecated) {
102
- if (Attr-> Message .empty () && Attr-> Rename .empty ()) {
103
- getDiagnostics (severity, Out, diag::availability_deprecated,
104
- D, Attr-> hasPlatform (), Platform,
105
- Attr-> Deprecated .has_value (), DeprecatedVersion,
103
+ if (Message.empty () && NewName .empty ()) {
104
+ getDiagnostics (severity, Out, diag::availability_deprecated, D,
105
+ Attr. isPlatformSpecific (), Platform,
106
+ Attr. getDeprecated () .has_value (), DeprecatedVersion,
106
107
/* message*/ StringRef ());
107
- } else if (!Attr-> Message .empty ()) {
108
- EncodedDiagnosticMessage EncodedMessage (Attr-> Message );
109
- getDiagnostics (severity, Out, diag::availability_deprecated,
110
- D, Attr-> hasPlatform (), Platform,
111
- Attr-> Deprecated .has_value (), DeprecatedVersion,
108
+ } else if (!Message.empty ()) {
109
+ EncodedDiagnosticMessage EncodedMessage (Message);
110
+ getDiagnostics (severity, Out, diag::availability_deprecated, D,
111
+ Attr. isPlatformSpecific (), Platform,
112
+ Attr. getDeprecated () .has_value (), DeprecatedVersion,
112
113
EncodedMessage.Message );
113
114
} else {
114
- getDiagnostics (severity, Out, diag::availability_deprecated_rename,
115
- D, Attr-> hasPlatform (), Platform,
116
- Attr-> Deprecated .has_value (), DeprecatedVersion, false ,
117
- /* ReplaceKind*/ 0 , Attr-> Rename );
115
+ getDiagnostics (severity, Out, diag::availability_deprecated_rename, D,
116
+ Attr. isPlatformSpecific (), Platform,
117
+ Attr. getDeprecated () .has_value (), DeprecatedVersion, false ,
118
+ /* ReplaceKind*/ 0 , NewName );
118
119
}
119
120
} else {
120
121
// '100000' is used as a version number in API that will be deprecated in an
@@ -123,36 +124,34 @@ bool CodeCompletionDiagnostics::getDiagnosticForDeprecated(
123
124
static llvm::VersionTuple DISTANT_FUTURE_VESION (100000 );
124
125
bool isDistantFuture = DeprecatedVersion >= DISTANT_FUTURE_VESION;
125
126
126
- if (Attr-> Message .empty () && Attr-> Rename .empty ()) {
127
- getDiagnostics (severity, Out, diag::ide_availability_softdeprecated,
128
- D, Attr-> hasPlatform (), Platform,
129
- !isDistantFuture, DeprecatedVersion,
127
+ if (Message.empty () && NewName .empty ()) {
128
+ getDiagnostics (severity, Out, diag::ide_availability_softdeprecated, D,
129
+ Attr. isPlatformSpecific (), Platform, !isDistantFuture ,
130
+ DeprecatedVersion,
130
131
/* message*/ StringRef ());
131
- } else if (!Attr->Message .empty ()) {
132
- EncodedDiagnosticMessage EncodedMessage (Attr->Message );
133
- getDiagnostics (severity, Out, diag::ide_availability_softdeprecated,
134
- D, Attr->hasPlatform (), Platform,
135
- !isDistantFuture, DeprecatedVersion,
136
- EncodedMessage.Message );
132
+ } else if (!Message.empty ()) {
133
+ EncodedDiagnosticMessage EncodedMessage (Message);
134
+ getDiagnostics (severity, Out, diag::ide_availability_softdeprecated, D,
135
+ Attr.isPlatformSpecific (), Platform, !isDistantFuture,
136
+ DeprecatedVersion, EncodedMessage.Message );
137
137
} else {
138
- getDiagnostics (severity, Out, diag::ide_availability_softdeprecated_rename,
139
- D, Attr->hasPlatform (), Platform,
140
- !isDistantFuture, DeprecatedVersion, Attr->Rename );
138
+ getDiagnostics (severity, Out,
139
+ diag::ide_availability_softdeprecated_rename, D,
140
+ Attr.isPlatformSpecific (), Platform, !isDistantFuture,
141
+ DeprecatedVersion, NewName);
141
142
}
142
143
}
143
- return false ;;
144
+ return false ;
144
145
}
145
146
146
147
bool CodeCompletionDiagnostics::getDiagnosticForDeprecated (
147
148
const ValueDecl *D, CodeCompletionDiagnosticSeverity &severity,
148
149
llvm::raw_ostream &Out) {
149
150
if (auto attr = D->getDeprecatedAttr ())
150
- return getDiagnosticForDeprecated (D, attr->getParsedAttr (), false , severity,
151
- Out);
151
+ return getDiagnosticForDeprecated (D, *attr, false , severity, Out);
152
152
153
153
if (auto attr = D->getSoftDeprecatedAttr ())
154
- return getDiagnosticForDeprecated (D, attr->getParsedAttr (), true , severity,
155
- Out);
154
+ return getDiagnosticForDeprecated (D, *attr, true , severity, Out);
156
155
157
156
return true ;
158
157
}
0 commit comments