Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

prettier-plugin-java

Package Overview
Dependencies
Maintainers
6
Versions
48
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

prettier-plugin-java - npm Package Compare versions

Comparing version 0.8.3 to 1.0.0

8

package.json
{
"name": "prettier-plugin-java",
"version": "0.8.3",
"version": "1.0.0",
"description": "Prettier Java Plugin",

@@ -9,5 +9,5 @@ "main": "src/index.js",

"dependencies": {
"java-parser": "0.8.2",
"java-parser": "1.0.0",
"lodash": "4.17.20",
"prettier": "2.1.1"
"prettier": "2.2.0"
},

@@ -24,3 +24,3 @@ "scripts": {

},
"gitHead": "c1f867092f74ebfdf68ccb843f8186c943bfdeca"
"gitHead": "0980a79ea2f0efbd41f435f6911191ed5860c867"
}

@@ -124,3 +124,3 @@ [![npm](https://img.shields.io/npm/v/prettier-plugin-java.svg)](https://www.npmjs.com/package/prettier-plugin-java)

```prettier --write MyJava.java --entrypoint compilationUnit``` \
[Here](https://github.com/jhipster/prettier-java/blob/master/packages/prettier-plugin-java/src/options.js) is the exhaustive list of all entrypoints.
[Here](https://github.com/jhipster/prettier-java/blob/main/packages/prettier-plugin-java/src/options.js) is the exhaustive list of all entrypoints.

@@ -127,0 +127,0 @@ ### Example

@@ -28,5 +28,7 @@ "use strict";

{ value: "switchBlock" },
{ value: "switchCase" },
{ value: "switchBlockStatementGroup" },
{ value: "switchLabel" },
{ value: "enumConstantName" },
{ value: "switchRule" },
{ value: "switchRuleLabel" },
{ value: "caseConstant" },
{ value: "whileStatement" },

@@ -56,5 +58,7 @@ { value: "doStatement" },

{ value: "resourceInit" },
{ value: "yieldStatement" },
{ value: "variableAccess" },
{ value: "isBasicForStatement" },
{ value: "isLocalVariableDeclaration" },
{ value: "isClassicSwitchLabel" },
{ value: "classDeclaration" },

@@ -79,2 +83,3 @@ { value: "normalClassDeclaration" },

{ value: "unannPrimitiveType" },
{ value: "unannPrimitiveTypeWithOptionalDimsSuffix" },
{ value: "unannReferenceType" },

@@ -119,3 +124,2 @@ { value: "unannClassOrInterfaceType" },

{ value: "isDims" },
{ value: "constantExpression" },
{ value: "expression" },

@@ -122,0 +126,0 @@ { value: "lambdaExpression" },

"use strict";
const { line, softline, hardline } = require("prettier").doc.builders;
const { group, indent, concat, join } = require("./prettier-builder");
const { group, indent, dedent, concat, join } = require("./prettier-builder");
const { printTokenWithComments } = require("./comments/format-comments");

@@ -198,3 +198,6 @@ const {

switchBlock(ctx) {
const switchCases = this.mapVisit(ctx.switchCase);
const switchCases =
ctx.switchBlockStatementGroup !== undefined
? this.mapVisit(ctx.switchBlockStatementGroup)
: this.mapVisit(ctx.switchRule);

@@ -209,7 +212,18 @@ return putIntoBraces(

switchCase(ctx) {
const switchLabel = this.visit(ctx.switchLabel);
switchBlockStatementGroup(ctx) {
const switchLabels = this.mapVisit(ctx.switchLabel);
const labels = [];
for (let i = 0; i < switchLabels.length; i++) {
labels.push(concat([switchLabels[i], ctx.Colon[i]]));
}
const blockStatements = this.visit(ctx.blockStatements);
return indent(rejectAndJoin(hardline, [switchLabel, blockStatements]));
return indent(
rejectAndJoin(hardline, [
dedent(rejectAndJoin(hardline, labels)),
blockStatements
])
);
}

@@ -219,14 +233,28 @@

if (ctx.Case) {
const constantExpression = this.visit(ctx.constantExpression);
const caseConstants = this.mapVisit(ctx.caseConstant);
return rejectAndConcat([
concat([ctx.Case[0], " "]),
constantExpression,
ctx.Colon[0]
rejectAndJoin(" ,", caseConstants)
]);
}
return concat([ctx.Default[0], ctx.Colon[0]]);
return concat([ctx.Default[0]]);
}
enumConstantName(ctx) {
switchRule(ctx) {
const switchLabel = this.visit(ctx.switchLabel);
let caseInstruction;
if (ctx.throwStatement !== undefined) {
caseInstruction = this.visit(ctx.throwStatement);
} else if (ctx.block !== undefined) {
caseInstruction = this.visit(ctx.block);
} else {
caseInstruction = concat([this.visit(ctx.expression), ctx.Semicolon[0]]);
}
return join(" ", [switchLabel, ctx.Arrow[0], caseInstruction]);
}
caseConstant(ctx) {
return this.visitSingle(ctx);

@@ -528,2 +556,7 @@ }

yieldStatement(ctx) {
const expression = this.visit(ctx.expression);
return join(" ", [ctx.Yield[0], concat([expression, ctx.Semicolon[0]])]);
}
variableAccess(ctx) {

@@ -540,2 +573,6 @@ return this.visitSingle(ctx);

}
isClassicSwitchLabel() {
return "isClassicSwitchLabel";
}
}

@@ -542,0 +579,0 @@

@@ -312,6 +312,6 @@ "use strict";

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

@@ -415,7 +415,2 @@ const dims = this.visit(ctx.dims);

let throwsPart = "";
if (throws) {
throwsPart = indent(rejectAndConcat([softline, throws]));
}
return group(

@@ -428,3 +423,3 @@ concat([

declarator,
throwsPart
throws
])

@@ -529,3 +524,4 @@ ])

const exceptionTypeList = this.visit(ctx.exceptionTypeList);
return join(" ", [ctx.Throws[0], exceptionTypeList]);
const throwsDeclaration = join(" ", [ctx.Throws[0], exceptionTypeList]);
return group(indent(rejectAndConcat([softline, throwsDeclaration])));
}

@@ -570,7 +566,2 @@

let throwsPart = "";
if (throws) {
throwsPart = indent(rejectAndConcat([softline, throws]));
}
return rejectAndJoin(" ", [

@@ -583,3 +574,3 @@ group(

constructorDeclarator,
throwsPart
throws
])

@@ -586,0 +577,0 @@ ])

@@ -25,6 +25,2 @@ "use strict";

class ExpressionsPrettierVisitor {
constantExpression(ctx) {
return this.visitSingle(ctx);
}
expression(ctx, params) {

@@ -366,3 +362,3 @@ return this.visitSingle(ctx, params);

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

@@ -369,0 +365,0 @@ }

@@ -6,3 +6,3 @@ "use strict";

literal(ctx) {
if (ctx.CharLiteral || ctx.StringLiteral || ctx.Null) {
if (ctx.CharLiteral || ctx.TextBlock || ctx.StringLiteral || ctx.Null) {
return printTokenWithComments(this.getSingle(ctx));

@@ -9,0 +9,0 @@ }

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc