@@ -3825,16 +3825,10 @@ static void diagnoseProtocolStubFixit(
3825
3825
NoStubRequirements);
3826
3826
auto &Diags = Ctx.Diags ;
3827
3827
3828
- // If we are in editor mode, squash all notes into a single fixit.
3829
- if (Ctx.LangOpts .DiagnosticsEditorMode ) {
3830
- if (!FixIt.empty ()) {
3831
- Diags.diagnose (ComplainLoc, diag::missing_witnesses_general).
3832
- fixItInsertAfter (FixitLocation, FixIt);
3833
- }
3834
- return ;
3828
+ if (!FixIt.empty ()) {
3829
+ Diags.diagnose (ComplainLoc, diag::missing_witnesses_general).
3830
+ fixItInsertAfter (FixitLocation, FixIt);
3835
3831
}
3836
- auto &SM = Ctx.SourceMgr ;
3837
- auto FixitBufferId = SM.findBufferContainingLoc (FixitLocation);
3838
3832
for (const auto &Missing : MissingWitnesses) {
3839
3833
auto VD = Missing.requirement ;
3840
3834
@@ -3843,11 +3837,6 @@ static void diagnoseProtocolStubFixit(
3843
3837
if (isNSObjectProtocol (VD->getDeclContext ()->getSelfProtocolDecl ()))
3844
3838
continue ;
3845
3839
3846
- // Whether this VD has a stub printed.
3847
- bool AddFixit = !NoStubRequirements.count (VD);
3848
- bool SameFile = VD->getLoc ().isValid () ?
3849
- SM.findBufferContainingLoc (VD->getLoc ()) == FixitBufferId : false ;
3850
-
3851
3840
// Issue diagnostics for witness types.
3852
3841
if (auto MissingTypeWitness = dyn_cast<AssociatedTypeDecl>(VD)) {
3853
3842
std::optional<InFlightDiagnostic> diag;
@@ -3859,50 +3848,15 @@ static void diagnoseProtocolStubFixit(
3859
3848
diag.emplace (Diags.diagnose (MissingTypeWitness, diag::no_witnesses_type,
3860
3849
MissingTypeWitness));
3861
3850
}
3862
- if (SameFile) {
3863
- // If the protocol member decl is in the same file of the stub,
3864
- // we can directly associate the fixit with the note issued to the
3865
- // requirement.
3866
- diag->fixItInsertAfter (FixitLocation, FixIt);
3867
- } else {
3868
- diag.value ().flush ();
3869
-
3870
- // Otherwise, we have to issue another note to carry the fixit,
3871
- // because editor may assume the fixit is in the same file with the note.
3872
- if (Ctx.LangOpts .DiagnosticsEditorMode ) {
3873
- Diags.diagnose (ComplainLoc, diag::missing_witnesses_general)
3874
- .fixItInsertAfter (FixitLocation, FixIt);
3875
- }
3876
- }
3851
+ diag.value ().flush ();
3877
3852
continue ;
3878
3853
}
3879
3854
3880
3855
// Issue diagnostics for witness values.
3881
3856
Type RequirementType =
3882
3857
getRequirementTypeForDisplay (Conf, VD);
3883
- if (AddFixit) {
3884
- if (SameFile) {
3885
- // If the protocol member decl is in the same file of the stub,
3886
- // we can directly associate the fixit with the note issued to the
3887
- // requirement.
3888
- Diags
3889
- .diagnose (VD, diag::no_witnesses, getProtocolRequirementKind (VD),
3890
- VD, RequirementType, true )
3891
- .fixItInsertAfter (FixitLocation, FixIt);
3892
- } else {
3893
- // Otherwise, we have to issue another note to carry the fixit,
3894
- // because editor may assume the fixit is in the same file with the note.
3895
- Diags.diagnose (VD, diag::no_witnesses, getProtocolRequirementKind (VD),
3896
- VD, RequirementType, false );
3897
- if (Ctx.LangOpts .DiagnosticsEditorMode ) {
3898
- Diags.diagnose (ComplainLoc, diag::missing_witnesses_general)
3899
- .fixItInsertAfter (FixitLocation, FixIt);
3900
- }
3901
- }
3902
- } else {
3903
- Diags.diagnose (VD, diag::no_witnesses, getProtocolRequirementKind (VD),
3904
- VD, RequirementType, true );
3905
- }
3858
+ Diags.diagnose (VD, diag::no_witnesses, getProtocolRequirementKind (VD), VD,
3859
+ RequirementType);
3906
3860
}
3907
3861
}
3908
3862
0 commit comments