Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix transitive dependencies #425

Merged
merged 2 commits into from
Aug 31, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
# Latest v0.8.1
# Latest v0.8.2

## Fixes

- Revert: Parsing of unannPrimitiveType in primary ([#421](https://github.com/jhipster/prettier-java/pull/421)).
It was causing a breaking change in the java-parser

- uses exact dependencies when releasing a new version of java-parser and prettier-plugin-java


# v0.8.1

## Enhancements

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"benchmark/*"
],
"scripts": {
"lerna:version": "lerna version --git-remote upstream",
"lerna:version": "lerna version --exact --git-remote upstream",
"lerna:publish": "lerna publish from-git --yes",
"ci": "npm-run-all build lint format:validate test",
"ci:all": "yarn run ci && yarn run test:prettier-plugin-java test:e2e-jhipster1 && yarn run test:prettier-plugin-java test:e2e-jhipster2",
Expand Down
295 changes: 65 additions & 230 deletions packages/java-parser/api.d.ts

Large diffs are not rendered by default.

18 changes: 9 additions & 9 deletions packages/java-parser/src/productions/classes.js
Original file line number Diff line number Diff line change
Expand Up @@ -222,19 +222,19 @@ function defineRules($, t) {
$.OR([
// Spec Deviation: The array type "dims" suffix was extracted to this rule
// to avoid backtracking for performance reasons.
{ ALT: () => $.SUBRULE($.unannPrimitiveTypeWithOptionalDimsSuffix) },
{
ALT: () => {
$.SUBRULE($.unannPrimitiveType);
$.OPTION({
GATE: () => this.BACKTRACK_LOOKAHEAD($.isDims),
DEF: () => $.SUBRULE2($.dims)
});
}
},
{ ALT: () => $.SUBRULE($.unannReferenceType) }
]);
});

$.RULE("unannPrimitiveTypeWithOptionalDimsSuffix", () => {
$.SUBRULE($.unannPrimitiveType);
$.OPTION({
GATE: () => this.BACKTRACK_LOOKAHEAD($.isDims),
DEF: () => $.SUBRULE2($.dims)
});
});

// https://docs.oracle.com/javase/specs/jls/se11/html/jls-8.html#jls-UnannPrimitiveType
$.RULE("unannPrimitiveType", () => {
$.OR([
Expand Down
4 changes: 3 additions & 1 deletion packages/java-parser/src/productions/expressions.js
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,9 @@ function defineRules($, t) {
{ ALT: () => $.SUBRULE($.literal) },
{ ALT: () => $.CONSUME(t.This) },
{ ALT: () => $.CONSUME(t.Void) },
{ ALT: () => $.SUBRULE($.unannPrimitiveTypeWithOptionalDimsSuffix) },
// should be extracted to primitive type with optional dims suffix?
{ ALT: () => $.SUBRULE($.numericType) },
{ ALT: () => $.CONSUME(t.Boolean) },
{ ALT: () => $.SUBRULE($.fqnOrRefType) },
{
GATE: () => isCastExpression,
Expand Down
5 changes: 0 additions & 5 deletions packages/java-parser/test/bugs-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,4 @@ describe("The Java Parser fixed bugs", () => {
const input = "(left) < right";
expect(() => javaParser.parse(input, "expression")).to.not.throw();
});

it("issue #412 - should parse a double[][] as primaryPrefix", () => {
const input = "double[][]";
expect(() => javaParser.parse(input, "primaryPrefix")).to.not.throw();
});
});
2 changes: 1 addition & 1 deletion packages/prettier-plugin-java/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"repository": "https://github.com/jhipster/prettier-java",
"license": "Apache-2.0",
"dependencies": {
"java-parser": "^0.8.1",
"java-parser": "0.8.1",
"lodash": "4.17.20",
"prettier": "2.1.1"
},
Expand Down
1 change: 0 additions & 1 deletion packages/prettier-plugin-java/src/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ module.exports = {
{ value: "variableInitializer" },
{ value: "unannType" },
{ value: "unannPrimitiveType" },
{ value: "unannPrimitiveTypeWithOptionalDimsSuffix" },
{ value: "unannReferenceType" },
{ value: "unannClassOrInterfaceType" },
{ value: "unannClassType" },
Expand Down
6 changes: 3 additions & 3 deletions packages/prettier-plugin-java/src/printers/classes.js
Original file line number Diff line number Diff line change
Expand Up @@ -300,10 +300,10 @@ class ClassesPrettierVisitor {
}

unannType(ctx) {
return this.visitSingle(ctx);
}
if (ctx.unannReferenceType !== undefined) {
return this.visit(ctx.unannReferenceType);
}

unannPrimitiveTypeWithOptionalDimsSuffix(ctx) {
const unannPrimitiveType = this.visit(ctx.unannPrimitiveType);
const dims = this.visit(ctx.dims);

Expand Down
2 changes: 1 addition & 1 deletion packages/prettier-plugin-java/src/printers/expressions.js
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ class ExpressionsPrettierVisitor {
}

primaryPrefix(ctx, params) {
if (ctx.This || ctx.Void) {
if (ctx.This || ctx.Void || ctx.Boolean) {
return printTokenWithComments(this.getSingle(ctx));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public void printIf() {
}

if(myValue != 42 && 42/42 || myValue & 42 && myValue > 42 || myValue < 42 && myValue == 42) {

}

if(myValue != 42 && myValue == 42) {
Expand All @@ -103,11 +103,11 @@ public void printSwitch() {
}

switch(myValue != 42 && 42/42 || myValue & 42 && myValue > 42 || myValue < 42 && myValue == 42) {

}

switch(myValue != 42) {

}

switch(myValue != 42 && myValue == 42) {
Expand All @@ -117,17 +117,17 @@ public void printSwitch() {

public void printWhile() {
while/*infinite*/ (true) /*stop the program*/throw new RuntimeException();

while(myValue == 42 || myValue == 42 && myValue == 42 && myValue == 42 || myValue == 42 && myValue == 42) {

}

while(myValue != 42 && 42/42 || myValue & 42 && myValue > 42 || myValue < 42 && myValue == 42) {

}

while(myValue != 42) {

}

while(myValue != 42 && myValue == 42) {
Expand Down Expand Up @@ -178,12 +178,9 @@ public void longFullyQualifiedName() {
com
.me.very.very.very.very.very.very.very.very.very.very.very.very.very.longg.fully.qualified.name.FullyQualifiedName.builder()
.build();

com.FullyQualifiedName.builder();
}

public void unannTypePrimitiveWithMethodReferenceSuffix(String[] args) {
List.of(new double[][] { 1,2,3,4.1,5.6846465}, new double[][] { 1,2,3,4.1,5.6846465}, new double[][] { 1,2,3,4.1,5.6846465}).toArray(double[][]::new);
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -235,14 +235,4 @@ public void longFullyQualifiedName() {

com.FullyQualifiedName.builder();
}

public void unannTypePrimitiveWithMethodReferenceSuffix(String[] args) {
List
.of(
new double[][] { 1, 2, 3, 4.1, 5.6846465 },
new double[][] { 1, 2, 3, 4.1, 5.6846465 },
new double[][] { 1, 2, 3, 4.1, 5.6846465 }
)
.toArray(double[][]::new);
}
}