@Override
public void visit(Tree.ModuleDescriptor that) {
super.visit(that);
if (phase==Phase.SRC_MODULE) {
String version = getVersionString(that.getVersion());
ImportPath importPath = that.getImportPath();
List<String> name = getNameAsList(importPath);
if (pkg.getNameAsString().isEmpty()) {
that.addError("module descriptor encountered in root source directory");
}
else if (name.isEmpty()) {
that.addError("missing module name");
}
else {
String initialName = name.get(0);
if (initialName.equals(Module.DEFAULT_MODULE_NAME)) {
importPath.addError("reserved module name: 'default'");
}
else if (name.size()==1 && initialName.equals("ceylon")) {
importPath.addError("reserved module name: 'ceylon'");
}
else {
if (initialName.equals("ceylon")) {
importPath.addUsageWarning(Warning.ceylonNamespace,
"discouraged module name: this namespace is used by Ceylon platform modules");
}
else if (initialName.equals("java") || initialName.equals("javax")) {
importPath.addUnsupportedError("unsupported module name: this namespace is used by Java platform modules");
}
mainModule = moduleManager.getOrCreateModule(name, version);
importPath.setModel(mainModule);
if (!completeOnlyAST) {
mainModule.setUnit(unit.getUnit());
mainModule.setVersion(version);
}
String nameString = formatPath(importPath.getIdentifiers());
if ( !pkg.getNameAsString().equals(nameString) ) {
importPath
.addError("module name does not match descriptor location: '" +
nameString + "' should be '" + pkg.getNameAsString() + "'",
8000);
}
if (!completeOnlyAST) {