In IntellIJ IDEA how can I exclude a few files from find in path? - intellij-idea

When I do a find all (Ctrl-Shift-F) it takes very long, because I have some autogenerated js files in my project that are quite large.
How can I exclude those files from my searches?
Obviously I don't want to exclude all js files.
IntelliJ let's you pick one or more file types to search, but is there any way to search everything except 2 or 3 known files.
I tried marking them as ignored, but they still show up in searches.
The help is here https://www.jetbrains.com/help/idea/2018.3/finding-and-replacing-text-in-project.html#limit_search
It recommends restricting to a directory, or a module, but there are quite a few directories and it's all in the same module, so that does not work for me.

In the File Mask you can use ! oparand to exclude the files for example for not in js file then the file mask would be !*.js. You can use , to add multiple conditions to exclude or select the file types you are interested into.

!*.json, !*.txt,!*.js,!*Test*.java,*.java
In IntelliJ 2021, you can include specific file type by .ext1 separated with commas and to exclude !.ext2
Refer image, I need only .java file and not !.js
you can also exclude !Test.java as well.

Related

Simple question about File class in kotlin

I'm trying to read from a file in kotlin using the File class. It's just a simple txt file with a list of names with each name occupying an independent row. This is my project structure:
and here's my function for pulling out a name depending on the day of the year:
private fun getNameOfTheDay(): String {
val cal = Calendar.getInstance()
val day = cal[Calendar.DATE]
return File("data${File.separator}names.txt")
.bufferedReader()
.lineSequence()
.elementAt(day - 1)
}
I keep on getting a FileNotFound exception so I would assume that my file path is somehow wrong... What am I doing wrong here? Sorry for the dumb question, I'm still learning. By the way the function shown above is called from the MainActivity. Thanks in Advance!
Filenames can be absolute or relative. Absolute filenames start from the top level (e.g. the root directory on Unix-like filesystems, which Macs have; or a drive letter on Windows), and so specify the filename unambiguously. Relative filenames don't, and so give a file in (or in relation to) the current working directory.
In this case, data/names.txt is a relative filename. It assumes that the current directory has a subdirectory called data, and refers to a file in that.
However, the file is actually in the directory app/src/main/java/com/example/mynameis/data/ within your project — so this would only work if the current directory was /<pathToYourProject>/app/src/main/java/com/example/mynameis/, which is highly unlikely! So that probably explains the failure.
I don't know about Android projects, but in normal JVM projects the standard practice is to put data files in a src/main/resources/ directory. Gradle (or Maven) knows to copy them into the classpath when building the project. You would then load it from the classpath, e.g. with:
javaClass.getResource("data/names.txt").readText()
See e.g. this question for more details and variations.
The advantage of loading from the classpath instead of a file path is that you don't need to know exactly where the file is; it could be loose on the filesystem, or bundled into a jar or other archive (even compressed), with ways to select between different versions depending on the run profile — all completely transparent to your code.
As I said, I don't know Android, and can't find any direct answers on StackOverflow. (This question seems to suggest using a android.resource:// URI, but I don't know if that would apply here.) Maybe these external sites can give you some hints.
You should try "data\names.txt". Oftentimes slashes don't work for file paths.

Kotlin to Javascript file compilation

Currently, I have two .kt files in a Kotlin/JS project I'm working on. These two .kt files compile to one single .js file (the one in "out/production/myprojectfolder/myproject.js" which is the default directory).
Each of the .kt files represent two separate html pages. I want each of the html page to have its own single .js file.
My question is that, is there a way the two .kt files compile to two separate .js files?
It would seem that this is not possible at the moment [source], you can workaround the issue by using multiple modules, but that would mean 1 module per page, which may get complicated quickly.

Exclude folders based on regular expressions in IntelliJ Idea PhpStorm

Is there any way to exclude folders in PhpStorm through regular expressions?
I have multiple "subproject" folders in my main project folder and every subproject has its own vendor folder I want to exclude from indexing.
So far I've been excluding those folders manually but since every week or so more subprojects are added the maintenance is annoying. If I decided to exclude another subproject folder, I'd have repeat that action for 30+ subprojects.
This question suggests ignoring folders (which can use file masks to select files/folders), but I need to be able to see the folders in my project window and ignoring the folders hides them.
This question suggests ignoring folders (which uses regex to select files/folders)
It does not uses regex. It excludes by exact name or ordinary file masks (e.g. standard * char that means any).
Back to the subject -- it's not possible.
https://youtrack.jetbrains.com/issue/IDEA-127753
https://youtrack.jetbrains.com/issue/IDEA-150784
Watch those and related tickets (star/vote/comment) to get notified on any progress.

How does one change the path that Grammar-Kit's generated lexer Java file is generated into?

How do I change the path that Grammar-Kit's generated JFlex lexer Java file is generated into?
I've asked on Grammar-Kit's issue tracker, but haven't received any response.
I'm tired of of the lexer not being put into my generated files directory (where I would be able to easily delete it along with all my other generated file, and exclude it from searches, and IDE warnings and such).
I, too, got tired of of the lexer not being put into a generated files directory, so I skimmed through the plugin's source code to come up with an answer.
Grammar-Kit uses its own heuristic to decide where to stick your JFlex-generated lexer file, but that heuristic is obviously choosing wrongly in both of our cases.
If you want your generated lexer to go in the generated folder, and Grammar-Kit isn't doing that, it's because the way that GK is designed, your .flex file cannot be inside a source root. Of course, the .flex file is indeed a source file, but for GK's purposes it can't be marked that way — not if you want it to do the right thing and put its generated .java file into your designated generated folder [1].
Instead, move your .flex file out of any source folders, and into a content root that is not marked as a source directory. GK should now behave mostly properly [1]. For it's own source file, the .bnf file, it doesn't behave this odd way; only with the .flex file.
[1]: (actually, in my skimming, I think it may have looked like it's hardcoded specifically to go into a folder named 'gen', but I was only quickly skimming, so that may not be accurate. In either case, generating into a folder named 'gen' {the name most people choose for their generated folder anyway} should at least be sufficient, as your generated flex lexer will at least no longer be mixed in with your normal source files.)

bazaar merge questions2

in my previous question on how to avoid merging specific files i received an answer
see
Bazaar merge questions
the solution is running a resolve command that takes the .THIS files for specific files that i dont want to merge. (like *.hex, *.s19...)
My question is how i make resolve command to run on all the files in all directories without making batch file that contains all the directoreis names. (what will work but needs modifications every project)
P.S i know what * is stand for , what is the meaning of ** ?
thanks
If I understand correctly, it means "subtree". In other words, subdirectories and their subdirectories, and their subdirectories, etc. So, "*/.hex" would match all files with the "hex" extension in the current directory and anywhere in the subtree under that.