@@ -9939,13 +9939,30 @@ SourceRange AbstractFunctionDecl::getSignatureSourceRange() const {
9939
9939
if (isImplicit())
9940
9940
return SourceRange();
9941
9941
9942
- auto paramList = getParameters() ;
9942
+ SourceLoc endLoc ;
9943
9943
9944
- auto endLoc = paramList->getSourceRange().End;
9945
- if (endLoc.isValid())
9946
- return SourceRange(getNameLoc(), endLoc);
9944
+ // name(parameter list...) async throws(E)
9945
+ if (auto *typeRepr = getThrownTypeRepr())
9946
+ endLoc = typeRepr->getSourceRange().End;
9947
+ if (endLoc.isInvalid())
9948
+ endLoc = getThrowsLoc();
9949
+ if (endLoc.isInvalid())
9950
+ endLoc = getAsyncLoc();
9947
9951
9948
- return getNameLoc();
9952
+ if (endLoc.isInvalid())
9953
+ return getParameterListSourceRange();
9954
+ return SourceRange(getNameLoc(), endLoc);
9955
+ }
9956
+
9957
+ SourceRange AbstractFunctionDecl::getParameterListSourceRange() const {
9958
+ if (isImplicit())
9959
+ return SourceRange();
9960
+
9961
+ auto endLoc = getParameters()->getSourceRange().End;
9962
+ if (endLoc.isInvalid())
9963
+ return getNameLoc();
9964
+
9965
+ return SourceRange(getNameLoc(), endLoc);
9949
9966
}
9950
9967
9951
9968
std::optional<Fingerprint> AbstractFunctionDecl::getBodyFingerprint() const {
@@ -10982,43 +10999,32 @@ DestructorDecl *DestructorDecl::getSuperDeinit() const {
10982
10999
}
10983
11000
10984
11001
SourceRange FuncDecl::getSourceRange() const {
10985
- SourceLoc StartLoc = getStartLoc();
11002
+ SourceLoc startLoc = getStartLoc();
10986
11003
10987
- if (StartLoc .isInvalid())
11004
+ if (startLoc .isInvalid())
10988
11005
return SourceRange();
10989
11006
10990
11007
if (getBodyKind() == BodyKind::Unparsed)
10991
- return { StartLoc, BodyRange.End };
10992
-
10993
- SourceLoc RBraceLoc = getOriginalBodySourceRange().End;
10994
- if (RBraceLoc.isValid()) {
10995
- return { StartLoc, RBraceLoc };
10996
- }
10997
-
10998
- if (isa<AccessorDecl>(this))
10999
- return StartLoc;
11000
-
11001
- if (getBodyKind() == BodyKind::Synthesize)
11002
- return SourceRange();
11003
-
11004
- auto TrailingWhereClauseSourceRange = getGenericTrailingWhereClauseSourceRange();
11005
- if (TrailingWhereClauseSourceRange.isValid())
11006
- return { StartLoc, TrailingWhereClauseSourceRange.End };
11008
+ return { startLoc, BodyRange.End };
11007
11009
11008
- const auto ResultTyEndLoc = getResultTypeSourceRange().End;
11009
- if (ResultTyEndLoc.isValid())
11010
- return { StartLoc, ResultTyEndLoc };
11010
+ SourceLoc endLoc = getOriginalBodySourceRange().End;
11011
+ if (endLoc.isInvalid()) {
11012
+ if (isa<AccessorDecl>(this))
11013
+ return startLoc;
11011
11014
11012
- if (hasThrows() )
11013
- return { StartLoc, getThrowsLoc() } ;
11015
+ if (getBodyKind() == BodyKind::Synthesize )
11016
+ return SourceRange() ;
11014
11017
11015
- if (hasAsync())
11016
- return { StartLoc, getAsyncLoc() };
11018
+ endLoc = getGenericTrailingWhereClauseSourceRange().End;
11019
+ }
11020
+ if (endLoc.isInvalid())
11021
+ endLoc = getResultTypeSourceRange().End;
11022
+ if (endLoc.isInvalid())
11023
+ endLoc = getSignatureSourceRange().End;
11024
+ if (endLoc.isInvalid())
11025
+ endLoc = startLoc;
11017
11026
11018
- auto LastParamListEndLoc = getParameters()->getSourceRange().End;
11019
- if (LastParamListEndLoc.isValid())
11020
- return { StartLoc, LastParamListEndLoc };
11021
- return StartLoc;
11027
+ return { startLoc, endLoc };
11022
11028
}
11023
11029
11024
11030
EnumElementDecl::EnumElementDecl(SourceLoc IdentifierLoc, DeclName Name,
@@ -11122,8 +11128,6 @@ SourceRange ConstructorDecl::getSourceRange() const {
11122
11128
SourceLoc End = getOriginalBodySourceRange().End;
11123
11129
if (End.isInvalid())
11124
11130
End = getGenericTrailingWhereClauseSourceRange().End;
11125
- if (End.isInvalid())
11126
- End = getThrowsLoc();
11127
11131
if (End.isInvalid())
11128
11132
End = getSignatureSourceRange().End;
11129
11133
0 commit comments