diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/core/lombok/javac/JavacResolution.java | 2 | ||||
-rw-r--r-- | src/delombok/lombok/delombok/Delombok.java | 37 | ||||
-rw-r--r-- | src/delombok/lombok/delombok/PrettyPrinter.java | 11 | ||||
-rw-r--r-- | src/stubs/com/sun/tools/javac/file/BaseFileManager.java | 7 | ||||
-rw-r--r-- | src/stubs/com/sun/tools/javac/main/Arguments.java | 13 |
5 files changed, 61 insertions, 9 deletions
diff --git a/src/core/lombok/javac/JavacResolution.java b/src/core/lombok/javac/JavacResolution.java index 0b6e1341..ded6284b 100644 --- a/src/core/lombok/javac/JavacResolution.java +++ b/src/core/lombok/javac/JavacResolution.java @@ -223,7 +223,7 @@ public class JavacResolution { private void attrib(JCTree tree, Env<AttrContext> env) { if (tree instanceof JCBlock) attr.attribStat(tree, env); - else if (tree instanceof JCMethodDecl) attr.attribStat(((JCMethodDecl)tree).body, env); + else if (tree instanceof JCMethodDecl) attr.attribStat(((JCMethodDecl) tree).body, env); else if (tree instanceof JCVariableDecl) attr.attribStat(tree, env); else throw new IllegalStateException("Called with something that isn't a block, method decl, or variable decl"); } diff --git a/src/delombok/lombok/delombok/Delombok.java b/src/delombok/lombok/delombok/Delombok.java index 609590ec..0d887cb9 100644 --- a/src/delombok/lombok/delombok/Delombok.java +++ b/src/delombok/lombok/delombok/Delombok.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009-2015 The Project Lombok Authors. + * Copyright (C) 2009-2017 The Project Lombok Authors. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -49,6 +49,7 @@ import java.util.Set; import java.util.regex.Pattern; import javax.tools.DiagnosticListener; +import javax.tools.JavaFileManager; import javax.tools.JavaFileObject; import lombok.Lombok; @@ -59,6 +60,8 @@ import lombok.javac.apt.LombokProcessor; import com.sun.tools.javac.code.Symtab; import com.sun.tools.javac.comp.Todo; +import com.sun.tools.javac.file.BaseFileManager; +import com.sun.tools.javac.main.Arguments; import com.sun.tools.javac.main.JavaCompiler; import com.sun.tools.javac.tree.JCTree.JCCompilationUnit; import com.sun.tools.javac.util.Context; @@ -494,6 +497,29 @@ public class Delombok { options.setFormatPreferences(new FormatPreferences(formatPrefs)); options.put("compilePolicy", "check"); + if (Javac.getJavaCompilerVersion() >= 9) { + Arguments args = Arguments.instance(context); + List<String> argsList = new ArrayList<String>(); + if (classpath != null) { + argsList.add("--class-path"); + argsList.add(options.get("--class-path")); + } + if (sourcepath != null) { + argsList.add("--source-path"); + argsList.add(options.get("--source-path")); + } + if (bootclasspath != null) { + argsList.add("--boot-class-path"); + argsList.add(options.get("--boot-class-path")); + } + if (charset != null) { + argsList.add("-encoding"); + argsList.add(charset.name()); + } + String[] argv = argsList.toArray(new String[0]); + args.init("javac", argv); + } + CommentCatcher catcher = CommentCatcher.create(context); JavaCompiler compiler = catcher.getCompiler(); @@ -502,6 +528,15 @@ public class Delombok { Set<LombokProcessor> processors = Collections.singleton(new lombok.javac.apt.LombokProcessor()); + if (Javac.getJavaCompilerVersion() >= 9) { + JavaFileManager jfm_ = context.get(JavaFileManager.class); + if (jfm_ instanceof BaseFileManager) { + Arguments args = Arguments.instance(context); + ((BaseFileManager) jfm_).setContext(context); // reinit with options + ((BaseFileManager) jfm_).handleOptions(args.getDeferredFileManagerOptions()); + } + } + if (Javac.getJavaCompilerVersion() < 9) { compiler.initProcessAnnotations(processors); } else { diff --git a/src/delombok/lombok/delombok/PrettyPrinter.java b/src/delombok/lombok/delombok/PrettyPrinter.java index d372463e..1a36ab7e 100644 --- a/src/delombok/lombok/delombok/PrettyPrinter.java +++ b/src/delombok/lombok/delombok/PrettyPrinter.java @@ -1433,22 +1433,19 @@ public class PrettyPrinter extends JCTree.Visitor { if ("JCTypeUnion".equals(simpleName)) { List<JCExpression> types = readObject(tree, "alternatives", List.<JCExpression>nil()); print(types, " | "); - return; } else if ("JCTypeIntersection".equals(simpleName)) { print(readObject(tree, "bounds", List.<JCExpression>nil()), " & "); - return; } else if ("JCMemberReference".equals(simpleName)) { printMemberReference0(tree); - return; } else if ("JCLambda".equals(simpleName)) { printLambda0(tree); - return; } else if ("JCAnnotatedType".equals(simpleName)) { printAnnotatedType0(tree); - return; + } else if ("JCPackageDecl".equals(simpleName)) { + // Starting with JDK9, this is inside the import list, but we've already printed it. Just ignore it. + } else { + throw new AssertionError("Unhandled tree type: " + tree.getClass() + ": " + tree); } - - throw new AssertionError("Unhandled tree type: " + tree.getClass() + ": " + tree); } private void printMemberReference0(JCTree tree) { diff --git a/src/stubs/com/sun/tools/javac/file/BaseFileManager.java b/src/stubs/com/sun/tools/javac/file/BaseFileManager.java index df24ca3c..a56a2430 100644 --- a/src/stubs/com/sun/tools/javac/file/BaseFileManager.java +++ b/src/stubs/com/sun/tools/javac/file/BaseFileManager.java @@ -4,8 +4,15 @@ package com.sun.tools.javac.file; import javax.tools.JavaFileManager; + +import com.sun.tools.javac.main.Option; +import com.sun.tools.javac.util.Context; + import java.nio.charset.Charset; +import java.util.Map; public abstract class BaseFileManager implements JavaFileManager { protected BaseFileManager(Charset charset) {} + public void setContext(Context context) {} + public boolean handleOptions(Map<Option, String> deferredFileManagerOptions) { return false; } } diff --git a/src/stubs/com/sun/tools/javac/main/Arguments.java b/src/stubs/com/sun/tools/javac/main/Arguments.java new file mode 100644 index 00000000..ea866b6e --- /dev/null +++ b/src/stubs/com/sun/tools/javac/main/Arguments.java @@ -0,0 +1,13 @@ +package com.sun.tools.javac.main; + +import java.util.Map; + +import com.sun.tools.javac.util.Context; + +public class Arguments { + public static final Context.Key<Arguments> argsKey = new Context.Key<Arguments>(); + public static Arguments instance(Context context) { return null; } + public void init(String ownName, String... argv) {} + public Map<Option, String> getDeferredFileManagerOptions() { return null; } + public boolean validate() { return false; } +} |