@@ -9950,13 +9950,30 @@ SourceRange AbstractFunctionDecl::getSignatureSourceRange() const {
9950
9950
if (isImplicit ())
9951
9951
return SourceRange ();
9952
9952
9953
- auto paramList = getParameters () ;
9953
+ SourceLoc endLoc ;
9954
9954
9955
- auto endLoc = paramList->getSourceRange ().End ;
9956
- if (endLoc.isValid ())
9957
- return SourceRange (getNameLoc (), endLoc);
9955
+ // name(parameter list...) async throws(E)
9956
+ if (auto *typeRepr = getThrownTypeRepr ())
9957
+ endLoc = typeRepr->getSourceRange ().End ;
9958
+ if (endLoc.isInvalid ())
9959
+ endLoc = getThrowsLoc ();
9960
+ if (endLoc.isInvalid ())
9961
+ endLoc = getAsyncLoc ();
9958
9962
9959
- return getNameLoc ();
9963
+ if (endLoc.isInvalid ())
9964
+ return getParameterListSourceRange ();
9965
+ return SourceRange (getNameLoc (), endLoc);
9966
+ }
9967
+
9968
+ SourceRange AbstractFunctionDecl::getParameterListSourceRange () const {
9969
+ if (isImplicit ())
9970
+ return SourceRange ();
9971
+
9972
+ auto endLoc = getParameters ()->getSourceRange ().End ;
9973
+ if (endLoc.isInvalid ())
9974
+ return getNameLoc ();
9975
+
9976
+ return SourceRange (getNameLoc (), endLoc);
9960
9977
}
9961
9978
9962
9979
std::optional<Fingerprint> AbstractFunctionDecl::getBodyFingerprint () const {
@@ -10993,43 +11010,32 @@ DestructorDecl *DestructorDecl::getSuperDeinit() const {
10993
11010
}
10994
11011
10995
11012
SourceRange FuncDecl::getSourceRange () const {
10996
- SourceLoc StartLoc = getStartLoc ();
11013
+ SourceLoc startLoc = getStartLoc ();
10997
11014
10998
- if (StartLoc .isInvalid ())
11015
+ if (startLoc .isInvalid ())
10999
11016
return SourceRange ();
11000
11017
11001
11018
if (getBodyKind () == BodyKind::Unparsed)
11002
- return { StartLoc, BodyRange.End };
11003
-
11004
- SourceLoc RBraceLoc = getOriginalBodySourceRange ().End ;
11005
- if (RBraceLoc.isValid ()) {
11006
- return { StartLoc, RBraceLoc };
11007
- }
11008
-
11009
- if (isa<AccessorDecl>(this ))
11010
- return StartLoc;
11011
-
11012
- if (getBodyKind () == BodyKind::Synthesize)
11013
- return SourceRange ();
11014
-
11015
- auto TrailingWhereClauseSourceRange = getGenericTrailingWhereClauseSourceRange ();
11016
- if (TrailingWhereClauseSourceRange.isValid ())
11017
- return { StartLoc, TrailingWhereClauseSourceRange.End };
11019
+ return { startLoc, BodyRange.End };
11018
11020
11019
- const auto ResultTyEndLoc = getResultTypeSourceRange ().End ;
11020
- if (ResultTyEndLoc.isValid ())
11021
- return { StartLoc, ResultTyEndLoc };
11021
+ SourceLoc endLoc = getOriginalBodySourceRange ().End ;
11022
+ if (endLoc.isInvalid ()) {
11023
+ if (isa<AccessorDecl>(this ))
11024
+ return startLoc;
11022
11025
11023
- if (hasThrows () )
11024
- return { StartLoc, getThrowsLoc () } ;
11026
+ if (getBodyKind () == BodyKind::Synthesize )
11027
+ return SourceRange () ;
11025
11028
11026
- if (hasAsync ())
11027
- return { StartLoc, getAsyncLoc () };
11029
+ endLoc = getGenericTrailingWhereClauseSourceRange ().End ;
11030
+ }
11031
+ if (endLoc.isInvalid ())
11032
+ endLoc = getResultTypeSourceRange ().End ;
11033
+ if (endLoc.isInvalid ())
11034
+ endLoc = getSignatureSourceRange ().End ;
11035
+ if (endLoc.isInvalid ())
11036
+ endLoc = startLoc;
11028
11037
11029
- auto LastParamListEndLoc = getParameters ()->getSourceRange ().End ;
11030
- if (LastParamListEndLoc.isValid ())
11031
- return { StartLoc, LastParamListEndLoc };
11032
- return StartLoc;
11038
+ return { startLoc, endLoc };
11033
11039
}
11034
11040
11035
11041
EnumElementDecl::EnumElementDecl (SourceLoc IdentifierLoc, DeclName Name,
@@ -11133,8 +11139,6 @@ SourceRange ConstructorDecl::getSourceRange() const {
11133
11139
SourceLoc End = getOriginalBodySourceRange ().End ;
11134
11140
if (End.isInvalid ())
11135
11141
End = getGenericTrailingWhereClauseSourceRange ().End ;
11136
- if (End.isInvalid ())
11137
- End = getThrowsLoc ();
11138
11142
if (End.isInvalid ())
11139
11143
End = getSignatureSourceRange ().End ;
11140
11144
0 commit comments