use of com.sun.tools.javac.util.Context in project ceylon-compiler by ceylon.
the class TestLog method test.
static void test(boolean genEndPos) throws IOException {
Context context = new Context();
Options options = Options.instance(context);
options.put("diags", "%b:%s/%o/%e:%_%t%m|%p%m");
Log log = Log.instance(context);
log.multipleErrors = true;
JavacFileManager.preRegister(context);
ParserFactory pfac = ParserFactory.instance(context);
final String text = "public class Foo {\n" + " public static void main(String[] args) {\n" + " if (args.length == 0)\n" + " System.out.println(\"no args\");\n" + " else\n" + " System.out.println(args.length + \" args\");\n" + " }\n" + "}\n";
JavaFileObject fo = new StringJavaFileObject("Foo", text);
log.useSource(fo);
CharSequence cs = fo.getCharContent(true);
Parser parser = pfac.newParser(cs, false, genEndPos, false);
JCTree.JCCompilationUnit tree = parser.parseCompilationUnit();
log.setEndPosTable(fo, tree.endPositions);
TreeScanner ts = new LogTester(log, tree.endPositions);
ts.scan(tree);
check(log.nerrors, 4, "errors");
check(log.nwarnings, 4, "warnings");
}
use of com.sun.tools.javac.util.Context in project ceylon-compiler by ceylon.
the class T6589361 method main.
public static void main(String[] args) throws Exception {
JavacFileManager fm = null;
try {
fm = new JavacFileManager(new Context(), false, null);
Set<JavaFileObject.Kind> set = new HashSet<JavaFileObject.Kind>();
set.add(JavaFileObject.Kind.CLASS);
Iterable<JavaFileObject> files = fm.list(StandardLocation.PLATFORM_CLASS_PATH, "java.lang", set, false);
for (JavaFileObject file : files) {
// we normalize the filename as well.
if (file.getName().replace(File.separatorChar, '/').contains("java/lang/Object.class")) {
String str = fm.inferBinaryName(StandardLocation.CLASS_PATH, file);
if (!str.equals("java.lang.Object")) {
throw new AssertionError("Error in JavacFileManager.inferBinaryName method!");
} else {
return;
}
}
}
} finally {
if (fm != null) {
fm.close();
}
}
throw new AssertionError("Could not find java/lang/Object.class while compiling");
}
use of com.sun.tools.javac.util.Context in project ceylon-compiler by ceylon.
the class A method getFileManager.
JavaFileManager getFileManager(String classpathProperty, boolean symFileKind, boolean zipFileIndexKind) throws IOException {
Context ctx = new Context();
Options options = Options.instance(ctx);
options.put("useOptimizedZip", Boolean.toString(zipFileIndexKind == USE_ZIP_FILE_INDEX));
if (symFileKind == IGNORE_SYMBOL_FILE)
options.put("ignore.symbol.file", "true");
JavacFileManager fm = new JavacFileManager(ctx, false, null);
List<File> path = getPath(System.getProperty(classpathProperty));
fm.setLocation(CLASS_PATH, path);
return fm;
}
use of com.sun.tools.javac.util.Context in project ceylon-compiler by ceylon.
the class T6838467 method createFileManager.
JavacFileManager createFileManager(boolean useOptimizedZip) {
Context ctx = new Context();
Options options = Options.instance(ctx);
options.put("useOptimizedZip", Boolean.toString(useOptimizedZip));
return new JavacFileManager(ctx, false, null);
}
use of com.sun.tools.javac.util.Context in project ceylon-compiler by ceylon.
the class T6877206 method createFileManager.
JavacFileManager createFileManager(boolean useOptimizedZip, boolean useSymbolFile) {
Context ctx = new Context();
Options options = Options.instance(ctx);
options.put("useOptimizedZip", Boolean.toString(useOptimizedZip));
if (!useSymbolFile) {
options.put("ignore.symbol.file", "true");
}
return new JavacFileManager(ctx, false, null);
}
Aggregations