Intellij IDEA 13: how to disable comments and refactoring lines?

public class KV<K, V> { public K key; public V value; public KV(K key, V value) { this.key = key; this.value = value; } } 

I am trying to reorganize a class variable of value that happens in place. This means that the dialog does not open; I press the enter button and he is trying to reorganize the entire project, including comments, and what is not, including:

 <%--<link href="<c:url value="../core/core.css" />" />--%> 

in the .jsp file. It's too smart to try to reorganize comments that fit the entire project. This often leads to a big risk of error, and refactoring in the Java environment is no longer safe.

The same thing happened in Intellij 12. Seriously, I do not need Intellij to recommend anything that is considered unsafe, or when it is not sure that it is one and the same!

I can rule out refactoring, but I don’t have time to evaluate the five “sentences” each time. It just increases the likelihood of human error: most of the time I just press the enter button and all things are reorganized.

Refactoring is also a serious issue in the Java environment when it sometimes tries to replace files in .js. Seriously, this should stop.

Without a pop-up dialog, I cannot cancel the "search bar". Even if this has been noted, Intellij should never include default sentences, especially if it is outside the current file. He may also recommend reorganizing them, but they should be excluded by default. That is, it should be a selection function, and not by default destroy everything.

This is a serious problem with a user with the later so-called Intellij smart refactoring. When refactoring JS files, I don’t want to look for Java files for comments or lines! Period! And vice versa!

Safety comes first! Developers who know what they are doing will look for the strings themselves if necessary. In a dynamic language environment, this makes Intellij impossible to use, because often and without any clear picture, sometimes refactoring goes on, sometimes it changes things according to the project and what doesn't.

There should be an option that says: "refactoring only in relation to this file or when 100% is output!", Especially for dynamic languages! For static languages, it should not even try to search for comments and lines outside the file.

I was not going to publish this, but I posed this question more than 2 years ago in bugtracker, but no one paid attention.

EDIT

For those of you who think I can go far, I just tried this:

With this class:

 public class KV<K, V> { public K key; public V val; public KV(K key, V val) { this.key = key; this.val = val; } } 

And adding this to any Java class, for example:

 public class CoreConfig { String abc = "kv.val"; String def = "somethingElse.val"; } 

When refactoring KV.val , as before, I get the following recommendations: ENTER from the disaster and something that I should evaluate and exclude one at a time. It takes effort and is simply annoying and risky. It's like someone screaming, STOP! And then oh, nothing after a minute, disappointment and a 1000 long word essay (this).

enter image description here

Seriously, is there a way to disable this risky behavior !? And is there a reason this is the default?
+45
intellij-idea
Jan 01 '14 at 17:21
source share
2 answers

When you press Shift + F6 (Refactor Rename) twice, it opens a dialog box, and you can turn off "Search by comments and lines"

+56
Jan 01 '14 at
source share

And is there a reason this is the default?

Yes there is. These days, people tend to use too many DSLs, templates, and language injections. In plain old Java, all of these things basically exist as strings. The Reflection API also represents the name of the method / class as String. It is impossible for any IDE to support and recognize them all, so it is best to provide you with a protective grid against possible refactoring errors. However, if you have excellent unit test coverage, then you are likely to be safe here.

As for comments, they often contain code samples. These pieces of code quickly become obsolete during renaming, so it’s useful when the IDE reminds you of its existence.

This check, of course, sometimes leads to false positives. However, if you give your variables descriptive self-evident names (I don't mean “var” or “val”), this is unlikely to happen. Thus, the IDE somehow pushes you to a better code style.

If you're still not sure, follow @Meo's advice and turn off search in lines and comments.

+6
Jan 01 '14 at 18:18
source share



All Articles