In Android Studio 1.1.0, is there a way to change the color of only those method names defined in the current file/class? - intellij-idea

I can imagine that this might not (ever) be a feature.
(I wouldn't necessarily want "other" method calls to be blue as shown in the second block; blue is just to emphasize what's different from first block.)
If there's a way to just color methods defined in the current class, please advise.
(I want this because my eyes need all the help they can get.)

No, there is no such feature in IntelliJ IDEA as of version 14.1. It can be implemented as a plugin, but I'm not aware of any such plugin.

Just documenting, as I was looking for a way to do this and I have found a way that is satisfactory enough to me.
There's a way, but it's a workaround, it will have side effects.
How:
Go to File > Settings > Inspections (Choose the Global Profile if necessary).
Type in the search: qualified.
Tick the checkbox next to "Instance method call not qualified with 'this'".
Click on Severity > Edit severities, add new entry by clicking the green + button.
Name it whatever you want.
You must put it at the bottom of the list using the arrows. If you don't, the F2 key will no longer work as you expect it as it will prioritize errors at the top of the list.
Set the Error stripe mark to #FFFFFF, or the same color as the scrollbar.
Set it bold if you wish.
If you want to set a color, you must set a background color to white (or black if you have a black interface). If you don't, the color will appear black in most conditions.
If you really want to, do the same for "Unnecessary 'this' qualifier"; there is an additional checkbox to make it only apply to methods and not fields.
Side effects:
This enables inspections, which is not desired.
Pointing the mouse cursor onto the method calls will cause a hover text to appear describing the inspection.
If your code has no errors, no warnings, and no additional informative inspections, pressing F2 will jump through these calls.

Related

Pycharm - How do I set the page margin? [duplicate]

The other day I mis-clicked on and mis-dragged something probably and then the left "side bar" of the editor window got wider than normal.
Since this happened by mis-clicking and dragging, I don't know how to reset it back to the normal width. It simply doesn't respond when I try to click and drag the borderline. Didn't find anything related in Settings either.
It's not possible to change the gutter width at the moment. It adjusts itself automatically when needed (e.g. there is a gutter icon for override method and a breakpoint on the same line).
Looking at your screenshot, the width is actually standard. It needs some extra space to allow you setting breakpoints without accidentally clicking the line number.
You could submit a feature request/usability problem to https://youtrack.jetbrains.com/issues/IDEA, but to me, it seems fine.
But since you say it was different the other day and then something happened and it became wider, you could try starting PyCharm with default settings by renaming/removing configuration folder. Here is the article on how to find it.
Go to Settings -> Editor -> General -> Gutter Icon and uncheck the Show gutter icons.
But you should be careful: this action will hide information about recursive calls, override methods etc...

How to find the name for indentation of object-attributes in .tsx-file in PhpStorm

I'm editting a .tsx-file and are reaching upon this bonkers file-formatting:
... If I enlarge the window a bit, then it makes more sense:
But I would still like to change it, so value and onClick aren't aligned all that way to the right. Ideally, it would try to align them with the opening bracket (as they do), unless the opening bracket is more than 35 characters, from the line start. Or something like that.
Now, I assume that it's the TypeScript-formatting that dictates the Code Style for a .tsx-file. But when I open the settings: Editor >> Code Style >> TypeScript then there are BAZILLIONS of settings.
Which leads me to three questions:
Does anyone know what I need to change, so object-attributes doesn't follow the opening-brackets width?
Could I find the name of what I'm looking for, in some smart way? I tried hovering over the massive space, hoping that the little yellow light-bulb could shine some light on, what I was after.
Are there any presets, to be found somewhere? So I don't need to engineer a new Code Style, if I dislike the default.
Make sure that the following option is disabled:
Settings (Preferences on macOS)
Editor | Code Style | TypeScript | Wrapping and Braces
Function call arguments: Align when multiline
NOTE: It is possible that the default value has been changed somewhere since the previous version as I have seen a few questions for the same option but different language (PHP and JavaScript).
HINT 1: Did you know that you can paste your own code in the preview area and start changing options to see how they will affect it? It helps locating the right option a lot.
HINT 2: There is a special popup that shows formatting rules applied to the code. It does not show all possible options but can give you a hint what to look for. To invoke it:
Use Help | Find Action... (or Action tab on Search Everywhere -- they use to be different popups but are using the same popup nowadays)
Type adjust to filer actions
Select and invoke "Adjust code style settings" action
It will give you a popup with applicable rules (it's a limited set: may not list all).
An example for PHP code:

Intellij: Highlight current block of code

I was wondering if it is possible to highlight the block of code you are working on in Intellij Idea.
There was a similar question here: Is there a way to highlight the currently active code block in Visual Studio 2010? .
So what I mean is that if you have clicked into e.g. a method or a while loop... ,the background of the whole block becomes a bit lighter or whatever.
There's already one such feature, but it's more subtle, in the form of a vertical line inside the left gutter... I can't recall whether it's enabled by default or not, but you can activate it by File -> Settings -> Editor -> General, scroll to the Highlight on Caret Movement section (about half of the page).
I looked around for a while but I have not yet found a way to change its appearance to match your description, although I personally prefer this less intrusive highlight than having all the background changed.
P.S. Not sure this is relevant or useful to you, but there was a plugin I tried a while ago called CodeGlance which offered a scrollable-map of the class:
I don't know when this feature was implemented. As of 2021, if you double click anywhere in the scope ( but not on text ), Intellij selects the current block of code ( text within two curly braces ).

Multiple "right margins" or guides in PHPStorm

PHPStorm has a vertical line on what they call the "right margin" which is set by default to 120 characters or columns...
Given that PSR standards state There MUST NOT be a hard limit on line length; the soft limit MUST be 120 characters; lines SHOULD be 80 characters or less., it'd be nice if I could get another visual indicator at the 80 character mark...
I'm well aware that it says what line/column you're on in the status bar, but I typically hide most panels (status bar included) while coding.
Therefore, is there a way (feature or plugin) that would allow me to add a 2nd vertical line to indicate the 80th column?
It is not currently possible .. and no plugin comes into my mind.
https://youtrack.jetbrains.com/issue/IDEA-99875 -- star/vote/comment to get notified on progress.
P.S. Considering that this is rather PHP/Python specific (other languages do not care about this) .. I would not expect JB to have it implemented in nearest future...
I suggest the following workaround, it works for me on PhpStorm 9.0:
Open Settings page (usually Ctrl+Alt+S), go to Plugins -> Browse Repositories
Find and install BackgroundImage plugin
Restart IDE, it may output an error, something like "unknown protocol d" - don't worry, go forth
Make an image with height=1px, and width=(desired width of additional margin). Give it, say, white background and paint one rightmost pixel to say, black. I took a screenshot of an editor and cropped it in PS, to avoid annoying search and adjustment of the image width. Every change of background image requires to restart PhpStorm.
Open Settings again, goto Other settings -> BackgroundImage
Set Enabled checkbox, browse your created image, and check the FileSystem radio button
Restart IDE again and change the margin and you will get two margins
The image is left-aligned, so when you resize an editor on x-axis (move the splitter between Editor and Project View or File System View, etc.), the margin will remain truthy.
Some side-effects - it appears also on console window, event log, perhaps somewhere else.
If the plugin doesn't work, check out this page (there said that most JetBrains plugins should work on all products on IntelliJ Platform, and some workaround if they does not): http://www.jetbrains.org/intellij/sdk/docs/basics/getting_started/plugin_compatibility.html
ADDED: Doesn't work with scaling an editor (Ctrl + MouseWheel) - the scale of the image (fake margin), remains the same and the margin becomes not truthy.
In the latest PHPStorm, this is now possible. This would be PHPStorm 2017.3. The instructions on the ticket mentioned in the accepted answer explains it quite well:
Will be available in the next EAP build. You can set it up at
Settings|Editor|Code Style|Visual guides for all languages or on
"Wrapping and Braces" tab for a specific language ("Other" tab for
XML/HTML). You can change the visual indent guide color at
Settings|Editor|Color Scheme|General|Guides|Visual guides. Please
submit separate reports if you find any problems.
I personally found the setting in Settings|Editor|Code Style|PHP|Wrapping and Braces|Visual guides. It should be there for every language.

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.