8

如果您按 Shift+Ctrl+T 或选择“导航 > 打开类型...”,您将获得“打开类型”对话框,用于快速导航到已知类。当您开始输入名称时,只有名称匹配的类保持可见。这样,您可以很快找到一个您知道名称的类,而无需浏览包资源管理器树。

直到今天早上,这对我来说一直很有效。突然之间,对于我的几个项目,我只看到了一些存在的类型。当然,我尝试了刷新项目、清理项目、重新构建项目、在外部重新构建项目的明显步骤,但都无济于事。这有点奇怪,因为这些类型在其他地方是已知的。如果我添加一个导入语句,Eclipse 不会抱怨它不知道类型,我可以通过 Ctrl-Click 类型来访问它们的文件。但是,类型导航对它们一无所知。

过去,当 InteliJ 曾经对我这样做时,我会找到它的缓存文件并删除它们,迫使它重建。Eclipse 是否有类似的事情我可能会做(我是 Eclipse 新手)?我正在使用 Eclipse 3.4.2,并且我已将其配置为彻底删除文件(因为我们的实际构建过程将文件放入我不希望 Eclipse 处理的输出目录中)。

4

8 回答 8

20

您是否尝试过关闭并重新打开项目?只有打开项目中的类型保存在内存中,当您第一次在新打开的项目上使用 Shift+Ctrl+T 时会发生刷新。

编辑添加:Ctrl+Shift+R 还显示类型(以及其他所有内容),但它还支持 Camel-case 以快速查找 Java 类型。

于 2009-05-18T19:30:26.513 回答
7

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

于 2014-04-29T08:34:46.297 回答
3

尝试使用 -clean 标志启动 eclipse,您可以将其添加到 eclipse.ini 中,该文件可以在与 eclispe.exe 相同的目录中找到,或者如果您使用 bat 或 shell 脚本启动 eclipse,请将其添加为启动参数,例如 eclipse -clean。

clean 将整理您的工作区,并应强制 eclipse JDT 重新计算类型。我遇到了 .snap 文件的问题(似乎是在脏关机时创建的),这些文件似乎破坏了我的工作区,直到我清理它们,不久前 eclipse 丢失了 Object 类!犯了一些有趣的错误!

于 2009-05-18T19:51:33.087 回答
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.

于 2009-08-10T14:39:52.257 回答
0

This worked for me -

  1. Select your project in Package Explorer
  2. Press F5 or Right click and select Refresh
于 2015-02-25T06:29:16.553 回答
0

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

于 2015-08-24T13:16:26.507 回答
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

于 2017-03-14T17:09:09.867 回答
-2

(警告:前方无耻营销)

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.

于 2009-05-19T04:04:43.700 回答