I've recently switched over to intellij for scala development.
I'm having trouble finding the following shortcut:
In eclipse, I could type a method call e.g.
method("hello", 1)
and press <command>1 to have eclipse popup a suggestion to let me create a method stub.
Is there such a shortcut in intellij?
Use Alt+Enter (Show Intention Actions in Settings | Keymap).
Verified, works fine in IDEA 11.0.1 with the current Scala plug-in:
Activate Type aware highlighting (See the [T] symbol in the image) and
Set Highlighting level to Inspections
Then it is possible to use alt + enter (similar to Ctrl+1 in Eclipse) to show menu, which has create method option.
Why isn't it enabled by default?
The feature is in beta (or maybe in alpha) and sometimes may report "false errors" in regular code. Usually, such "errors" "found" only in a truly complex code, and, normally, everything works just fine.
Scala plugin doesn't rely on compiler to analyze code. We're implementing our own model of the language, and sometimes it's challenging, especially when it comes to Scala's type system and type inference (to size up the problem, you may try to formally "infer" a type of "foo".map(_ + 1) expression by hand).
Related
I would like to exclude a specific line (or minimum sized unit) from IntelliJ's clean-up code option. We need to workaround this problem with type inference of exceptions which was fixed in Java 9 but we are stuck in Java 8.
The workaround being cleaned by IntelliJ is given by Oracle in the link:
- return g(f("Hi", MyException.class));
+ return g(this.<String, MyException>f("Hi", MyException.class));
This fix is cleaned up by intellij if you tick clean-up code.
We can push with 'clean-up code' unticked but it has many contributors so someone will eventually tick and undo the fix.
You can define formatter markers: Preferences | Editor | Code Style | Enable formatter markers.
Check Example of using formatting markers
Solved, critically in the code as we do not push changes to our individual IntelliJ configurations.
Alt + Enter on the greyed out generic (the warning)
highlight Remove all type arguments and press right arrow
Suppress for ...
For 'method' an annotation #SuppressWarnings will appear - this is my personal preference.
In WebStorm I can type something like
document.gEBI
press tab key, and it'll autocomplete to
document.getElementById()
But when I do the similar thing in IntelliJ
fmt.Prl
Auto completion doesn't work (the desired result fmt.Println()) at all, it works only if all the letters match strictly in order.
Is it possible to enable this functionality in IntelliJ? I've imported all the settings from WebStorm.
These Tab key shortcuts aren't part of the auto-complete system the Jetbrains use for all their IDEs as LazyOne says, they are actually part of the template-invocation system.
The auto-complete functionality is built into the shortcut: Ctrl+Space.
I suggest looking up the template invocation for .Println() in the settings, Jetbrains documentation, or raising a ticket with Jetbrains on YouTrack for clearer documenation/control over template-invocation.
Coming from Eclipse, I like to use a field first (for example) this.fieldname = "value", and then quick fix (control-1) the field declaration into existence without having to type it myself. It would create "private String fieldname;" for example in my class file.
In intellij I thought the same thing was possible across its editors, but I am not able to alt-enter or control space the field into existence. How do I accomplish this? This is for Typescript in Intellij Ultimate. I have enabled the TypeScript compiler per the banner popup.
It really annoys me that IntelliJ highlights certain 'errors' (that don't prevent successful compilation) the same way that real errors are highlighted. For example, a magic number is not really an error, but it will be flagged in exactly the same way as an incompatible type error.
How can I change this?
Go to Settings -> Inspections. Then you need to search through the long list for the offending inspection, which you can get the name of by hovering on the warning marker in the margin. You can change the severity of the inspection, whether it's an error, warning, etc. or just disable it altogether.
Edit: if you search for "magic" in Settings, you get the following, which should be helpful:
Whenever you see an inspection warning/error you can place the caret on it and press Alt+Enter (a light bulb also appears that tells you that). A menu will appear with suggested quick fixes. You may need to open a submenu by pressing Right, and you'll find "Edit inspection settings" there. Having invoked that, you may proceed as in hvgotcodes's answer :), it's just a faster way of getting to those settings.
As Michael Calvin said you can use the SuppressWarnings annotation. For example:
#SuppressWarnings("OptionalUsedAsFieldOrParameterType")
See https://github.com/JetBrains/intellij-community/blob/master/plugins/InspectionGadgets/src/inspectionDescriptions/OptionalUsedAsFieldOrParameterType.html
Usually searching the internet for the exact description leads me to this.
Not directly relevant to the OP, but may be of use to future Googlers
I got to this question while trying to figure out how to disable IntelliJ IDEA's warnings about Guava functionalities that have been replaced by Java 8 features. I'm not able to use the Java 8 versions of these features in my case because of a library we're using that was built with Guava (despite being a Java 8 project). So to solve that, I added a SuppressWarnings annotation before any class using Guava:
#SuppressWarnings(Guava)
public final class...
I'm trying to migrate from Eclipse to IDEA. In Eclipse, when I hit the TAB key while typing in function parameters and in other contextual situations it will forward the cursor to the next place I can type (next parameter, end of the line for semi-colon, etc.). I use it constantly. Is there a way to get similar functionality in IDEA?
There is not direct equivalent to this action. See completion features page for the advanced features.
Regarding the semicolon insertion see Webstorm/Intellij put ";" always at the end of line.
See also Things possible in Eclipse that aren’t possible in IntelliJ?.