[HN Gopher] Clang-expand: Expand function invocations into curre... ___________________________________________________________________ Clang-expand: Expand function invocations into current scope Author : 6keZbCECT2uB Score : 24 points Date : 2023-09-20 16:48 UTC (6 hours ago) (HTM) web link (github.com) (TXT) w3m dump (github.com) | kevincox wrote: | rust-analyzer has this as well. I've never actually used it | though. In most cases where I would have found it useful the | function was so simple that I just did it manually without | thinking. This also seems to do a better job cleaning up the | resulting code than rust-analyzer does for example. | let cell = self.cell_mut(pos); | | Becomes: let cell = { let ref mut | this = self; &mut this.board[usize::from(pos)] | }; | | Instead of: let cell = &mut | self.board[usize::from(pos)]; | | It did manage to simplify the argument (maybe because it was the | same name?) but had to rename `self`. | gpderetta wrote: | Very very nice. But it should really be an action in clangd | instead of its own tool, for simple integration with LSP. | | Also instead of always replacing the text, it could also be an | overlay, where the function call is temporarily expanded in your | IDE while in some special mode. | 6keZbCECT2uB wrote: | The choice between replacing and making it an overlay is up to | your editor. I think it would be pretty to handle either choice | as a plugin in your editor given the returned json. | | I was surprised it wasn't combined with clangd. ___________________________________________________________________ (page generated 2023-09-20 23:00 UTC)