Right now we can only add a single warning, notes are not possible.
Apparently some provisions were made to allow notes (ASTEdit::Note), but they were never
propagated all the way to the diagnostics.
Differential D128807
[clang][transformer] Finish plumbing `Note` all the way to the output. courbet on Jun 29 2022, 5:09 AM. Authored by
Details Right now we can only add a single warning, notes are not possible. Apparently some provisions were made to allow notes (ASTEdit::Note), but they were never
Diff Detail
Event TimelineComment Actions Overall, looks good. But my main question is whether this functionality should be supported in the Edit's Metadata field instead. Eric -- what do you think? You've thought a lot more about metadata recently.
Comment Actions (Apologies for the delay. Still struggling to figure out a good workflow for reviewing patches...) Can you say more about what your intended use of the note is? Perhaps that can motivate some of the discussion. From what I can see, here's my thoughts:
I don't have a lot of experience with how notes appear when surfaced, but I suspect that this interface might encourage callers to tack notes on without putting a lot of thought to where the note shows up. As is, I'm inclined to think that extending the metadata from std::string to something richer would be a better design. Let me know if I'm misunderstanding the code or the intent of the patch.
Comment Actions Eric, these are great points. Originally, the idea for note (IIRC) came from the observation that sometimes a single match will generate edits in multiple locations, each which deserve a different diagnostic note (perhaps the same text, but appearing at the respective location). The intent was *not* to allow noting the insertion of paren, for example. So, I think it was a mistake. Yes, sometimes an ASTEdit is a coherent change, but sometimes (as the paren example demonstrates) its just a fragment. So, from my original intent, I think that we'd just want to support multiple notes per rule, with each keyed on a source range. That said, we could decide to use ASTEdit for that purpose, assuming we're ok with ASTEdit with a null Replacement field. But, we'd have to think about th implications before we go down that route. Clement -- what was your intended application? That may help clarify. Comment Actions Thank for the comments. For my particular case, I just need multiple notes per rule. I don't need them to be associated to a particular edit (and in that very particular case, I don't even need a source location). In terms of the overall design requirements, non-transformer checks can have multiple notes per rule, associated to a source location (and multiple checks are using the note location to point to somewhere else in the code, so that is a required feature if we want to be as powerful as the original clang-tidies, which I think we do). Notes cannot be associated to a particular FixitHint, and I'm not sure whether that's useful. I went with the design in this patch (notes associated to edits) because:
No strong opinion on that front though :) Comment Actions
I'm not sure I understand: you need this additional note, but it doesn't need to be tied to a source location, so, why can't you concatenate it to the main note?
Yes, that's the goal, essentially. And the Note field came from exactly that observation.
Right. I'm not sure about that. It seems more intuitive for the note to be bundled with the associated FixitHint in the same DiagnosticBuilder. That is, if we want to (mostly) go with this design, I would think we'd create a separate diagnostic per note or somesuch. Overall, I'm fine with adding support for additional notes, but I want to get these details sorted out first, since they subtly change the API.
Comment Actions For my specific check the notes carry structure beyond what's typically in a warning, so I need the information to be separate. Comment Actions Based on our conversation offline, I'm inclined towards the change with the note below about API. Thanks!
Comment Actions Thanks for the comments.
|
Are we sure that this is what someone would want? Perhaps I am not creative enough, but this seems like it could explode a large number of notes that coincide to edits, which seems like an odd thing to want.