In IntelliJ, is it possible to show an overview of all methods (and maybe class variables) of the currently opened file? For instance, in Eclipse, the default settings comprise an overview as desired.
Have you tried "View | File Structure"?
Related
Currently in Intellij if I try to create a new file via "New > whatever", I don't see any option to choose a JUnit file. I dug deeper and found out the "Edit File Templates...".
While you can add a variety of files from there to the context menu, there is no ability to choose JUnit.
If you browse over to "Code" tab you can see various JUnit templates. However I have no idea if these are just code generation templates instead of file generation templates. And besides, there is no option to port them to the "Files" tab.
The closest SO thread describing this issue is this and it failed to match my needs.
Mind you I am relatively new to Intellij and I come from eclipse.
P.S: I am aware you can generate tests from existing classes. I am currently trying to implement TDD so that does not answer my needs.
While I don't have an answer for this exact question, I think there's an easier way to handle the underlying requirements (easily creating tests):
Navigate to the class you want to test and press ALT+ENTER. In the context menu, pick "Create Test":
After you choose it, you'll get a dialog with several options including the framework to use (e.g., JUnit 5, JUnit 5, TestNG), the methods you want to generate test stubs for, etc:
I am new to Intellij Idea plugin development using gradle! I am hoping to develop a simple plugin to read the contents of java class and print it in the console(Toolwindow) in a live manner(i.e when I type a new word in the java class it should print the work in the console even if the class is saved or not)
Currently I am refering to the Intellij plugin architecture and components in https://www.jetbrains.org/intellij/sdk/docs/basics/plugin_structure/plugin_components.html. I came across concepts such as editor panes and all But I have no idea how to read the contents in IDE editor(current java file)! How can I do it?
You can grab the raw text of an editor window:
Editor editor = anActionEvent.getRequiredData(CommonDataKeys.EDITOR);
editor.getDocument().getText();
If you want to get some structure from the contents of the editor window, you can use the PsiFile API:
PsiFile psi = anActionEvent.getData(CommonDataKeys.PSI_FILE);
The PsiFile API lets you walk through a file in whatever language(s) make sense. For example, for Java files there is a PsiJavaFile interface that knows about Java specific features like package name, imports, etc.
http://www.jetbrains.org/intellij/sdk/docs/basics/architectural_overview/psi_files.html
Lastly, to print a message you can try normal System.out.print() or you can use the ConsoleView class to work with the IntelliJ console tool views:
TextConsoleBuilderFactory.getInstance()
.createBuilder(anActionEvent.getProject())
.getConsole()
.print("Hello", ConsoleViewContentType.NORMAL_OUTPUT);
One note: All of the above code assumes you're working with an ActionEvent. You might want to check out the TypedActionHandler interface to get notified when the editor text changes:
http://www.jetbrains.org/intellij/sdk/docs/tutorials/editor_basics/editor_events.html#handling-keystrokes-in-the-editor
How can I set PhpStorm file structure view to show inherited members by default (or change key binding from Ctrl+F12 to show)?
The question pretty much says it all.
I configured file structure to show up with Ctrl+Alt+S, but cannot change the default setting for show inherited and can't change the keys either.
Is there a file, where default non editable configurations are in?
For example there is an xml file under PHPStormRoot\config\keymaps
What would the action be for that?
Is there a plugin for more configurations?
Should I consider writing a plugin myself (would I be able to change such things)?
I found that if you remove the other configurations(ctrl+F12) for opening file structure, show inherited members becomes your keybinding(ctrl+alt+S).
However it can be buggy, won't open until you re open the IDE.
Also you will be delighted to know that if the method you are looking for doesn't exist it will automatically search from inherited members too.
I also removed f12 from my keymap at PHPStormRoot\config\keymaps\$YOURCONFIGFILE.xml
EDIT: Show extra info
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
I'm having an issue with IntelliJ, that I cannot seem to find a solution for myself. I have not changed any settings, yet when I started my IDE this morning, all Inspections and other highlighting has disappeared.
By highlighting, I mean stuff like variable names becoming purple, static finals shown with italic text, etc.
Inheritance seems to be broken as well, in that an implementing method links to the implemented interface method, but interface methods do not link to the implementing method.
My search for this tells me that there is an icon for this in the bottom right. That's set to "Inspections", and under configuration, it seems like everything is set to default.
Is there some way to un-break my IDE?
Another solution:
File -> Power Save mode
It needs to be disabled.
The (or at least one) answer to this is:
File -> Invalidate Caches
Make sure the folder the code is in is marked as the sources root. If it's not marked as the sources root, syntax highlighting will be very limited.
To mark a directory as the sources root, right click the directory, then navigate down to "Mark directory as" and select "Sources root."