Skip to content

Commit 021657d

Browse files
committed
Add updated patch
1 parent 4248c68 commit 021657d

File tree

4 files changed

+74
-10
lines changed

4 files changed

+74
-10
lines changed

prettier-maven-plugin-integration-tests/src/test/resources/pom-template.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
<prettierJavaVersion>${prettierJavaVersion}</prettierJavaVersion>
1818
<ignoreConfigFile>true</ignoreConfigFile>
1919
<ignoreEditorConfig>true</ignoreEditorConfig>
20+
<disableGenericsLinebreaks>true</disableGenericsLinebreaks>
2021
<inputGlobs>
2122
${inputGlobs}
2223
</inputGlobs>
Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,6 @@
1-
public class Test {}
1+
import java.util.Map;
2+
3+
public class Test {
4+
5+
private static final Map<VeryLongTypeNameAsTheMapKeyType, AnotherVeryLongTypeNameAsTheyMapValueType> map;
6+
}

prettier-maven-plugin/src/main/java/com/hubspot/maven/plugins/prettier/PrettierArgs.java

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,15 @@
55
import com.hubspot.maven.plugins.prettier.internal.OperatingSystemFamily;
66
import com.hubspot.maven.plugins.prettier.internal.PrettierDownloader;
77
import com.hubspot.maven.plugins.prettier.internal.PrettierPatcher;
8+
import org.apache.maven.plugin.AbstractMojo;
9+
import org.apache.maven.plugin.MojoExecutionException;
10+
import org.apache.maven.plugin.MojoFailureException;
11+
import org.apache.maven.plugin.descriptor.PluginDescriptor;
12+
import org.apache.maven.plugins.annotations.Component;
13+
import org.apache.maven.plugins.annotations.Parameter;
14+
import org.apache.maven.project.MavenProject;
15+
16+
import javax.annotation.Nullable;
817
import java.io.File;
918
import java.io.IOException;
1019
import java.net.URL;
@@ -15,14 +24,6 @@
1524
import java.util.Arrays;
1625
import java.util.List;
1726
import java.util.Optional;
18-
import javax.annotation.Nullable;
19-
import org.apache.maven.plugin.AbstractMojo;
20-
import org.apache.maven.plugin.MojoExecutionException;
21-
import org.apache.maven.plugin.MojoFailureException;
22-
import org.apache.maven.plugin.descriptor.PluginDescriptor;
23-
import org.apache.maven.plugins.annotations.Component;
24-
import org.apache.maven.plugins.annotations.Parameter;
25-
import org.apache.maven.project.MavenProject;
2627

2728
public abstract class PrettierArgs extends AbstractMojo {
2829
/**
@@ -134,7 +135,9 @@ protected Path downloadPrettierJava(NodeInstall nodeInstall) throws MojoExecutio
134135

135136
if (disableGenericsLinebreaks) {
136137
if (prettierJavaVersion.startsWith("2")) {
137-
URL patch = getClass().getResource("/no-linebreak-generics.patch");
138+
URL patch = "2.5".compareTo(prettierJavaVersion) < 0
139+
? getClass().getResource("/no-linebreak-generics-2.5.patch")
140+
: getClass().getResource("/no-linebreak-generics.patch") ;
138141
return new PrettierPatcher(prettierJava, getLog()).patch(patch, prettierJavaVersion);
139142
} else if ("1.5.0".compareTo(prettierJavaVersion) > 0) {
140143
// versions before 1.5.0 don't linebreak generics
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
diff --git a/node_modules/prettier-plugin-java/dist/printers/classes.js b/node_modules/prettier-plugin-java/dist/printers/classes.js
2+
index c5197bc..b28507a 100644
3+
--- a/node_modules/prettier-plugin-java/dist/printers/classes.js
4+
+++ b/node_modules/prettier-plugin-java/dist/printers/classes.js
5+
@@ -104,12 +104,12 @@ var ClassesPrettierVisitor = /** @class */ (function (_super) {
6+
};
7+
ClassesPrettierVisitor.prototype.typeParameters = function (ctx) {
8+
var typeParameterList = this.visit(ctx.typeParameterList);
9+
- return (0, printer_utils_1.putIntoBraces)(typeParameterList, softline, ctx.Less[0], ctx.Greater[0]);
10+
+ return (0, printer_utils_1.rejectAndConcat)([ctx.Less[0], typeParameterList, ctx.Greater[0]]);
11+
};
12+
ClassesPrettierVisitor.prototype.typeParameterList = function (ctx) {
13+
var typeParameter = this.mapVisit(ctx.typeParameter);
14+
- var commas = ctx.Comma ? ctx.Comma.map(function (elt) { return (0, prettier_builder_1.concat)([elt, line]); }) : [];
15+
- return (0, prettier_builder_1.group)((0, printer_utils_1.rejectAndJoinSeps)(commas, typeParameter));
16+
+ var commas = ctx.Comma ? ctx.Comma.map(function (elt) { return (0, prettier_builder_1.concat)([elt, " "]); }) : [];
17+
+ return (0, printer_utils_1.rejectAndJoinSeps)(commas, typeParameter);
18+
};
19+
ClassesPrettierVisitor.prototype.superclass = function (ctx) {
20+
return (0, prettier_builder_1.join)(" ", [ctx.Extends[0], this.visit(ctx.classType)]);
21+
diff --git a/node_modules/prettier-plugin-java/dist/printers/types-values-and-variables.js b/node_modules/prettier-plugin-java/dist/printers/types-values-and-variables.js
22+
index 6505bbb..ea6fd01 100644
23+
--- a/node_modules/prettier-plugin-java/dist/printers/types-values-and-variables.js
24+
+++ b/node_modules/prettier-plugin-java/dist/printers/types-values-and-variables.js
25+
@@ -148,12 +148,10 @@ var TypesValuesAndVariablesPrettierVisitor = /** @class */ (function (_super) {
26+
TypesValuesAndVariablesPrettierVisitor.prototype.typeBound = function (ctx) {
27+
var classOrInterfaceType = this.visit(ctx.classOrInterfaceType);
28+
var additionalBound = this.mapVisit(ctx.additionalBound);
29+
- return (0, prettier_builder_1.concat)([
30+
- (0, printer_utils_1.rejectAndJoin)(" ", [ctx.Extends[0], classOrInterfaceType]),
31+
- (0, prettier_builder_1.indent)((0, prettier_builder_1.group)((0, prettier_builder_1.concat)([
32+
- additionalBound.length ? line : "",
33+
- (0, printer_utils_1.rejectAndJoin)(line, additionalBound)
34+
- ])))
35+
+ return (0, printer_utils_1.rejectAndJoin)(" ", [
36+
+ ctx.Extends[0],
37+
+ classOrInterfaceType,
38+
+ (0, prettier_builder_1.join)(" ", additionalBound)
39+
]);
40+
};
41+
TypesValuesAndVariablesPrettierVisitor.prototype.additionalBound = function (ctx) {
42+
@@ -162,11 +160,11 @@ var TypesValuesAndVariablesPrettierVisitor = /** @class */ (function (_super) {
43+
};
44+
TypesValuesAndVariablesPrettierVisitor.prototype.typeArguments = function (ctx) {
45+
var typeArgumentList = this.visit(ctx.typeArgumentList);
46+
- return (0, printer_utils_1.putIntoBraces)(typeArgumentList, softline, ctx.Less[0], ctx.Greater[0]);
47+
+ return (0, printer_utils_1.rejectAndConcat)([ctx.Less[0], typeArgumentList, ctx.Greater[0]]);
48+
};
49+
TypesValuesAndVariablesPrettierVisitor.prototype.typeArgumentList = function (ctx) {
50+
var typeArguments = this.mapVisit(ctx.typeArgument);
51+
- var commas = ctx.Comma ? ctx.Comma.map(function (elt) { return (0, prettier_builder_1.concat)([elt, line]); }) : [];
52+
+ var commas = ctx.Comma ? ctx.Comma.map(function (elt) { return (0, prettier_builder_1.concat)([elt, " "]); }) : [];
53+
return (0, printer_utils_1.rejectAndJoinSeps)(commas, typeArguments);
54+
};
55+
TypesValuesAndVariablesPrettierVisitor.prototype.typeArgument = function (ctx) {

0 commit comments

Comments
 (0)