How to find the commented code in IntelliJ IDE? - intellij-idea

Does anyone know a way to search for all (and only) the commented code across all classes in a java project?
For example, using "Find in Path" to search for "//" is not what I want because it also returns URIs (http://......). I want a specialized way to do that.
Thanks in advance.

You can use Structural Search in IntelliJ IDEA.
Below screens as for the version 2019.1.1 (Ultimate Edition) (Works for IntelliJ IDEA 2020.3 too)
Go to Edit > Find > Search Structurally...
File type should be Java and select any path wherever you like to search.
From the top right corner click on gear icon and click on Existing Templates...
Then from Java > Comments, Javadoc and Metadata select comments
Then it will add /* $CommentContent$ */ to the Structural Search window as for the first screenshot.
This will find all the commented code (including Javadoc) from the selected path.
For more info refer : Structural search and replace

About the best you could do would be the Find In Path and use a REGEX of:
^//
That will fix your http:// problem. But it won't find comments that don't start at the beginning of a line. I suppose you could write a much more complex REGEX to find "//" but not proceeded by http: But of course comments can be in /* */ blocks too. So it all depends on how absolute you want to get.

As of intellij 2020.3, there is an inspection for commented out code in java:
Java | Code maturity | Commented out code
So if you want a list of commented out code, you can:
right+click your project, module, subfolder, directory or file where you want to search.
click analyze > inspect code
Click OK
This should open the inspection result window where all your commented out code will be grouped under Java | Code maturity | Commented out code :
If you don't want intellij to search for other issues too, you can create a new profile in File | Settings | Editor | Inspections exactly for that and select it in the analyze dialog.

Related

How to make my own Code abbreviation in intellij idea

in IDEA ,I can type soutto represent System.out.println();and I want to know how to make my own code abbreviation.For example, alias System.out.print(); to sounor any other names
This is called a Live Template in IntelliJ.
Go to File > Settings > Editor > Live Templates. From there, select Java and on the right, you'll see a plus sign. By clicking it, you'll get a 1. Live Template and that will get you a new abbreviation.
Name it soun and the text should be
System.out.print($END$);
Once you're done, make sure you've enabled that abbreviation by clicking the check box next to it.
The docs of IntelliJ cover in detail what the syntax is for these templates.
The $END$ syntax indicates the position of the cursor when the code snippet is complete, and you can no longer press Tab to jump to the next variable.
There are more variables to look at as well and other configurations to do!
Edit: there is an answer here for this question, but it looks like it doesn't necessarily answer the question asked on that post, so that's why I've decided to post a dedicated answer (tackling the issue at hand).

How to hide path location in Run Window in Pycharm?

Today is my first day with Python and I started Using Pycharm Community edition in my Mac. This IDE is really good but one thing annoyed me a lot.
Is there any way I can remove the whole path from showing every time I run a program?
Wanted to remove this Path :
/Users/rajvivan/PycharmProjects/Python/venv/bin/python /Users/rajvivan/PycharmProjects/Python/App.py
Would just like to see the exact responses from the program:
First Day in Python
Hello, World!
There is no option to hide it completely, you can only make it appear folded by adding a pattern like /bin/python in File | Settings | Editor | General | Console, Fold console lines that contain.
In watching the Bro Code channel on Youtube, he changed the font color of the file path so that it's camouflaged. His words not mine just thought I'd share. I can't find the exact area that he's referring to as of yet so if someone else see's it, please share for the rest of us.
Thank you
Based on Bro Code's response I believe the attached is what he was referring too. This is what I came up with. If you goto Help>Find Action>output you'll see Console//System output. Change/Camouflage the color codes as in the picture. Hopefully this works for others.
If you copy the path into
File | Settings | Editor | General | Console`
and paste it as new Fold console lines, it will hide the line as <1 internal line>.

Lazarus - How to create an own $(CustomRelativeUnitPath)

as mentioned quiet similar in the header, may someone tell me, how can I create an own custom-relative-unit-path for the lazarus IDE (version: 2.0.6) .
The IDE has alreaday some internal $(RelativePaths) but I would like to create my own ones and setting them up in the "other unit paths" and finally use them of course ^^
i wanna do somewhere like: "$(MyCustomPath) = C:\Lazarus(someotherpathhere..)"
and put $(MyCustompath) in the "other unit" line and have it work ^^
Below what I would like to see :-)
Best regards
Shpendicus
enter image description here
I think the way to do this may be to use Lazarus IDE macros.
See https://wiki.freepascal.org/IDE_Macros_in_paths_and_filenames for full documentation.
In the section IDE Macros it says
IDE macros: they can be used in almost all IDE fields, e.g. search paths, custom options, file names, run parameters. They are replaced with their value before calling external tools like the compiler or the debugger. They are case insensitive.
and the IDE macro format section includes a few examples of ones which are already defined.
Creating macros is explained here: https://wiki.freepascal.org/Macros_and_Conditionals
To set a macro up for the current project, do the following:
Go to Project | Project Options | Compiler Options | Additions and Overrides
On the righthand side, click Add and select IDE Macro from the drop-down menu
This will open an IDE Macro line in the editor below. In it, replace
MacroName by MyCustomPath and Value by whatever you like. I used D:\Lazarus2\MA
Close the Project Options pop-up
Next, in the directory that MyCustomPath points to, create a unit e.g. Test.Pas that includes a compile stopper like an ! I used
unit Test
interface
!
implementation
end.
Add Test.Pas to the project's Uses list and attempt to compile. The compiler should complain that it can't find Test.Pas.
Next, open Project | Project Options | Compiler Options | Paths and in the Other unit files box at the top insert $(MyCustomPath)
Close Project Options and compile - now the compilation should proceed until it encounters the compile-stopping ! in Test.Pas

List of all errors in project in CLion

CLion 2016.2 helpfully detects potential errors in the file you're editing, which can be seen in the validation bar to the right of the code.
That's just a single file though, is there a way (like a tool window) to get a list of all such warnings in the whole project, or specific parts of it?
Bonus points if it also lists warnings and errors from the compiler, though that's less important, because the compiler output already includes any it found.
Yes, it is possible. The feature you are looking for is called the Inspector.
Do: Find Action... | Inspect Code. It will show a pop-up that will allow you to select the scope: file, whole project, custom, and the Inspection profile (you can choose the type of errors you want to see):
After clicking OK, this is an example of the output, that you can navigate with the mouse or with keyboard shortcuts:
In version 2017.2, I have it under Code | Inspect Code....
You can also right click a folder in Project view and select Inspect Code... there to be able to check only that folder.

Intellij exclude file from being compiled

I am trying to exclude a particular file in my project from being compiled.
According to the Intellij IDEA documentation you do this by "marking the file as plain text".
However, the context menu in the project view where this functionality is supposedly located has no such action. I am using version 13.02 of Intellij. Here is what my context menu looks like:
Under File > Settings > Build, Execution, Deployment > Compiler > Excludes, add an entry.
Any attempts to run a path specified here will result in a ClassNotFoundException, and a very important class indicator as well.
Just to compound on Makoto's answer (would comment but don't have reputation), it looks like this feature does not apply to classes (.java) or assets (images)...for these types of files, it looks like you will need to actually go to the compiler and explicitly state that the file(s) should be excluded.
However, for .htm, .xml, or really anything that isn't a class or asset you will find and can use the 'Mark as plain text' option.
Edit: It looks like you can also go to the 'Messages Make' error / warnings view and Exclude from there, a little less work IMHO.
The answer that #Makoto has given is pretty much the way to go, but in case that you are like me and you get easily both distracted and frustrated looking for that menu, you could use this shortcut:
press ctrl + shift + a , and in the input box that appears type excludes, and select the first item that appears.