Eclipse:刷新Java项目中的已知类型

时间:2023-02-05 12:00:06

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.

如果按Shift + Ctrl + T或选择“导航>打开类型...”,则会出现“打开类型”对话框,以便快速导航到已知类。当您开始键入名称时,只有名称匹配的类保持可见。通过这种方式,您可以快速找到一个您知道名称的类,而无需浏览包浏览器树。

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.

直到今天早上,这一直对我很有用。对于我的几个项目突然间,我只看到了一些存在的类型。当然,我尝试了清理项目,清理项目,重建项目,在外部重建项目的明显步骤,但都无济于事。这有点奇怪,因为这些类型在其他地方是已知的。如果我添加一个import语句,Eclipse不会抱怨它不知道类型,我可以按住Ctrl键单击类型来获取它们的文件。但是,类型导航对它们一无所知。

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).

过去,当InteliJ以前对我这样做时,我会找到它的缓存文件并删除它们,迫使它重建。 Eclipse有类似的东西(我是Eclipse新手)吗?我正在使用Eclipse 3.4.2并且我将它配置为不删除干净的文件(因为我们的实际构建过程将文件放入我不希望Eclipse混淆的输出目录中)。

8 个解决方案

#1


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.

您是否尝试过关闭并重新开放项目?只有来自打开项目的类型才会保留在内存中,并且在新打开的项目中第一次按Shift + Ctrl + T时会进行刷新。

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.

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

#2


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

关闭eclipse并删除任何.index文件和workspace / .metadata / .plugins / org.eclipse.jdt.core中的savedIndexNames.txt文件一旦eclipse重新启动它将重建整个索引为Ctrl + T

#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.

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

干净将整理你的工作区,并应强制日食JDT重新计算类型。我有问题.snap文件(似乎是在脏关机上创建)似乎破坏了我的工作区,直到我清理它们,不久前eclipse失去了Object类!为一些有趣的错误!

#4


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 ;-)).

我经常遇到这样的问题。我尝试了你的解决方案,注意到它似乎重建了它的搜索索引,但我仍然找不到我的任何类。然后我看了一下该对话框右上角的绿色小箭头,注意到我选择了一个属于另一个项目的工作集。我发现Eclipse有点愚蠢,Eclipse并没有警告你这个或任何事情,因为这可能是一个非常烦人的小细节,人们往往会忘记(至少我;-))。

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.

无论如何,点击“取消选择工作集”和bam我可以再次找到我的课程。以为我会在这里添加这个,因为其他人可能会犯同样的错误。

#5


This worked for me -

这对我有用 -

  1. Select your project in Package Explorer
  2. 在Package Explorer中选择您的项目

  3. Press F5 or Right click and select Refresh
  4. 按F5或右键单击并选择“刷新”

#6


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

我在eclipse.ini(Juno版本)中使用了“-clean”作为第一行,并且像魅力一样工作。

#7


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.

我尝试了所有的答案,但我仍然遇到了问题。然后我尝试了这个:我删除了项目(它是一个maven项目)并重新导入它。这一次,我确保选中“将项目添加到工作集”复选框。之后,Eclipse能够在该项目中找到类。

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

问题必须已经开始,因为我在第一次导入此项目时没有选中此复选框。顺便说一下,我正在使用霓虹灯

#8


(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.

如果你喜欢这个功能,你会喜欢nWire。除其他外,nWire不仅可以快速搜索类型,还可以快速搜索任何可能的Java元素,如方法或字段。它还使用非模态的导航视图。搜索后,您可以非常快速简便地查看课程关联。看看我们网站上的视频。

#1


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.

您是否尝试过关闭并重新开放项目?只有来自打开项目的类型才会保留在内存中,并且在新打开的项目中第一次按Shift + Ctrl + T时会进行刷新。

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.

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

#2


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

关闭eclipse并删除任何.index文件和workspace / .metadata / .plugins / org.eclipse.jdt.core中的savedIndexNames.txt文件一旦eclipse重新启动它将重建整个索引为Ctrl + T

#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.

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

干净将整理你的工作区,并应强制日食JDT重新计算类型。我有问题.snap文件(似乎是在脏关机上创建)似乎破坏了我的工作区,直到我清理它们,不久前eclipse失去了Object类!为一些有趣的错误!

#4


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 ;-)).

我经常遇到这样的问题。我尝试了你的解决方案,注意到它似乎重建了它的搜索索引,但我仍然找不到我的任何类。然后我看了一下该对话框右上角的绿色小箭头,注意到我选择了一个属于另一个项目的工作集。我发现Eclipse有点愚蠢,Eclipse并没有警告你这个或任何事情,因为这可能是一个非常烦人的小细节,人们往往会忘记(至少我;-))。

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.

无论如何,点击“取消选择工作集”和bam我可以再次找到我的课程。以为我会在这里添加这个,因为其他人可能会犯同样的错误。

#5


This worked for me -

这对我有用 -

  1. Select your project in Package Explorer
  2. 在Package Explorer中选择您的项目

  3. Press F5 or Right click and select Refresh
  4. 按F5或右键单击并选择“刷新”

#6


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

我在eclipse.ini(Juno版本)中使用了“-clean”作为第一行,并且像魅力一样工作。

#7


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.

我尝试了所有的答案,但我仍然遇到了问题。然后我尝试了这个:我删除了项目(它是一个maven项目)并重新导入它。这一次,我确保选中“将项目添加到工作集”复选框。之后,Eclipse能够在该项目中找到类。

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

问题必须已经开始,因为我在第一次导入此项目时没有选中此复选框。顺便说一下,我正在使用霓虹灯

#8


(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.

如果你喜欢这个功能,你会喜欢nWire。除其他外,nWire不仅可以快速搜索类型,还可以快速搜索任何可能的Java元素,如方法或字段。它还使用非模态的导航视图。搜索后,您可以非常快速简便地查看课程关联。看看我们网站上的视频。