automated-refactoring

Visual studio: automatically update C++ cpp/header file when the other is changed?

你。 提交于 2019-12-22 08:14:09
问题 For example, if I change the signature in a function in either the header or the cpp, I'd like it to automatically change in the other one. If I add a new function in either, it should appear in both. If I delete a function, it could probably comment out the other one. Manually having to duplicate one's changes seems silly. Some people have mentioned http://www.lazycplusplus.com/ in response to a similar question, but it seems that that's a command line tool which would require saving and

Automated-refactoring tool to find similar duplicate source code for Java/Javascript?

我怕爱的太早我们不能终老 提交于 2019-12-22 05:36:07
问题 I'm looking for a tool to find duplicate or similar code of Java/Javascript. I can't tell the exact definition of " similar ", but I wish the tool is smart enough and give me advices to refactor the code, e.g., (1) class A and class B have imilar methods (e.g., there 5 methods have same method name, arguments and similar implementation appearing in both classes), then it should advise to move these similar methods into a base class. (2) class A has similar code lines at different places

C++ Refactoring - Move method to implementation file

蓝咒 提交于 2019-12-21 12:59:04
问题 I have lots of header files with long method implementation inside. Is there An automatic way of doing that? One-by-one can take a lot of time... Thanks. 回答1: If you are using Visual Studio, there's an add-in called Visual Assist that can help you to do this. I'm using it at work and it is really helpful. Unfortunately this add-in is not free but you can install the trial to do your stuff and test it. 回答2: KDevelop has such ability too: Right click to the method -> Refactoring -> Move to cpp

How to extract common/similar code blocks to function in Visual Studio C#

蓝咒 提交于 2019-12-19 03:44:10
问题 I want to select code, e.g. doSomething(myEnum.firstThing) doSomethingElse(myEnum.firstThing) evenMoreStuff(myEnum.firstThing) and convert it to a function GroupCommonStuf(myEnum.firstThing) which would look like: GroupCommonStuff(myEnum id) { doSomething(id) doSomethingElse(id) evenMoreStuff(id) } Preferably it would catch any code that is: doSomething(myEnum.secondThing) doSomethingElse(myEnum.secondThing) evenMoreStuff(myEnum.secondThing) and convert it to GroupCommonStuf(myEnum

How to update in hundreds m scripts a variable definition?

末鹿安然 提交于 2019-12-13 05:12:09
问题 We have in University hundreds of m scripts and we want to change/update some definitions of the variables. We want to change all the ufix(*), sfix(*) to fixdt(*,*) . So I imagine that I could make an m-script that read the m-files and changes all the definitions. I think the difficult part of the script is to find for example a ufix(8)-unsigned 8bit and to change into fixdt(0,8) . Do you know a function in Matlab which makes this automatic? 来源: https://stackoverflow.com/questions/31510356

How to use Xcode Extract refactoring feature?

 ̄綄美尐妖づ 提交于 2019-12-13 02:23:28
问题 How do you use Xcode's Extract refactoring tool? Whatever code I select, I always get the same unhelpful error message. The selection does not contain anything that can be extracted. Make a different selection and try again. See the screenshots below: What do I need to follow to have it work? I am doing this on a simple iOS project, nothing special, no C++. Tried with the latest version of Xcode (4.4) and the newer latest developer preview releases. Is this a bug? Any workaround? 回答1: For

Changing references to deprecated methods C++

风格不统一 提交于 2019-12-12 21:09:43
问题 I have some methods that are deprecated in my codebase and I know how I'm supposed to replace them, is there any way to do this automatically? I'm using Visual studio 2015 update 3 but I'm open to using other text editors... The code looks like this : // Deprecated method myFunction(char* firstParam, char* secondParam = NULL); // New method, same name, different params myFunction(char* firstParam, bool flag, char* secondParam = NULL); I just want something that could replace all references to

Replace function or define by the text itself [duplicate]

牧云@^-^@ 提交于 2019-12-12 20:24:43
问题 This question already has an answer here : how to replace a function by it content [duplicate] (1 answer) Closed 2 years ago . How can I replace all occurence of check_free_set_to_null(&pointer) by if (pointer) { free(pointer) printf(pointer have been freed) } else { printf(pointer couldnt had been freed) return (1) } maybe using some sort of {1} = check_free_set_to_null(CONTENT) if ({1}) { free({1}) printf({1} have been freed) } else { printf({1} couldnt had been freed) return (1) } how

Moving Objective-C hard-coded string literals to constants automatically

北慕城南 提交于 2019-12-11 12:51:13
问题 I have a project source code with like 100s of classes that liberally uses hard coded strings throughout the code. NSArray *sql_stmt = [[NSArray alloc] initWithObjects: DB_QUERY, [[jsonDictionary objectAtIndex:i] valueForKey:@"RECORD_ID"], [[jsonDictionary objectAtIndex:i] valueForKey:@"RECORD_LANGUAGE"], [[jsonDictionary objectAtIndex:i] valueForKey:@"INDEX_PATH"], [[jsonDictionary objectAtIndex:i] valueForKey:@"KEY"], [[jsonDictionary objectAtIndex:i] valueForKey:@"VALUE"],nil]; The

How to detect if(true) and other refactoring issues?

大憨熊 提交于 2019-12-11 08:47:56
问题 It is common in java, when using "modern" IDEs, to inline variable values and perform heavy refactoring that can, as an example, transform this source code boolean test = true; //... if(test) { //... } Into this code if(true) { //... } Obviously, this code can be simplified, but Eclipse won't perform that simplification for me. So, is there any way (using Eclipse or - even better - maven) that can detect and (possibly) simplify that code ? (it would be obviously way better if such a tool was