Remark: This question is (up to now) not a duplicate. I know how to disable the hints. This is not what I am looking for.
In intelliJ a feature "hides" parts of my code, e.g. variable declarations as "var" or getter methods like in the example below.
The code shows t.message, but the code behind this visual abbrevation is t.getMessage(). How can I disable that feature and always show t.getMessage()?
Abbreviated code:
Real code:
Because I don't know the name of the feature I have no idea what I am looking for. Any ideas?
To disable showing val/var instead of variable type
go to Settings | Editor | General | Code Folding
and UnCheck Variable Declaration
And just next to it
Uncheck Getters and setters
to start showing getter Setter method calls with full method name
refer- https://stackoverflow.com/a/48271952/3661654
Related
I somehow manages to change my settings such that I do not get the suggestion for generating getter/setter methods. At least not for all types.
The image below shows that name, in contrast to the fields id and appUser, is not greyed out:
Pressing Alt + Enter I get a suggestion for "Create getter and setter" for id
But this does not happen for the field name:
I remember pressing Enter accidentally and since then my settings seems to be messed up. Since I couldn't find anything in Settings I was hoping somebody could help me out here.
The fix to generate Getter/Setter was suggested by Unused Declaration inspection (Java | Declaration redundancy | Unused declaration).
Also the fix to suppress the inspection is suggested in case it's annotated by particular annotation:
Probably you've mistakenly applied the suppression, so the #Column annotation was added to "Entry points" list.
To remove the annotation from this list do the following:
- open the inspection's settings -> Entry points pane:
press the "Annotations..."
and remove the #Column annotation from the list
save
For one of my enum classes I'd like to use non-standard naming:
enum class MyEnum {
I_like_to_use,
This_strange_naming_here
}
The IDE (and code inspection) rightfully complains with:
Enum entry name 'This_strange_naming_here' doesn't match regex '[A-Z]([A-Za-z\d]*|[A-Z_\d]*)'.
This inspection reports enum entry named that do not follow the recommended naming conventions.
However in this case, I would like to actively suppress this warning. I tried with #Suppress("naming"), but to no avail.
For Kotlin/Java add
#Suppress("LocalVariableName", "PropertyName")
above the class name to suppress naming conventions warnings for global and local variables.
#Suppress("EnumEntryName") use these
Please see Suppress inspections. You are not supposed to type it by hand.
Use Alt+Enter to invoke the pop-up menu for the light bulb, select the inspection or the suggested quick fix from the drop-down menu, press the right arrow on the keyboard to open the sub-menu on the right, choose the Suppress option.
After upgrading to IntelliJ IDEA 2017.1 variables now do not show their types. Instead, it shows var. Also, it abbreviates some method calls. For example instead me.getIdAsStr() it shows me.idAsStr. How to revert to the old behavior?
This behavior is caused by the Advanced Java Folding plug-in. Either disable the plug-in or change its setting to not fold certain code elements.
To disable showing val/var instead of variable type
go to Settings | Editor | General | Code Folding
and UnCheck Variable Declaration
And just next to it
Uncheck Getters and setters
to start showing getter Setter method calls with full method name
How can I suppress the inspection in Kotlin for an unused variable
val xyz = abc
I get the squiggly line but ALT-ENTER is useless for this, I tried also to create in another method several variables unused and they also lack the ALT-ENTER ability to ignore the warning. Although I have definitely used ALT-ENTER for this in the past, although maybe it was only in java, can't remember.
So I must manually construct it by hand. I've been trying several variations but I can't get anything to work. Please tell me the correct //noinspection or #SupressWarnings to use, thanks
In IntelliJ IDEA, a right-side arrow on an ALT+ENTER context menu (like this: ) means that you can use your arrow keys to navigate further along the menu. In this case, it leads to your answer:
#Suppress("UNUSED_VARIABLE")
val unused = ""
If you do not get the initial context menu (Remove variable '...'), you may have disabled the "Unused assignment" inspection in your current project. You can fix this by going to Settings -> Editor -> Inspections.
I use the Generate function in the context menu to create my getter and setter methods. But there seems no way to tell Intellij to place the generated methods after the last method in the file ie at the bottom of the class definition. This is possible in Eclipse. Anybody know how to do it automatically in Intellij?
First of all a little hint. IntelliJ is designed to use without a mouse, so I prefer using the keyboard-shortcut Alt + Insert for code generating.
I don't know any possibility to generally define the place for inserting generated code. I recommend to place the cursor there, where you want to insert generated code and then generate it.
If you want to generate getters and setters via Generate menu, the only way is to place cursor at the bottom of your class (or wherever you want them to be)
But if your field is not used yet, there is another option: navigate to the field you need getter/setter for, press Alt+Enter (it calls intentions dialog) and choose "generate getter and setter" option. Then getter and setter will be generated at the bottom of the class (but not below inner classes if any).
settings > code style > java > arrangement
lets you customize the auto formatting options