如何使Netbeans在自动完成时使用import语句代替完全限定的类名? [英] How can I get Netbeans to use import statements instead of fully qualified class names on autocomplete?

查看:150
本文介绍了如何使Netbeans在自动完成时使用import语句代替完全限定的类名?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我最近从PDT转到了Netbeans,有些事情我不知道.如何让IDE在自动完成的类名的文件开头使用'use'语句? 喜欢:

use \Foo\Bar\Baz;

class Something extends Baz { /* ... */ }

相反,如果我使用自动补全功能,则会得到

class Something extends \Foo\Bar\Baz { /* ... */ }

我已经检查了代码完成设置,但是最有前途的选项(智能)希望我首先编写导入内容,以便对短类名使用自动完成功能. PDT能够将该行写入文件的开头.

解决方案

在较新版本的Netbeans(即7.3+)中,您可以按Ctrl+Shift+I键(尽管Alt+Shift+I不能按预期运行).

首先,它搜索文件中任何智能或完全合格的实例,然后询问您所找到的实例应为哪种类型.然后,它将完全合格的use语句添加到文件顶部,并将源中的现有实例更改为不合格.


I've moved from PDT to Netbeans recently, and there is something I can't figure out. How do I get the IDE to use 'use' statements at the beginning of a file on autocompleting class names? Like:

use \Foo\Bar\Baz;

class Something extends Baz { /* ... */ }

Instead, if I use autocompletion I get

class Something extends \Foo\Bar\Baz { /* ... */ }

I've checked the code completion settings, but the most promising option (smart) wanted me to first write the imports in order to use autocompletion for short class names. PDT was capable writing that line to the beginning of the file.

解决方案

In newer versions of Netbeans (i.e. 7.3+), you can press Ctrl+Shift+I (Alt+Shift+I won't work as expected, though).

First, it searches for any smart or fully qualified instances in your file and then asks you of what types the found ones should be. It then adds fully qualified use statements to the top of your file and changes existing instances in the source to unqualified.

这篇关于如何使Netbeans在自动完成时使用import语句代替完全限定的类名?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆