简体   繁体   中英

How do I make eclipse (Indigo) collapse empty (parent) packages?

What I want to do is simply use the eclipse package explorer in hierarchical view but with empty packages being collapsed so I don't have to open 5+ packages to find the first Java file.

I'm not even sure how I did it in previous versions, but I've never had any trouble finding it before, it just seems to be gone now. I have a feeling there was a "flatten hierarchy" tick-box somewhere.

To clarify I get this:

com
  example
    etc
      file1.java

Rather than:

com.example.etc
  file1.java

I'm using Eclipse Indigo (v. 3.7.1)

请求的设置截图

Open the View menu (small triangle in top right corner), open filters and check Empty parent packages.

In most cases it works, but in case of existing projects it does not always work as expected. If you seem to have troubles, try to export the project, remove it, then re-add the exported version (or re-checkout from your VCS).

Assuming the view filter is engaged properly, perhaps your source folders are not as "empty" as you think.

For example, on Apple OS X, Eclipse will detect .DS_STORE entires along your src/package/hierarchy, making the parent packages technically non-empty.

Delete any such hidden files and refresh your project.

I don't know what the problem actually was, but I couldn't get it fixed until I gave up altogether and reinstalled the OS (it was a fresh install anyway), and eclipse. It was completely fine after that. :\\

单击“Package explorer”右上角的箭头,然后选择“Package presentation - > flat”

Window - Preferences - Java - Appearance - Abbreviate package names

And enter the following rule:

com.example.etc={cee}

Try to restart Eclipse once in a while. I had trouble getting it to work, and after an Eclipse restart it suddenly was working again.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM