Details
- Reviewers
sammccall - Commits
- rG6f6cf2da8d94: [clangd] Omit parameter hint for setter functions
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
I chose to be conservative here and only omit the hint in the case where the setter's name (after the "set") matches the parameter name (ignoring case).
I gave void setTimeout(int timeoutMillis); as a motivating example for where a non-matching parameter name could contain extra information that could be useful to show in a hint. Let me know if you agree with this reasoning.
I'm not sure how related this is, but Hover has methods that try to detect setter functions in class to give them a trivial description, would that be of any help here?
clang-tools-extra/clangd/InlayHints.cpp | ||
---|---|---|
114 | This heuristic is far from perfect. There's definitely diminishing returns for the more advanced you make it, but I'd argue it makes sense to strip any underscore from the Name, e.g, |
clang-tools-extra/clangd/InlayHints.cpp | ||
---|---|---|
114 | Good call, snake_case is definitely worth supporting |
It looks like that code introspects the body of the function to see if it's a setter based on what it does, regardless of its name. Not sure if that's a good match for cases where it makes sense to omit a parameter hint.
clang-tools-extra/clangd/InlayHints.cpp | ||
---|---|---|
108 | This is nice and conservative, but a bit style dependent. Seems fine for now, maybe we want to tweak at some point. | |
114 | This doesn't handle multi-word variable names if params use snake case and functions don't, e.g.: e.g. void setExceptionHandler(EHFunc exception_handler) This is fine for now but probably worth a comment. | |
clang-tools-extra/clangd/unittests/InlayHintTests.cpp | ||
344 | can you add setTimeoutMillis(int timeout_millis) just to show the current behavior? |
This is nice and conservative, but a bit style dependent.
e.g. setSema(Sema &S)
Seems fine for now, maybe we want to tweak at some point.