简体   繁体   English

蚀包资源管理器:文件节点是否重复类型节点?

[英]eclipse package explorer: file node duplicates type node?

When you activate Java members for the package explorer in eclipse, the tree hierarchy goes source folder > package > java file > type > methods. 当您在eclipse中为包资源管理器激活Java成员时,树层次结构将进入源文件夹>包> Java文件>类型>方法。 Together with Mylyn that is actually quite handy. 与Mylyn一起使用实际上非常方便。 However, I feel that the Java file node is superfluous. 但是,我觉得Java文件节点是多余的。 Since every file contains exactly one "root" type, there will always be exactly one type node under the file node showing the same name. 由于每个文件仅包含一个“根”类型,因此在文件节点下将始终仅存在一个显示相同名称的类型节点。 That just takes space away and doesn't add any info. 这样只会占用空间,并且不会添加任何信息。 It would make much more sense to have only the Java language elements in this tree: package > type > members. 在此树中仅包含Java语言元素会更有意义:package> type> Members。 When you disable members it makes sense to replace type nodes with file nodes to avoid having to load the additional information from the file. 禁用成员时,将类型节点替换为文件节点是很有意义的,以避免必须从文件中加载其他信息。 But when members are enabled it doesn't. 但是,启用成员后则不会。

Is there some option which makes the package explorer skip the file nodes, or am I missing some rationale here? 是否有一些选项可以使程序包浏览器跳过文件节点,或者我在这里缺少一些基本原理?

I think if you explore source code, files are very important part of appearance. 我认为,如果您探索源代码, 文件是外观中非常重要的部分。 They can be not just java files (does not contain types), can contain more than 1 type (file with non-public classes) etc. If you just skip file names you would have a bunch of classes under package level and not aware what class belongs to what file. 它们不仅可以是Java文件(不包含类型),还可以包含不止一种类型(具有非公共类的文件)等。如果您仅跳过文件名,则在软件包级别下会有很多类,并且不知道什么类属于什么文件。

@Wolfgang, I agree with your rationale. @沃尔夫冈,我同意你的理由。 For vast majority of cases, there is a 1-to-1 mapping between a .java file and its contained type. 在大多数情况下,.java文件与其包含的类型之间存在一对一的映射。 While it is possible to have multiple top-level types in one .java file, this practice is not common, especially after advent of inner types. 尽管在一个.java文件中可以有多个顶级类型,但是这种做法并不常见,尤其是在内部类型出现之后。 Arguably, even if you are using multiple top-level types feature, explicit relationship to the .java file is not that important. 可以说,即使您正在使用多个顶级类型功能,与.java文件的显式关系也不是那么重要。 If you delete all types in a file, the file can go away. 如果删除文件中的所有类型,则文件可能消失。

Unfortunately, there is no option to suppress .java file nodes. 不幸的是,没有选择禁止显示.java文件节点。 I suspect that this is mostly for historic inertia reasons. 我怀疑这主要是出于历史惯性原因。 The various navigational views started as basic file navigators way back when. 各种导航视图从基本文件导航器开始时就开始了。

I would suggest opening enhancement request for Eclipse Java Developer Tools. 我建议打开对Eclipse Java Developer Tools的增强请求。

https://bugs.eclipse.org/bugs/enter_bug.cgi?product=JDT https://bugs.eclipse.org/bugs/enter_bug.cgi?product=JDT

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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