Disable intellij indexing on specific folder - indexing

In my project I have .deploy folder which is created/updated when I deploy my app locally. Is it possible to disable indexing on that folder? Everything slows down whenever I deploy and it's really annoying - I have to wait a few minutes whilist intellij doing unnecessary indexing. In module view I excluded that folder but it's not helping. Any help would be appreciated.

Mark this folder as Excluded in the File | Project Structure | Modules | Sources tab.
Edit: also make sure it's not added as a library in the project.

On IntelliJ 13+ (don't know for earlier versions), you can right click on a folder > Mark Directory As > Excluded.

if you cannot do it throu the Modules menu because your intellij freezes (like in my case) edit .iml file of your projet and add excludeFolder line as below:
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/features" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/resources" type="java-test-resource" />
<excludeFolder url="file://$MODULE_DIR$/node_modules" />
<excludeFolder url="file://$MODULE_DIR$/target" />
</content>

The option is now called Stop/Start Index, available from the folder context menu in solution explorer. When index is stopped, the folder will appear with "no index" annotation on the right.
I excluded the build output folder and no longer getting lengthy index refreshes after each build. Also full text search is a lot faster (near instant).

After applying the Mark As > Excluded method to a folder you still might see unwanted results.
You have to explicitly mark sub-folders as well to disable certain functionalities for sub-folders.
indexing, find usages etc.

Sometimes it is not possible to mark the folder as excluded. It happens with direct node dependencies.
For that, it's a bit extreme but you can add it to Editor-> File types -> ignored file types and folders. It won't be indexed at all. It won't be shown in the project either

Related

How to import external JARs from one project to another?

I have created a new IntelliJ Project, and I want it to have JAR dependencies like I have in another project.
Is there a way to Export-Import / Copy-Paste JAR dependencies from one IntelliJ project to another without using POM?
Thanks.
Optional Solution:
1. Open <old-project>/.idea/libraries folder and <new-project>/.idea/libraries folder.
2. Make sure to enable the displaying of hidden files (in Win7, go to control-panel--> Folder Options --> View, and select the 'Show hidden files...')
3. Copy all XML files exists in .idea/libraries from the old project to the new one.
4. Make sure that each xml points to the right location of Jar. (In case of relative link)
5. Open the <old-project>.iml and <new-project>.iml, and copy all <orderEntry type="library" name"..."/> elements.
6. Restart your new project.
I'm not aware of a way to do this from within IDEA, but under your project folder you can find a directory called .idea/libraries that has a series of XML files, one for each external dependency. You should be able to copy these between projects and thus "share" dependencies.

How to mark a directory as library root?

I've 2 projects in PhpStorm: one is working well while another won't work and I can't figure what make the first one working.
The first one is working well with library root for bower, npm and composer :
The second one is bower, npm are not detected as library root :
So the behaviour in PhpStorm is different, when I use the navigate file on second project, I see all the vendor file by default :
If I mark the directory as excluded, the ide don't understand the vendor class :
So how can we configure the IDE to mark a directory as library root ?
Thanks to #LazyOne comment, found the solution : Select Preferences | Languages & Frameworks | JavaScript | Libraries and click Add. Select the path you want to add and the folder will be marked as library root. Really useful for non standard path (not bower_components for example)
Found a solution that worked for me.
I opened the .idea folder (in sublime), searched all files for the text node_modules and removed the lines containing it.
In my case I had 2 entries
workspace.xml
<property name="ts.external.directory.path" value="$PROJECT_DIR$/node_modules/typescript/lib" />
project-name.iml
<content url="file://$MODULE_DIR$/node_modules" />
Now my node_modules directory is automatically marked as library root again
File > Settings > Directories
Remove any node_modules entries (right-hand side, x's)
Thank you to #Allisone for providing the manual solution.
Based on their response, I was able to replicate the solution using the settings.

Exclude user_home directory from Header Search Paths list

Clion always tries to index my USER_HOME directory and it takes much time to complete. Deleting line <root url="file://$USER_HOME$" /> in project iml file give effect, but it continues while cmake project is not reloaded. When it happens something external change iml file back and return <root url="file://$USER_HOME$" /> line.
How to exclude this directory forewer? "Mark directory as" does not exist in popup menu. CLion 2016.2. Win10

Where are IntelliJ scratch files located?

In IntelliJ IDEA 14, we can create scratch files from Tools > New Scratch File...
Are they stored in some temporary files? If the answer is yes, where are they?
Attempts:
1) I pressed right click > Copy Reference and I pasted it:
1d0b26a2/scratch.2:1
2) I opened .idea\workspace.xml and I have the following part for scratch files:
<file leaf-file-name="scratch.2" pinned="false" current-in-tab="true">
<entry file="scratchpad://1d0b26a2/scratch.2">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.0" vertical-offset="0" max-vertical-offset="636">
<caret line="0" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="20" />
<folding />
</state>
</provider>
</entry>
</file>
For a normal file the entry path starts with file:// instead of scratchpad://.
Starting with 14.1, Scratch Files are stored under .IntellijIdea14/config/scratches.
They are displayed either in Scratches and Consoles or on the Scratches tab (depends on the version you are using).
Current UI:
Earlier UI:
IntelliJ IDEA Help - Scratch files
I upgraded my IntelliJ IDEA to 14.1 and I found the scratch files.
If you create a scratch file, its path can be found in many different ways:
On the title bar
Right click on the tab > Copy Reference
You can paste it anywhere and it will look like:
C:/Users/username/.IntelliJIdea14/config/scratches/scratch
Right click on the tab > Rename File...
Right click on the tab > Local History > Show History
In .idea\workspace.xml it looks like:
<file leaf-file-name="scratch" pinned="false" current-in-tab="false">
<entry file="file://$APPLICATION_CONFIG_DIR$/scratches/scratch">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.0">
<caret line="4" column="17" selection-start-line="4" selection-start-column="17" selection-end-line="4" selection-end-column="17" />
<folding />
</state>
</provider>
</entry>
</file>
You can switch to project view and you'll be able to see them under "Scratches and consoles"
~/Library/Application\ Support/JetBrains/IntelliJIdea2020.1
for macOS this is the location of both
database consoles (all the neat little db helper scripts)
scratch files (stored as plain files, a scratch you created in your idea app under the name scratch.py you will find in this directory as scratch.py)
To migrate your scratches, you just need to copy over these directories to your new environment under the above mentioned path.
However, please mind that this works for IntelliJ version 2020.1 on macOS. I'm not 100% sure where earlier versions used to store scratches and on other operating systems.
Here's another solution if you can't find your scratch files in the Scratches tab as #fnt suggested (which normally is the most convenient way probably).
In my case, I've recently updated my editor from PhpStorm 2018.1 to PhpStorm 2018.2. The scratch files are saved along with all preferences in a path specific to each version of your editor. In case of MacOS it's ~/Library/Preferences/PhpStorm2018.2.
This means that when you update your IDE, it starts using the new path and it doesn't see your old scratches anymore. If you still need to open them, simply navigate to path specific for your OS and all you're scratches are there.
All paths, are listed in official docs.
Opening accidentally closed scratch files can be easily done with Cmd-E, which shows the "Recent Files" popup. Closed scratch files show up there.
#rolf wrote this comment and I want to promote it as the answer here cause it's not already written. But the best way is to
Opening accidentally closed scratch files can be easily done with
Cmd-E, which shows the "Recent Files" popup. Closed scratch files show
up there. – Rolf
Thanks rolf!

Folders missing in project pane in Webstorm

I've built a project in WebStorm and then submitted the project to GitHub.
When I rebooted the computer and relaunched WebStorm (and the project), all I can see in the project pane is the root files, and none of the folders (yes the folders are there)
See the image below for reference.
Does anyone know how I can get those folders to re-appear in the project pane of Webstorm?
It can be caused by the corrupted .idea/modules.xml project file. You can either try to fix it manually (restore from Local History, version control or backup) or create the new project from scratch.
Check this issue for the hints/workarounds.
It happens sometimes in WebStorm 9.
The easiest way to fix it for me:
close WebStorm;
in project's folder remove .idea/ (hidden directory);
open your project, enjoy:)
Solution:
Creating a new project from existing sources
File => New => Project
Select "Empty Project"
Browse to the location of your project with folder issues
Click "Create"
Select "Create from Existing Sources" in the "Directory Is Not Empty" dialog
Why this solution:
Editing and deleting in various combinations of .idea and XML files did not solve the issue for me. Hence the solution above. Back up your .idea directory in case you have project customizations you want to keep. This likely overwrites them.
Outcome:
All the various folders I had created were now visible and the project worked as expected. The .idea directory was now formatted correctly with all the necessary files.
Find the .idea/modules.xml in your project root
make sure that these lines are correct :
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/NameOfYourProject.iml" filepath="$PROJECT_DIR$/.idea/NameOfYourProject.iml" />
</modules>
Replace NameOfYourProject.iml with the name of your project.
Then, make sure that the file .idea/NameOfYourProject.iml exists, if not , create it and put this in it :
<?xml version="1.0" encoding="UTF-8"?>
<module type="WEB_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="module-library">
<library name="PHP">
<CLASSES>
<root url="file://$MODULE_DIR$/../../php/PEAR" />
</CLASSES>
<SOURCES />
</library>
</orderEntry>
</component>
</module>
You do not need to delete whole .idea folder and reconfigure your whole project, just
delete the .idea/modules.xml
restart the IDE and your folders are there again!
I ran into the same issue and resolved it by invalidating the cache.
The option is under File > Invalidate Caches/Restart.
On the prompt click Invalidate and restart.
Note: The project in concern needs to be open before you do this.
I see this from time to time. I use Git, and I have my .gitignore file set up as recommended, specifically:
.idea/workspace.xml
.idea/tasks.xml
.idea/*.iml
I sometimes see this after cloning the repository, and when trying to figure out why, I came across this post and read the accepted answer.
I deleted the modules.xml file and reopened WebStorm (2016.2.4), and it was resolved. I looked at the new modules.xml and found that its contents were exactly the same as before, but my <projectName>.iml file was bigger.
So it seems to be a corruption in the .iml file, not modules.xml. I assume that deleting modules.xml triggers a rebuild of the .iml file. Not sure if this helps anyone with anything, but thought I would offer the extra insight.
floor 36 solve my problem. in WebStrorm 11
It happens sometimes in WebStorm 9. The easiest way to fix it for me:
close WebStorm;
in project's folder remove .idea/ (hidden directory);
open your project, enjoy:)
Try deleting workspace.xml and watchertask.xml then just restart the IDE. You must see your full source code in all folders there.
Finally I found the culprit, it was Team Foundation Server - Version Control Integration plugin from https://plugins.jetbrains.com/plugin/7961-team-foundation-server--version-control-integration/
I looked at the system/log/idea.log file and found that this plugin was producing Null exception whenever I open a new folder as a new project and breaks the content root auto detection by the IDE, and after I uninstalled this plugin, all folders show up as it should.
You might have this issue because of a culprit plugin, and disabling those which you have just installed recently just before this issue occurs, will resolve the issue. Check the log file and search for ERROR.
If it is found to be an important plugin you are actively using which you are not willing to disable, then a temporary fix is to open Settings->Directories and click Add content root button to add the root folder of your project, click Ok now folders will show up and indexing will begin, and of course you have to do this everytime you open a new folder as new project.