For more information, refer to Exclude files from reformatting. You can exclude specific files and folders from import optimization. The Optimize Imports feature helps you remove unused imports and organize import statements in the current file or in all files in a directory at once according to the rules specified in Settings | Editor | Code Style | | Imports. In the Exclude from auto-import and completion section of the Auto Import dialog, select whether you want to exclude items from the current project or from all projects, and apply the changes. Press Alt+Enter on a missing class to open the list of import suggestions.Ĭlick the right arrow next to a package and select an item (a class or an entire package) that you want to exclude. You can also select whether you want to exclude items from the current project or from all projects (globally). In the Exclude from auto-import and completion section, click Alt+Insert, and specify a class or a package that you want to exclude. The list of excluded classes and packages is common for auto-import and code completion. You can exclude redundant entries from automatic import so that the list of suggestions contains only relevant items. The list of import suggestions may include classes and packages that you don't need. The automatic insertion of import statements is disabled.Įxclude classes and packages from auto import If you want to completely disable auto-import, make sure that: To replace an import statement with single class imports in a file without changing the settings, place the caret at the import statement, press Alt+Enter (or use the intention action icon), and select Replace with single class imports. In the Class count to use import with '*' and Names count to use static import with '*' fields, specify values that definitely exceed the number of classes in a package and the number of names in a class (for example, 999). Make sure that the Use single class import option is enabled. Press Control+Alt+S to open the IDE settings and then select Editor | Code Style | Java. When the number of classes that IntelliJ IDEA has imported from the same package reaches the limit ( 5 by default), the IDE modifies the statements in order to import the entire package instead of importing several single classes from this package: Disable wildcard imports to always import single classes Make sure the necessary options are selected for the Show auto-import tooltip for setting (both checkboxes, Classes and Static methods and fields, are enabled by default). Hover the mouse over the inspection widget in the top-right corner of the editor, click, and disable the Show Auto-Import Tooltip option.ĭisable tooltips for classes or static methods and fields To view the list of suggestions, click this icon (or press Alt+Enter) and select Import class. When tooltips are disabled, unresolved references are underlined and marked with the red bulb icon. Press Control+Alt+S to open the IDE settings and then select Editor | Code Style | Java | Imports.Ĭlear the Use single class import checkbox, and apply the changes. You can change the settings to import entire packages instead. IntelliJ IDEA suggests to import single classes by default. Import packages instead of single classes If you want to change that, from the Insert imports on paste list, select Ask to confirm every insertion or Never to insert import statements manually. When you are pasting blocks of code that contain references to classes or static methods and fields that are not yet imported, the IDE automatically inserts the missing import statements. Select the Add unambiguous imports on the fly checkbox, and apply the changes. Press Control+Alt+S to open the IDE settings and then select Editor | General | Auto Import. You can configure the IDE to automatically add import statements if there are no options to choose from. Statically imported methods, classes, fields have different style in the editor. To change the background color for import tooltip, press Control+Alt+S and go to Editor | Color Scheme | General | Popups and Hints | Question hint. If there's more than one possible source of import, pressing Alt+Enter will open the list of suggestions. Press Alt+Enter to accept the suggestion. If you're using a class, a static method, or a static field that you haven't imported yet, the IDE shows you a tooltip prompting to add a missing import statement so that you don't have to add it manually. For information on imports in Kotlin, refer to Packages and Imports.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |