Can I customize the "New File" menu in PhpStorm? - intellij-idea

I would like to add some other options, like "PHP Enum" or "PHP Interface" directly to this menu. Also, I would like to put PHP-related options first. It is possible tu customize this in PhpStorm? I'm using last version (2022.3.2) with the new UI enabled.
I tried using Appearance & Behaviour -> Menus & Toolbars but that didn't work for me.

Do you know that you can use the universal PHP Class entry and just change the type of the object (and therefore the file template) there? That can be done right away when typing the file or class name -- just use Arrow Up / Down keys:
(GREEN rectangle area is where that Up / Down key will work; RED rectangle shows my custom file templates)
P.S. The template for PHP Enums is also there, it just the screenshot was taken in a project with PHP 8.0 language level (need 8.1 for enums to appear).
P.P.S. The IDE will remember the last used template when you invoke this dialog again.
https://www.jetbrains.com/help/phpstorm/creating-php-classes.html
You can add new entries to this menu by creating custom File Templates at Settings/Preferences | Editor | File and Code Templates
https://www.jetbrains.com/help/phpstorm/settings-file-and-code-templates.html
Here are my test custom file templates:
And this is how they appear in that menu:
Customizing this menu (removing items, changing their order)
This is not possible at the moment. https://youtrack.jetbrains.com/issue/IDEA-143090 -- watch this ticket (star/vote/comment) to get notified with any progress.

Related

Intellij new Java Class opening a different dialog than usual

When creating a new java class via new -> Java Class while using IntelliJ IDE, a random Dialog started appearing, and I can't find how to disable it.
This is the strange dialog that started showing, a sort of a wizard. Clicking the help button get's me There is no help for this dialog message.
How can I disable this window in the Intellij IDEA?
I too had the same problem, the exact same dialog. In my case, it actually ended up not being a bug, but IJ acting properly (kinda).
TL;DR: The template code for creating a "Class" object got automagically changed after an IJ update so that it would prompt for answers from the coder when creating a new class file. Changing it back in "Settings/File and Code Templates" to the default template code removes the problem, as the default template code does not use any variables that are prompted for upon class object creation (ex.: ${IMPORT_BLOCK}).
Long version ...
Bring up the Settings dialog for IJ, and in the search field type "template", and then select the "File and Code Templates" option. You'll see on the right side of the dialog the "Editor > File and Code Templates" area. If you select "Class" from the list of template types, to the right of that list of template types you'll see the template used when you create a class ...
Now I don't know why, but after a particular IJ update some months back, via their Toolbox app, the default template text/code was different, so that it looked like this ...
... and that latter template code/text caused the second dialog to appear that you see.
To fix the problem, highlight the "Class" template from the list, then click on the "Reset to Default" button that appears below the Files/Includes/Code/Other tabs (looks like a piece of paper with a 180 degree curving arrow on top of it), so that the template text goes back to what I have showing in the first screenshot, and then select the OK button.
Assuming your "default" template for the Class template is not corrupted/bad, you should no longer see the dialog that you asked about.
Go to Settings/File and Code Templates -> class and change it to:
#if (${PACKAGE_NAME} && ${PACKAGE_NAME} != "")package ${PACKAGE_NAME};#end
#parse("File Header.java")
public class ${NAME} {
}
You can also try hitting the reset to default button, as Adrian Romanelli suggested.

IDEA IDE - disable inspection for one file

Is there a way to disable inspection for one file opened in the editor? I occasionally open large library file in the editor to inspect its source code, and don't want IDEA to run inspections on this particular file.
Use Hector the Inspector guy. You can access it by clicking on "guy in a hat" icon in Status Bar or via Code | Configure Current File Analysis... from the main menu.
Once there you can move the "Highlighting Level" slider from "Inspections" to "Syntax" .. or even "None" in case of a large or complex file.
Notes:
Settings here affect current file only (excludes "Power Save Mode" option)
Depending on a file, you may have multiple sliders (e.g. in .php file you will see separate sliders for HTML and PHP languages: this may change depending on some other settings):
P.S.
If your file is actually part of the library (PHP or JavaScript; "Library" in terms of IDE, of course) then they by default should not have inspections enabled in them:
UPDATE 2021-06-11:
Hector the Inspector has been removed from the status bar since 2020.2 version or so. You can get it back by installing Hector the Inspector plugin from Settings/Preferences | Plugins
You can set scope for your project and run inspections only for selected scopes.
#see Inspection severity and scopes

Using file templates in IntelliJ

I'm quite confused when it comes to file templates in IntelliJ. Basically, when I right click anything and hover my mouse over to New, I can see the usual file templates like Java Class, HTML File and so on. I downloaded Scala plugin and I can see Scala templates (Scala Class, Scala Object, etc.) if I go to Edit File Templates, but I can't actually use/see them in the New menu. Is there a way to modify what I see in the New menu? I'd like to be able to create Scala classes.
Go to Settings -> Menus and Toolbars
There you will see many type of menus. You need edit the menu you want the files to be displayed. Most Probably "Project View Popup Menu".
Click on "Add After" button on right. There you choose the file form plug-ins or other category to be displayed.
I added "Show Bytecode" to meny well it does not make sense here. You can add files from scala plugin like that.
You can restore to Defaults if you mess up easily by clicking on
"Restore All Defaults" button.

What does the scheme dropdown menu do in Phpstorm?

In the settings window of Phpstorm, there is a dropdown box labelled scheme
What does it do?
What does it do?
You may be surprised .. but it allows you to choose another (different) Code Style scheme for this project.
PhpStorm supports globally defined schemas (by default it provides only one -- "Default") which can be used by any project and project-specific schema called "Project" which available for this project only (and stored together with other project-specific settings).
You can read more in official help page.
The Code Style is used for code formatting: be it automatic as you type / use live templates etc .. or manual reformat via Code | Reformat Code...
It's used to
choose the code style scheme to be used as the base for your custom coding style for the selected language (Source).
In other words: after selecting a scheme, you can set different formatting options, like tabs vs spaces, tab size or line breaks etc. To use those settings in your current project, you need to click Manage, select your edited scheme and click Copy to Project. After this, you can press Ctrl + Alt + L (Code > Reformat Code...) in the editor to reformat a file according to those scheme settings.

Editor context Menu - Eclipse-RCP

I have an Eclipse RCP application. I have created an Editor. There are few context menu (default), when I right click on the Editor. I have not created these menus.
Please let me know, How to remove the context menu of the Editor?
It needs different approach by which editor you extends.
Let me know What you extends, than I can answer more efficient one.
In general way:
IWorkbenchParSite#registerContextMenu(...) will be used, So find where calls that, override it. It is not recommend. Because by doing this, Menu Extensions which is contributed for your editor will not work anymore.
If you mean the system menu that appears on editor tabs and view tabs, that menu is provided by the presentation (2.1, Classic, Default, etc). There is no tweak to simply modify it.
The 2 ways to remove it would be:
write your own presentation, using
the
org.eclipse.ui.presentations.StackPresentation
API and matching extension point.
Writing a presentation is a involved
undertaking.
Change the internal classes in the
org.eclipse.ui.workbench plugin
and patch that plugin in your RCP
app.
If you use Text or StyleText you will get the system default menu (cut,copy,paste, maybe something about encoding or input). If you are not going to supply your own menu, simply create an empty SWT Menu and set it:
Menu emptyMenu = new Menu(text);
text.setMenu(emptyMenu);
Eclipse also has a text editing framework, if you need more than a basic text box you should check it out. http://wiki.eclipse.org/The_Official_Eclipse_FAQs#Text_Editors