I have checked the box for "Enable auto-import in namespace scope" in preferences, however when I select a class from the autocomplete, the FQN remains rather than placing it in a use statement. What am I doing wrong and how can I force phpstorm to auto-import these?
In the Settings/Preferences dialog ( Ctrl+Alt+S ), click Editor | General | Auto Import. Select the Add unambiguous imports on the fly checkbox, and apply the changes.
You can disable auto-import on completion and use quick-fixes instead: In the Settings/Preferences dialog ( Ctrl+Alt+S ), go to Editor | General | Auto Import. On the Auto Import page that opens, use the checkboxes in the TypeScript/JavaScript area to enable or disable import generation on code completion.
The option “Do not import exactly from” allows you to tell the IDE that you don't want any imports that are from the specific path (e.g. @material-ui/core ) or path pattern (e.g. @material-ui/core/** ). The IDE will then use an alternative path if there is one.
In general, in IntelliJ IDEA, you can use Ctrl - Shift - A and press part of a command to find it and know the appropriate shortcut. Typing Ctrl - Shift - A (or if you're on a Mac ⌘ - Shift - A ) and then search for "import" allows finding this command easily.
Make sure that the file where you performing this is actually properly namespaced (as that is the requirement for Enable auto-import in namespace scope
option).
If working in non-namepsaced file .. you should enable Enable auto-import in file scope
option (it is not enabled by default for better compatibility with older existing code reasons).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With