Questions tagged [automated-refactoring]

Automated refactoring refers to the restructuring of source code (see refactoring) where a computer program does the structure modification, usually guided by user input. Many IDEs have automated refactoring capabilities that significantly reduce the possibility of error when restructuring code.

Questions using this tag will generally pertain to whether a given refactoring can be performed automatically, and if so, by which tool.

Refactoring refers to changing the structure of code while not changing its behavior. Automated refactoring indicates that computers do a significant amount of the refactoring work. This most often refers to the physical modification of code where certain correctness conditions are upheld. For example, when a class's public method is renamed, an automated refactoring tool will typically modify all client classes that call the renamed method to reflect the name change. Some automated refactoring tools may also indicate where code may be in need of refactoring (a.k.a "smell detection") or may suggest ways to fix the problematic code.

Some good places to get started:

350 questions
46
votes
1 answer

Eclipse : transform static method invocation to a static import

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 list =…
gontard
  • 28,720
  • 11
  • 94
  • 117
34
votes
6 answers

How to refactor a static inner class to a top level class in Eclipse?

I am having trouble finding the correct refactor option for the following scenario: I have code like this (in Outer.java): public class Outer { // ... class stuff public static class Inner { // ... inner class stuff } } I…
Grundlefleck
  • 124,925
  • 25
  • 94
  • 111
30
votes
3 answers

R language aware code reformatting/refactoring tools?

Recently I've found myself working with R code that is all over the map in terms of coding style - multiple authors and individual authors who aren't rigorous about sticking to a single structure. There are certain tasks that I'd like to automate…
geoffjentry
  • 4,674
  • 3
  • 31
  • 37
25
votes
2 answers

Automated refactoring to add parameter names to method calls

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…
Dio F
  • 2,458
  • 1
  • 22
  • 39
23
votes
12 answers

Java source refactoring of 7000 references

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…
Hayati Guvence
  • 718
  • 2
  • 6
  • 22
20
votes
5 answers

Are there any open source command line tools to refactor java code?

I use vim as my editor but I would like to get some of the same power of the IDE's for java when it comes to refactoring. Are there any commandline tools for refactoring java? I could probably hack something together using perl or vim scripting but…
Jeremy Wall
  • 23,907
  • 5
  • 55
  • 73
20
votes
6 answers

C / C++ packages to understand code for refactoring

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…
Alok Save
  • 202,538
  • 53
  • 430
  • 533
19
votes
3 answers

Refactor Pro versus Visual Assist X for C++ Development

There are two major refactoring tools which can be installed for Visual Studio that provide C++ support. The full versions of both tools are $250, and they seem to offer similar functionality. They are: Developer Express' Refactor Pro +…
Billy ONeal
  • 104,103
  • 58
  • 317
  • 552
18
votes
5 answers

Auto generify non-generic interface implementation

I have interface public interface ObjectBuilder { E buildObject(); } Also, the project has a lot of classes that implement non-generic version of the interface. class MyClassBuilder implements ObjectBuilder { public MyClass…
turbanoff
  • 2,439
  • 6
  • 42
  • 99
17
votes
2 answers

Xcode: How to refactor/rename method and ADD (or REMOVE) its PARAMETERS?

Is Xcode 5 able to change method's signature? As far as I can tell no, but I'd like to be shown wrong. If I either try to add (or remove) a method's parameter, I am welcomed by the Needs 1 fewer (more) colon to match original error. Must I really do…
Blaz
  • 3,548
  • 5
  • 26
  • 40
16
votes
1 answer

Simple Custom Refactoring in IntelliJ

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 { …
16
votes
4 answers

Automatically split (refactor) .h into header and implementation (h+cpp)

When writing C++ code, I often start by writing full 'implementation' code in my header files, then later need to refactor the implementation into a .cpp file. This is great, but I find this process laborious, but otherwise pretty easy, so I…
aaaidan
  • 7,093
  • 8
  • 66
  • 102
15
votes
3 answers

Is there way for extracting string resources in Android project in IntelliJ IDE?

When I'm working on Android project I would like to use some magic shortcut that would extract my string to strings.xml and also allow me to change the key. Is there any? If there isn't, is there a way to develop new refactorization methods and…
Michal Chudy
  • 1,883
  • 2
  • 21
  • 41
15
votes
3 answers

Automatic regenerate designer files

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…
14
votes
3 answers

Getting clang-tidy to fix header files

I'm in the process of moving a project currently compiling with gcc to clang, and have a bunch of warnings that gcc didn't generate (-Winconsistent-missing-override). clang-tidy works for fixing these errors in the *.cpp files, however it doesn't…
nishantjr
  • 1,788
  • 1
  • 15
  • 39
1
2 3
23 24