Hide files from /build directory in navigate class/file action - intellij-idea

One of the most productive actions in Android Studio is Navigate action. The problem is it shows so much useless files. Sometimes it's hard to find the class/file you're looking for.
Take below image as an example. If you're looking for AndroidManifest.xml in module b you have to scroll down the list to find the file you want.
Is there a way to filter what this dialog shows, in particular exclude some directories from results? All of the files from the /build directory are completely useless.
I know that I can filter what types of files are shown but it doesn't help much.

Mark your build folder as excluded:
File > Project Settings > Modules > Sources > Mark as Excluded (red icon)
Alternatively, right click on your build folder and select Mark Directory as > Excluded.
Excluded folders (shown as rootExcluded) are ones that IntelliJ IDEA "partially ignores". Very limited coding assistance is provided for files in excluded folders. Classes contained in excluded folders don't appear in code completion suggestion lists, references to such classes are shown in the editor as unresolved. When searching, IntelliJ IDEA doesn't look in excluded folders, etc.
Source
Another way is to define a custom scope as described here.

Related

PhpStorm Search Everywhere is not working, do you know the solution?

I don't know this is off topic or not, I'm using general channels. Is there a solution for Search Anywhere in PhpStorm. I work with Laravel but when I use the feature I can't find the file even though it exists.
Looking at your screenshot: based on the fact that ALL files in the project tree have that sort of "dirty yellow" background color... it looks like ALL of your files are considered excluded / outside of the project for some reason.
Most likely a user error of some kind. E.g. you may have opened it from a different path (i.e. when symlink is involved), may have c=misconfigured it later somehow (marked folder as Excluded by mistake or whatnot) or maybe even some sort of config file corruption (pretty unlikely).
Anyway, please do this:
Close your project
Go to the project root folder and delete your .idea subfolder (that's where your project settings are stored).
If you have that project still visible in the IDE (Recent Projects on the Welcome screen) -- you may remove it there as well (to avoid any possible confusion).
Now create a new project in PhpStorm from scratch using existing files: just use "Open" and point to the folder with your project.
Please check filter option. If you are doing file search then click on Files tab.

Has anyone tried/had trouble with being able to build the Redbeard "Pages" tutorial project?

If I download the source and build it works fine, but if I do it myself Xcode won't find the default.inc.json file. If I alter the path to /default-theme/default.inc.json then that particular file is found, but other theme files aren't
Clearly, for some reason my set up is causing grief. However, analysing the directory structure of my app and the source comes up with no differences.
Has anyone run into the same?
Are you trying to set the 'root' theme file? If so it should be named 'theme.inc.json'. From there you should add in your own theme files and include files.
See this for further information about themes and the general structure. http://redbeard.io/documentation/theme-reference
I was having the exact same problem.
The problem was when one drags the 'default-theme' folder into the project.
A window will appear asking how you want to add the files: make sure "Copy items if needed" is checked, and "Create groups" is selected. Important: do not choose "Create folder references" otherwise your project will not work.
The example now works as documented.

Ignore a folder in search results

I'm searching for a string and getting matches in a source folder, and a build folder (file in source gets copied to build during build).
I do not need the build folder result.
Vim has wildignore which helps filter out results.
Is there something similar in intelij?
Mark your build folder as excluded:
File > Project Structure > Modules > Sources > Mark as Excluded (red icon)
You can also just right click on your folder and select Mark Directory As > Excluded.
Excluded folders (shown as rootExcluded) are ones that IntelliJ IDEA "partially ignores". Very limited coding assistance is provided for files in excluded folders. Classes contained in excluded folders don't appear in code completion suggestion lists, references to such classes are shown in the editor as unresolved. When searching, IntelliJ IDEA doesn't look in excluded folders, etc.
Source
Note: See the answer by Nader Hadji Ghanbari for another approach using Scopes.
Short Answer
By defining a Scope when searching, you can include/exclude arbitrary files/folders from that scope.
Detailed Answer
One way to achieve your requirement (excluding files and folders from a search) is to define a custom scope. This is specifically useful because sometimes you just want to exclude a folder from your search and not from the whole project.
Follow these steps:
Edit -> Find -> Find in path or press Ctrl+Shift+F.
Choose Custom in the Scope section and then choose <unknown scope>
Now click on the + button to add a new local custom scope
Give the scope a name and save it.
Now you can include and exclude directories from this scope. You can first add everything by choosing the include recursively and then exclude one by one by choosing exclude or exclude recursively.
Note that you can even include or exclude libraries your project is dependent on.
When searching you can choose the effective scope by in Scope section in Find in Path dialog.
More info
You can check the JetBrains docs on Scopes for more info. Scopes can be used not only when searching but also in a bunch of other use cases in IntelliJ IDEA.
Patterns
You can use Patterns to define a scope which makes them even more powerful and future proof.
using patterns is another way to exclude files and folders. For instance
file:src/main/java//*&&!file:src/main/java/my//* will exclude all files in my folder.
In Intellij 15, to exclude a folder just do this:
in the Project window, select the folder then right click and choose "Mark Directory As" > "Excluded"
IntelliJ IDEA 2021.3.3 (Ultimate Edition)
In my case, all the generated files in .tox and _build kept showing up in my Find results. It may be a blunt instrument but I added these two folder types to the Preferences -> Editor -> File Types -> Ignored Files and Folders: .tox, _build. For whatever reason, adding _build will not be accepted as part of the ignored set.
Caveat, you will not see these files and folders in your Project navigator. However, it’s a small price to pay for not having them show up consistently in my search results.
A number of answers work well for older versions of IntelliJ, but in 2020.2, and possibly other recent versions, I keep seeing excluded folders in my search results. In my case: node_modules.
I found something that does work, though. For javascript projects, at least. There might be something similar available for other languages.
First, of course, exclude the directory from your project.
Hopefully this works, but if it doesn't, and you're using Javascript, continue:
Go to Settings -> Languages & Frameworks -> Javascript -> Libraries
There, uncheck all the directories you don't want included in your search.
Whether this is a good idea remains to be seen; IntelliJ doesn't merely exclude them from your search, but from all its code parsing, which means it might not recognise imports from that directory either. For me it seems to work fine at the moment, but I give no guarantees. Try it, but remember how to revert this.
It's an ugly work around. IntelliJ clearly needs a better way to exclude directories from searches.
As some have mentioned, simply setting a folder to 'Excluded' doesn't work in many versions. A combination of the following does for me:
Set the offending folder to 'Excluded' as suggested.
Use the pre-defined Scope 'Project Files'
Profit
Excluding files and folders from projects
Article last modified: 08 June 2020
Mark a file as plain text
In the Project tool window, select the desired file.
From the context menu of the selection, choose Mark as plain text:
Exclude files and folders by name patterns
In the Settings/Preferences dialog Ctrl+Alt+S, click Directories .
In the Exclude files field, type the masks that define the names of files and folders to be excluded, for example, *.min.js or lib. Use semicolons as separators.
If the name of a file matches any of these patterns, the file is treated as excluded.
If the name of a folder matches a pattern, all the files in this folder and in its subfolders are excluded.
Source: https://www.jetbrains.com/help/phpstorm/excluding-files-from-project.html
This one the only thing that works for me on IntelliJ 2022.3.1, even when marking directory as excluded didn't work (it only change the icon as red, but still shows up).
File > Preferences > Editor > Ignored Files and Folders
I can ignore the generated bla.html with this.
If you are searching for usages, open the "Find Usages Settings..." , by default Ctrl+Alt+Shift+F7, to narrow down the scope from "All files" to "Project files".

How to exclude a file extension from IntelliJ IDEA search?

Is there a way to exclude particular file extension from the results in IntelliJ IDEA's "Find in Path" dialog (invoked by CTRL + SHIFT + F)? I want to exclude all .css files.
In intellij 16 there is a section "File name Filter" to exclude an extension use !*.java. You can give more detailed patterns as well for example I use the pattern below to only return .java files except those with a name starting or ending with test.
Pattern: !*test.java,*.java,!Test*.java
In recent versions of Intellij the GUI has been updated a bit but the same still applies see the "File mask" on the top right hand corner see image below:
In "Find in Path" and "Find in Files" (Ctrl+Shift+F) you can use the "File mask" input.
For example, this would exclude all js, css and twig:
!*.js, !*.css, !*.twig
It's handy cause it also keeps a list of previous inputs, but it gets messy easily when you add a lot of extensions. If it gets too crowded, consider excluding some folders as well (right-click -> "Mark directory as" -> "Excluded")
You can create custom scope there:
In 'Find in Path' dialog you can check radio button 'Custom' and open scopes window.
There you can customize path and search pattern.
Examples of Patterns for Pattern field:
!file:*.css - exclude CSS files
file[MyMod]:src/main/java/com/example/my_package//* - include files from the directory in a project.
src[MyMod]:com.example.my_package..* - recursively include all files in a package.
file:*.js||file:*.coffee - include all JavaScript and CoffeeScript files.
file:*js&&!file:*.min.* - include all JavaScript files except those that were generated through minification, which is indicated by the min extension.
Or check the official documentation.
Good luck!
If you are like me that don't want to use the File Mask option or create a custom scope, etc. but just wanted to be able to add it to project settings one time and be done with it, then here's a solution for you.
I wanted my Find in Path to not search in lock files (auto-generated manifest file by package managers), here's what I had to do for that:
Goto File >> Project Structure (or just press Command+;)
Select Modules under Project Settings
Add a pattern or file names to the Exclude files text-box, in this case: *.lock;package-lock.json and hit Apply, and then ok.
Note The above option is available in IntelliJ 2019 and versions after that, not sure about older versions. For more info, https://www.jetbrains.com/help/phpstorm/excluding-files-from-project.html
WebStorm 2021
CTRL+SHIFT+F and follow the pictures
For 2019.2, the pattern is not set in scope but in the right top windows "File mask" in Find in path dialog. You must tick it.
The syntax I tested are:
exclude files with extension css: !*.css
exclude all under out dir: !out/*
Patterns are separated by comma.
Reference: https://www.jetbrains.com/help/idea/finding-and-replacing-text-in-project.html
For 2021.3.2, just right-click to the folder and Mark Directory as -> Excluded. This will work for logs etc but be careful about source folders.

How to stop huge Prefix.pch.gch file from being copied into application bundle

For some reason, XCode has decided to start copying a huge Prefix.pch.gch file into my application's resources folder when building. This file is not in the Copy Bundle Resources build phase, nor can I find any other project setting that should tell XCode to do this. Has anyone seen this before and know what's going on?
I had a problem with the same symptoms today, it turned out that it was due to one of my objective C files being included in the Copy Bundle Resources files phase of the target (either due to a drag and drop accident, or the xcodeproj file getting corrupted at some point). GCC was then helpfully including the precompiled headers for the prefix header in the target as there is a dependency from the source file.
Doing a Get Info on the source file in question didn't show all the tabs on the file info dialog, even though the file type was set to sourcecode.c.objc.
Removing the file from the project and re-adding it cured the problem.
You could try doing "Show Package Contents" on your xcode project file in the finder, then opening the project.pbxproj file in a text editor (not xcode).
If you search for ".pch" and/or ".gch", you might spot something.
Are there any Copy Files phases?
Is the Prefix.pch.gch file in your project's group tree? The easiest way to check this would be to select the project object, then search for “gch” in the Detail view.
I solved this problem in a different way. Firstly I like to make use of the prefix file so I have lots of includes for standard logging, colours etc.
For every include to the prefix file ensure that each include is only processed once! This can be done by putting:
#ifndef __<Classname>__
#define __<Classname>__
< your original header file here >
#endif
If you select the "Project" item of the "Project menu and then the "Detail" tab view and then select the project in the "Groups & Files" list on the left is the files listed on the right view have a checkbox? and is that checkbox checked? if so then un-check it.