use of com.redhat.ceylon.compiler.typechecker.context.Context 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.context.Context in project ceylon-compiler by ceylon.
the class NamingTests method getDecls.
protected List<Declaration> getDecls(String resource) throws Exception {
final String name = PKGNAME.replace('.', '/') + "/" + resource;
File file = new File("test/src", name);
if (!file.exists()) {
throw new RuntimeException("Unable to find resource " + name);
}
RepositoryManagerBuilder builder = new RepositoryManagerBuilder(new NullLogger(), false, 20000, java.net.Proxy.NO_PROXY);
RepositoryManager repoManager = builder.buildRepository();
VFS vfs = new VFS();
Context context = new Context(repoManager, vfs);
PhasedUnits pus = new PhasedUnits(context);
// Make the module manager think we're looking at this package
// even though there's no module descriptor
pus.getModuleSourceMapper().push(PKGNAME);
pus.parseUnit(vfs.getFromFile(file), vfs.getFromFile(new File("test-src")));
final java.util.List<PhasedUnit> listOfUnits = pus.getPhasedUnits();
PhasedUnit pu = listOfUnits.get(0);
pu.validateTree();
pu.scanDeclarations();
pu.scanTypeDeclarations();
pu.validateRefinement();
pu.analyseTypes();
pu.analyseFlow();
return pu.getDeclarations();
}
Aggregations