torshepherd wrote:

Ok I took a stab at doing lambda captures as hover instead.

- Targeting the exact '=' or '&' is nontrivial since the capture list isn't in 
the AST, the lambda is just `LambdaExpr` with children for the parameters and 
the CompoundStmt body.
- `auto MyLambda = [...` already produces a nice function-like hover over the 
variable. I tested adding a "Captures:" bullet-list, it works well enough but 
isn't very noticeable.
- We could take the above HoverInfo over the variable containing the lambda and 
apply it to hovering the lambda itself as well?


It strikes me, if we could either add HoverInfo or styling to the variables 
within the body of the lambda themselves, that would be the most readable 
representation probably.

For instance:

- Can we add an inlay hint like `[&] ` before actual variables in the body of 
the lambda?
- Can we apply a semantic token to style lambda captures differently? Maybe as 
`property` since they are similar conceptually to struct members?
- Can we use the `mutable`-ness of the lambda to color tokens as const if they 
are captured by copy and the lambda is not mutable?

Overall I think capture hints should be removed from this PR so we can get 
default args in in the meantime.

https://github.com/llvm/llvm-project/pull/95712
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to