Community
Participate
Working Groups
Build Identifier: 20110218-0911 The "Inline" refactoring, when initiated at a method call site, asks me whether I want to inline just that call or all calls. This choice is useful. The "Inline" refactoring, when initiated at a reference to a local, assumes I want to inline the local to all its references. This is often not what I want: I often want to inline just that one occurrence. (Also, it feels inconsistent with the method inlining behavior.) Reproducible: Always Steps to Reproduce: Consider a function like this: void foo() { int bar = 2; int baz = bar + 1; int bat = bar % 5; } If I put my cursor on the reference to "bar" in the initialization of "baz" and invoke the Inline refactoring, it asks "Inline 2 occurrences of local variable 'bar'?". There is no way for me to inline only this one occurrence. That is, I would hope to end up with: void foo() { int bar = 2; int baz = 2 + 1; int bat = bar % 5; }
Sorry, for added clarity I should have included the 'final' keyword on at least bar's declaration.
Agree that this could be helpful. Inline Local Variable should work the same way as Inline Constant (same UI and same default options, depending on whether a reference or a declaration is selected).
Can this ticket can be expanded to inlining single instances of a constant? I extracted a string constant in my source file, and then realized this was a mistake. The identical string was being used for 2 different purposes; I needed to go back and inline where the context was different. The strings being equal were just a design coincidence.