Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I get Netbeans to use import statements instead of fully qualified class names on autocomplete?

Tags:

php

netbeans


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.

like image 384
sallaigy Avatar asked May 16 '11 11:05

sallaigy


1 Answers

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.

like image 114
John McFo Avatar answered Sep 22 '22 14:09

John McFo