use of org.eclipse.ceylon.compiler.typechecker.analyzer.ModuleValidator in project ceylon by eclipse.
the class TypeChecker method executePhases.
private void executePhases(PhasedUnits phasedUnits, boolean forceSilence) {
List<PhasedUnit> listOfUnits = phasedUnits.getPhasedUnits();
phasedUnits.getModuleManager().prepareForTypeChecking();
phasedUnits.visitModules();
phasedUnits.getModuleManager().modulesVisited();
// By now le language module version should be known
// (as local) or we should use the default one.
Module languageModule = context.getModules().getLanguageModule();
if (languageModule.getVersion() == null) {
languageModule.setVersion(LANGUAGE_MODULE_VERSION);
}
ModuleValidator moduleValidator = new ModuleValidator(context, phasedUnits);
if (verifyDependencies) {
moduleValidator.verifyModuleDependencyTree();
}
phasedUnitsOfDependencies = moduleValidator.getPhasedUnitsOfDependencies();
executePhases(listOfUnits);
if (!forceSilence) {
for (PhasedUnit pu : listOfUnits) {
if (verbose) {
pu.display();
}
pu.generateStatistics(statsVisitor);
pu.runAssertions(assertionVisitor);
}
if (verbose || statistics) {
statsVisitor.print();
}
assertionVisitor.print(verbose);
}
}
use of org.eclipse.ceylon.compiler.typechecker.analyzer.ModuleValidator in project ceylon by eclipse.
the class CeyloncCompilerDelegate method resolveModuleDependencies.
@Override
public void resolveModuleDependencies(PhasedUnits phasedUnits) {
final StatusPrinter sp = getStatusPrinter();
org.eclipse.ceylon.compiler.typechecker.context.Context ceylonContext = LanguageCompiler.getCeylonContextInstance(context);
final ModuleValidator validator = new ModuleValidator(ceylonContext, phasedUnits);
if (sp != null) {
validator.setListener(new StatusPrinterProgressListener(validator, sp));
sp.clearLine();
sp.log("Starting resolving");
}
validator.verifyModuleDependencyTree();
if (sp != null) {
sp.clearLine();
sp.log("Done resolving");
}
}
use of org.eclipse.ceylon.compiler.typechecker.analyzer.ModuleValidator in project ceylon by eclipse.
the class CeylonDocTool method initialize.
@Override
public void initialize(CeylonTool mainTool) throws Exception {
super.initialize(mainTool);
TypeCheckerBuilder builder = new TypeCheckerBuilder();
for (File src : sourceFolders) {
builder.addSrcDirectory(src);
}
// set up the artifact repository
RepositoryManager repository = getRepositoryManager();
builder.setRepositoryManager(repository);
// make a destination repo
outputRepositoryManager = getOutputRepositoryManager();
// create the actual list of modules to process
List<File> srcs = FileUtil.applyCwd(cwd, sourceFolders);
Collection<String> expandedModules = ModuleWildcardsHelper.expandWildcards(srcs, moduleSpecs, null);
final List<ModuleSpec> modules = ModuleSpec.parseEachList(expandedModules);
final Callable<PhasedUnits> getPhasedUnits = new Callable<PhasedUnits>() {
@Override
public PhasedUnits call() throws Exception {
return typeChecker.getPhasedUnits();
}
};
// we need to plug in the module manager which can load from .cars
builder.moduleManagerFactory(new ModuleManagerFactory() {
@Override
public ModuleManager createModuleManager(Context context) {
return new PhasedUnitsModuleManager(getPhasedUnits, context, modules, outputRepositoryManager, bootstrapCeylon, getLogger());
}
@Override
public ModuleSourceMapper createModuleManagerUtil(Context context, ModuleManager moduleManager) {
return new LazyModuleSourceMapper(context, (PhasedUnitsModuleManager) moduleManager, null, false, null, getEncoding());
}
});
// only parse what we asked for
List<String> moduleFilters = new LinkedList<String>();
for (ModuleSpec spec : modules) {
moduleFilters.add(spec.getName());
if (spec.getName().equals(Module.LANGUAGE_MODULE_NAME) && !bootstrapCeylon) {
throw new CeylondException("error.languageModuleBootstrapOptionMissing");
}
}
builder.setModuleFilters(moduleFilters);
String fileEncoding = getEncoding();
if (fileEncoding == null) {
fileEncoding = CeylonConfig.get(DefaultToolOptions.DEFAULTS_ENCODING);
}
if (fileEncoding != null) {
builder.encoding(fileEncoding);
}
// We do this ourselves, so we can report on the resolution errors before
// running typeChecker.process();
builder.skipDependenciesVerification();
typeChecker = builder.getTypeChecker();
{
PhasedUnits phasedUnits = typeChecker.getPhasedUnits();
phasedUnits.getModuleManager().prepareForTypeChecking();
phasedUnits.visitModules();
phasedUnits.getModuleManager().modulesVisited();
}
ModuleValidator moduleValidator = new ModuleValidator(typeChecker.getContext(), typeChecker.getPhasedUnits());
moduleValidator.verifyModuleDependencyTree();
AssertionVisitor av = new AssertionVisitor();
for (PhasedUnit pu : typeChecker.getPhasedUnits().getPhasedUnits()) {
pu.getCompilationUnit().visit(av);
}
if (haltOnError && av.getErrors() > 0) {
throw new CeylondException("error.failedParsing", new Object[] { av.getErrors() }, null);
}
typeChecker.process();
if (haltOnError && typeChecker.getErrors() > 0) {
throw new CeylondException("error.failedTypechecking", new Object[] { typeChecker.getErrors() }, null);
}
initModules(modules);
initPhasedUnits();
}
Aggregations