From 3765835181fd4f69c4b7032687e066ae9c10c500 Mon Sep 17 00:00:00 2001 From: Roel Spilker Date: Mon, 8 Dec 2014 22:28:05 +0100 Subject: ShadowClassLoader didn't work on windows. The usual 'converting paths to urls and back is an utter mystery' problems. --- src/core/lombok/core/Main.java | 2 +- src/launch/lombok/launch/ShadowClassLoader.java | 14 ++++++++------ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/core/lombok/core/Main.java b/src/core/lombok/core/Main.java index 0856d3b3..dc613b0d 100644 --- a/src/core/lombok/core/Main.java +++ b/src/core/lombok/core/Main.java @@ -143,7 +143,7 @@ public class Main { out.println("------------------------------"); } out.println("projectlombok.org " + Version.getFullVersion()); - out.println("Copyright (C) 2009-2012 The Project Lombok Authors."); + out.println("Copyright (C) 2009-2015 The Project Lombok Authors."); out.println("Run 'lombok license' to see the lombok license agreement."); out.println(); out.println("Run lombok without any parameters to start the graphical installer."); diff --git a/src/launch/lombok/launch/ShadowClassLoader.java b/src/launch/lombok/launch/ShadowClassLoader.java index 79809b2f..b883bd71 100644 --- a/src/launch/lombok/launch/ShadowClassLoader.java +++ b/src/launch/lombok/launch/ShadowClassLoader.java @@ -211,24 +211,26 @@ class ShadowClassLoader extends ClassLoader { if (!location.isFile() || !location.canRead()) return null; - String absolutePath; { + File absoluteFile; { try { - absolutePath = location.getCanonicalPath(); + absoluteFile = location.getCanonicalFile(); } catch (Exception e) { - absolutePath = location.getAbsolutePath(); + absoluteFile = location.getAbsoluteFile(); } } - List jarContents = getOrMakeJarListing(absolutePath); + List jarContents = getOrMakeJarListing(absoluteFile.getAbsolutePath()); + + String absoluteUri = absoluteFile.toURI().toString(); try { if (jarContents.contains(altName)) { - return new URI("jar:file:" + absolutePath + "!/" + altName).toURL(); + return new URI("jar:" + absoluteUri + "!/" + altName).toURL(); } } catch (Exception e) {} try { if (jarContents.contains(name)) { - return new URI("jar:file:" + absolutePath + "!/" + name).toURL(); + return new URI("jar:" + absoluteUri + "!/" + name).toURL(); } } catch(Exception e) {} -- cgit From b56bdb1b0937fd83c8a2f7a4b7820c9493e56a21 Mon Sep 17 00:00:00 2001 From: Roel Spilker Date: Tue, 9 Dec 2014 19:58:36 +0100 Subject: Our quirky 'hider' trick, with a public class inside a package private class, doesn't work after all. Removed it and renamed the launching processor to _ShadowLaunchingAnnotationProcessor. --- build.xml | 2 +- src/launch/lombok/launch/AnnotationProcessor.java | 77 ---------------------- .../_ShadowLaunchingAnnotationProcessor.java | 75 +++++++++++++++++++++ 3 files changed, 76 insertions(+), 78 deletions(-) delete mode 100644 src/launch/lombok/launch/AnnotationProcessor.java create mode 100644 src/launch/lombok/launch/_ShadowLaunchingAnnotationProcessor.java diff --git a/build.xml b/build.xml index 6339ec92..b066539e 100644 --- a/build.xml +++ b/build.xml @@ -195,7 +195,7 @@ the common tasks and can be called on to run the main aspects of all the sub-scr - lombok.launch.AnnotationProcessorHider.AnnotationProcessor + lombok.launch._ShadowLaunchingAnnotationProcessor diff --git a/src/launch/lombok/launch/AnnotationProcessor.java b/src/launch/lombok/launch/AnnotationProcessor.java deleted file mode 100644 index 35c26b7c..00000000 --- a/src/launch/lombok/launch/AnnotationProcessor.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright (C) 2014 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 - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package lombok.launch; - -import java.util.Set; - -import javax.annotation.processing.AbstractProcessor; -import javax.annotation.processing.Completion; -import javax.annotation.processing.ProcessingEnvironment; -import javax.annotation.processing.RoundEnvironment; -import javax.lang.model.SourceVersion; -import javax.lang.model.element.AnnotationMirror; -import javax.lang.model.element.Element; -import javax.lang.model.element.ExecutableElement; -import javax.lang.model.element.TypeElement; - -class AnnotationProcessorHider { - public static class AnnotationProcessor extends AbstractProcessor { - private final AbstractProcessor instance = createWrappedInstance(); - - @Override public Set getSupportedOptions() { - return instance.getSupportedOptions(); - } - - @Override public Set getSupportedAnnotationTypes() { - return instance.getSupportedAnnotationTypes(); - } - - @Override public SourceVersion getSupportedSourceVersion() { - return instance.getSupportedSourceVersion(); - } - - @Override public void init(ProcessingEnvironment processingEnv) { - instance.init(processingEnv); - super.init(processingEnv); - } - - @Override public boolean process(Set annotations, RoundEnvironment roundEnv) { - return instance.process(annotations, roundEnv); - } - - @Override public Iterable getCompletions(Element element, AnnotationMirror annotation, ExecutableElement member, String userText) { - return instance.getCompletions(element, annotation, member, userText); - } - - private static AbstractProcessor createWrappedInstance() { - ClassLoader cl = Main.createShadowClassLoader(); - try { - Class mc = cl.loadClass("lombok.core.AnnotationProcessor"); - return (AbstractProcessor) mc.newInstance(); - } catch (Throwable t) { - if (t instanceof Error) throw (Error) t; - if (t instanceof RuntimeException) throw (RuntimeException) t; - throw new RuntimeException(t); - } - } - } -} diff --git a/src/launch/lombok/launch/_ShadowLaunchingAnnotationProcessor.java b/src/launch/lombok/launch/_ShadowLaunchingAnnotationProcessor.java new file mode 100644 index 00000000..36787ec9 --- /dev/null +++ b/src/launch/lombok/launch/_ShadowLaunchingAnnotationProcessor.java @@ -0,0 +1,75 @@ +/* + * Copyright (C) 2014 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 + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package lombok.launch; + +import java.util.Set; + +import javax.annotation.processing.AbstractProcessor; +import javax.annotation.processing.Completion; +import javax.annotation.processing.ProcessingEnvironment; +import javax.annotation.processing.RoundEnvironment; +import javax.lang.model.SourceVersion; +import javax.lang.model.element.AnnotationMirror; +import javax.lang.model.element.Element; +import javax.lang.model.element.ExecutableElement; +import javax.lang.model.element.TypeElement; + +public class _ShadowLaunchingAnnotationProcessor extends AbstractProcessor { + private final AbstractProcessor instance = createWrappedInstance(); + + @Override public Set getSupportedOptions() { + return instance.getSupportedOptions(); + } + + @Override public Set getSupportedAnnotationTypes() { + return instance.getSupportedAnnotationTypes(); + } + + @Override public SourceVersion getSupportedSourceVersion() { + return instance.getSupportedSourceVersion(); + } + + @Override public void init(ProcessingEnvironment processingEnv) { + instance.init(processingEnv); + super.init(processingEnv); + } + + @Override public boolean process(Set annotations, RoundEnvironment roundEnv) { + return instance.process(annotations, roundEnv); + } + + @Override public Iterable getCompletions(Element element, AnnotationMirror annotation, ExecutableElement member, String userText) { + return instance.getCompletions(element, annotation, member, userText); + } + + private static AbstractProcessor createWrappedInstance() { + ClassLoader cl = Main.createShadowClassLoader(); + try { + Class mc = cl.loadClass("lombok.core.AnnotationProcessor"); + return (AbstractProcessor) mc.newInstance(); + } catch (Throwable t) { + if (t instanceof Error) throw (Error) t; + if (t instanceof RuntimeException) throw (RuntimeException) t; + throw new RuntimeException(t); + } + } +} -- cgit From 671f2a202e9e8b597dccc30a7ac4c8a1fbdb3625 Mon Sep 17 00:00:00 2001 From: Roel Spilker Date: Tue, 9 Dec 2014 22:25:01 +0100 Subject: Actually the previous commit lied; you CAN use the hider trick to have a class be invisible to most autocomplete dialogs and yet still work as an SPI provider; SPI lines are binary names (with dollars for inner classes), that's all. Name fixed and previous commit reverted. --- build.xml | 2 +- src/launch/lombok/launch/AnnotationProcessor.java | 77 ++++++++++++++++++++++ .../_ShadowLaunchingAnnotationProcessor.java | 75 --------------------- 3 files changed, 78 insertions(+), 76 deletions(-) create mode 100644 src/launch/lombok/launch/AnnotationProcessor.java delete mode 100644 src/launch/lombok/launch/_ShadowLaunchingAnnotationProcessor.java diff --git a/build.xml b/build.xml index b066539e..9fe952b9 100644 --- a/build.xml +++ b/build.xml @@ -195,7 +195,7 @@ the common tasks and can be called on to run the main aspects of all the sub-scr - lombok.launch._ShadowLaunchingAnnotationProcessor + lombok.launch.AnnotationProcessorHider$AnnotationProcessor diff --git a/src/launch/lombok/launch/AnnotationProcessor.java b/src/launch/lombok/launch/AnnotationProcessor.java new file mode 100644 index 00000000..35c26b7c --- /dev/null +++ b/src/launch/lombok/launch/AnnotationProcessor.java @@ -0,0 +1,77 @@ +/* + * Copyright (C) 2014 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 + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package lombok.launch; + +import java.util.Set; + +import javax.annotation.processing.AbstractProcessor; +import javax.annotation.processing.Completion; +import javax.annotation.processing.ProcessingEnvironment; +import javax.annotation.processing.RoundEnvironment; +import javax.lang.model.SourceVersion; +import javax.lang.model.element.AnnotationMirror; +import javax.lang.model.element.Element; +import javax.lang.model.element.ExecutableElement; +import javax.lang.model.element.TypeElement; + +class AnnotationProcessorHider { + public static class AnnotationProcessor extends AbstractProcessor { + private final AbstractProcessor instance = createWrappedInstance(); + + @Override public Set getSupportedOptions() { + return instance.getSupportedOptions(); + } + + @Override public Set getSupportedAnnotationTypes() { + return instance.getSupportedAnnotationTypes(); + } + + @Override public SourceVersion getSupportedSourceVersion() { + return instance.getSupportedSourceVersion(); + } + + @Override public void init(ProcessingEnvironment processingEnv) { + instance.init(processingEnv); + super.init(processingEnv); + } + + @Override public boolean process(Set annotations, RoundEnvironment roundEnv) { + return instance.process(annotations, roundEnv); + } + + @Override public Iterable getCompletions(Element element, AnnotationMirror annotation, ExecutableElement member, String userText) { + return instance.getCompletions(element, annotation, member, userText); + } + + private static AbstractProcessor createWrappedInstance() { + ClassLoader cl = Main.createShadowClassLoader(); + try { + Class mc = cl.loadClass("lombok.core.AnnotationProcessor"); + return (AbstractProcessor) mc.newInstance(); + } catch (Throwable t) { + if (t instanceof Error) throw (Error) t; + if (t instanceof RuntimeException) throw (RuntimeException) t; + throw new RuntimeException(t); + } + } + } +} diff --git a/src/launch/lombok/launch/_ShadowLaunchingAnnotationProcessor.java b/src/launch/lombok/launch/_ShadowLaunchingAnnotationProcessor.java deleted file mode 100644 index 36787ec9..00000000 --- a/src/launch/lombok/launch/_ShadowLaunchingAnnotationProcessor.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright (C) 2014 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 - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package lombok.launch; - -import java.util.Set; - -import javax.annotation.processing.AbstractProcessor; -import javax.annotation.processing.Completion; -import javax.annotation.processing.ProcessingEnvironment; -import javax.annotation.processing.RoundEnvironment; -import javax.lang.model.SourceVersion; -import javax.lang.model.element.AnnotationMirror; -import javax.lang.model.element.Element; -import javax.lang.model.element.ExecutableElement; -import javax.lang.model.element.TypeElement; - -public class _ShadowLaunchingAnnotationProcessor extends AbstractProcessor { - private final AbstractProcessor instance = createWrappedInstance(); - - @Override public Set getSupportedOptions() { - return instance.getSupportedOptions(); - } - - @Override public Set getSupportedAnnotationTypes() { - return instance.getSupportedAnnotationTypes(); - } - - @Override public SourceVersion getSupportedSourceVersion() { - return instance.getSupportedSourceVersion(); - } - - @Override public void init(ProcessingEnvironment processingEnv) { - instance.init(processingEnv); - super.init(processingEnv); - } - - @Override public boolean process(Set annotations, RoundEnvironment roundEnv) { - return instance.process(annotations, roundEnv); - } - - @Override public Iterable getCompletions(Element element, AnnotationMirror annotation, ExecutableElement member, String userText) { - return instance.getCompletions(element, annotation, member, userText); - } - - private static AbstractProcessor createWrappedInstance() { - ClassLoader cl = Main.createShadowClassLoader(); - try { - Class mc = cl.loadClass("lombok.core.AnnotationProcessor"); - return (AbstractProcessor) mc.newInstance(); - } catch (Throwable t) { - if (t instanceof Error) throw (Error) t; - if (t instanceof RuntimeException) throw (RuntimeException) t; - throw new RuntimeException(t); - } - } -} -- cgit From 091f6ee83a98ea2a303164380aeeac093ceb8e47 Mon Sep 17 00:00:00 2001 From: Roel Spilker Date: Wed, 10 Dec 2014 00:04:31 +0100 Subject: [issue #759] delombok now plays nicely with exotic characters, encodings, and backslash U escapes. --- doc/changelog.markdown | 1 + src/delombok/lombok/delombok/Delombok.java | 6 ++- .../lombok/delombok/PrettyCommentsPrinter.java | 43 +++++++++++++++++++--- .../lombok/delombok/UnicodeEscapeWriter.java | 2 +- test/core/src/lombok/AbstractRunTests.java | 4 +- test/core/src/lombok/LombokTestSource.java | 32 ++++++++++++++-- test/core/src/lombok/RunTestsViaDelombok.java | 4 +- test/core/src/lombok/RunTestsViaEcj.java | 4 +- .../resource/after-delombok/EncodingUsAscii.java | 9 +++++ .../resource/after-delombok/EncodingUtf8.java | 8 ++++ .../resource/after-ecj/EncodingUsAscii.java | 1 + .../transform/resource/after-ecj/EncodingUtf8.java | 9 +++++ .../transform/resource/before/EncodingUsAscii.java | 5 +++ test/transform/resource/before/EncodingUtf8.java | 5 +++ 14 files changed, 116 insertions(+), 17 deletions(-) create mode 100644 test/transform/resource/after-delombok/EncodingUsAscii.java create mode 100644 test/transform/resource/after-delombok/EncodingUtf8.java create mode 100644 test/transform/resource/after-ecj/EncodingUsAscii.java create mode 100644 test/transform/resource/after-ecj/EncodingUtf8.java create mode 100644 test/transform/resource/before/EncodingUsAscii.java create mode 100644 test/transform/resource/before/EncodingUtf8.java diff --git a/doc/changelog.markdown b/doc/changelog.markdown index e4a004af..5974cf07 100644 --- a/doc/changelog.markdown +++ b/doc/changelog.markdown @@ -3,6 +3,7 @@ Lombok Changelog ### v1.14.9.shadow "Edgy Shadowy Guinea Pig" * Added a launcher to the lombok boot process which removes the need for `-Xbootclasspath` to be in your `eclipse.ini` file, and removes all non-public API and third party dependencies (such as ASM) from the lombok jar, thus removing them from your IDE's auto complete offerings in any project that uses lombok. For those debugging lombok, the launcher enables hot code replace which makes debugging a lot easier, as previously one was required to shut down the IDE, rebuild the jar, and relaunch. Add `-Dshadow.override.lombok=/path/to/lombok/bin` to the launch target for hot code replace. +* BUGFIX: delombok: Using exotic characters in your source files would overzealously backslash-u escape them. Now, all characters are printed unescaped, assuming your chosen encoding can support them. Otherwise, they are escaped. [Issue #759](https://code.google.com/p/projectlombok/issues/detail?id=759) ### v1.14.8 (September 15th, 2014) * PERFORMANCE: The configuration system typically hit the filesystem twice per read configuration key instead of hardly ever. This is a continuation of [Issue #682](https://code.google.com/p/projectlombok/issues/detail?id=682). diff --git a/src/delombok/lombok/delombok/Delombok.java b/src/delombok/lombok/delombok/Delombok.java index f64e36a1..059bb004 100644 --- a/src/delombok/lombok/delombok/Delombok.java +++ b/src/delombok/lombok/delombok/Delombok.java @@ -509,7 +509,7 @@ public class Delombok { DelombokResult result = new DelombokResult(catcher.getComments(unit), unit, force || options.isChanged(unit), fps); if (verbose) feedback.printf("File: %s [%s]\n", unit.sourcefile.getName(), result.isChanged() ? "delomboked" : "unchanged"); Writer rawWriter; - if (presetWriter != null) rawWriter = presetWriter; + if (presetWriter != null) rawWriter = createUnicodeEscapeWriter(presetWriter); else if (output == null) rawWriter = createStandardOutWriter(); else rawWriter = createFileWriter(output, baseMap.get(unit), unit.sourcefile.toUri()); BufferedWriter writer = new BufferedWriter(rawWriter); @@ -605,6 +605,10 @@ public class Delombok { return createUnicodeEscapeWriter(System.out); } + private Writer createUnicodeEscapeWriter(Writer writer) { + return new UnicodeEscapeWriter(writer, charset); + } + private Writer createUnicodeEscapeWriter(OutputStream out) { return new UnicodeEscapeWriter(new OutputStreamWriter(out, charset), charset); } diff --git a/src/delombok/lombok/delombok/PrettyCommentsPrinter.java b/src/delombok/lombok/delombok/PrettyCommentsPrinter.java index 9dd7e40e..72a8ff59 100644 --- a/src/delombok/lombok/delombok/PrettyCommentsPrinter.java +++ b/src/delombok/lombok/delombok/PrettyCommentsPrinter.java @@ -104,7 +104,6 @@ import com.sun.tools.javac.tree.JCTree.LetExpr; import com.sun.tools.javac.tree.JCTree.TypeBoundKind; import com.sun.tools.javac.tree.TreeInfo; import com.sun.tools.javac.tree.TreeScanner; -import com.sun.tools.javac.util.Convert; import com.sun.tools.javac.util.List; import com.sun.tools.javac.util.Name; import com.sun.tools.javac.util.Position; @@ -209,7 +208,6 @@ public class PrettyCommentsPrinter extends JCTree.Visitor { private void consumeComments(int until, JCTree tree) throws IOException { boolean prevNewLine = onNewLine; - boolean found = false; CommentInfo head = comments.head; while (comments.nonEmpty() && head.pos < until) { printComment(head); @@ -355,7 +353,7 @@ public class PrettyCommentsPrinter extends JCTree.Visitor { } needsSpace = false; - out.write(Convert.escapeUnicode(s.toString())); + out.write(s.toString()); onNewLine = false; aligned = false; @@ -1413,16 +1411,51 @@ public class PrettyCommentsPrinter extends JCTree.Visitor { else if (CTC_FLOAT.equals(typeTag)) print(tree.value + "F"); else if (CTC_DOUBLE.equals(typeTag)) print(tree.value.toString()); else if (CTC_CHAR.equals(typeTag)) { - print("\'" + Convert.quote(String.valueOf((char)((Number)tree.value).intValue())) + "\'"); + print("\'" + quoteChar((char)((Number)tree.value).intValue()) + "\'"); } else if (CTC_BOOLEAN.equals(typeTag)) print(((Number)tree.value).intValue() == 1 ? "true" : "false"); else if (CTC_BOT.equals(typeTag)) print("null"); - else print("\"" + Convert.quote(tree.value.toString()) + "\""); + else print("\"" + quoteChars(tree.value.toString()) + "\""); } catch (IOException e) { throw new UncheckedIOException(e); } } + public static String quoteChars(String s) { + StringBuilder buf = new StringBuilder(); + for (int i = 0; i < s.length(); i++) { + buf.append(quoteChar(s.charAt(i))); + } + return buf.toString(); + } + + /** + * Escapes a character if it has an escape sequence or is non-printable + * ASCII. Leaves non-ASCII characters alone. + */ + public static String quoteChar(char ch) { + switch (ch) { + case '\b': + return "\\b"; + case '\f': + return "\\f"; + case '\n': + return "\\n"; + case '\r': + return "\\r"; + case '\t': + return "\\t"; + case '\'': + return "\\'"; + case '\"': + return "\\\""; + case '\\': + return "\\\\"; + default: + return ch < 32 ? String.format("\\%03o", (int) ch) : String.valueOf(ch); + } + } + public void visitTypeIdent(JCPrimitiveTypeTree tree) { TypeTag typetag = typeTag(tree); try { diff --git a/src/delombok/lombok/delombok/UnicodeEscapeWriter.java b/src/delombok/lombok/delombok/UnicodeEscapeWriter.java index 95b55078..9c2ef190 100644 --- a/src/delombok/lombok/delombok/UnicodeEscapeWriter.java +++ b/src/delombok/lombok/delombok/UnicodeEscapeWriter.java @@ -63,6 +63,6 @@ public class UnicodeEscapeWriter extends Writer { } protected void writeUnicodeEscape(char c) throws IOException { - writer.write("\\u" + Integer.toHexString(c)); + writer.write(String.format("\\u%04x", (int) c)); } } \ No newline at end of file diff --git a/test/core/src/lombok/AbstractRunTests.java b/test/core/src/lombok/AbstractRunTests.java index a1f535b4..85d4d4f3 100644 --- a/test/core/src/lombok/AbstractRunTests.java +++ b/test/core/src/lombok/AbstractRunTests.java @@ -75,7 +75,7 @@ public abstract class AbstractRunTests { } }); - transformCode(messages, writer, file); + transformCode(messages, writer, file, sourceDirectives.getSpecifiedEncoding()); compare(file.getName(), expected, writer.toString(), messages, params.printErrors(), sourceDirectives.isSkipCompareContent() || expected.isSkipCompareContent()); return true; @@ -97,7 +97,7 @@ public abstract class AbstractRunTests { return 8; } - protected abstract void transformCode(Collection messages, StringWriter result, File file) throws Throwable; + protected abstract void transformCode(Collection messages, StringWriter result, File file, String encoding) throws Throwable; protected String readFile(File file) throws IOException { BufferedReader reader; diff --git a/test/core/src/lombok/LombokTestSource.java b/test/core/src/lombok/LombokTestSource.java index 402001e9..f31d7be7 100644 --- a/test/core/src/lombok/LombokTestSource.java +++ b/test/core/src/lombok/LombokTestSource.java @@ -49,7 +49,8 @@ public class LombokTestSource { private final boolean skipCompareContent; private final int versionLowerLimit, versionUpperLimit; private final ConfigurationResolver configuration; - + private final String specifiedEncoding; + public boolean versionWithinLimit(int version) { return version >= versionLowerLimit && version <= versionUpperLimit; } @@ -74,6 +75,10 @@ public class LombokTestSource { return skipCompareContent; } + public String getSpecifiedEncoding() { + return specifiedEncoding; + } + public ConfigurationResolver getConfiguration() { return configuration; } @@ -123,6 +128,7 @@ public class LombokTestSource { int versionUpper = Integer.MAX_VALUE; boolean ignore = false; boolean skipCompareContent = false; + String encoding = null; for (String directive : directives) { directive = directive.trim(); @@ -154,10 +160,15 @@ public class LombokTestSource { continue; } + if (lc.startsWith("encoding:")) { + encoding = directive.substring(9).trim(); + continue; + } + Assert.fail("Directive line \"" + directive + "\" in '" + file.getAbsolutePath() + "' invalid: unrecognized directive."); throw new RuntimeException(); } - + this.specifiedEncoding = encoding; this.versionLowerLimit = versionLower; this.versionUpperLimit = versionUpper; this.ignore = ignore; @@ -194,13 +205,17 @@ public class LombokTestSource { } public static LombokTestSource read(File sourceFolder, File messagesFolder, String fileName) throws IOException { + return read0(sourceFolder, messagesFolder, fileName, "UTF-8"); + } + + private static LombokTestSource read0(File sourceFolder, File messagesFolder, String fileName, String encoding) throws IOException { StringBuilder content = null; List directives = new ArrayList(); File sourceFile = new File(sourceFolder, fileName); if (sourceFile.exists()) { @Cleanup val rawIn = new FileInputStream(sourceFile); - BufferedReader in = new BufferedReader(new InputStreamReader(rawIn, "UTF-8")); + BufferedReader in = new BufferedReader(new InputStreamReader(rawIn, encoding)); for (String i = in.readLine(); i != null; i = in.readLine()) { if (content != null) { content.append(i).append("\n"); @@ -234,6 +249,15 @@ public class LombokTestSource { } } - return new LombokTestSource(sourceFile, content.toString(), messages, directives); + LombokTestSource source = new LombokTestSource(sourceFile, content.toString(), messages, directives); + String specifiedEncoding = source.getSpecifiedEncoding(); + + // The source file has an 'encoding' header to test encoding issues. Of course, reading the encoding header + // requires knowing the encoding of the file first. In practice we get away with it, because UTF-8 and US-ASCII are compatible enough. + // The fix is therefore to read in as UTF-8 initially, and if the file requests that it should be read as another encoding, toss it all + // and reread that way. + + if (specifiedEncoding == null || specifiedEncoding.equalsIgnoreCase(encoding)) return source; + return read0(sourceFolder, messagesFolder, fileName, specifiedEncoding); } } diff --git a/test/core/src/lombok/RunTestsViaDelombok.java b/test/core/src/lombok/RunTestsViaDelombok.java index 6a08642b..1482c865 100644 --- a/test/core/src/lombok/RunTestsViaDelombok.java +++ b/test/core/src/lombok/RunTestsViaDelombok.java @@ -34,10 +34,10 @@ public class RunTestsViaDelombok extends AbstractRunTests { private Delombok delombok = new Delombok(); @Override - public void transformCode(Collection messages, StringWriter result, final File file) throws Throwable { + public void transformCode(Collection messages, StringWriter result, final File file, String encoding) throws Throwable { delombok.setVerbose(false); delombok.setForceProcess(true); - delombok.setCharset("UTF-8"); + delombok.setCharset(encoding == null ? "UTF-8" : encoding); delombok.setDiagnosticsListener(new CapturingDiagnosticListener(file, messages)); diff --git a/test/core/src/lombok/RunTestsViaEcj.java b/test/core/src/lombok/RunTestsViaEcj.java index f4584493..1a94baf1 100644 --- a/test/core/src/lombok/RunTestsViaEcj.java +++ b/test/core/src/lombok/RunTestsViaEcj.java @@ -93,7 +93,7 @@ public class RunTestsViaEcj extends AbstractRunTests { } @Override - public void transformCode(Collection messages, StringWriter result, File file) throws Throwable { + public void transformCode(Collection messages, StringWriter result, File file, String encoding) throws Throwable { final AtomicReference compilationResult_ = new AtomicReference(); final AtomicReference compilationUnit_ = new AtomicReference(); ICompilerRequestor bitbucketRequestor = new ICompilerRequestor() { @@ -103,7 +103,7 @@ public class RunTestsViaEcj extends AbstractRunTests { }; String source = readFile(file); - final CompilationUnit sourceUnit = new CompilationUnit(source.toCharArray(), file.getName(), "UTF-8"); + final CompilationUnit sourceUnit = new CompilationUnit(source.toCharArray(), file.getName(), encoding == null ? "UTF-8" : encoding); Compiler ecjCompiler = new Compiler(createFileSystem(file), ecjErrorHandlingPolicy(), ecjCompilerOptions(), bitbucketRequestor, new DefaultProblemFactory(Locale.ENGLISH)) { @Override protected synchronized void addCompilationUnit(ICompilationUnit inUnit, CompilationUnitDeclaration parsedUnit) { diff --git a/test/transform/resource/after-delombok/EncodingUsAscii.java b/test/transform/resource/after-delombok/EncodingUsAscii.java new file mode 100644 index 00000000..a9e6b1a5 --- /dev/null +++ b/test/transform/resource/after-delombok/EncodingUsAscii.java @@ -0,0 +1,9 @@ +//ENCODING: US-ASCII +class EncodingUsAscii { + String foo\u0e51\u0e51 = "\016\t\b "; + @java.lang.Override + @java.lang.SuppressWarnings("all") + public java.lang.String toString() { + return "EncodingUsAscii(foo\u0e51\u0e51=" + this.foo\u0e51\u0e51 + ")"; + } +} \ No newline at end of file diff --git a/test/transform/resource/after-delombok/EncodingUtf8.java b/test/transform/resource/after-delombok/EncodingUtf8.java new file mode 100644 index 00000000..9ae3e30a --- /dev/null +++ b/test/transform/resource/after-delombok/EncodingUtf8.java @@ -0,0 +1,8 @@ +class EncodingUtf8 { + String foo๑๑ = "\016\t\b "; + @java.lang.Override + @java.lang.SuppressWarnings("all") + public java.lang.String toString() { + return "EncodingUtf8(foo๑๑=" + this.foo๑๑ + ")"; + } +} \ No newline at end of file diff --git a/test/transform/resource/after-ecj/EncodingUsAscii.java b/test/transform/resource/after-ecj/EncodingUsAscii.java new file mode 100644 index 00000000..b66feb0c --- /dev/null +++ b/test/transform/resource/after-ecj/EncodingUsAscii.java @@ -0,0 +1 @@ +//ignore: This test serves to check what happens with 'weird' characters when you use delombok. It's just not relevant for ecj. diff --git a/test/transform/resource/after-ecj/EncodingUtf8.java b/test/transform/resource/after-ecj/EncodingUtf8.java new file mode 100644 index 00000000..5a7a1644 --- /dev/null +++ b/test/transform/resource/after-ecj/EncodingUtf8.java @@ -0,0 +1,9 @@ +@lombok.ToString class EncodingUtf8 { + String foo๑๑ = "\t\b "; + EncodingUtf8() { + super(); + } + public @java.lang.Override @java.lang.SuppressWarnings("all") java.lang.String toString() { + return (("EncodingUtf8(foo๑๑=" + this.foo๑๑) + ")"); + } +} \ No newline at end of file diff --git a/test/transform/resource/before/EncodingUsAscii.java b/test/transform/resource/before/EncodingUsAscii.java new file mode 100644 index 00000000..dbcd150b --- /dev/null +++ b/test/transform/resource/before/EncodingUsAscii.java @@ -0,0 +1,5 @@ +//ENCODING: US-ASCII +@lombok.ToString +class EncodingUsAscii { + String foo\u0e51\u0e51 = "\u000e \10 "; +} \ No newline at end of file diff --git a/test/transform/resource/before/EncodingUtf8.java b/test/transform/resource/before/EncodingUtf8.java new file mode 100644 index 00000000..75b0ee00 --- /dev/null +++ b/test/transform/resource/before/EncodingUtf8.java @@ -0,0 +1,5 @@ +//ENCODING: UTF-8 +@lombok.ToString +class EncodingUtf8 { + String foo\u0e51๑ = "\u000e \10 "; +} \ No newline at end of file -- cgit From e97e0cc23eca1b34d657f382d123ce2298ceb5a8 Mon Sep 17 00:00:00 2001 From: Roel Spilker Date: Tue, 13 Jan 2015 16:26:41 +0100 Subject: Bug fix in postcompiler app which seemed to not correctly identify changes. --- src/core/lombok/bytecode/PostCompilerApp.java | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/src/core/lombok/bytecode/PostCompilerApp.java b/src/core/lombok/bytecode/PostCompilerApp.java index d2c3157c..5f49bd81 100644 --- a/src/core/lombok/bytecode/PostCompilerApp.java +++ b/src/core/lombok/bytecode/PostCompilerApp.java @@ -98,7 +98,7 @@ public class PostCompilerApp extends LombokApp { byte[] original = readFile(file); byte[] clone = original.clone(); byte[] transformed = PostCompiler.applyTransformations(clone, file.toString(), DiagnosticsReceiver.CONSOLE); - if (clone != transformed && !Arrays.equals(clone, transformed)) { + if (clone != transformed && !Arrays.equals(original, transformed)) { filesTouched++; if (args.verbose) System.out.println("Rewriting " + file.getAbsolutePath()); writeFile(file, transformed); @@ -138,18 +138,24 @@ public class PostCompilerApp extends LombokApp { byte[] buffer = new byte[1024]; ByteArrayOutputStream bytes = new ByteArrayOutputStream(); FileInputStream fileInputStream = new FileInputStream(file); - while (true) { - int read = fileInputStream.read(buffer); - if (read == -1) break; - bytes.write(buffer, 0, read); + try { + while (true) { + int read = fileInputStream.read(buffer); + if (read == -1) break; + bytes.write(buffer, 0, read); + } + } finally { + fileInputStream.close(); } - fileInputStream.close(); return bytes.toByteArray(); } static void writeFile(File file, byte[] transformed) throws IOException { FileOutputStream out = new FileOutputStream(file); - out.write(transformed); - out.close(); + try { + out.write(transformed); + } finally { + out.close(); + } } } -- cgit From 296d1c2ed8a6aa29fb2a1ce7f16ea9e39b49d7d5 Mon Sep 17 00:00:00 2001 From: Roel Spilker Date: Tue, 20 Jan 2015 03:00:02 +0100 Subject: [shadowloader] all the patching we do for ecj are ALL entrypoints and need shadowloader treatment. This commit makes it happen. --- .../lombok/eclipse/agent/EclipsePatcher.java | 121 ++--- .../lombok/eclipse/agent/PatchFixes.java | 384 -------------- .../eclipse/agent/PatchFixesShadowLoaded.java | 53 ++ .../lombok/launch/PatchFixesHider.java | 587 +++++++++++++++++++++ 4 files changed, 698 insertions(+), 447 deletions(-) delete mode 100644 src/eclipseAgent/lombok/eclipse/agent/PatchFixes.java create mode 100644 src/eclipseAgent/lombok/eclipse/agent/PatchFixesShadowLoaded.java create mode 100644 src/eclipseAgent/lombok/launch/PatchFixesHider.java diff --git a/src/eclipseAgent/lombok/eclipse/agent/EclipsePatcher.java b/src/eclipseAgent/lombok/eclipse/agent/EclipsePatcher.java index 96f253f2..efc7ce94 100644 --- a/src/eclipseAgent/lombok/eclipse/agent/EclipsePatcher.java +++ b/src/eclipseAgent/lombok/eclipse/agent/EclipsePatcher.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009-2012 The Project Lombok Authors. + * Copyright (C) 2009-2015 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 @@ -76,9 +76,6 @@ public class EclipsePatcher implements AgentLauncher.AgentLaunchable { sm.registerTransformer(instrumentation); if (!ecjOnly) { EclipseLoaderPatcher.patchEquinoxLoaders(sm, launchingContext); - } - - if (!ecjOnly) { patchCatchReparse(sm); patchIdentifierEndReparse(sm); patchRetrieveEllipsisStartPosition(sm); @@ -112,7 +109,7 @@ public class EclipsePatcher implements AgentLauncher.AgentLaunchable { sm.addScript(ScriptBuilder.wrapMethodCall() .target(new MethodTarget("org.eclipse.jdt.internal.compiler.SourceElementNotifier", "notifySourceElementRequestor", "void", "org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration", "org.eclipse.jdt.internal.compiler.ast.TypeDeclaration", "org.eclipse.jdt.internal.compiler.ast.ImportReference")) .methodToWrap(new Hook("org.eclipse.jdt.internal.compiler.util.HashtableOfObjectToInt", "get", "int", "java.lang.Object")) - .wrapMethod(new Hook("lombok.eclipse.agent.PatchFixes", "getSourceEndFixed", "int", "int", "org.eclipse.jdt.internal.compiler.ast.ASTNode")) + .wrapMethod(new Hook("lombok.launch.PatchFixesHider$PatchFixes", "getSourceEndFixed", "int", "int", "org.eclipse.jdt.internal.compiler.ast.ASTNode")) .requestExtra(StackRequest.PARAM1) .transplant().build()); @@ -125,7 +122,7 @@ public class EclipsePatcher implements AgentLauncher.AgentLaunchable { "org.eclipse.jdt.core.dom.MethodDeclaration" )) .methodToWrap(new Hook("org.eclipse.jface.text.IDocument", "get", "java.lang.String", "int", "int")) - .wrapMethod(new Hook("lombok.eclipse.agent.PatchFixes", "getRealMethodDeclarationSource", "java.lang.String", "java.lang.String", "java.lang.Object", "org.eclipse.jdt.core.dom.MethodDeclaration")) + .wrapMethod(new Hook("lombok.launch.PatchFixesHider$PatchFixes", "getRealMethodDeclarationSource", "java.lang.String", "java.lang.String", "java.lang.Object", "org.eclipse.jdt.core.dom.MethodDeclaration")) .requestExtra(StackRequest.THIS, StackRequest.PARAM4) .transplant().build()); @@ -134,20 +131,20 @@ public class EclipsePatcher implements AgentLauncher.AgentLaunchable { .target(new MethodTarget("org.eclipse.jdt.internal.corext.refactoring.structure.ExtractInterfaceProcessor", "createMemberDeclarations")) .target(new MethodTarget("org.eclipse.jdt.internal.corext.refactoring.structure.ExtractInterfaceProcessor", "createMethodComments")) .methodToReplace(new Hook("org.eclipse.jdt.internal.corext.refactoring.structure.ASTNodeSearchUtil", "getMethodDeclarationNode", "org.eclipse.jdt.core.dom.MethodDeclaration", "org.eclipse.jdt.core.IMethod", "org.eclipse.jdt.core.dom.CompilationUnit")) - .replacementMethod(new Hook("lombok.eclipse.agent.PatchFixes", "getRealMethodDeclarationNode", "org.eclipse.jdt.core.dom.MethodDeclaration", "org.eclipse.jdt.core.IMethod", "org.eclipse.jdt.core.dom.CompilationUnit")) + .replacementMethod(new Hook("lombok.launch.PatchFixesHider$PatchFixes", "getRealMethodDeclarationNode", "org.eclipse.jdt.core.dom.MethodDeclaration", "org.eclipse.jdt.core.IMethod", "org.eclipse.jdt.core.dom.CompilationUnit")) .transplant().build()); /* Do not add @Override's for generated methods */ sm.addScript(ScriptBuilder.exitEarly() .target(new MethodTarget("org.eclipse.jdt.core.dom.rewrite.ListRewrite", "insertFirst")) - .decisionMethod(new Hook("lombok.eclipse.agent.PatchFixes", "isListRewriteOnGeneratedNode", "boolean", "org.eclipse.jdt.core.dom.rewrite.ListRewrite")) + .decisionMethod(new Hook("lombok.launch.PatchFixesHider$PatchFixes", "isListRewriteOnGeneratedNode", "boolean", "org.eclipse.jdt.core.dom.rewrite.ListRewrite")) .request(StackRequest.THIS) .transplant().build()); /* Do not add comments for generated methods */ sm.addScript(ScriptBuilder.exitEarly() .target(new MethodTarget("org.eclipse.jdt.internal.corext.refactoring.structure.ExtractInterfaceProcessor", "createMethodComment")) - .decisionMethod(new Hook("lombok.eclipse.agent.PatchFixes", "isGenerated", "boolean", "org.eclipse.jdt.core.dom.ASTNode")) + .decisionMethod(new Hook("lombok.launch.PatchFixesHider$PatchFixes", "isGenerated", "boolean", "org.eclipse.jdt.core.dom.ASTNode")) .request(StackRequest.PARAM2) .transplant().build()); } @@ -160,7 +157,7 @@ public class EclipsePatcher implements AgentLauncher.AgentLaunchable { */ sm.addScript(ScriptBuilder.wrapReturnValue() .target(new MethodTarget("org.eclipse.core.internal.runtime.Product", "getProperty", "java.lang.String", "java.lang.String")) - .wrapMethod(new Hook("lombok.eclipse.agent.PatchFixes", "addLombokNotesToEclipseAboutDialog", "java.lang.String", "java.lang.String", "java.lang.String")) + .wrapMethod(new Hook("lombok.launch.PatchFixesHider$LombokDeps", "addLombokNotesToEclipseAboutDialog", "java.lang.String", "java.lang.String", "java.lang.String")) .request(StackRequest.RETURN_VALUE, StackRequest.PARAM1) .transplant().build()); } @@ -173,8 +170,8 @@ public class EclipsePatcher implements AgentLauncher.AgentLaunchable { .target(new MethodTarget("org.eclipse.jdt.internal.ui.search.OccurrencesFinder", "addUsage")) .target(new MethodTarget("org.eclipse.jdt.internal.ui.search.OccurrencesFinder", "addWrite")) .target(new MethodTarget("org.eclipse.jdt.internal.ui.javaeditor.SemanticHighlightingReconciler$PositionCollector", "visit", "boolean", "org.eclipse.jdt.core.dom.SimpleName")) - .decisionMethod(new Hook("lombok.eclipse.agent.PatchFixes", "isGenerated", "boolean", "org.eclipse.jdt.core.dom.ASTNode")) - .valueMethod(new Hook("lombok.eclipse.agent.PatchFixes", "returnFalse", "boolean", "java.lang.Object")) + .decisionMethod(new Hook("lombok.launch.PatchFixesHider$PatchFixes", "isGenerated", "boolean", "org.eclipse.jdt.core.dom.ASTNode")) + .valueMethod(new Hook("lombok.launch.PatchFixesHider$PatchFixes", "returnFalse", "boolean", "java.lang.Object")) .request(StackRequest.PARAM1) .build()); } @@ -199,9 +196,9 @@ public class EclipsePatcher implements AgentLauncher.AgentLaunchable { .target(new MethodTarget("org.eclipse.jdt.internal.corext.fix.CodeStyleFix$CodeStyleVisitor", "visit", "boolean", "org.eclipse.jdt.core.dom.QualifiedName")) .target(new MethodTarget("org.eclipse.jdt.internal.corext.fix.CodeStyleFix$CodeStyleVisitor", "visit", "boolean", "org.eclipse.jdt.core.dom.SimpleName")) // if a generated node has children we can just ignore them as well; - .decisionMethod(new Hook("lombok.eclipse.agent.PatchFixes", "isGenerated", "boolean", "org.eclipse.jdt.core.dom.ASTNode")) + .decisionMethod(new Hook("lombok.launch.PatchFixesHider$PatchFixes", "isGenerated", "boolean", "org.eclipse.jdt.core.dom.ASTNode")) .request(StackRequest.PARAM1) - .valueMethod(new Hook("lombok.eclipse.agent.PatchFixes", "returnFalse", "boolean", "java.lang.Object")) + .valueMethod(new Hook("lombok.launch.PatchFixesHider$PatchFixes", "returnFalse", "boolean", "java.lang.Object")) .build()); } @@ -209,7 +206,7 @@ public class EclipsePatcher implements AgentLauncher.AgentLaunchable { sm.addScript(ScriptBuilder.replaceMethodCall() .target(new MethodTarget("org.eclipse.jdt.internal.core.dom.rewrite.ASTRewriteAnalyzer$ListRewriter", "rewriteList")) .methodToReplace(new Hook("org.eclipse.jdt.internal.core.dom.rewrite.RewriteEvent", "getChildren", "org.eclipse.jdt.internal.core.dom.rewrite.RewriteEvent[]")) - .replacementMethod(new Hook("lombok.eclipse.agent.PatchFixes", "listRewriteHandleGeneratedMethods", "org.eclipse.jdt.internal.core.dom.rewrite.RewriteEvent[]", "org.eclipse.jdt.internal.core.dom.rewrite.RewriteEvent")) + .replacementMethod(new Hook("lombok.launch.PatchFixesHider$PatchFixes", "listRewriteHandleGeneratedMethods", "org.eclipse.jdt.internal.core.dom.rewrite.RewriteEvent[]", "org.eclipse.jdt.internal.core.dom.rewrite.RewriteEvent")) .build()); } @@ -221,37 +218,37 @@ public class EclipsePatcher implements AgentLauncher.AgentLaunchable { sm.addScript(ScriptBuilder.wrapMethodCall() .target(new MethodTarget("org.eclipse.jdt.internal.core.SortElementsOperation$2", "visit", "boolean", "org.eclipse.jdt.core.dom.CompilationUnit")) .methodToWrap(new Hook("org.eclipse.jdt.core.dom.CompilationUnit", "types", "java.util.List")) - .wrapMethod(new Hook("lombok.eclipse.agent.PatchFixes", "removeGeneratedNodes", "java.util.List", "java.util.List")) + .wrapMethod(new Hook("lombok.launch.PatchFixesHider$PatchFixes", "removeGeneratedNodes", "java.util.List", "java.util.List")) .transplant().build()); sm.addScript(ScriptBuilder.wrapMethodCall() .target(new MethodTarget("org.eclipse.jdt.internal.core.SortElementsOperation$2", "visit", "boolean", "org.eclipse.jdt.core.dom.AnnotationTypeDeclaration")) .methodToWrap(new Hook("org.eclipse.jdt.core.dom.AnnotationTypeDeclaration", "bodyDeclarations", "java.util.List")) - .wrapMethod(new Hook("lombok.eclipse.agent.PatchFixes", "removeGeneratedNodes", "java.util.List", "java.util.List")) + .wrapMethod(new Hook("lombok.launch.PatchFixesHider$PatchFixes", "removeGeneratedNodes", "java.util.List", "java.util.List")) .transplant().build()); sm.addScript(ScriptBuilder.wrapMethodCall() .target(new MethodTarget("org.eclipse.jdt.internal.core.SortElementsOperation$2", "visit", "boolean", "org.eclipse.jdt.core.dom.AnonymousClassDeclaration")) .methodToWrap(new Hook("org.eclipse.jdt.core.dom.AnonymousClassDeclaration", "bodyDeclarations", "java.util.List")) - .wrapMethod(new Hook("lombok.eclipse.agent.PatchFixes", "removeGeneratedNodes", "java.util.List", "java.util.List")) + .wrapMethod(new Hook("lombok.launch.PatchFixesHider$PatchFixes", "removeGeneratedNodes", "java.util.List", "java.util.List")) .transplant().build()); sm.addScript(ScriptBuilder.wrapMethodCall() .target(new MethodTarget("org.eclipse.jdt.internal.core.SortElementsOperation$2", "visit", "boolean", "org.eclipse.jdt.core.dom.TypeDeclaration")) .methodToWrap(new Hook("org.eclipse.jdt.core.dom.TypeDeclaration", "bodyDeclarations", "java.util.List")) - .wrapMethod(new Hook("lombok.eclipse.agent.PatchFixes", "removeGeneratedNodes", "java.util.List", "java.util.List")) + .wrapMethod(new Hook("lombok.launch.PatchFixesHider$PatchFixes", "removeGeneratedNodes", "java.util.List", "java.util.List")) .transplant().build()); sm.addScript(ScriptBuilder.wrapMethodCall() .target(new MethodTarget("org.eclipse.jdt.internal.core.SortElementsOperation$2", "visit", "boolean", "org.eclipse.jdt.core.dom.EnumDeclaration")) .methodToWrap(new Hook("org.eclipse.jdt.core.dom.EnumDeclaration", "bodyDeclarations", "java.util.List")) - .wrapMethod(new Hook("lombok.eclipse.agent.PatchFixes", "removeGeneratedNodes", "java.util.List", "java.util.List")) + .wrapMethod(new Hook("lombok.launch.PatchFixesHider$PatchFixes", "removeGeneratedNodes", "java.util.List", "java.util.List")) .transplant().build()); sm.addScript(ScriptBuilder.wrapMethodCall() .target(new MethodTarget("org.eclipse.jdt.internal.core.SortElementsOperation$2", "visit", "boolean", "org.eclipse.jdt.core.dom.EnumDeclaration")) .methodToWrap(new Hook("org.eclipse.jdt.core.dom.EnumDeclaration", "enumConstants", "java.util.List")) - .wrapMethod(new Hook("lombok.eclipse.agent.PatchFixes", "removeGeneratedNodes", "java.util.List", "java.util.List")) + .wrapMethod(new Hook("lombok.launch.PatchFixesHider$PatchFixes", "removeGeneratedNodes", "java.util.List", "java.util.List")) .transplant().build()); } @@ -259,7 +256,7 @@ public class EclipsePatcher implements AgentLauncher.AgentLaunchable { sm.addScript(ScriptBuilder.replaceMethodCall() .target(new MethodTarget("org.eclipse.jdt.internal.core.dom.rewrite.ASTRewriteAnalyzer", "visit")) .methodToReplace(new Hook("org.eclipse.jdt.internal.core.dom.rewrite.TokenScanner", "getTokenEndOffset", "int", "int", "int")) - .replacementMethod(new Hook("lombok.eclipse.agent.PatchFixes", "getTokenEndOffsetFixed", "int", "org.eclipse.jdt.internal.core.dom.rewrite.TokenScanner", "int", "int", "java.lang.Object")) + .replacementMethod(new Hook("lombok.launch.PatchFixesHider$PatchFixes", "getTokenEndOffsetFixed", "int", "org.eclipse.jdt.internal.core.dom.rewrite.TokenScanner", "int", "int", "java.lang.Object")) .requestExtra(StackRequest.PARAM1) .transplant() .build()); @@ -271,7 +268,7 @@ public class EclipsePatcher implements AgentLauncher.AgentLaunchable { .target(new MethodTarget("org.eclipse.jdt.internal.core.builder.IncrementalImageBuilder", "writeClassFileContents")) .target(new MethodTarget("org.eclipse.jdt.internal.core.builder.AbstractImageBuilder", "writeClassFileContents")) .methodToWrap(new Hook("org.eclipse.jdt.internal.compiler.ClassFile", "getBytes", "byte[]")) - .wrapMethod(new Hook("lombok.eclipse.agent.PatchFixes", "runPostCompiler", "byte[]", "byte[]", "java.lang.String")) + .wrapMethod(new Hook("lombok.launch.PatchFixesHider$LombokDeps", "runPostCompiler", "byte[]", "byte[]", "java.lang.String")) .requestExtra(StackRequest.PARAM3) .build()); } @@ -280,24 +277,22 @@ public class EclipsePatcher implements AgentLauncher.AgentLaunchable { sm.addScript(ScriptBuilder.wrapMethodCall() .target(new MethodTarget("org.eclipse.jdt.internal.compiler.tool.EclipseCompilerImpl", "outputClassFiles")) .methodToWrap(new Hook("javax.tools.JavaFileObject", "openOutputStream", "java.io.OutputStream")) - .wrapMethod(new Hook("lombok.eclipse.agent.PatchFixes", "runPostCompiler", "java.io.OutputStream", "java.io.OutputStream")) - .transplant() - .build()); + .wrapMethod(new Hook("lombok.launch.PatchFixesHider$LombokDeps", "runPostCompiler", "java.io.OutputStream", "java.io.OutputStream")) + .transplant().build()); sm.addScript(ScriptBuilder.wrapMethodCall() .target(new MethodTarget("org.eclipse.jdt.internal.compiler.util.Util", "writeToDisk")) .methodToWrap(new Hook("java.io.BufferedOutputStream", "", "void", "java.io.OutputStream", "int")) - .wrapMethod(new Hook("lombok.eclipse.agent.PatchFixes", "runPostCompiler", "java.io.BufferedOutputStream", "java.io.BufferedOutputStream", "java.lang.String", "java.lang.String")) + .wrapMethod(new Hook("lombok.launch.PatchFixesHider$LombokDeps", "runPostCompiler", "java.io.BufferedOutputStream", "java.io.BufferedOutputStream", "java.lang.String", "java.lang.String")) .requestExtra(StackRequest.PARAM2, StackRequest.PARAM3) - .transplant() - .build()); + .transplant().build()); } private static void patchHideGeneratedNodes(ScriptManager sm) { sm.addScript(ScriptBuilder.wrapReturnValue() .target(new MethodTarget("org.eclipse.jdt.internal.corext.dom.LinkedNodeFinder", "findByNode")) .target(new MethodTarget("org.eclipse.jdt.internal.corext.dom.LinkedNodeFinder", "findByBinding")) - .wrapMethod(new Hook("lombok.eclipse.agent.PatchFixes", "removeGeneratedSimpleNames", "org.eclipse.jdt.core.dom.SimpleName[]", + .wrapMethod(new Hook("lombok.launch.PatchFixesHider$PatchFixes", "removeGeneratedSimpleNames", "org.eclipse.jdt.core.dom.SimpleName[]", "org.eclipse.jdt.core.dom.SimpleName[]")) .request(StackRequest.RETURN_VALUE).build()); @@ -317,22 +312,22 @@ public class EclipsePatcher implements AgentLauncher.AgentLaunchable { sm.addScript(ScriptBuilder.exitEarly() .target(new MethodTarget("org.eclipse.jdt.core.dom.rewrite.ASTRewrite", "replace")) .target(new MethodTarget("org.eclipse.jdt.core.dom.rewrite.ASTRewrite", "remove")) - .decisionMethod(new Hook("lombok.eclipse.agent.PatchFixes", "skipRewritingGeneratedNodes", "boolean", + .decisionMethod(new Hook("lombok.launch.PatchFixesHider$PatchFixes", "skipRewritingGeneratedNodes", "boolean", "org.eclipse.jdt.core.dom.ASTNode")) .transplant().request(StackRequest.PARAM1).build()); sm.addScript(ScriptBuilder.wrapMethodCall() .target(new MethodTarget("org.eclipse.jdt.internal.corext.refactoring.rename.RenameTypeProcessor", "addConstructorRenames")) .methodToWrap(new Hook("org.eclipse.jdt.core.IType", "getMethods", "org.eclipse.jdt.core.IMethod[]")) - .wrapMethod(new Hook("lombok.eclipse.agent.PatchFixes", "removeGeneratedMethods", "org.eclipse.jdt.core.IMethod[]", + .wrapMethod(new Hook("lombok.launch.PatchFixesHider$PatchFixes", "removeGeneratedMethods", "org.eclipse.jdt.core.IMethod[]", "org.eclipse.jdt.core.IMethod[]")) .transplant().build()); sm.addScript(ScriptBuilder.exitEarly() .target(new MethodTarget("org.eclipse.jdt.internal.corext.refactoring.rename.TempOccurrenceAnalyzer", "visit", "boolean", "org.eclipse.jdt.core.dom.SimpleName")) .target(new MethodTarget("org.eclipse.jdt.internal.corext.refactoring.rename.RenameAnalyzeUtil$ProblemNodeFinder$NameNodeVisitor", "visit", "boolean", "org.eclipse.jdt.core.dom.SimpleName")) - .decisionMethod(new Hook("lombok.eclipse.agent.PatchFixes", "isGenerated", "boolean", "org.eclipse.jdt.core.dom.ASTNode")) - .valueMethod(new Hook("lombok.eclipse.agent.PatchFixes", "returnTrue", "boolean", "java.lang.Object")) + .decisionMethod(new Hook("lombok.launch.PatchFixesHider$PatchFixes", "isGenerated", "boolean", "org.eclipse.jdt.core.dom.ASTNode")) + .valueMethod(new Hook("lombok.launch.PatchFixesHider$PatchFixes", "returnTrue", "boolean", "java.lang.Object")) .request(StackRequest.PARAM1) .transplant().build()); } @@ -340,21 +335,21 @@ public class EclipsePatcher implements AgentLauncher.AgentLaunchable { private static void patchCatchReparse(ScriptManager sm) { sm.addScript(ScriptBuilder.wrapReturnValue() .target(new MethodTarget("org.eclipse.jdt.core.dom.ASTConverter", "retrieveStartingCatchPosition")) - .wrapMethod(new Hook("lombok.eclipse.agent.PatchFixes", "fixRetrieveStartingCatchPosition", "int", "int", "int")) + .wrapMethod(new Hook("lombok.launch.PatchFixesHider$PatchFixes", "fixRetrieveStartingCatchPosition", "int", "int", "int")) .transplant().request(StackRequest.RETURN_VALUE, StackRequest.PARAM1).build()); } private static void patchIdentifierEndReparse(ScriptManager sm) { sm.addScript(ScriptBuilder.wrapReturnValue() .target(new MethodTarget("org.eclipse.jdt.core.dom.ASTConverter", "retrieveIdentifierEndPosition")) - .wrapMethod(new Hook("lombok.eclipse.agent.PatchFixes", "fixRetrieveIdentifierEndPosition", "int", "int", "int")) + .wrapMethod(new Hook("lombok.launch.PatchFixesHider$PatchFixes", "fixRetrieveIdentifierEndPosition", "int", "int", "int")) .transplant().request(StackRequest.RETURN_VALUE, StackRequest.PARAM2).build()); } private static void patchRetrieveEllipsisStartPosition(ScriptManager sm) { sm.addScript(ScriptBuilder.wrapReturnValue() .target(new MethodTarget("org.eclipse.jdt.core.dom.ASTConverter", "retrieveEllipsisStartPosition")) - .wrapMethod(new Hook("lombok.eclipse.agent.PatchFixes", "fixRetrieveEllipsisStartPosition", "int", "int", "int")) + .wrapMethod(new Hook("lombok.launch.PatchFixesHider$PatchFixes", "fixRetrieveEllipsisStartPosition", "int", "int", "int")) .transplant().request(StackRequest.RETURN_VALUE, StackRequest.PARAM2).build()); } @@ -362,7 +357,7 @@ public class EclipsePatcher implements AgentLauncher.AgentLaunchable { sm.addScript(ScriptBuilder.wrapReturnValue() .target(new MethodTarget("org.eclipse.jdt.core.dom.ASTConverter", "retrieveRightBraceOrSemiColonPosition")) .target(new MethodTarget("org.eclipse.jdt.core.dom.ASTConverter", "retrieveRightBrace")) - .wrapMethod(new Hook("lombok.eclipse.agent.PatchFixes", "fixRetrieveRightBraceOrSemiColonPosition", "int", "int", "int")) + .wrapMethod(new Hook("lombok.launch.PatchFixesHider$PatchFixes", "fixRetrieveRightBraceOrSemiColonPosition", "int", "int", "int")) .transplant().request(StackRequest.RETURN_VALUE, StackRequest.PARAM2).build()); } @@ -394,14 +389,14 @@ public class EclipsePatcher implements AgentLauncher.AgentLaunchable { return Collections.singleton("org.eclipse.jdt.core.dom.ASTConverter"); } }).request(StackRequest.PARAM1, StackRequest.RETURN_VALUE) - .wrapMethod(new Hook("lombok.eclipse.agent.PatchFixes", "setIsGeneratedFlag", "void", + .wrapMethod(new Hook("lombok.launch.PatchFixesHider$PatchFixes", "setIsGeneratedFlag", "void", "org.eclipse.jdt.core.dom.ASTNode", "org.eclipse.jdt.internal.compiler.ast.ASTNode")) .transplant().build()); sm.addScript(ScriptBuilder.wrapReturnValue() .target(new MethodTarget("org.eclipse.jdt.core.dom.ASTConverter", "convert", "org.eclipse.jdt.core.dom.ASTNode", "boolean", "org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration")) .request(StackRequest.PARAM2, StackRequest.RETURN_VALUE) - .wrapMethod(new Hook("lombok.eclipse.agent.PatchFixes", "setIsGeneratedFlag", "void", + .wrapMethod(new Hook("lombok.launch.PatchFixesHider$PatchFixes", "setIsGeneratedFlag", "void", "org.eclipse.jdt.core.dom.ASTNode", "org.eclipse.jdt.internal.compiler.ast.ASTNode")) .transplant().build()); @@ -419,7 +414,7 @@ public class EclipsePatcher implements AgentLauncher.AgentLaunchable { .target(new MethodTarget("org.eclipse.jdt.core.dom.ASTConverter", "convertToVariableDeclarationStatement", "org.eclipse.jdt.core.dom.VariableDeclarationStatement", "org.eclipse.jdt.internal.compiler.ast.LocalDeclaration")) /* Targets above are only patched because the resulting dom nodes should be marked if generated. */ .request(StackRequest.PARAM1, StackRequest.RETURN_VALUE) - .wrapMethod(new Hook("lombok.eclipse.agent.PatchFixes", "setIsGeneratedFlag", "void", + .wrapMethod(new Hook("lombok.launch.PatchFixesHider$PatchFixes", "setIsGeneratedFlag", "void", "org.eclipse.jdt.core.dom.ASTNode", "org.eclipse.jdt.internal.compiler.ast.ASTNode")) .transplant().build()); @@ -441,7 +436,7 @@ public class EclipsePatcher implements AgentLauncher.AgentLaunchable { } }).methodToWrap(new Hook("org.eclipse.jdt.core.dom.SimpleName", "", "void", "org.eclipse.jdt.core.dom.AST")) .requestExtra(StackRequest.PARAM1) - .wrapMethod(new Hook("lombok.eclipse.agent.PatchFixes", "setIsGeneratedFlagForName", "void", + .wrapMethod(new Hook("lombok.launch.PatchFixesHider$PatchFixes", "setIsGeneratedFlagForName", "void", "org.eclipse.jdt.core.dom.Name", "java.lang.Object")) .transplant().build()); @@ -449,7 +444,7 @@ public class EclipsePatcher implements AgentLauncher.AgentLaunchable { .target(new MethodTarget("org.eclipse.jdt.core.dom.ASTConverter", "convert", "org.eclipse.jdt.core.dom.ASTNode", "boolean", "org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration")) .methodToWrap(new Hook("org.eclipse.jdt.core.dom.SimpleName", "", "void", "org.eclipse.jdt.core.dom.AST")) .requestExtra(StackRequest.PARAM2) - .wrapMethod(new Hook("lombok.eclipse.agent.PatchFixes", "setIsGeneratedFlagForName", "void", + .wrapMethod(new Hook("lombok.launch.PatchFixesHider$PatchFixes", "setIsGeneratedFlagForName", "void", "org.eclipse.jdt.core.dom.Name", "java.lang.Object")) .transplant().build()); @@ -458,7 +453,7 @@ public class EclipsePatcher implements AgentLauncher.AgentLaunchable { .target(new MethodTarget("org.eclipse.jdt.core.dom.ASTConverter", "setQualifiedNameNameAndSourceRanges", "org.eclipse.jdt.core.dom.QualifiedName", "char[][]", "long[]", "int", "org.eclipse.jdt.internal.compiler.ast.ASTNode")) .methodToWrap(new Hook("org.eclipse.jdt.core.dom.SimpleName", "", "void", "org.eclipse.jdt.core.dom.AST")) .requestExtra(StackRequest.PARAM4) - .wrapMethod(new Hook("lombok.eclipse.agent.PatchFixes", "setIsGeneratedFlagForName", "void", + .wrapMethod(new Hook("lombok.launch.PatchFixesHider$PatchFixes", "setIsGeneratedFlagForName", "void", "org.eclipse.jdt.core.dom.Name", "java.lang.Object")) .transplant().build()); @@ -466,7 +461,7 @@ public class EclipsePatcher implements AgentLauncher.AgentLaunchable { .target(new MethodTarget("org.eclipse.jdt.core.dom.ASTConverter", "setQualifiedNameNameAndSourceRanges", "org.eclipse.jdt.core.dom.QualifiedName", "char[][]", "long[]", "int", "org.eclipse.jdt.internal.compiler.ast.ASTNode")) .methodToWrap(new Hook("org.eclipse.jdt.core.dom.QualifiedName", "", "void", "org.eclipse.jdt.core.dom.AST")) .requestExtra(StackRequest.PARAM4) - .wrapMethod(new Hook("lombok.eclipse.agent.PatchFixes", "setIsGeneratedFlagForName", "void", + .wrapMethod(new Hook("lombok.launch.PatchFixesHider$PatchFixes", "setIsGeneratedFlagForName", "void", "org.eclipse.jdt.core.d