use of org.eclipse.ceylon.compiler.typechecker.tree.Tree.ImportPath in project ceylon by eclipse.
the class PhasedUnit method validateTree.
public void validateTree() {
// System.out.println("Validating tree for " + fileName);
if (!treeValidated) {
String fn = unit.getRelativePath();
for (int i = 0; i < fn.length(); i = fn.offsetByCodePoints(i, 1)) {
int cp = fn.codePointAt(i);
if (cp > 127) {
rootNode.addUsageWarning(Warning.filenameNonAscii, "source file name has non-ASCII characters: " + fn);
}
}
String ufn = unit.getFilename();
for (Unit u : unit.getPackage().getUnits()) {
if (!u.equals(unit) && u.getFilename().equalsIgnoreCase(ufn)) {
if (u.getFilename().equals(ufn)) {
String errorMessage = "identical source files: " + unit.getFullPath() + " and " + u.getFullPath();
if (u.getFilename().equals(MODULE_FILE) || u.getFilename().equals(PACKAGE_FILE)) {
errorMessage += " (a module/package descriptor should be defined only once, even in case of multiple source directories)";
}
rootNode.addError(errorMessage);
} else {
rootNode.addUsageWarning(Warning.filenameCaselessCollision, "source file names differ only by case: " + unit.getFullPath() + " and " + u.getFullPath());
}
}
}
rootNode.visit(new Validator().setExceptionHandler(this));
rootNode.visit(new Visitor() {
@Override
public void visit(ModuleDescriptor that) {
super.visit(that);
ImportPath importPath = that.getImportPath();
if (importPath != null) {
String moduleName = formatPath(importPath.getIdentifiers());
ModuleSourceMapper moduleManagerUtil = moduleSourceMapperRef.get();
if (moduleManagerUtil != null) {
for (Module otherModule : moduleManagerUtil.getCompiledModules()) {
String otherModuleName = otherModule.getNameAsString();
if (moduleName.startsWith(otherModuleName + ".") || otherModuleName.startsWith(moduleName + ".")) {
StringBuilder error = new StringBuilder().append("Found two modules within the same hierarchy: '").append(otherModule.getNameAsString()).append("' and '").append(moduleName).append("'");
that.addError(error.toString());
}
}
}
}
}
}.setExceptionHandler(this));
treeValidated = true;
}
}
Aggregations