automated-refactoring

Simple Custom Refactoring in IntelliJ

孤街浪徒 提交于 2019-12-03 10:25:51
This question is a follow-up for this . Say I have some class Foo. class Foo { protected String x = "x"; public String getX() { return x; } } I have a program that uses Foo and violates LoD ( Law of Demeter ). class Bar { protected Foo foo; public Bar() { this.foo = new Foo(); } public Foo getFoo() { return foo; } } public static void main(String [] args) { Bar bar = new Bar(); String x = bar.getFoo().getX(); } I can refactor this code to use LoD in two steps. ⌥ ⌘ m bar.getFoo().getX() -> getFooX(bar) (extract to method, also find and replace occurrences) F6 getFooX(bar) -> bar.getFooX() (move

Automatic regenerate designer files

拈花ヽ惹草 提交于 2019-12-03 05:35:30
Recently I've been making some improvements to a lot of the controls we use, for example give properties default values and making buttons private instead of protected. By making this kind of adjustments you need to regenerate the designer files of the forms which have this control on it or controls which inherit from the control. In the past this wasn't really a problem because we only had 20-30 forms. At the moment we've got more than 300 forms which would mean opening the same amount of designers in VS2010. So my question: do you know a way of automating this process so all of the forms get

Automated refactoring to add parameter names to method calls

て烟熏妆下的殇ゞ 提交于 2019-12-03 04:59:46
I am in the middle of a big refactoring. I have dozens of methods, which are called via positional parameters. Now I would like to have them called via named parameters. The methods exist in several, non-inherited classes and have the same name and their signatures differ. Example: Definitions public class Foo { public static Foo Create(int count, string name) { ... } } public class Bar { public static Bar Create(string description, bool yesNo, float factor) { ... } } And the following calls I would like to replace, from public void CreateSomeObjects() { var foo = Foo.Create(123, "foo"); var

Eclipse : transform static method invocation to a static import

女生的网名这么多〃 提交于 2019-12-03 04:04:45
问题 Is there a way to transform automatically this static method invocation ( Arrays.asList ): import java.util.Arrays; import java.util.List; public class StaticImport { public static void main(String[] args) { List<String> list = Arrays.asList("hello", "world"); System.out.println(list); } } to this invocation using a static import : import static java.util.Arrays.asList; import java.util.List; public class StaticImport { public static void main(String[] args) { List<String> list = asList(

C++ refactoring: conditional expansion and block elimination

戏子无情 提交于 2019-12-01 18:02:18
I'm in the process of refactoring a very large amount of code, mostly C++, to remove a number of temporary configuration checks which have become permanantly set to given values. So for example, I would have the following code: #include <value1.h> #include <value2.h> #include <value3.h> ... if ( value1() ) { // do something } bool b = value2(); if ( b && anotherCondition ) { // do more stuff } if ( value3() < 10 ) { // more stuff again } where the calls to value return either a bool or an int. Since I know the values that these calls always return, I've done some regex substitution to expand

C++ refactoring: conditional expansion and block elimination

試著忘記壹切 提交于 2019-12-01 17:24:25
问题 I'm in the process of refactoring a very large amount of code, mostly C++, to remove a number of temporary configuration checks which have become permanantly set to given values. So for example, I would have the following code: #include <value1.h> #include <value2.h> #include <value3.h> ... if ( value1() ) { // do something } bool b = value2(); if ( b && anotherCondition ) { // do more stuff } if ( value3() < 10 ) { // more stuff again } where the calls to value return either a bool or an int

Tool to parse C++ source and move in-header inline methods to the .cpp source file? [closed]

♀尐吖头ヾ 提交于 2019-11-30 18:46:43
The source code of our application is hundreds of thousands of line, thousands of files, and in places very old - the app was first written in 1995 or 1996. Over the past few years my team has greatly improved the quality of the source, but one issue remains that particularly bugs me: a lot of classes have a lot of methods fully defined in their header file. I have no problem with methods declared inline in a header in some cases - a struct's constructor, a simple method where inlining measurably makes it faster (we have some math functions like this), etc. But the liberal use of inlined

Tool to parse C++ source and move in-header inline methods to the .cpp source file? [closed]

自古美人都是妖i 提交于 2019-11-30 02:37:42
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 4 years ago . The source code of our application is hundreds of thousands of line, thousands of files, and in places very old - the app was first written in 1995 or 1996. Over the past few years my team has greatly improved the quality of the source, but one issue remains that particularly bugs me: a lot of classes have a lot

Java source refactoring of 7000 references

倖福魔咒の 提交于 2019-11-30 01:45:27
I need to change the signature of a method used all over the codebase. Specifically, the method void log(String) will take two additional arguments ( Class c, String methodName ), which need to be provided by the caller, depending on the method where it is called. I can't simply pass null or similar. To give an idea of the scope, Eclipse found 7000 references to that method, so if I change it the whole project will go down. It will take weeks for me to fix it manually. As far as I can tell Eclipse's refactoring plugin of Eclipse is not up to the task, but I really want to automate it. So, how

C / C++ packages to understand code for refactoring

依然范特西╮ 提交于 2019-11-29 20:29:56
I am about to starting to work on a project which involves refactoring and modifying existing code which is in c & c++. The code is a bloated one and is in huge volume. Of course since the code needs to be modified, an understanding of the code has to be developed and in a very short span of time since we have some pretty time pressed project schedule. Can anyone please suggest any open source tools which will help in achieving the above. In short what I am looking for is tool which can: Reverse engineering tools which will help understand the design. Sequence generator tools which will help