Community
Participate
Working Groups
I can't see any of my default-package classes in Package Explorer for a certain build layout. I have my java source tree starting at the root of my project but have certain non-source folders. If I put **/*.java as my _include_, everything compiles just as I want it, including default-package source files in the project's root directory. However, these files are invisible in Package Explorer. This is the case with either hierarchical or flat package layout. I don't see the `(default package)` entry at all. Adding *.java doesn't help (and shouldn't be necessary). This is easy to reproduce and affects only the Package Explorer. There is no good workaround and it's pretty disruptive to have to use Navigator to edit my classes!
Reproduced in 3.2 - create new project with project a source folder - add class A.java in default package - configure **/*.java as inclusion filter of the source folder package explorer doesn't show A.java anymore open type still contains A.
As far as I know, **/*.java means to select compilation units at least in one folder level whereas */*.java means to select compilation units starting at the first level. Surprisingly in this case the compilation A.java in the default package is shown as not being on the classpath. If you add 'A.java' and '*/*.java', A is not shown.
In fact, the Package Explorer will *never* display files in the root of a project if you have class path _include_ qualifiers. For example, adding the pattern "*.java" still fails to cause the files in the root directory to show in Package Explorer. Regardless of any possible debate about the meaning of **, the Package Explorer is broken. However, I strongly believe that the compiler's interpretation of the double-star globbing operator is correct to include files in the root directory. If you look at the default behavior of UNIX shells, you'll find that they don't agree on whether to include the root directory. By default, zsh (arguably the most powerful interactive shell) would include a file in the current directory while bash (probably the most popular interactive shell) would not. Both (and probably any other shell you can find) follow the convention that a single-star globbing operator will never substitute an expression that contains a slash. Neither would include a file in the root directory with the pattern "*/*.java", which always means to find *.java 1-level deep. Before you argue that we should change the way Eclipse's globbing works to match bash, consider that it's less-powerful convention. With bash's default behavior, we'd have no single pattern available to find all the .java files within a directory: we could only find those one level deep. We'd have to use two patterns, **/*.java and *.java. It's hard to imagine a good use case where you want to exclude files in the root directory anyway, but the zsh-style syntax offers a mechanism to do that too! In zsh, you can always write */**/*.java to include directories at least one level deep: the single-star operator forces you past the first level and the double-star operator finds everything beneath it. Note, I use zsh and bash as examples because they are popular, but you'll find that nearly all shells adopt nearly the same conventions. If it helps, you can think of the inconsistent behavior between ** operators as the difference between the * and + quantifiers in a regular expression.
Changed Util.isExcluded(IResource,char[][],char[][]) and JavaProject#isOnClasspath(IResource) to consider that an IProject is a folder path. Added regression test InclusionPatternsTests#testDefaultPackageProjectIsSource(). Released for 3.3 M1 in HEAD.
Verified for 3.3 M1 using build I20060807-0010.