use of com.redhat.ceylon.compiler.typechecker.util.ModuleManagerFactory in project ceylon-compiler by ceylon.
the class CeylonDocTool method initialize.
@Override
public void initialize(CeylonTool 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);
List<String> expandedModules = ModuleWildcardsHelper.expandWildcards(srcs, moduleSpecs, null);
final List<ModuleSpec> modules = ModuleSpec.parseEachList(expandedModules);
// 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 CeylonDocModuleManager(CeylonDocTool.this, context, modules, outputRepositoryManager, bootstrapCeylon, log);
}
@Override
public ModuleSourceMapper createModuleManagerUtil(Context context, ModuleManager moduleManager) {
return new CeylonDocModuleSourceMapper(context, (CeylonDocModuleManager) moduleManager, CeylonDocTool.this);
}
});
// 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);
}
typeChecker = builder.getTypeChecker();
// collect all units we are typechecking
initTypeCheckedUnits(typeChecker);
typeChecker.process();
if (haltOnError && typeChecker.getErrors() > 0) {
throw new CeylondException("error.failedParsing", new Object[] { typeChecker.getErrors() }, null);
}
initModules(modules);
initPhasedUnits();
}
use of com.redhat.ceylon.compiler.typechecker.util.ModuleManagerFactory in project ceylon-compiler by ceylon.
the class LanguageCompiler method getPhasedUnitsInstance.
/**
* Get the PhasedUnits instance for this context.
*/
public static PhasedUnits getPhasedUnitsInstance(final Context context) {
PhasedUnits phasedUnits = context.get(phasedUnitsKey);
if (phasedUnits == null) {
com.redhat.ceylon.compiler.typechecker.context.Context ceylonContext = getCeylonContextInstance(context);
phasedUnits = new PhasedUnits(ceylonContext, new ModuleManagerFactory() {
@Override
public ModuleManager createModuleManager(com.redhat.ceylon.compiler.typechecker.context.Context ceylonContext) {
CompilerDelegate phasedUnitsManager = getCompilerDelegate(context);
return phasedUnitsManager.getModuleManager();
}
@Override
public ModuleSourceMapper createModuleManagerUtil(com.redhat.ceylon.compiler.typechecker.context.Context ceylonContext, ModuleManager moduleManager) {
CompilerDelegate phasedUnitsManager = getCompilerDelegate(context);
return phasedUnitsManager.getModuleSourceMapper();
}
});
context.put(phasedUnitsKey, phasedUnits);
}
return phasedUnits;
}
Aggregations