From 94d9755be4843620e1191dc62ae3fc539856aa45 Mon Sep 17 00:00:00 2001 From: Roel Spilker Date: Tue, 7 Feb 2017 14:51:58 +0100 Subject: trivial --- src/eclipseAgent/lombok/eclipse/agent/EclipsePatcher.java | 2 -- 1 file changed, 2 deletions(-) (limited to 'src') diff --git a/src/eclipseAgent/lombok/eclipse/agent/EclipsePatcher.java b/src/eclipseAgent/lombok/eclipse/agent/EclipsePatcher.java index 77f615b5..135b5c77 100644 --- a/src/eclipseAgent/lombok/eclipse/agent/EclipsePatcher.java +++ b/src/eclipseAgent/lombok/eclipse/agent/EclipsePatcher.java @@ -30,8 +30,6 @@ import java.util.Collection; import java.util.Collections; import java.util.List; -import org.eclipse.jdt.internal.corext.refactoring.SearchResultGroup; - import lombok.core.AgentLauncher; import lombok.patcher.Filter; import lombok.patcher.Hook; -- cgit From ca2966f735416b62b1906edb22e68bad3963dc5e Mon Sep 17 00:00:00 2001 From: Roel Spilker Date: Tue, 7 Feb 2017 14:56:47 +0100 Subject: Display changelog in installer --- src/installer/lombok/installer/InstallerGUI.java | 164 ++++++++++++++++++----- 1 file changed, 132 insertions(+), 32 deletions(-) (limited to 'src') diff --git a/src/installer/lombok/installer/InstallerGUI.java b/src/installer/lombok/installer/InstallerGUI.java index ebdf2035..7a94d595 100644 --- a/src/installer/lombok/installer/InstallerGUI.java +++ b/src/installer/lombok/installer/InstallerGUI.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009-2016 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 @@ -39,6 +39,8 @@ import java.awt.event.ActionListener; import java.awt.font.TextAttribute; import java.io.File; import java.io.FilenameFilter; +import java.io.InputStream; +import java.io.InputStreamReader; import java.net.URI; import java.util.ArrayList; import java.util.Collections; @@ -65,6 +67,8 @@ import javax.swing.JScrollPane; import javax.swing.Scrollable; import javax.swing.SwingUtilities; import javax.swing.filechooser.FileFilter; +import javax.swing.plaf.basic.BasicHTML; +import javax.swing.text.View; import lombok.core.Version; import lombok.installer.OsUtils.OS; @@ -85,6 +89,7 @@ public class InstallerGUI { private Component ideArea; private Component uninstallArea; private Component howIWorkArea; + private Component successArea; private Box uninstallBox; private JHyperLink uninstallButton; @@ -113,6 +118,8 @@ public class InstallerGUI { uninstallArea.setVisible(false); howIWorkArea = buildHowIWorkArea(); howIWorkArea.setVisible(false); + successArea = buildSuccessArea(); + successArea.setVisible(false); buildChrome(appWindow.getContentPane()); appWindow.pack(); } catch (Throwable t) { @@ -153,6 +160,7 @@ public class InstallerGUI { howIWorkArea.setVisible(false); javacArea.setVisible(true); ideArea.setVisible(true); + successArea.setVisible(false); appWindow.pack(); } }); @@ -160,9 +168,76 @@ public class InstallerGUI { constraints.gridy = 2; container.add(buttonBar, constraints); + container.setPreferredSize(new Dimension(462, 415)); return container; } + private void showSuccess(String installSpecific) { + successExplanation.setText(SUCCESS_EXPLANATION.replace("%%%", installSpecific)); + howIWorkArea.setVisible(false); + javacArea.setVisible(false); + ideArea.setVisible(false); + successArea.setVisible(true); + appWindow.pack(); + } + + private JLabel successExplanation; + + private Component buildSuccessArea() { + JPanel container = new JPanel(); + + container.setLayout(new GridBagLayout()); + GridBagConstraints constraints = new GridBagConstraints(); + constraints.anchor = GridBagConstraints.WEST; + + container.add(new JLabel(SUCCESS_TITLE), constraints); + + constraints.gridy = 1; + constraints.insets = new Insets(8, 0, 0, 16); + container.add(successExplanation = new JLabel(SUCCESS_EXPLANATION), constraints); + + constraints.gridy++; + constraints.fill = GridBagConstraints.BOTH; + + JLabel notes = new JLabel(); + notes.setText(readChangeLog()); + + JScrollPane scroller = new JScrollPane(notes); + container.add(scroller, constraints); + scroller.setPreferredSize(new Dimension(380, 240)); + + View view = (View) notes.getClientProperty(BasicHTML.propertyKey); + view.setSize(380, 0.0f); + float w = view.getPreferredSpan(View.X_AXIS); + float h = view.getPreferredSpan(View.Y_AXIS); + notes.setSize((int) w, (int) h); + + container.setPreferredSize(new Dimension(462, 415)); + return container; + } + + private String readChangeLog() { + InputStream in = Installer.class.getResourceAsStream("/latestchanges.html"); + try { + char[] buff = new char[8192]; + StringBuilder contents = new StringBuilder(); + InputStreamReader reader = new InputStreamReader(in, "UTF-8"); + while (true) { + int read = reader.read(buff); + if (read == -1) break; + contents.append(buff, 0, read); + } + return "" + contents + ""; + } catch (Exception e) { + return "No Changelog available"; + } + finally { + try { + in.close(); + } catch (Exception ignore){ /**/} + } + } + private Component buildUninstallArea() { JPanel container = new JPanel(); @@ -210,6 +285,7 @@ public class InstallerGUI { constraints.gridy = 4; container.add(buttonBar, constraints); + container.setPreferredSize(new Dimension(462, 415)); return container; } @@ -232,6 +308,7 @@ public class InstallerGUI { constraints.gridy = 2; container.add(example, constraints); + container.setPreferredSize(new Dimension(462, 105)); return container; } @@ -419,7 +496,7 @@ public class InstallerGUI { uninstallPlaceholder.setVisible(false); container.add(uninstallPlaceholder, constraints); - + container.setPreferredSize(new Dimension(462, 296)); return container; } @@ -427,6 +504,7 @@ public class InstallerGUI { javacArea.setVisible(false); ideArea.setVisible(false); howIWorkArea.setVisible(true); + successArea.setVisible(false); appWindow.pack(); } @@ -453,6 +531,7 @@ public class InstallerGUI { spinner.setOpaque(true); spinner.setLayout(new FlowLayout()); spinner.add(new JLabel(new ImageIcon(Installer.class.getResource("loading.gif")))); + final Container appWindowContent = appWindow.getContentPane(); appWindow.setContentPane(spinner); final AtomicInteger successes = new AtomicInteger(); @@ -500,20 +579,13 @@ public class InstallerGUI { try { SwingUtilities.invokeAndWait(new Runnable() { @Override public void run() { + appWindow.setContentPane(appWindowContent); + appWindow.pack(); StringBuilder installSpecific = new StringBuilder(); for (String installSpecificMessage : installSpecificMessages) { installSpecific.append("
").append(installSpecificMessage); } - JOptionPane.showMessageDialog(appWindow, - "Lombok has been installed on the selected IDE installations.
" + - "Don't forget to add lombok.jar to your projects, and restart your IDE!" + installSpecific.toString() + "", - "Install successful", - JOptionPane.INFORMATION_MESSAGE); - appWindow.setVisible(false); - synchronized (exitMarker) { - exitMarker.set(0); - exitMarker.notifyAll(); - } + showSuccess(installSpecific.toString()); } }); } catch (Exception e) { @@ -711,6 +783,8 @@ public class InstallerGUI { appWindowContainer.add(howIWorkArea, constraints); + appWindowContainer.add(successArea, constraints); + constraints.gridy++; constraints.gridwidth = 2; constraints.gridx = 0; @@ -719,9 +793,33 @@ public class InstallerGUI { constraints.ipadx = 0; constraints.ipady = 0; constraints.fill = GridBagConstraints.HORIZONTAL; - constraints.anchor = GridBagConstraints.SOUTHEAST; + constraints.anchor = GridBagConstraints.SOUTHWEST; constraints.insets = new Insets(0, 16, 8, 8); + + appWindow.add(buildButtonBar(), constraints); + } + + private Box buildButtonBar() { Box buttonBar = Box.createHorizontalBox(); + + JHyperLink aboutLink = new JHyperLink(Installer.ABOUT_LOMBOK_URL.toString()); + aboutLink.addActionListener(openBrowser(aboutLink, Installer.ABOUT_LOMBOK_URL)); + buttonBar.add(aboutLink); + + buttonBar.add(Box.createRigidArea(new Dimension(16, 1))); + + JLabel versionLabel = new JLabel(); + versionLabel.setText("v" + Version.getVersion()); + + buttonBar.add(versionLabel); + buttonBar.add(Box.createRigidArea(new Dimension(16, 1))); + + JHyperLink changelogLink = new JHyperLink("View full changelog"); + changelogLink.addActionListener(openBrowser(changelogLink, Installer.ABOUT_LOMBOK_URL.resolve("/changelog.html"))); + buttonBar.add(changelogLink); + + buttonBar.add(Box.createHorizontalGlue()); + JButton quitButton = new JButton("Quit Installer"); quitButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { @@ -729,14 +827,18 @@ public class InstallerGUI { System.exit(0); } }); - final JHyperLink hyperlink = new JHyperLink(Installer.ABOUT_LOMBOK_URL.toString()); - hyperlink.addActionListener(new ActionListener() { + buttonBar.add(quitButton); + return buttonBar; + } + + private ActionListener openBrowser(final JHyperLink hyperlink, final URI location) { + return new ActionListener() { @Override public void actionPerformed(ActionEvent event) { hyperlink.setForeground(new Color(85, 145, 90)); try { //java.awt.Desktop doesn't exist in 1.5. Object desktop = Class.forName("java.awt.Desktop").getMethod("getDesktop").invoke(null); - Class.forName("java.awt.Desktop").getMethod("browse", URI.class).invoke(desktop, Installer.ABOUT_LOMBOK_URL); + Class.forName("java.awt.Desktop").getMethod("browse", URI.class).invoke(desktop, location); } catch (Exception e) { Runtime rt = Runtime.getRuntime(); try { @@ -746,34 +848,27 @@ public class InstallerGUI { cmd[0] = "cmd.exe"; cmd[1] = "/C"; cmd[2] = "start"; - cmd[3] = Installer.ABOUT_LOMBOK_URL.toString(); + cmd[3] = location.toString(); rt.exec(cmd); break; case MAC_OS_X: - rt.exec("open " + Installer.ABOUT_LOMBOK_URL.toString()); + rt.exec("open " + location.toString()); break; default: case UNIX: - rt.exec("firefox " + Installer.ABOUT_LOMBOK_URL.toString()); + rt.exec("firefox " + location.toString()); break; } } catch (Exception e2) { JOptionPane.showMessageDialog(appWindow, "Well, this is embarrassing. I don't know how to open a webbrowser.\n" + - "I guess you'll have to open it. Browse to:\n" + Installer.ABOUT_LOMBOK_URL + + "I guess you'll have to open it. Browse to:\n" + location + " for more information about Lombok.", "I'm embarrassed", JOptionPane.INFORMATION_MESSAGE); } } } - }); - buttonBar.add(hyperlink); - buttonBar.add(Box.createRigidArea(new Dimension(16, 1))); - buttonBar.add(new JLabel("v" + Version.getVersion() + "")); - - buttonBar.add(Box.createHorizontalGlue()); - buttonBar.add(quitButton); - appWindow.add(buttonBar, constraints); + }; } /** @@ -791,7 +886,7 @@ public class InstallerGUI { } private static final String IDE_TITLE = - "IDEs"; + "IDEs "; private static final String IDE_EXPLANATION = "Lombok can update your Eclipse or eclipse-based IDE to fully support all Lombok features.
" + @@ -801,7 +896,7 @@ public class InstallerGUI { "Scanning your drives for IDE installations..."; private static final String JAVAC_TITLE = - "Javac       (and tools that invoke javac such as ant and maven)"; + "Javac       (and tools that invoke javac such as ant and maven)"; private static final String JAVAC_EXPLANATION = "Lombok works 'out of the box' with javac.
Just make sure the lombok.jar is in your classpath when you compile."; @@ -810,13 +905,13 @@ public class InstallerGUI { "Example: javac -cp lombok.jar MyCode.java"; private static final String UNINSTALL_TITLE = - "Uninstall"; + "Uninstall "; private static final String UNINSTALL_EXPLANATION = "Uninstall Lombok from the following IDE Installations?"; private static final String HOW_I_WORK_TITLE = - "What this installer does"; + "What this installer does "; private static final String HOW_I_WORK_EXPLANATION = "

Eclipse

    " + @@ -826,6 +921,11 @@ public class InstallerGUI { "On Mac OS X, eclipse.ini is hidden in
    " + "Eclipse.app/Contents/MacOS so that's where I place the jar files."; + private static final String SUCCESS_TITLE = "Install successful "; + private static final String SUCCESS_EXPLANATION = "Lombok has been installed on the selected IDE installations.
    " + + "Don't forget to add lombok.jar to your projects, and exit and start your IDE!%%%"; + + private static class JHyperLink extends JButton { private static final long serialVersionUID = 1L; -- cgit From b42fef8edc8b3d5458c74c8b049c0cbb842b1ca1 Mon Sep 17 00:00:00 2001 From: Reinier Zwitserloot Date: Thu, 9 Feb 2017 22:46:21 +0100 Subject: A shot-in-the-dark fix for issue #1293 which is not reproducible: Occasional duplicate class def errors in eclipse. --- src/launch/lombok/launch/ShadowClassLoader.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/launch/lombok/launch/ShadowClassLoader.java b/src/launch/lombok/launch/ShadowClassLoader.java index 37c479ee..2bcf46b5 100644 --- a/src/launch/lombok/launch/ShadowClassLoader.java +++ b/src/launch/lombok/launch/ShadowClassLoader.java @@ -451,7 +451,12 @@ class ShadowClassLoader extends ClassLoader { Class alreadyDefined = highlanderMap.get(name); if (alreadyDefined != null) return alreadyDefined; } - throw e; + try { + c = this.findLoadedClass(name); + } catch (LinkageError e2) { + throw e; + } + if (c == null) throw e; } if (highlanders.contains(name)) { -- cgit From 70f77f928ac7a6edf3ef91a41399c9a79561c871 Mon Sep 17 00:00:00 2001 From: Roel Spilker Date: Thu, 9 Feb 2017 22:45:45 +0100 Subject: [i1014] Only add lombok.Generated if it is explicitly turned on --- src/core/lombok/ConfigurationKeys.java | 14 ++++++-------- src/core/lombok/core/handlers/HandlerUtil.java | 4 ++-- src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java | 4 ++-- src/core/lombok/javac/handlers/JavacHandlerUtil.java | 4 ++-- 4 files changed, 12 insertions(+), 14 deletions(-) (limited to 'src') diff --git a/src/core/lombok/ConfigurationKeys.java b/src/core/lombok/ConfigurationKeys.java index ff17ca09..f0e070e2 100644 --- a/src/core/lombok/ConfigurationKeys.java +++ b/src/core/lombok/ConfigurationKeys.java @@ -41,30 +41,28 @@ public class ConfigurationKeys { /** * lombok configuration: {@code lombok.addGeneratedAnnotation} = {@code true} | {@code false}. * - * If unset or {@code true}, lombok generates various annotations to mark generated code like {@code @javax.annotation.Generated("lombok")} and {@code @lombok.Generated}. + * If unset or {@code true}, lombok generates {@code @javax.annotation.Generated("lombok")} on all fields, methods, and types that are generated, unless {@code lombok.addJavaxGeneratedAnnotation} is set. * * @see ConfigurationKeys#ADD_JAVAX_GENERATED_ANNOTATIONS * @see ConfigurationKeys#ADD_LOMBOK_GENERATED_ANNOTATIONS + * @deprecated Since version 1.16.14, use {@link #ADD_JAVAX_GENERATED_ANNOTATIONS} instead. */ - public static final ConfigurationKey ADD_GENERATED_ANNOTATIONS = new ConfigurationKey("lombok.addGeneratedAnnotation", "Generate @javax.annotation.Generated on all generated code (default: true).") {}; + @Deprecated + public static final ConfigurationKey ADD_GENERATED_ANNOTATIONS = new ConfigurationKey("lombok.addGeneratedAnnotation", "Generate @javax.annotation.Generated on all generated code (default: true). Deprecated, use 'lombok.addJavaxGeneratedAnnotation' instead.") {}; /** * lombok configuration: {@code lombok.addJavaxGeneratedAnnotation} = {@code true} | {@code false}. * * If unset or {@code true}, lombok generates {@code @javax.annotation.Generated("lombok")} on all fields, methods, and types that are generated, unless {@code lombok.addGeneratedAnnotation} is set to {@code false}. - * - * @see ConfigurationKeys#ADD_GENERATED_ANNOTATIONS */ public static final ConfigurationKey ADD_JAVAX_GENERATED_ANNOTATIONS = new ConfigurationKey("lombok.addJavaxGeneratedAnnotation", "Generate @javax.annotation.Generated on all generated code (default: follow lombok.addGeneratedAnnotation).") {}; /** * lombok configuration: {@code lombok.addLombokGeneratedAnnotation} = {@code true} | {@code false}. * - * If unset or {@code true}, lombok generates {@code @lombok.Generated} on all fields, methods, and types that are generated, unless {@code lombok.addGeneratedAnnotation} is set to {@code false}. - * - * @see ConfigurationKeys#ADD_GENERATED_ANNOTATIONS + * If {@code true}, lombok generates {@code @lombok.Generated} on all fields, methods, and types that are generated. */ - public static final ConfigurationKey ADD_LOMBOK_GENERATED_ANNOTATIONS = new ConfigurationKey("lombok.addLombokGeneratedAnnotation", "Generate @lombok.Generated on all generated code (default: follow lombok.addGeneratedAnnotation).") {}; + public static final ConfigurationKey ADD_LOMBOK_GENERATED_ANNOTATIONS = new ConfigurationKey("lombok.addLombokGeneratedAnnotation", "Generate @lombok.Generated on all generated code (default: false).") {}; /** * lombok configuration: {@code lombok.extern.findbugs.addSuppressFBWarnings} = {@code true} | {@code false}. diff --git a/src/core/lombok/core/handlers/HandlerUtil.java b/src/core/lombok/core/handlers/HandlerUtil.java index a05578d4..7e6d6d66 100644 --- a/src/core/lombok/core/handlers/HandlerUtil.java +++ b/src/core/lombok/core/handlers/HandlerUtil.java @@ -109,8 +109,8 @@ public class HandlerUtil { } } - public static boolean shouldAddGenerated(LombokNode node, ConfigurationKey key) { - Boolean add = node.getAst().readConfiguration(key); + public static boolean shouldAddGenerated(LombokNode node) { + Boolean add = node.getAst().readConfiguration(ConfigurationKeys.ADD_JAVAX_GENERATED_ANNOTATIONS); if (add != null) return add; return !Boolean.FALSE.equals(node.getAst().readConfiguration(ConfigurationKeys.ADD_GENERATED_ANNOTATIONS)); } diff --git a/src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java b/src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java index f822e095..ab4ca27b 100644 --- a/src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java +++ b/src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java @@ -1345,10 +1345,10 @@ public class EclipseHandlerUtil { public static Annotation[] addGenerated(EclipseNode node, ASTNode source, Annotation[] originalAnnotationArray) { Annotation[] result = originalAnnotationArray; - if (HandlerUtil.shouldAddGenerated(node, ConfigurationKeys.ADD_JAVAX_GENERATED_ANNOTATIONS)) { + if (HandlerUtil.shouldAddGenerated(node)) { result = addAnnotation(source, result, JAVAX_ANNOTATION_GENERATED, new StringLiteral(LOMBOK, 0, 0, 0)); } - if (HandlerUtil.shouldAddGenerated(node, ConfigurationKeys.ADD_LOMBOK_GENERATED_ANNOTATIONS)) { + if (Boolean.TRUE.equals(node.getAst().readConfiguration(ConfigurationKeys.ADD_LOMBOK_GENERATED_ANNOTATIONS))) { result = addAnnotation(source, result, LOMBOK_GENERATED, null); } return result; diff --git a/src/core/lombok/javac/handlers/JavacHandlerUtil.java b/src/core/lombok/javac/handlers/JavacHandlerUtil.java index 0b4e839d..af8289a3 100644 --- a/src/core/lombok/javac/handlers/JavacHandlerUtil.java +++ b/src/core/lombok/javac/handlers/JavacHandlerUtil.java @@ -1025,10 +1025,10 @@ public class JavacHandlerUtil { public static void addGenerated(JCModifiers mods, JavacNode node, int pos, JCTree source, Context context) { if (!LombokOptionsFactory.getDelombokOptions(context).getFormatPreferences().generateGenerated()) return; - if (HandlerUtil.shouldAddGenerated(node, ConfigurationKeys.ADD_JAVAX_GENERATED_ANNOTATIONS)) { + if (HandlerUtil.shouldAddGenerated(node)) { addAnnotation(mods, node, pos, source, context, "javax.annotation.Generated", node.getTreeMaker().Literal("lombok")); } - if (HandlerUtil.shouldAddGenerated(node, ConfigurationKeys.ADD_LOMBOK_GENERATED_ANNOTATIONS)) { + if (Boolean.TRUE.equals(node.getAst().readConfiguration(ConfigurationKeys.ADD_LOMBOK_GENERATED_ANNOTATIONS))) { addAnnotation(mods, node, pos, source, context, "lombok.Generated", null); } } -- cgit From 3127930afa4866ad5e1b45e700045ad656cd2d9e Mon Sep 17 00:00:00 2001 From: Roel Spilker Date: Thu, 9 Feb 2017 22:52:25 +0100 Subject: Make it possible to copy from the release notes --- src/installer/lombok/installer/InstallerGUI.java | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/installer/lombok/installer/InstallerGUI.java b/src/installer/lombok/installer/InstallerGUI.java index 7a94d595..5c0efcb4 100644 --- a/src/installer/lombok/installer/InstallerGUI.java +++ b/src/installer/lombok/installer/InstallerGUI.java @@ -64,11 +64,12 @@ import javax.swing.JLabel; import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.JScrollPane; +import javax.swing.JTextPane; import javax.swing.Scrollable; import javax.swing.SwingUtilities; +import javax.swing.UIManager; import javax.swing.filechooser.FileFilter; -import javax.swing.plaf.basic.BasicHTML; -import javax.swing.text.View; +import javax.swing.text.html.HTMLDocument; import lombok.core.Version; import lombok.installer.OsUtils.OS; @@ -199,19 +200,23 @@ public class InstallerGUI { constraints.gridy++; constraints.fill = GridBagConstraints.BOTH; - JLabel notes = new JLabel(); + JTextPane notes = new JTextPane(); + notes.setContentType("text/html"); notes.setText(readChangeLog()); + notes.setEditable(false); + notes.setOpaque(false); + notes.setBorder(null); + notes.setSelectionStart(0); + notes.setSelectionEnd(0); + + Font font = UIManager.getFont("Label.font"); + String bodyRule = "body { font-family: " + font.getFamily() + "; font-size: " + font.getSize() + "pt; }"; + ((HTMLDocument)notes.getDocument()).getStyleSheet().addRule(bodyRule); JScrollPane scroller = new JScrollPane(notes); container.add(scroller, constraints); scroller.setPreferredSize(new Dimension(380, 240)); - View view = (View) notes.getClientProperty(BasicHTML.propertyKey); - view.setSize(380, 0.0f); - float w = view.getPreferredSpan(View.X_AXIS); - float h = view.getPreferredSpan(View.Y_AXIS); - notes.setSize((int) w, (int) h); - container.setPreferredSize(new Dimension(462, 415)); return container; } -- cgit From 4ea6857c7f14babe1c7130a7418f943186979885 Mon Sep 17 00:00:00 2001 From: Reinier Zwitserloot Date: Thu, 9 Feb 2017 23:23:29 +0100 Subject: made the installer a little wider; this also fixes bizarre layouting for macosx. --- src/installer/lombok/installer/InstallerGUI.java | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/installer/lombok/installer/InstallerGUI.java b/src/installer/lombok/installer/InstallerGUI.java index 5c0efcb4..ff89df89 100644 --- a/src/installer/lombok/installer/InstallerGUI.java +++ b/src/installer/lombok/installer/InstallerGUI.java @@ -80,6 +80,7 @@ import lombok.installer.OsUtils.OS; * Also offers info on what this installer does in case people want to instrument their IDE manually. */ public class InstallerGUI { + private static final int INSTALLER_WINDOW_WIDTH = 662; static final AtomicReference exitMarker = new AtomicReference(); private JFrame appWindow; @@ -169,7 +170,7 @@ public class InstallerGUI { constraints.gridy = 2; container.add(buttonBar, constraints); - container.setPreferredSize(new Dimension(462, 415)); + container.setPreferredSize(new Dimension(INSTALLER_WINDOW_WIDTH, 415)); return container; } @@ -215,9 +216,9 @@ public class InstallerGUI { JScrollPane scroller = new JScrollPane(notes); container.add(scroller, constraints); - scroller.setPreferredSize(new Dimension(380, 240)); + scroller.setPreferredSize(new Dimension(INSTALLER_WINDOW_WIDTH - 82, 240)); - container.setPreferredSize(new Dimension(462, 415)); + container.setPreferredSize(new Dimension(INSTALLER_WINDOW_WIDTH, 415)); return container; } @@ -290,7 +291,7 @@ public class InstallerGUI { constraints.gridy = 4; container.add(buttonBar, constraints); - container.setPreferredSize(new Dimension(462, 415)); + container.setPreferredSize(new Dimension(INSTALLER_WINDOW_WIDTH, 415)); return container; } @@ -313,7 +314,7 @@ public class InstallerGUI { constraints.gridy = 2; container.add(example, constraints); - container.setPreferredSize(new Dimension(462, 105)); + container.setPreferredSize(new Dimension(INSTALLER_WINDOW_WIDTH, 105)); return container; } @@ -501,7 +502,7 @@ public class InstallerGUI { uninstallPlaceholder.setVisible(false); container.add(uninstallPlaceholder, constraints); - container.setPreferredSize(new Dimension(462, 296)); + container.setPreferredSize(new Dimension(INSTALLER_WINDOW_WIDTH, 296)); return container; } -- cgit From 2335512c8e134a1f6a7a567948543bf87613544b Mon Sep 17 00:00:00 2001 From: Roel Spilker Date: Fri, 10 Feb 2017 00:10:07 +0100 Subject: [i1274] Add outer name to type name for nested types in equals. --- .../eclipse/handlers/HandleEqualsAndHashCode.java | 70 +++++++++++++--------- .../javac/handlers/HandleEqualsAndHashCode.java | 36 +++++------ 2 files changed, 58 insertions(+), 48 deletions(-) (limited to 'src') diff --git a/src/core/lombok/eclipse/handlers/HandleEqualsAndHashCode.java b/src/core/lombok/eclipse/handlers/HandleEqualsAndHashCode.java index a56eee89..bc25ae2a 100644 --- a/src/core/lombok/eclipse/handlers/HandleEqualsAndHashCode.java +++ b/src/core/lombok/eclipse/handlers/HandleEqualsAndHashCode.java @@ -67,6 +67,7 @@ import org.eclipse.jdt.internal.compiler.ast.MethodDeclaration; import org.eclipse.jdt.internal.compiler.ast.NameReference; import org.eclipse.jdt.internal.compiler.ast.NullLiteral; import org.eclipse.jdt.internal.compiler.ast.OperatorIds; +import org.eclipse.jdt.internal.compiler.ast.ParameterizedQualifiedTypeReference; import org.eclipse.jdt.internal.compiler.ast.ParameterizedSingleTypeReference; import org.eclipse.jdt.internal.compiler.ast.QualifiedNameReference; import org.eclipse.jdt.internal.compiler.ast.QualifiedTypeReference; @@ -458,7 +459,14 @@ public class HandleEqualsAndHashCode extends EclipseAnnotationHandler list = new ArrayList(); list.add(type.getName()); EclipseNode tNode = type.up(); @@ -468,21 +476,44 @@ public class HandleEqualsAndHashCode extends EclipseAnnotationHandler fields, boolean callSuper, ASTNode source, FieldAccess fieldAccess, boolean needsCanEqual, List onParam) { int pS = source.sourceStart; int pE = source.sourceEnd; long p = (long)pS << 32 | pE; - TypeDeclaration typeDecl = (TypeDeclaration)type.get(); MethodDeclaration method = new MethodDeclaration( ((CompilationUnitDeclaration) type.top().get()).compilationResult); @@ -528,7 +559,7 @@ public class HandleEqualsAndHashCode extends EclipseAnnotationHandler other = (MyType) o; */ { + /* Outer.Inner.MyType other = (Outer.Inner.MyType) o; */ { if (!fields.isEmpty() || needsCanEqual) { LocalDeclaration other = new LocalDeclaration(otherName, pS, pE); other.modifiers |= ClassFileConstants.AccFinal; setGeneratedBy(other, source); - char[] typeName = typeDecl.name; - TypeReference targetType; - if (typeDecl.typeParameters == null || typeDecl.typeParameters.length == 0) { - targetType = new SingleTypeReference(typeName, p); - setGeneratedBy(targetType, source); - other.type = new SingleTypeReference(typeName, p); - setGeneratedBy(other.type, source); - } else { - TypeReference[] typeArgs = new TypeReference[typeDecl.typeParameters.length]; - for (int i = 0; i < typeArgs.length; i++) { - typeArgs[i] = new Wildcard(Wildcard.UNBOUND); - typeArgs[i].sourceStart = pS; typeArgs[i].sourceEnd = pE; - setGeneratedBy(typeArgs[i], source); - } - targetType = new ParameterizedSingleTypeReference(typeName, typeArgs, 0, p); - setGeneratedBy(targetType, source); - other.type = new ParameterizedSingleTypeReference(typeName, copyTypes(typeArgs, source), 0, p); - setGeneratedBy(other.type, source); - } + TypeReference targetType = createTypeReference(type, p, source, true); + setGeneratedBy(targetType, source); + other.type = createTypeReference(type, p, source, true); + setGeneratedBy(other.type, source); NameReference oRef = new SingleNameReference(new char[] { 'o' }, p); setGeneratedBy(oRef, source); other.initialization = makeCastExpression(oRef, targetType, source); @@ -772,7 +788,7 @@ public class HandleEqualsAndHashCode extends EclipseAnnotationHandler list = new ArrayList(); list.add(type.getName()); JavacNode tNode = type.up(); @@ -372,20 +372,28 @@ public class HandleEqualsAndHashCode extends JavacAnnotationHandler wildcards = new ListBuffer(); + for (int i = 0 ; i < typeDecl.typarams.length() ; i++) { + wildcards.append(maker.Wildcard(maker.TypeBoundKind(BoundKind.UNBOUND), null)); + } + + return maker.TypeApply(chain, wildcards.toList()); } public JCMethodDecl createEquals(JavacNode typeNode, List fields, boolean callSuper, FieldAccess fieldAccess, boolean needsCanEqual, JCTree source, List onParam) { JavacTreeMaker maker = typeNode.getTreeMaker(); - JCClassDecl type = (JCClassDecl) typeNode.get(); Name oName = typeNode.toName("o"); Name otherName = typeNode.toName("other"); @@ -408,27 +416,13 @@ public class HandleEqualsAndHashCode extends JavacAnnotationHandler other = (MyType) o; */ { + /* Outer.Inner.MyType other = (Outer.Inner.MyType) o; */ { if (!fields.isEmpty() || needsCanEqual) { - final JCExpression selfType1, selfType2; - ListBuffer wildcards1 = new ListBuffer(); - ListBuffer wildcards2 = new ListBuffer(); - for (int i = 0 ; i < type.typarams.length() ; i++) { - wildcards1.append(maker.Wildcard(maker.TypeBoundKind(BoundKind.UNBOUND), null)); - wildcards2.append(maker.Wildcard(maker.TypeBoundKind(BoundKind.UNBOUND), null)); - } - - if (type.typarams.isEmpty()) { - selfType1 = maker.Ident(type.name); - selfType2 = maker.Ident(type.name); - } else { - selfType1 = maker.TypeApply(maker.Ident(type.name), wildcards1.toList()); - selfType2 = maker.TypeApply(maker.Ident(type.name), wildcards2.toList()); - } + final JCExpression selfType1 = createTypeReference(typeNode, true), selfType2 = createTypeReference(typeNode, true); statements.append( maker.VarDef(maker.Modifiers(finalFlag), otherName, selfType1, maker.TypeCast(selfType2, maker.Ident(oName)))); @@ -533,7 +527,7 @@ public class HandleEqualsAndHashCode extends JavacAnnotationHandler params = List.of(maker.VarDef(maker.Modifiers(flags, onParam), otherName, objectType, null)); JCBlock body = maker.Block(0, List.of( - maker.Return(maker.TypeTest(maker.Ident(otherName), createTypeReference(typeNode))))); + maker.Return(maker.TypeTest(maker.Ident(otherName), createTypeReference(typeNode, false))))); return recursiveSetGeneratedBy(maker.MethodDef(mods, canEqualName, returnType, List.nil(), params, List.nil(), body, null), source, typeNode.getContext()); } -- cgit From fc7d32af36f3913e13b2827780326a9a5c728fb2 Mon Sep 17 00:00:00 2001 From: Reinier Zwitserloot Date: Fri, 10 Feb 2017 03:09:59 +0100 Subject: Updated ShadowClassLoader’s finding of ‘self’; it failed exactly once on me and I’d like to know the classloader when that happens (error condition was loading lombok.jar as an AP in eclipse which normally you don’t even do, so it’s not a big deal). MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/launch/lombok/launch/ShadowClassLoader.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/launch/lombok/launch/ShadowClassLoader.java b/src/launch/lombok/launch/ShadowClassLoader.java index 2bcf46b5..72f006e8 100644 --- a/src/launch/lombok/launch/ShadowClassLoader.java +++ b/src/launch/lombok/launch/ShadowClassLoader.java @@ -118,12 +118,16 @@ class ShadowClassLoader extends ClassLoader { SELF_BASE = selfBase; SELF_BASE_LENGTH = selfBase.length(); } else { - String sclClassUrl = ShadowClassLoader.class.getResource("ShadowClassLoader.class").toString(); - if (!sclClassUrl.endsWith(SELF_NAME)) throw new InternalError("ShadowLoader can't find itself."); - SELF_BASE_LENGTH = sclClassUrl.length() - SELF_NAME.length(); + URL sclClassUrl = ShadowClassLoader.class.getResource("ShadowClassLoader.class"); + String sclClassStr = sclClassUrl == null ? null : sclClassUrl.toString(); + if (sclClassStr == null || !sclClassStr.endsWith(SELF_NAME)) { + ClassLoader cl = ShadowClassLoader.class.getClassLoader(); + throw new RuntimeException("ShadowLoader can't find itself. SCL loader type: " + (cl == null ? "*NULL*" : cl.getClass().toString())); + } + SELF_BASE_LENGTH = sclClassStr.length() - SELF_NAME.length(); String decoded; try { - decoded = URLDecoder.decode(sclClassUrl.substring(0, SELF_BASE_LENGTH), "UTF-8"); + decoded = URLDecoder.decode(sclClassStr.substring(0, SELF_BASE_LENGTH), "UTF-8"); } catch (UnsupportedEncodingException e) { throw new InternalError("UTF-8 not available"); } -- cgit From 87822a7142e9f91da8557467d27b5854e0ebe2ec Mon Sep 17 00:00:00 2001 From: Reinier Zwitserloot Date: Fri, 10 Feb 2017 03:20:27 +0100 Subject: pre-release version bump. --- src/core/lombok/core/Version.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/core/lombok/core/Version.java b/src/core/lombok/core/Version.java index 4fdb7216..c6dc83fa 100644 --- a/src/core/lombok/core/Version.java +++ b/src/core/lombok/core/Version.java @@ -30,9 +30,9 @@ public class Version { // ** CAREFUL ** - this class must always compile with 0 dependencies (it must not refer to any other sources or libraries). // Note: In 'X.Y.Z', if Z is odd, its a snapshot build built from the repository, so many different 0.10.3 versions can exist, for example. // Official builds always end in an even number. (Since 0.10.2). - private static final String VERSION = "1.16.13"; - private static final String RELEASE_NAME = "Edgy Guinea Pig"; -// private static final String RELEASE_NAME = "Candid Duck"; + private static final String VERSION = "1.16.14"; +// private static final String RELEASE_NAME = "Edgy Guinea Pig"; + private static final String RELEASE_NAME = "Candid Duck"; private Version() { //Prevent instantiation -- cgit From 5eaf74ec22879e8fabc3f9d86a520fc04a097dc3 Mon Sep 17 00:00:00 2001 From: Reinier Zwitserloot Date: Fri, 10 Feb 2017 04:06:01 +0100 Subject: Post-release version bump. --- src/core/lombok/core/Version.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/core/lombok/core/Version.java b/src/core/lombok/core/Version.java index c6dc83fa..a50b72d5 100644 --- a/src/core/lombok/core/Version.java +++ b/src/core/lombok/core/Version.java @@ -30,9 +30,9 @@ public class Version { // ** CAREFUL ** - this class must always compile with 0 dependencies (it must not refer to any other sources or libraries). // Note: In 'X.Y.Z', if Z is odd, its a snapshot build built from the repository, so many different 0.10.3 versions can exist, for example. // Official builds always end in an even number. (Since 0.10.2). - private static final String VERSION = "1.16.14"; -// private static final String RELEASE_NAME = "Edgy Guinea Pig"; - private static final String RELEASE_NAME = "Candid Duck"; + private static final String VERSION = "1.16.15"; + private static final String RELEASE_NAME = "Edgy Guinea Pig"; +// private static final String RELEASE_NAME = "Candid Duck"; private Version() { //Prevent instantiation -- cgit From 9491bce6021d22c98dd615821d5dbb9fdf5e3fc5 Mon Sep 17 00:00:00 2001 From: Reinier Zwitserloot Date: Mon, 13 Feb 2017 20:40:03 +0100 Subject: [trivial] Added a suppress warnings (to suppress an expected and in this case analysed to be harmless, intentional use of our own deprecated API) --- src/core/lombok/core/handlers/HandlerUtil.java | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/core/lombok/core/handlers/HandlerUtil.java b/src/core/lombok/core/handlers/HandlerUtil.java index 7e6d6d66..6c3a0b79 100644 --- a/src/core/lombok/core/handlers/HandlerUtil.java +++ b/src/core/lombok/core/handlers/HandlerUtil.java @@ -109,6 +109,7 @@ public class HandlerUtil { } } + @SuppressWarnings("deprecation") public static boolean shouldAddGenerated(LombokNode node) { Boolean add = node.getAst().readConfiguration(ConfigurationKeys.ADD_JAVAX_GENERATED_ANNOTATIONS); if (add != null) return add; -- cgit From ad4bd36274d2bfe8dcf74977d921a114739386b1 Mon Sep 17 00:00:00 2001 From: Reinier Zwitserloot Date: Mon, 13 Feb 2017 21:47:48 +0100 Subject: Now searches through any subdir of any dir containing the string ‘eclipse’ (or STS or whatnot), to any depth, instead of requiring each subdir to be searched to again contain ‘eclipse’ or some variant thereof. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The mac installer installs to /Applications/eclipse/java-neon, for example, by default, so it wasn’t being found. --- .../lombok/installer/eclipse/EclipseProductLocationProvider.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/installer/lombok/installer/eclipse/EclipseProductLocationProvider.java b/src/installer/lombok/installer/eclipse/EclipseProductLocationProvider.java index 3710d7d9..b807f02b 100644 --- a/src/installer/lombok/installer/eclipse/EclipseProductLocationProvider.java +++ b/src/installer/lombok/installer/eclipse/EclipseProductLocationProvider.java @@ -288,10 +288,10 @@ public class EclipseProductLocationProvider implements IdeLocationProvider { abstract String findEclipseOnPlatform(File dir); void recurseDirectory(List locations, List problems, File dir) { - recurseDirectory0(locations, problems, dir, 0); + recurseDirectory0(locations, problems, dir, 0, false); } - private void recurseDirectory0(List locations, List problems, File f, int loopCounter) { + private void recurseDirectory0(List locations, List problems, File f, int loopCounter, boolean nameFound) { //Various try/catch/ignore statements are in this for loop. Weird conditions on the disk can cause exceptions, //such as an unformatted drive causing a NullPointerException on listFiles. Best action is almost invariably to just //continue onwards. @@ -301,9 +301,9 @@ public class EclipseProductLocationProvider implements IdeLocationProvider { for (File dir : listFiles) { if (!dir.isDirectory()) continue; try { - if (dir.getName().toLowerCase().contains(descriptor.getDirectoryName())) { + if (nameFound || dir.getName().toLowerCase().contains(descriptor.getDirectoryName())) { findEclipse(locations, problems, dir); - if (loopCounter < 50) recurseDirectory0(locations, problems, dir, loopCounter + 1); + if (loopCounter < 50) recurseDirectory0(locations, problems, dir, loopCounter + 1, true); } } catch (Exception ignore) {} } -- cgit From 627e9dc8a7f381ace59f91c9ee4a023733d4717e Mon Sep 17 00:00:00 2001 From: Reinier Zwitserloot Date: Mon, 13 Feb 2017 21:48:40 +0100 Subject: Updated the text to also mention rebuilding projects. Also fixed various size issues with swing’s… peculiar layouting mechanism. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/installer/lombok/installer/InstallerGUI.java | 28 ++++++++++++++---------- 1 file changed, 16 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/installer/lombok/installer/InstallerGUI.java b/src/installer/lombok/installer/InstallerGUI.java index ff89df89..b96fec9c 100644 --- a/src/installer/lombok/installer/InstallerGUI.java +++ b/src/installer/lombok/installer/InstallerGUI.java @@ -192,11 +192,15 @@ public class InstallerGUI { GridBagConstraints constraints = new GridBagConstraints(); constraints.anchor = GridBagConstraints.WEST; - container.add(new JLabel(SUCCESS_TITLE), constraints); + JLabel title; + container.add(title = new JLabel(SUCCESS_TITLE), constraints); + title.setPreferredSize(new Dimension(INSTALLER_WINDOW_WIDTH - 82, 20)); constraints.gridy = 1; constraints.insets = new Insets(8, 0, 0, 16); container.add(successExplanation = new JLabel(SUCCESS_EXPLANATION), constraints); + successExplanation.setPreferredSize(new Dimension(INSTALLER_WINDOW_WIDTH - 82, 175)); + successExplanation.setMinimumSize(new Dimension(INSTALLER_WINDOW_WIDTH - 82, 175)); constraints.gridy++; constraints.fill = GridBagConstraints.BOTH; @@ -212,13 +216,13 @@ public class InstallerGUI { Font font = UIManager.getFont("Label.font"); String bodyRule = "body { font-family: " + font.getFamily() + "; font-size: " + font.getSize() + "pt; }"; - ((HTMLDocument)notes.getDocument()).getStyleSheet().addRule(bodyRule); - + ((HTMLDocument) notes.getDocument()).getStyleSheet().addRule(bodyRule); JScrollPane scroller = new JScrollPane(notes); container.add(scroller, constraints); - scroller.setPreferredSize(new Dimension(INSTALLER_WINDOW_WIDTH - 82, 240)); - + scroller.setPreferredSize(new Dimension(INSTALLER_WINDOW_WIDTH - 82, 200)); + scroller.setMinimumSize(new Dimension(INSTALLER_WINDOW_WIDTH - 82, 200)); container.setPreferredSize(new Dimension(INSTALLER_WINDOW_WIDTH, 415)); + container.setMinimumSize(new Dimension(INSTALLER_WINDOW_WIDTH, 415)); return container; } @@ -372,11 +376,11 @@ public class InstallerGUI { if (locations.size() + problems.size() == 0) { JOptionPane.showMessageDialog(appWindow, - "I can't find any IDEs on your computer.\n" + - "If you have IDEs installed on this computer, please use the " + - "'Specify Location...' button to manually point out the \n" + - "location of your IDE installation to me. Thanks!", - "Can't find IDE", JOptionPane.INFORMATION_MESSAGE); + "I can't find any IDEs on your computer.\n" + + "If you have IDEs installed on this computer, please use the " + + "'Specify Location...' button to manually point out the \n" + + "location of your IDE installation to me. Thanks!", + "Can't find IDE", JOptionPane.INFORMATION_MESSAGE); } } }); @@ -929,8 +933,8 @@ public class InstallerGUI { private static final String SUCCESS_TITLE = "Install successful "; private static final String SUCCESS_EXPLANATION = "Lombok has been installed on the selected IDE installations.
    " + - "Don't forget to add lombok.jar to your projects, and exit and start your IDE!%%%"; - + "Don't forget to:
    • add lombok.jar to your projects,
    • exit and start your IDE,
    • rebuild all projects!
    %%%"; + private static class JHyperLink extends JButton { private static final long serialVersionUID = 1L; -- cgit From 1d32894ca316dd83c873d1e46746ee6ca37f8059 Mon Sep 17 00:00:00 2001 From: Reinier Zwitserloot Date: Tue, 14 Feb 2017 00:19:14 +0100 Subject: Fixes issue #1287 - if a field gets marked as static via `@UtilityClass`, don’t make it final via `@FieldDefaults`. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/core/lombok/eclipse/handlers/HandleUtilityClass.java | 2 ++ src/core/lombok/javac/handlers/HandleUtilityClass.java | 2 ++ 2 files changed, 4 insertions(+) (limited to 'src') diff --git a/src/core/lombok/eclipse/handlers/HandleUtilityClass.java b/src/core/lombok/eclipse/handlers/HandleUtilityClass.java index 199ce102..959c1d20 100644 --- a/src/core/lombok/eclipse/handlers/HandleUtilityClass.java +++ b/src/core/lombok/eclipse/handlers/HandleUtilityClass.java @@ -49,6 +49,7 @@ import org.mangosdk.spi.ProviderFor; import lombok.ConfigurationKeys; import lombok.core.AnnotationValues; +import lombok.core.HandlerPriority; import lombok.core.AST.Kind; import lombok.eclipse.EclipseAnnotationHandler; import lombok.eclipse.EclipseNode; @@ -57,6 +58,7 @@ import lombok.experimental.UtilityClass; /** * Handles the {@code lombok.experimental.UtilityClass} annotation for eclipse. */ +@HandlerPriority(-4096) //-2^12; to ensure @FieldDefaults picks up on the 'static' we set here. @ProviderFor(EclipseAnnotationHandler.class) public class HandleUtilityClass extends EclipseAnnotationHandler { @Override public void handle(AnnotationValues annotation, Annotation ast, EclipseNode annotationNode) { diff --git a/src/core/lombok/javac/handlers/HandleUtilityClass.java b/src/core/lombok/javac/handlers/HandleUtilityClass.java index 6d3ec63b..ee8081d6 100644 --- a/src/core/lombok/javac/handlers/HandleUtilityClass.java +++ b/src/core/lombok/javac/handlers/HandleUtilityClass.java @@ -44,6 +44,7 @@ import com.sun.tools.javac.util.Name; import lombok.ConfigurationKeys; import lombok.core.AST.Kind; import lombok.core.AnnotationValues; +import lombok.core.HandlerPriority; import lombok.experimental.UtilityClass; import lombok.javac.Javac; import lombok.javac.JavacAnnotationHandler; @@ -53,6 +54,7 @@ import lombok.javac.JavacTreeMaker; /** * Handles the {@code @UtilityClass} annotation for javac. */ +@HandlerPriority(-4096) //-2^12; to ensure @FieldDefaults picks up on the 'static' we set here. @ProviderFor(JavacAnnotationHandler.class) public class HandleUtilityClass extends JavacAnnotationHandler { @Override public void handle(AnnotationValues annotation, JCAnnotation ast, JavacNode annotationNode) { -- cgit From 05f93771e9aeb6ad0c884f22df4b9fa8c1f6cc2f Mon Sep 17 00:00:00 2001 From: Roel Spilker Date: Tue, 14 Feb 2017 00:36:00 +0100 Subject: [jdk9] Create FileObjects for jdk9 --- .../javac/apt/Javac9BaseFileObjectWrapper.java | 113 +++++++++++++++++++++ src/core/lombok/javac/apt/LombokFileObjects.java | 78 ++++++++++---- .../com/sun/tools/javac/file/BaseFileManager.java | 8 ++ .../com/sun/tools/javac/file/PathFileObject.java | 12 +++ 4 files changed, 189 insertions(+), 22 deletions(-) create mode 100644 src/core/lombok/javac/apt/Javac9BaseFileObjectWrapper.java create mode 100644 src/stubs/com/sun/tools/javac/file/BaseFileManager.java create mode 100644 src/stubs/com/sun/tools/javac/file/PathFileObject.java (limited to 'src') diff --git a/src/core/lombok/javac/apt/Javac9BaseFileObjectWrapper.java b/src/core/lombok/javac/apt/Javac9BaseFileObjectWrapper.java new file mode 100644 index 00000000..f9fe2a7d --- /dev/null +++ b/src/core/lombok/javac/apt/Javac9BaseFileObjectWrapper.java @@ -0,0 +1,113 @@ +/* + * Copyright (C) 2010-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 + * 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.javac.apt; + +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.io.Reader; +import java.io.Writer; +import java.net.URI; +import java.nio.file.Path; + +import javax.lang.model.element.Modifier; +import javax.lang.model.element.NestingKind; + +import com.sun.tools.javac.file.BaseFileManager; + +class Javac9BaseFileObjectWrapper extends com.sun.tools.javac.file.PathFileObject { + private final LombokFileObject delegate; + + public Javac9BaseFileObjectWrapper(BaseFileManager fileManager, Path path, LombokFileObject delegate) { + super(fileManager, path); + this.delegate = delegate; + } + + @Override public boolean isNameCompatible(String simpleName, Kind kind) { + return delegate.isNameCompatible(simpleName, kind); + } + + @Override public URI toUri() { + return delegate.toUri(); + } + + @SuppressWarnings("all") + @Override public String getName() { + return delegate.getName(); + } + + @Override public CharSequence getCharContent(boolean ignoreEncodingErrors) throws IOException { + return delegate.getCharContent(ignoreEncodingErrors); + } + + @Override public InputStream openInputStream() throws IOException { + return delegate.openInputStream(); + } + + @Override public Reader openReader(boolean ignoreEncodingErrors) throws IOException { + return delegate.openReader(ignoreEncodingErrors); + } + + @Override public Writer openWriter() throws IOException { + return delegate.openWriter(); + } + + @Override public OutputStream openOutputStream() throws IOException { + return delegate.openOutputStream(); + } + + @Override public long getLastModified() { + return delegate.getLastModified(); + } + + @Override public boolean delete() { + return delegate.delete(); + } + + @Override public Kind getKind() { + return delegate.getKind(); + } + + @Override public NestingKind getNestingKind() { + return delegate.getNestingKind(); + } + + @Override public Modifier getAccessLevel() { + return delegate.getAccessLevel(); + } + + @Override public boolean equals(Object obj) { + if (!(obj instanceof Javac9BaseFileObjectWrapper)) { + return false; + } + return delegate.equals(((Javac9BaseFileObjectWrapper)obj).delegate); + } + + @Override public int hashCode() { + return delegate.hashCode(); + } + + @Override public String toString() { + return delegate.toString(); + } +} \ No newline at end of file diff --git a/src/core/lombok/javac/apt/LombokFileObjects.java b/src/core/lombok/javac/apt/LombokFileObjects.java index 412e449b..7e818cab 100644 --- a/src/core/lombok/javac/apt/LombokFileObjects.java +++ b/src/core/lombok/javac/apt/LombokFileObjects.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2010-2011 The Project Lombok Authors. + * Copyright (C) 2010-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 @@ -23,19 +23,24 @@ package lombok.javac.apt; import java.lang.reflect.Method; +import java.net.URI; +import java.nio.file.Paths; import java.util.concurrent.atomic.AtomicBoolean; import javax.tools.JavaFileManager; import javax.tools.JavaFileObject; import javax.tools.JavaFileObject.Kind; +import com.sun.tools.javac.file.BaseFileManager; + import lombok.core.DiagnosticsReceiver; //Can't use SimpleJavaFileObject so we copy/paste most of its content here, because javac doesn't follow the interface, //and casts to its own BaseFileObject type. D'oh! final class LombokFileObjects { - enum Compiler { - JAVAC6 { + + interface Compiler { + Compiler JAVAC6 = new Compiler() { private Method decoderMethod = null; private final AtomicBoolean decoderIsSet = new AtomicBoolean(); @@ -46,13 +51,13 @@ final class LombokFileObjects { @Override public Method getDecoderMethod() { synchronized (decoderIsSet) { if (decoderIsSet.get()) return decoderMethod; - decoderMethod = getDecoderMethod("com.sun.tools.javac.util.BaseFileObject"); + decoderMethod = LombokFileObjects.getDecoderMethod("com.sun.tools.javac.util.BaseFileObject"); decoderIsSet.set(true); return decoderMethod; } } - }, - JAVAC7 { + }; + Compiler JAVAC7 = new Compiler() { private Method decoderMethod = null; private final AtomicBoolean decoderIsSet = new AtomicBoolean(); @@ -63,28 +68,28 @@ final class LombokFileObjects { @Override public Method getDecoderMethod() { synchronized (decoderIsSet) { if (decoderIsSet.get()) return decoderMethod; - decoderMethod = getDecoderMethod("com.sun.tools.javac.file.BaseFileObject"); + decoderMethod = LombokFileObjects.getDecoderMethod("com.sun.tools.javac.file.BaseFileObject"); decoderIsSet.set(true); return decoderMethod; } } }; - static Method getDecoderMethod(String className) { - Method m = null; - try { - m = Class.forName(className).getDeclaredMethod("getDecoder", boolean.class); - m.setAccessible(true); - } catch (NoSuchMethodException e) { - // Intentional fallthrough - getDecoder(boolean) is not always present. - } catch (ClassNotFoundException e) { - // Intentional fallthrough - getDecoder(boolean) is not always present. - } - return m; - } + JavaFileObject wrap(LombokFileObject fileObject); + Method getDecoderMethod(); + } - abstract JavaFileObject wrap(LombokFileObject fileObject); - abstract Method getDecoderMethod(); + static Method getDecoderMethod(String className) { + Method m = null; + try { + m = Class.forName(className).getDeclaredMethod("getDecoder", boolean.class); + m.setAccessible(true); + } catch (NoSuchMethodException e) { + // Intentional fallthrough - getDecoder(boolean) is not always present. + } catch (ClassNotFoundException e) { + // Intentional fallthrough - getDecoder(boolean) is not always present. + } + return m; } private LombokFileObjects() {} @@ -93,7 +98,16 @@ final class LombokFileObjects { String jfmClassName = jfm != null ? jfm.getClass().getName() : "null"; if (jfmClassName.equals("com.sun.tools.javac.util.DefaultFileManager")) return Compiler.JAVAC6; if (jfmClassName.equals("com.sun.tools.javac.util.JavacFileManager")) return Compiler.JAVAC6; - if (jfmClassName.equals("com.sun.tools.javac.file.JavacFileManager")) return Compiler.JAVAC7; + if (jfmClassName.equals("com.sun.tools.javac.file.JavacFileManager")) { + try { + Class superType = Class.forName("com.sun.tools.javac.file.BaseFileManager"); + if (superType.isInstance(jfm)) { + return new Java9Compiler(jfm); + } + } + catch (Exception e) {} + return Compiler.JAVAC7; + } try { if (Class.forName("com.sun.tools.javac.file.BaseFileObject") == null) throw new NullPointerException(); return Compiler.JAVAC7; @@ -112,4 +126,24 @@ final class LombokFileObjects { static JavaFileObject createIntercepting(Compiler compiler, JavaFileObject delegate, String fileName, DiagnosticsReceiver diagnostics) { return compiler.wrap(new InterceptingJavaFileObject(delegate, fileName, diagnostics, compiler.getDecoderMethod())); } + + static class Java9Compiler implements Compiler { + private final BaseFileManager fileManager; + + public Java9Compiler(JavaFileManager jfm) { + fileManager = (BaseFileManager) jfm; + } + + @Override public JavaFileObject wrap(LombokFileObject fileObject) { + URI uri = fileObject.toUri(); + if (uri.getScheme() == null) { + uri = URI.create("file://" + uri); + } + return new Javac9BaseFileObjectWrapper(fileManager, Paths.get(uri), fileObject); + } + + @Override public Method getDecoderMethod() { + throw new UnsupportedOperationException(); + } + } } diff --git a/src/stubs/com/sun/tools/javac/file/BaseFileManager.java b/src/stubs/com/sun/tools/javac/file/BaseFileManager.java new file mode 100644 index 00000000..7a2293d5 --- /dev/null +++ b/src/stubs/com/sun/tools/javac/file/BaseFileManager.java @@ -0,0 +1,8 @@ +/* + * These are stub versions of various bits of javac-internal API (for various different versions of javac). Lombok is compiled against these. + */ +package com.sun.tools.javac.file; + +import javax.tools.JavaFileManager; + +public abstract class BaseFileManager implements JavaFileManager{} diff --git a/src/stubs/com/sun/tools/javac/file/PathFileObject.java b/src/stubs/com/sun/tools/javac/file/PathFileObject.java new file mode 100644 index 00000000..c1ee6074 --- /dev/null +++ b/src/stubs/com/sun/tools/javac/file/PathFileObject.java @@ -0,0 +1,12 @@ +/* + * These are stub versions of various bits of javac-internal API (for various different versions of javac). Lombok is compiled against these. + */ +package com.sun.tools.javac.file; + +import java.nio.file.Path; + +import javax.tools.JavaFileObject; + +public abstract class PathFileObject implements JavaFileObject { + protected PathFileObject(BaseFileManager fileManager, Path path) {} +} -- cgit From e3a86782e590e11291e1f208417d5ca61aac4fac Mon Sep 17 00:00:00 2001 From: Roel Spilker Date: Tue, 14 Feb 2017 01:21:27 +0100 Subject: [jdk9] Fix members_field error --- .../lombok/javac/handlers/JavacHandlerUtil.java | 23 +++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/core/lombok/javac/handlers/JavacHandlerUtil.java b/src/core/lombok/javac/handlers/JavacHandlerUtil.java index af8289a3..918d23f1 100644 --- a/src/core/lombok/javac/handlers/JavacHandlerUtil.java +++ b/src/core/lombok/javac/handlers/JavacHandlerUtil.java @@ -894,16 +894,20 @@ public class JavacHandlerUtil { static class ClassSymbolMembersField { private static final Field membersField;