Bug 355148 - Missing function: "Code -> Move to source"
Summary: Missing function: "Code -> Move to source"
Status: RESOLVED FIXED
Alias: None
Product: kdevelop
Classification: Applications
Component: Language Support: CPP (old) (show other bugs)
Version: git master
Platform: Other Linux
: NOR wishlist
Target Milestone: ---
Assignee: kdevelop-bugs-null
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-11-10 19:17 UTC by Piotr Mierzwinski
Modified: 2016-02-28 06:38 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments
Patch (29.60 KB, patch)
2016-01-25 18:03 UTC, Sergey Kalinichev
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Piotr Mierzwinski 2015-11-10 19:17:12 UTC
In version 4.7.x was available quite useful function:
Code -> Move to source or hit Ctrl + Alt + S
Described here: https://userbase.kde.org/KDevelop4/Manual/Working_with_source_code like following: "This remove the code between curly braces from the header file (and replaces it by a semicolon as necessary to terminate the function declaration) and moves it into the source file"
Is it possible to restore it in KDevelop 5.x.x?

Reproducible: Always
Comment 1 Sergey Kalinichev 2015-12-13 13:51:05 UTC
Yes, I miss this feature too. 
There was an attept to use Clang for refactoring (I guess this included move to source too), but I'm not sure what happened to it . If we're not going to use it, then I could port the needed code over from oldcpp to make this feature work.

Milian, what's the status of Clang-based refactoring? Any plans on merging it into master?
Comment 2 Milian Wolff 2015-12-19 12:33:08 UTC
In my eyes, the Clang-based refactoring has a too high complexity and does not integrate that well into our existing structure and code base. It also had serious problems with project-wide refactorings.

So imo, we should try to look at bringing back this functionality requested here and others based on a slimmed down architecture, also leveraging our DUChain where possible.
Comment 3 Sergey Kalinichev 2016-01-25 18:03:25 UTC
Created attachment 96837 [details]
Patch

Here is a patch that adds "move into source" support. It still missing tests, also I noticed that there are some issues with e.g. const parameters, and probably more.

I'm not really sure when I'll have time to fix those issues (maybe in the next month), so I'm pasting this patch here, in case someone wants to work on it.
Comment 4 Sergey Kalinichev 2016-02-28 06:38:24 UTC
Git commit 9b001d16ff1e88dc09f40298eba82a59f5dc357b by Sergey Kalinichev.
Committed on 28/02/2016 at 06:28.
Pushed by skalinichev into branch '5.0'.

Added "move into source" helper

This mostly uses the code from oldcpp. Which I cleaned up a bit and
remove a lot of unused functionality. Also I had to introduce a couple of
changes to the code due to e.g. inconsistencies in internal vs.
function contexts with oldcpp.
Related: bug 358480

Differential revision: https://phabricator.kde.org/D1005

M  +2    -0    languages/clang/CMakeLists.txt
M  +10   -4    languages/clang/clangsupport.cpp
M  +2    -2    languages/clang/clangsupport.h
A  +251  -0    languages/clang/codegen/simplerefactoring.cpp     [License: GPL (v2/3)]
A  +58   -0    languages/clang/codegen/simplerefactoring.h     [License: GPL (v2/3)]
A  +321  -0    languages/clang/codegen/sourcemanipulation.cpp     [License: GPL (v2/3)]
A  +80   -0    languages/clang/codegen/sourcemanipulation.h     [License: GPL (v2/3)]
M  +97   -0    languages/clang/tests/test_assistants.cpp
M  +3    -0    languages/clang/tests/test_assistants.h

http://commits.kde.org/kdevelop/9b001d16ff1e88dc09f40298eba82a59f5dc357b