IntelliJ 中可能发生的事情在 Eclipse 中是不可能的?
我听说有人改变了任何一种方式,并且对其中一种发誓.
I have heard from people who have switched either way and who swear by the one or the other.
作为 Eclipse 的忠实粉丝,但没有时间试用 IntelliJ,我很想听听前 Eclipsians"IntelliJ 用户的一些具体事情,这些事情可以用 IntelliJ 做,而用 Eclipse 做不到.
Being a huge Eclipse fan but having not had the time to try out IntelliJ, I am interested in hearing from IntelliJ users who are "ex-Eclipsians" some specific things that you can do with IntelliJ that you can not do with Eclipse.
注意:这不是一个主观问题,也根本不是要变成一场 IDE 圣战.请对任何火焰诱饵的答案投反对票.
Note: This is not a subjective question nor at all meant to turn into an IDE holy war. Please downvote any flamebait answers.
推荐答案
CTRL-click在任何地方都可以使用
CTRL-click 将您带到定义单击对象的位置 - 不仅在 Java 代码中的 Java 类和变量中,而且在 Spring 配置中(您可以单击类名、属性或 bean 名),在Hibernate(您可以单击属性名称或类,或包含的资源),您可以一键从 Java 类导航到它用作 Spring 或 Hibernate bean 的位置;单击包含的 JSP 或 JSTL 标记也有效,按住 ctrl-单击 JavaScript 变量或函数会将您带到定义它的位置,如果有多个位置,则显示菜单,包括其他 .js 文件和 HTML 或 JSP 中的 JS 代码文件.
CTRL-click works anywhere
CTRL-click that brings you to where clicked object is defined works everywhere - not only in Java classes and variables in Java code, but in Spring configuration (you can click on class name, or property, or bean name), in Hibernate (you can click on property name or class, or included resource), you can navigate within one click from Java class to where it is used as Spring or Hibernate bean; clicking on included JSP or JSTL tag also works, ctrl-click on JavaScript variable or function brings you to the place it is defined or shows a menu if there are more than one place, including other .js files and JS code in HTML or JSP files.
HSQL 表达式、Hibernate 配置(包括类、属性和 DB 列名)、Spring 配置中的自动完成
Autocomplete in HSQL expressions, in Hibernate configuration (including class, property and DB column names), in Spring configuration
<property name="propName" ref="<hit CTRL-SPACE>"
它会显示您可以注入该属性的那些 bean 的列表.
and it will show you list of those beans which you can inject into that property.
Java 代码中非常智能的自动完成功能:
Very smart autocomplete in Java code:
interface Person {
String getName();
String getAddress();
int getAge();
}
//---
Person p;
String name = p.<CTRL-SHIFT-SPACE>
它只向您显示 getName()、getAddress() 和 toString()(仅它们按类型兼容)和 getName() 在列表中排在第一位,因为它具有更相关的名称.仍在 EAP 中的最新版本 8 具有更智能的自动完成功能.
and it shows you ONLY getName(), getAddress() and toString() (only they are compatible by type) and getName() is first in the list because it has more relevant name. Latest version 8 which is still in EAP has even more smart autocomplete.
interface Country{
}
interface Address {
String getStreetAddress();
String getZipCode();
Country getCountry();
}
interface Person {
String getName();
Address getAddress();
int getAge();
}
//---
Person p;
Country c = p.<CTRL-SHIFT-SPACE>
它会默默地自动完成它
Country c = p.getAddress().getCountry();
Javascript
JavaScript 中的智能自动完成功能.
Javascript
Smart autocomplete in JavaScript.
function Person(name,address) {
this.getName = function() { return name };
this.getAddress = function() { return address };
}
Person.prototype.hello = function() {
return "I'm " + this.getName() + " from " + this.get<CTRL-SPACE>;
}
并且它只显示 getName() 和 getAddress(),无论你在项目中的其他 JS 对象中如何获取 * 方法,然后 ctrl-clickon this.getName() 会将您带到定义这个的地方,即使您的项目中还有其他一些 getName() 函数.
and it shows ONLY getName() and getAddress(), no matter how may get* methods you have in other JS objects in your project, and ctrl-click on this.getName() brings you to where this one is defined, even if there are some other getName() functions in your project.
我是否提到了文件路径中的自动完成和 ctrl 单击,例如 <script src=""、<img src="" 等?
Did I mention autocomplete and ctrl-clicking in paths to files, like <script src="", <img src="", etc?
HTML 标记属性中的自动完成功能.HTML 标记的样式属性中的自动完成,包括属性名称和值.类属性中的自动完成功能也是如此.
键入 <div class="<CTRL-SPACE>,它将显示项目中定义的 CSS 类列表.选择一个,按住 ctrl 键单击它,您将被重定向到它的定义位置.
Autocomplete in HTML tag attributes. Autocomplete in style attribute of HTML tags, both attribute names and values. Autocomplete in class attributes as well.
Type <div class="<CTRL-SPACE> and it will show you list of CSS classes defined in your project. Pick one, ctrl-click on it and you will be redirected to where it is defined.
最新版本有语言注入,因此您可以声明您自定义的 JSTL 标签通常包含 JavaScript,并且它会突出显示其中的 JavaScript.
Latest version has language injection, so you can declare that you custom JSTL tag usually contains JavaScript and it will highlight JavaScript inside it.
<ui:obfuscateJavaScript>function something(){...}</ui:obfuscateJavaScript>
对所有项目进行索引搜索.
您可以使用任何 Java 类或方法的 Find Usages,它会找到它的使用位置,不仅包括 Java 类,还包括 Hibernate、Spring、JSP 和其他地方.重命名方法重构不仅在 Java 类中重命名方法,而且在包括注释在内的任何地方重命名方法(不能确定注释中的字符串是否真的是方法名称,所以它会询问).即使有另一个同名的类的方法,它也只会找到你的方法.良好的源代码控制集成(SVN 是否支持更改列表?IDEA 支持它们用于每个源代码控制),能够为您的更改创建补丁,这样您就可以将更改发送给其他团队成员而无需提交.
Indexed search across all project.
You can use Find Usages of any Java class or method and it will find where it is used including not only Java classes but Hibernate, Spring, JSP and other places. Rename Method refactoring renames method not only in Java classes but anywhere including comments (it can not be sure if string in comments is really method name so it will ask). And it will find only your method even if there are methods of another class with same name. Good source control integration (does SVN support changelists? IDEA support them for every source control), ability to create a patch with your changes so you can send your changes to other team member without committing them.
当我在调试器的监视窗口中查看 HashMap 时,我看到了逻辑视图 - 键和值,上次我在 Eclipse 中这样做时,它显示带有哈希和下一个字段的条目 - 我不是真的在调试HashMap,我只是想看看它的内容.
When I look at HashMap in debugger's watch window, I see logical view - keys and values, last time I did it in Eclipse it was showing entries with hash and next fields - I'm not really debugging HashMap, I just want to look at it contents.
当你编辑它时它会验证 Spring 和 Hibernate 配置,所以我不需要重新启动服务器就知道我拼错了类名,或者添加了构造函数参数,所以我的 Spring cfg 无效.
It validates Spring and Hibernate configuration right when you edit it, so I do not need to restart server to know that I misspelled class name, or added constructor parameter so my Spring cfg is invalid.
上次尝试时,我无法在 Windows XP x64 上运行 Eclipse.
Last time I tried, I could not run Eclipse on Windows XP x64.
它会建议您 person.name 或 person.address.按住 Ctrl 键单击 person.name,它将导航到 Person 类的 getName() 方法.
and it will suggest you person.name or person.address. Ctrl-click on person.name and it will navigate you to getName() method of Person class.
键入 Pattern.compile("");
将 \ 放在那里,按 CTRL-SPACE 并查看有关可以放入正则表达式的有用提示.您还可以在此处使用语言注入 - 定义您自己的采用字符串参数的方法,在 IntelliLang 选项对话框中声明您的参数是正则表达式 - 它也会在那里为您提供自动完成功能.不用说,它会突出显示不正确的正则表达式.
Type Pattern.compile("");
put \ there, hit CTRL-SPACE and see helpful hint about what you can put into your regular expression. You can also use language injection here - define your own method that takes string parameter, declare in IntelliLang options dialog that your parameter is regular expression - and it will give you autocomplete there as well. Needless to say it highlights incorrect regular expressions.
我不确定 Eclipse 中是否存在一些功能.但至少我们团队中使用 Eclipse 的每个成员也使用一些合并工具将本地更改与源代码控制中的更改合并,通常是 WinMerge.我从不需要它——合并 IDEA 对我来说就足够了.单击 3 次,我可以在源代码管理中查看文件版本列表,再单击 3 次,我可以比较以前的版本,或者以前和当前的版本,并可能合并.
There are few features which I'm not sure are present in Eclipse or not. But at least each member of our team who uses Eclipse, also uses some merging tool to merge local changes with changes from source control, usually WinMerge. I never need it - merging in IDEA is enough for me. By 3 clicks I can see list of file versions in source control, by 3 more clicks I can compare previous versions, or previous and current one and possibly merge.
它允许指定我需要 WEB-INFlib
文件夹中的所有 .jar,而无需单独选择每个文件,因此当有人将新的 .jar 提交到该文件夹时,它会自动选择它.
It allows to to specify that I need all .jars inside WEB-INFlib
folder, without picking each file separately, so when someone commits new .jar into that folder it picks it up automatically.
上面提到的可能是它所做的 10%.我不使用 Maven、Flex、Swing、EJB 和许多其他东西,所以我不知道它对它们有什么帮助.但确实如此.
Mentioned above is probably 10% of what it does. I do not use Maven, Flex, Swing, EJB and a lot of other stuff, so I can not tell how it helps with them. But it does.
相关文章