Is there a way to force indexing?

Answered

I'm relatively new to IDEA and I don't know all the tricks and ins-and-outs of it yet, so sorry if this feature already exists, or if it's a really easy question to answer...

Is there a way to tell IDEA "Hey, I want you to re-index this module (or directory, or file) right now, please."  In general, IDEA seems to be pretty good at staying on top of changes, but I've noticed a few times where IDEA's UI hasn't caught up to changes I've made (for example, if I remove a needed module dependency, I frequently have to actually open up .java files in the viewer before IDEA will re-index them and flag them as having an error.

Furthermore, a "Hey IDEA, stop indexing right now, I just want to read this damn file" button would be nice too, but I'm sure there are a bunch of reasons over my head for why that would be a terrible idea.

I'm sure I'm not the first person to think of this, and I bet it has been discussed before (I didn't find any threads in my cursory search, feel free to flame if I missed something obvious), so I imagine there's a good reason the feature doesn't seem to exist... I am just curious what it is.

7
18 comments

File > Invalidate Caches...


40

I don't think he really means "indexing", but what IDEA calls "Synchronize".
There's a menu item/toolbar button for that (File -> Synchronize, or third button on the toolbar).

5

Thanks for both the quick replies!  I'll play around with both of those and see if they help (I imagine it's exactly what I'm looking for).  You may well be right about my misuse of the term "indexing."  Like I said, I'm still getting acquainted with IDEA.

0

IDEA will synchronize the underlying file system, when switching from an external application back to IDEA. Then you will notice a little spinner in the bottom left of the window, which indicates, that the file system is being searched for changes.

For example we are using a Rake task to compile CSS files from SASS. After changing a SASS file in IDEA, we switch to the shell, where Rake is running and thanks to IDEAs feature of saving files at context switch, we even don't need to save the SASS file first. Rake notices the change and recompiles the CSS. Then, switching back to IDEA, the IDE will synchronize FS state and discover the changed CSS files. After the spinner has stopped, we switch to the browser and IDEA will update the new CSS files to the webapp server.

So, IDEA uses a lot of implicit synchronization. I imagine, you come from Eclipse, because Eclipse has this horrible "mirror-like-Eclipse-internal-file-system" which almost never shows the correct state. In fact, for me this was one of the main reasons for switching to IDEA.

0

I'd like to ask the opposite...

Is there a way to let it do indexing less often? Is there a way to let it only index certain types of files (e.g. index java but not javascript)? Is there a way to let it stop indexing and let you work normally again while it is busy indexing (in a case where you don't really care that the index will be a bit off then). Is there a way to let it not reindex everything after IntelliJ crashed or was in a deadlock and you had to kill its process?

I accidently slipped the mouse and pressed the synchronize instead of the save button. Boom, 15 minutes of time lost because it starts indexing and disables all kinds of actions while doing that...

Thanks!

0

Hello Aardwolf,

The indexes cannot be "a bit off"; they can be either available or not available.

To stop indexing certain types of files, you can remap them to plain text
file type.

We may be able to implement an action for suspending indexing, but you won't
be able to work normally in that state - all functionality relying on indexes
(such as Find Usages and refactorings) will not be available.

In general, if you see excessively long indexing in cases other than abnormal
termination of the IDEA process, there's something that can be optimized
in your project configuration to shorten the indexing time. In particular,
this can be achieved by marking directories as excluded in the project structure
dialog.

I'd like to ask the opposite...

Is there a way to let it do indexing less often? Is there a way to let
it only index certain types of files (e.g. index java but not
javascript)? Is there a way to let it stop indexing and let you work
normally again while it is busy indexing (in a case where you don't
really care that the index will be a bit off then). Is there a way to
let it not reindex everything after IntelliJ crashed or was in a
deadlock and you had to kill its process?


--
Dmitry Jemerov
Development Lead
JetBrains, Inc.
http://www.jetbrains.com/
"Develop with Pleasure!"


1
Avatar
Matheushsantosa

I'm trying to use Cucumber to do the functional tests of the project I'm working on, however IntelliJ is not synchronizing the .feature file. Can someone help me?

0
Avatar
Matheushsantosa

Ok, thank you.

0

For IntelliJ 2021.1 this seems reindex jdk as well as all libraries:

Help / Diagnostic Tools / Profile Indexing 

Im am not aware if earlier version have that feature.

 

2

The solution of michael.schaffler worked for me !

1

Removing the /.idea/ directory worked for me in RubyMine 2021.2.

0

`FIle->Repair IDE...` works to me

0

Is there a way to have Intellij index one file? Since invalidating the cache takes a long time...

0

Chang right-click on the affected file in Project View  | Repair IDE would rescan indexes for the particular file

1

invalidate caches forces a restart. This can't possibly be the recommended solution!
Also, I only installed a single package. Do I now have to re-index EVERYTHING?

 

makes no sense.

0

Noamzilo

If you right-click on the affected file in the Project view and choose 'Repair IDE on File', IDEA will only re-index that particular file.

0

Please sign in to leave a comment.