use of org.eclipse.ceylon.compiler.typechecker.TypeCheckerBuilder in project ceylon by eclipse.
the class Main method main.
/**
* Files that are not under a proper module structure are
* placed under a <nomodule> module.
*/
public static void main(String[] args) throws Exception {
if (args.length == 0) {
System.err.println("Usage Main <directoryNames>");
System.exit(-1);
return;
}
RepositoryManager repositoryManager = CeylonUtils.repoManager().systemRepo("../dist/dist/repo").logger(new LeakingLogger()).buildManager();
String verbose = System.getProperties().getProperty("verbose");
// ClosableVirtualFile latestZippedLanguageSourceFile =
// MainHelper.getLatestZippedLanguageSourceFile();
TypeCheckerBuilder tcb = new TypeCheckerBuilder().setRepositoryManager(repositoryManager).verbose("true".equals(verbose)).statistics(true);
// .addSrcDirectory(latestZippedLanguageSourceFile);
for (String path : args) {
tcb.addSrcDirectory(new File(path));
}
tcb.getTypeChecker().process();
// latestZippedLanguageSourceFile.close();
}
use of org.eclipse.ceylon.compiler.typechecker.TypeCheckerBuilder in project ceylon by eclipse.
the class MainForLanguage method main.
/**
* Files that are not under a proper module structure are
* placed under a <nomodule> module.
*/
public static void main(String[] args) throws Exception {
ClosableVirtualFile latestZippedLanguageSourceFile = MainHelper.getLatestZippedLanguageSourceFile();
RepositoryManager repositoryManager = CeylonUtils.repoManager().systemRepo("../dist/dist/repo").logger(new LeakingLogger()).buildManager();
TypeChecker typeChecker = new TypeCheckerBuilder().verbose(false).addSrcDirectory(latestZippedLanguageSourceFile).setRepositoryManager(repositoryManager).getTypeChecker();
typeChecker.process();
latestZippedLanguageSourceFile.close();
if (typeChecker.getErrors() > 0) {
System.exit(1);
}
}
use of org.eclipse.ceylon.compiler.typechecker.TypeCheckerBuilder in project ceylon by eclipse.
the class MainForJsTest method main.
public static void main(String[] args) throws Exception {
String distRepo = "../dist/dist/repo";
final Options opts = new Options().addRepo(distRepo).outRepo("build/test/proto");
System.out.println("Typechecking Ceylon test code...");
JsModuleManagerFactory.setVerbose(true);
TypeCheckerBuilder tcb = new TypeCheckerBuilder().verbose(false).moduleManagerFactory(new JsModuleManagerFactory(null)).usageWarnings(false);
final ArrayList<File> excludes = new ArrayList<>();
final ArrayList<File> resfiles = new ArrayList<>();
final ArrayList<File> resdirs = new ArrayList<>();
for (String dir : args) {
final File d = new File(dir.charAt(1) == ':' ? dir.substring(2) : dir);
if (dir.startsWith("X:")) {
excludes.add(d);
} else if (dir.startsWith("R:")) {
resdirs.add(d);
} else if (dir.startsWith("r:")) {
resfiles.add(d);
} else if (dir.startsWith("c:")) {
opts.cwd(d);
} else {
tcb.addSrcDirectory(d);
opts.addSrcDir(d);
}
}
final RepositoryManager repoman = CeylonUtils.repoManager().cwd(opts.getCwd()).systemRepo(opts.getSystemRepo()).userRepos(opts.getRepos()).outRepo(opts.getOutRepo()).buildManager();
tcb.setRepositoryManager(repoman);
final TypeChecker typeChecker = tcb.getTypeChecker();
for (File x : excludes) {
String ap = x.getPath();
// Fix for Windows
if ('/' != File.separatorChar) {
ap = ap.replace(File.separatorChar, '/');
}
for (PhasedUnit pu : typeChecker.getPhasedUnits().getPhasedUnits()) {
if (pu.getUnit().getFullPath().startsWith(ap)) {
typeChecker.getPhasedUnits().removePhasedUnitForRelativePath(pu.getPathRelativeToSrcDir());
}
}
}
TypeCache.doWithoutCaching(new Runnable() {
@Override
public void run() {
typeChecker.process();
}
});
if (typeChecker.getErrors() > 0) {
System.exit(1);
}
System.out.println("Compiling in prototype style");
opts.resourceDirs(resdirs);
JsCompiler jsc = new JsCompiler(typeChecker, opts).stopOnErrors(true);
ArrayList<File> sources = new ArrayList<>();
for (String dir : args) {
// The arg is src/test/ceylon for example
addFilesToList(new File(dir), sources);
}
Collections.sort(sources);
jsc.setSourceFiles(sources);
jsc.setResourceFiles(resfiles);
PrintWriter writer = new PrintWriter(System.out);
if (!jsc.generate()) {
jsc.printErrorsAndCount(writer);
}
}
use of org.eclipse.ceylon.compiler.typechecker.TypeCheckerBuilder in project ceylon by eclipse.
the class ModuleComplianceVisitor method main.
public static void main(String[] args) throws IOException {
System.out.println("Finding JS language module...");
File jsmod = findModule("build/runtime", "js");
if (jsmod == null && System.getenv("ceylon.repo") != null) {
jsmod = findModule(System.getenv("ceylon.repo"), "js");
}
if (jsmod == null && System.getProperty("user.home") != null) {
jsmod = findModule(System.getProperty("user.home"), "js");
}
if (jsmod == null) {
throw new IllegalStateException("Cannot find JS language module");
}
System.out.println("Finding Ceylon Language Module");
File mod = findModule("../language/build/dist", "src");
if (mod == null && System.getenv("ceylon.repo") != null) {
mod = findModule(System.getenv("ceylon.repo"), "src");
}
if (mod == null && System.getProperty("user.home") != null) {
mod = findModule(System.getProperty("user.home"), "src");
}
if (mod == null) {
throw new IllegalStateException("Cannot find JVM language module");
}
System.out.println("Reading JS language module into memory...");
FileReader reader = new FileReader(jsmod);
char[] buf = new char[16384];
StringWriter writer = new StringWriter();
while (reader.ready()) {
reader.read(buf);
writer.write(buf);
}
reader.close();
ModuleComplianceVisitor v = new ModuleComplianceVisitor(writer.toString());
System.out.println("Checking Ceylon vs JS modules...");
VFS vfs = new VFS();
TypeChecker tc = new TypeCheckerBuilder().verbose(false).addSrcDirectory(vfs.getFromZipFile(mod)).getTypeChecker();
tc.process();
for (PhasedUnit pu : tc.getPhasedUnits().getPhasedUnits()) {
pu.getCompilationUnit().visit(v);
}
}
use of org.eclipse.ceylon.compiler.typechecker.TypeCheckerBuilder in project ceylon by eclipse.
the class TestModuleManager method loadJsModel.
private static void loadJsModel() {
if (jstc == null) {
System.out.println("Pass 2: Loading model from JS");
final RepositoryManager repoman = CeylonUtils.repoManager().cwd(options.getCwd()).systemRepo(options.getSystemRepo()).userRepos(options.getRepos()).outRepo(options.getOutRepo()).buildManager();
// .verbose(true);
TypeCheckerBuilder tcb = new TypeCheckerBuilder().usageWarnings(false);
tcb.moduleManagerFactory(new JsModuleManagerFactory((String) null));
tcb.addSrcDirectory(new java.io.File("src/test/resources/loader/pass2"));
tcb.setRepositoryManager(repoman);
jstc = tcb.getTypeChecker();
jstc.process();
}
}
Aggregations