ceylon/ceylon-spec — Issue #100: Make proper use of Unit.get*Packages() after Module support
Author: emmanuelbernard
Created: 2011-12-12 12:31:53+00:00
State: open

There seems to be confusion in the code on the various methods to get the list of packages of a module. If your code area uses any of the Module.get*Packages(), read on. I expect the IDE, compiler and Gavin will be interested.

## Current methods

### Module.getPackages()
Lists the direct packages available in the module, shared or not

### Module.getSharedPackages()
Lists the shared direct packages available in the module.

### Module.getAllPackages()
Lists all direct packages and all shared packages from dependent modules

### Module.getAllKnownPackages() - non public
Lists all direct packages and all packages from dependent modules (shared or not) but only for the first level of dependency

### Module.getPackage(String name)
Return matching package even private ones returned by getAllKnownPackages()

## Proposal

### export

None of those methods take export into account so our concept of nested exported package is not visible.

My proposal is to:

- get rid of Module.getSharedPackages I can't see where this method would be right
- Create Module.getExportedPackages() that returns all shared packages of the module as well as Module.getExportedPackages() of dependencies assuming they export=true
that would be the correct version of Module.getSharedPackages in a way
- Make Module.getAllPackages() honor export and thus return direct packages and packages of each dependent module returned by Module.getExportedPackages()
- Rename Module.getAllPackages() to Module.getModuleVisiblePackages() to be clearer

I am not sure what to do with Module.getAllKnownPackages / Module.getPackage(String name) as I don't fully understand the intend:

- should we make Module.getAllKnownPackages return all packages even privates from all dependent modules recursively? Excluding language?

### Various

- Unit.getLanguageModuleDeclaration() uses getPackages(). I'm inclined to say it should use getSharedPackages()
- ceylon.language.metamodel has no package.module and is thus not shared, should it?

WDYT?