Eclipse: Refreshing known types in Java project
Asked Answered
N

8

9

If you press Shift+Ctrl+T or choose "Navigate > Open Type..." you get the "Open Type" dialog for quickly navigating to a known class. When you start typing a name only the classes for which the name matches stay visible. That way you can find a class of which you know the name very quick without having to browse through the package explorer tree.

This has been working great for me up until this morning. All of a sudden for a couple of my projects I am only seeing some of the types that exist. Of course I tried the obvious steps of refreshing the projects, cleaning the projects, re-building the projects, rebuilding the projects externally, but all to no avail. It is a bit odd since the types are known in other places. If I add an import statement Eclipse does not complain that it doesn't know the type and I can Ctrl-Click through the types to get to their file. However, the type navigation knows nothing about them.

In the past when InteliJ used to do this to me I would go find its cache files and delete them forcing it to rebuild. Does Eclipse have something similar I might do (I'm an Eclipse newbie)? I am using Eclipse 3.4.2 and I have it configured to not delete files on a clean (because our actual build process puts files into the output directories that I don't want Eclipse mucking with).

Nomadize answered 18/5, 2009 at 19:23 Comment(0)
C
23

Have you tried closing and reopening the project? Only types from open projects are held in memory, and the refresh occurs when you Shift+Ctrl+T for the first time on a newly opened project.

Edit to add: Ctrl+Shift+R also displays the types (along with everything else) but it also supports the Camel-case thing to find the Java types quickly.

Cata answered 18/5, 2009 at 19:30 Comment(2)
This seems to have done the trick. One odd thing though, I did stop and restart Eclipse during this process - is there something different about closing a project? One other note - at least in 3.4.2 Ctrl-Shift-T also supports the camel case notation (and limits you to types which can be nice).Nomadize
Eclispe has some obnoxious flaws, good most of them are easily fixable when you know what to do, thx! Oh, "Open Resource" ctrl+shift+R is actually very good as it seems restricted to current project resources, smaller list of options!Mascarenas
P
8

Close eclipse and delete any .index files and the savedIndexNames.txt file in workspace/.metadata/.plugins/org.eclipse.jdt.core once eclipse is restarted it will rebuildl the entire index for Ctrl+T

Pilaf answered 29/4, 2014 at 8:34 Comment(1)
Closing and reopening the projects didn't work for me. This should be the accepted answer.Brainless
M
3

try starting eclipse with the -clean flag, you can add this to your eclipse.ini which can be found in the same directory as you eclispe.exe, or if you start eclipse using a bat or shell script, add it as a startup argument, e.g. eclipse -clean.

The clean will tidy your workspace, and should force eclipse JDT to recalulate types. Ive had issue with .snap files (with seem to be created on dirty shutdowns) that seem to corrupt my workspace until I clean them up, not long ago eclipse lost the Object class!! made for some interesting errors!

Mohave answered 18/5, 2009 at 19:51 Comment(1)
Thanks for the info. I'm going to add this as well just to be on the safe side.Nomadize
K
1

I get problems like this often. I tried your solution, noticed it seemed to rebuild its search index, but I still couldn't find any of my classes. Then I took a look at the little green arrow on top right corner of that dialog, and noticed I had a working set selected which belonged to another project. I find it a little dumb that Eclipse doesn't warn you about this or anything, since this can be a very annoying little detail that one tends to forget (me at least ;-)).

Anyways, clicked on "Deselect Working Set" and bam I can find my classes again. Thought I'd add this here since others may make the same mistake.

Koo answered 10/8, 2009 at 14:39 Comment(2)
"Deselect Working Set" that is the safest, simplest, easiest answer. Took me so long to see it that your seem to not be around anymore :/, but thx anyway!Mascarenas
Not only working set may cause this. I wasn't able to open any class from java.* and javax.* packages, till I looked under "Type Filters" menu.BTW import didn't worked ether.Eclipse kept showing error, class not found. That was not fun.Albuminous
S
0

This worked for me -

  1. Select your project in Package Explorer
  2. Press F5 or Right click and select Refresh
Squarrose answered 25/2, 2015 at 6:29 Comment(0)
M
0

I used the "-clean" as first line in the eclipse.ini (version Juno) and worked like a charm.

Metaphysical answered 24/8, 2015 at 13:16 Comment(0)
J
0

I'v tried all the answers and I still had the issue. I then tried this:
I deleted the project (it's a maven project) and re-imported it. This time I made sure i check the "Add Project(s) to working set" checkbox. After that Eclipse was able to find the classes in that project.

The problem must have started because I didn't check this checkbox when i first imported this project.
By the way, I'm using Neon

Jodi answered 14/3, 2017 at 17:9 Comment(0)
W
-2

(Warning: Shameless marketing ahead)

If you like this feature, you would love nWire. nWire allows, among other things, to quickly search not only for types, but for any possible Java element like method or field. It also uses a navigator view which is non-modal. After searching you can see the class associations in a very quick and easy way. Check out the video on our site.

Wend answered 19/5, 2009 at 4:4 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.