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

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

问题描述


我最近从 PDT 转移到 Netbeans,有些事情我想不通.如何让 IDE 在自动完成类名的文件开头使用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 FooBarBaz;

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

相反,如果我使用自动完成功能,我会得到

Instead, if I use autocompletion I get

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

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

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.

推荐答案

在较新版本的 Netbeans(即 7.3+)中,您可以按 Ctrl+Shift+I (Alt+Shift+I 不会按预期工作.

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

首先,它会在您的文件中搜索任何智能或完全限定的实例,然后询问您找到的实例应该是什么类型.然后,它将完全限定的 use 语句添加到您的文件顶部,并将源中的现有实例更改为非限定.

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天全站免登陆