use of com.sun.tools.javac.util.Abort in project ceylon-compiler by ceylon.
the class JavadocTool method getRootDocImpl.
public RootDocImpl getRootDocImpl(String doclocale, String encoding, ModifierFilter filter, List<String> javaNames, List<String[]> options, boolean breakiterator, List<String> subPackages, List<String> excludedPackages, boolean docClasses, boolean legacyDoclet, boolean quiet) throws IOException {
docenv = DocEnv.instance(context);
docenv.showAccess = filter;
docenv.quiet = quiet;
docenv.breakiterator = breakiterator;
docenv.setLocale(doclocale);
docenv.setEncoding(encoding);
docenv.docClasses = docClasses;
docenv.legacyDoclet = legacyDoclet;
reader.sourceCompleter = docClasses ? null : this;
ListBuffer<String> names = new ListBuffer<String>();
ListBuffer<JCCompilationUnit> classTrees = new ListBuffer<JCCompilationUnit>();
ListBuffer<JCCompilationUnit> packTrees = new ListBuffer<JCCompilationUnit>();
try {
StandardJavaFileManager fm = (StandardJavaFileManager) docenv.fileManager;
for (List<String> it = javaNames; it.nonEmpty(); it = it.tail) {
String name = it.head;
if (!docClasses && name.endsWith(".java") && new File(name).exists()) {
JavaFileObject fo = fm.getJavaFileObjects(name).iterator().next();
docenv.notice("main.Loading_source_file", name);
JCCompilationUnit tree = parse(fo);
classTrees.append(tree);
} else if (isValidPackageName(name)) {
names = names.append(name);
} else if (name.endsWith(".java")) {
docenv.error(null, "main.file_not_found", name);
} else {
docenv.error(null, "main.illegal_package_name", name);
}
}
if (!docClasses) {
// Recursively search given subpackages. If any packages
//are found, add them to the list.
Map<String, List<JavaFileObject>> packageFiles = searchSubPackages(subPackages, names, excludedPackages);
// Parse the packages
for (List<String> packs = names.toList(); packs.nonEmpty(); packs = packs.tail) {
// Parse sources ostensibly belonging to package.
String packageName = packs.head;
parsePackageClasses(packageName, packageFiles.get(packageName), packTrees, excludedPackages);
}
if (messager.nerrors() != 0)
return null;
// Enter symbols for all files
docenv.notice("main.Building_tree");
enter.main(classTrees.toList().appendList(packTrees.toList()));
}
} catch (Abort ex) {
}
if (messager.nerrors() != 0)
return null;
if (docClasses)
return new RootDocImpl(docenv, javaNames, options);
else
return new RootDocImpl(docenv, listClasses(classTrees.toList()), names.toList(), options);
}
use of com.sun.tools.javac.util.Abort in project ceylon-compiler by ceylon.
the class CeylonEnter method prepareForTypeChecking.
public void prepareForTypeChecking(List<JCCompilationUnit> trees) {
if (hasRun)
throw new RuntimeException("Waaaaa, running twice!!!");
//By now le language module version should be known (as local)
//or we should use the default one.
int numParserErrors = log.nerrors;
// load the standard modules
timer.startTask("loadStandardModules");
compilerDelegate.loadStandardModules(modelLoader);
timer.endTask();
// load the modules we are compiling first
hasRun = true;
// make sure we don't load the files we are compiling from their class files
timer.startTask("setupSourceFileObjects");
compilerDelegate.setupSourceFileObjects(trees, modelLoader);
timer.endTask();
// resolve module dependencies
timer.startTask("verifyModuleDependencyTree");
compilerDelegate.resolveModuleDependencies(phasedUnits);
timer.endTask();
// now load package descriptors
timer.startTask("loadPackageDescriptors");
compilerDelegate.loadPackageDescriptors(modelLoader);
timer.endTask();
// at this point, abort if we had any errors logged due to module descriptors
timer.startTask("collectTreeErrors");
collectTreeErrors(false, false);
timer.endTask();
// check if we abort on errors or not
if (options.get(OptionName.CEYLONCONTINUE) == null) {
// they can't be re-logged and duplicated later on
if (log.nerrors - numParserErrors > 0)
throw new Abort();
}
}
use of com.sun.tools.javac.util.Abort in project ceylon-compiler by ceylon.
the class LanguageCompiler method addResources.
private void addResources() throws Abort {
HashSet<String> written = new HashSet<String>();
try {
for (JavaFileObject fo : resourceFileObjects) {
CeyloncFileManager dfm = (CeyloncFileManager) fileManager;
String jarFileName = JarUtils.toPlatformIndependentPath(dfm.getLocation(CeylonLocation.RESOURCE_PATH), fo.getName());
if (!written.contains(jarFileName)) {
dfm.setModule(modelLoader.findModuleForFile(new File(jarFileName)));
FileObject outFile = dfm.getFileForOutput(StandardLocation.CLASS_OUTPUT, "", jarFileName, null);
OutputStream out = outFile.openOutputStream();
try {
InputStream in = new FileInputStream(new File(fo.getName()));
try {
JarUtils.copy(in, out);
} finally {
in.close();
}
} finally {
out.close();
}
written.add(jarFileName);
}
}
} catch (IOException ex) {
throw new Abort(ex);
}
}
Aggregations