Community
Participate
Working Groups
Build Identifier: M20100909-0800 When inserting, replacing or moving statements the refactoring infrastructure always inserts four spaces instead of using the user set (project or workspace) indentation rules. Reproducible: Always Steps to Reproduce: 1. Set the workspace indentation settings to use a tab 2. Select some statements and choose Refactor -> Extract method 3. The new code in the new method uses four spaces for indentation
Created attachment 186458 [details] Bugfix that makes the refactoring infrastructure insert new code with user workspace indentation settings instead of four spaces Patch that changes the indentation of inserted/replaced statements to the user-specified settings (tab/space/mixed and number of spaces).
Comment by Emanuel Graf in original bug: (In reply to comment #7) > Created an attachment (id=184307) [details] > Patch that changes fixed four space statement indentation to user settings You use the workspace settings better use the project specific settings if available.
Created attachment 186459 [details] Bugfix: First attempt at a patch to set indentation width based on project settings if available This patch is a first attempt at a way to use project indentation settings, if available, to govern refactoring rewriting. The solution passes an option map down to the Scribe class and is not the cleanest, but the project seems only to be available at the higher levels. Specifically I found no way to retrieve a project if I have an AST node. I welcome alternate approaches. If not, then this might be good enough.
Attachment 186458 [details]: The class CCodeFormatter already has functionality to generate properly formatted indent strings, given project/workspace options, and should be used instead of the custom indent code. Attachment 186459 [details]: A CCodeFormatter should be passed down instead of the ugly and verbose options Map. Lastly, should look into how JDT handles this so as to avoid passing unnecessary state around.
*** Bug 347495 has been marked as a duplicate of this bug. ***
Fixed in cdt_8_0 and master.