Show a variable's type in AppCode - appcode

Is there a shortcut to quickly show the type of a variable in JetBrains' AppCode? Preferably this would be something akin to Visual Studio, which shows the type of a variable when you hover over it with the mouse.

Alternately, if you hold the command key while hovering, you can hover the variable to have the executive summary info bubble. By then clicking the keyword (not the info-bubble) you can then get 'beamed over' to the code that declares or implements the specific interface. For example, in the following line :
[fa.AoEspec addTileSpec:[AoEtile AoEtileFromString:#"0,0,50,hit"]];
I will get an 'info bubble' for fa (local variable), AoeSpec (a property) AoEtile (a class) AoeTileFromString ... all clickable.

You can press SHIFT-COMMAND I to see the definition of the variable under the cursor. It shows you the line that defines the variable, as well as which file. Pretty handy when looking at code you didn't write.

In AppCode 2.1.x Cmd+Shift+I is not a predefined keyboard shortcut (anymore?!). And the previous mentioned Cmd+MouseOver may not be suitable for keyboard-only-junkies. So here come some alternatives:
Cmd+B - to go to the definition (and Cmd+Alt+CursorLeft to go back)
Alt+Space or Cmd+y - to show the quick definition window [1]
Maybe this is helpful.
[1] In AppCode 2.1.2 there seems to be a bug I filed with JetBrains that the quick definition window is empty for iVars (these underscore variables that are generate by auto-synthesize from #property fields). But in all other cases quick definition window works fine! And maybe the bug is fixed when you read this...

What works for me in AppCode 2018.2 is control + command + ? when the variable is under the cursor (quick documentation under View).
You can see a couple of other useful combinations under the View menu.

Related

Any solution to having to scroll back up to the top of a program all the time to check variables declared?

I am programming in Pascal (compiling with the Free Pascal IDE) but I imagine the following issue could be in all programming languages, whether you have to declare variables or not.
In Pascal you have to declare your variables before you can use them. They can only be declared at the top of a function/procedure or, in the case of global variables, at top of the main program.
As my program got longer over the past year and more and more variables were declared, I have had to scroll back up all the time to check which variables I have declared in order to use them in a function or main part of the program.
Is there any solution to not have to scroll back up all the time?
Putting variables in a separate unit file and having the file opened next to the main program file is the only thing I can think of, but at this stage I have too many functions and classes to shift everything around that way. Too much rework of the code would have to be done.
In Lazarus, the freeware and excellent IDE for FPC[1], there is a simple way to do this:
Place the mouse over a variable
If the variable has been declared, the IDE will visually mark it
If it is marked, single-clicking the variable will take you straight to where
it is declared.
More generally, when you hover the mouse over a variable, the IDE will change its background color to something like light grey[2], including any other occurrences of it which are on-screen
at the time, so by itself this is sufficient to locate the variable's declaration site if it happens to be on-screen, as it often is if the variable is a local.
[1] I don't know why anyone would use Notepad++ or another IDE for FPC considering
how good Lazarus is.
[2] The top and bottom pixel rows of the changed background color are drawn darker than the others, which makes it look rather like (wearing my spectacles) the variable name is underlined.
Delphi IDE although a paid solution offers free community packages for students and such. i had a great time using it for my college assignments. its more user friendly as I had a lot of trouble navigating Lazarus. on delph I there is a side-panel that shows you all your stated variables,constants,uses,procedures and more.

How place getter/setter methods at the bottom of a class definition in intellij

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

intellij shortcut for creating method stub

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).

Rename using suggested var name with resharper

I'm Using resharper 6 nighty builds and VB.net. I've a big medium project with multiple files that don't follow the code style conventions of my company.
I've configured resharper with my own convenctions and It suggest to me the right name for each variable (perfect!).
But I can't find any automagic way to make the current name to be replaced with the suggested name.
Are there any way to do it? If not ... did you know ane fearure of coderush Xpress to achieve it?
Thanks.
If you've configured ReSharper with your naming conventions, then it should show a warning (blue squiggly underline) under any identifiers that don't comply. If you put the text cursor on one of those misnamed identifiers, you should see a pyramid icon appear near the left margin. Then you can press Alt+Enter (or click the pyramid icon) to drop down a quick-fix menu. There should be an option in the menu to "Rename to '_myField'". Usually it's the first item in the list, so you can just press Enter again to do the rename.
If you want to do this on everything in a source file, you can use the ReSharper > Inspect > Next Issue in File command (or its keyboard shortcut -- F12 in the IDEA keymap) to move the cursor to the next warning in the file. Then, if it's another name warning, you can use Alt+Enter, Enter again to fix it.
Unfortunately, there isn't a way to automatically fix every instance of a warning at once (though it's been requested; please feel free to vote for RSRP-126551 in their issue tracker).

Is there a way in Intellij IDEA to see the name of the method the current line belongs to?

In our code base there are a few very long methods (several pages worth of code). When reading the code, it would sometimes be good to be able to see the name of the method the current line belongs to, without paging up to the beginning of the method. Is this possible in Intellij IDEA? I am using Intellij IDEA 7.0.3.
You can use View | Context Info (Alt+Q, Ctrl+Shift+Q on Macs). It will display a pop-up on the top of the editor with the current context information (class/method signature).
IntelliJ 2018
This is shown by default at the bottom.
Unfortunately, the method is shown only by name (not including the parameters). If a method is overloaded you won't know for sure where you are.
If you want to move it from bottom to top, go to File > Settings... > Editor > General > Breadcrumbs > check Top:
In the structure panel select the "Autoscroll from source" option.
This way when you place the cursor inside any method the structure panel will show which method you're in.
Intellij now has support for breadcrumbs. Go to settings > appearance and tick "Show breadcrumbs". In this way you can view class/method name without Alt+Q.
For some reason (Alt-Q) wasn't consistent in Android Studio for me. I find (Ctrl-F12) to be pretty satisfactory for this purpose (Navigate|File Structure) though it can be a little laggy in larger files. And by pressing the hotkey again it will populate the list with all the inherited methods as well.