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.5.1 to 0.6.0

10

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

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

"dependencies": {
"java-parser": "^0.5.1",
"java-parser": "^0.6.0",
"lodash": "4.17.15",

@@ -16,3 +16,4 @@ "prettier": "1.18.2"

"test": "npm-run-all test:unit test:e2e-core",
"test:unit": "mocha \"test/unit-test/**/*-spec.js\"",
"test:unit": "mocha \"test/unit-test/**/*.spec.js\" \"test/unit-test/**/*-spec.js\"",
"test:unit:coverage": "nyc mocha \"test/unit-test/**/*.spec.js\" \"test/unit-test/**/*-spec.js\"",
"test:e2e-core": "node scripts/clone-samples e2e-core && mocha \"test/repository-test/core-test.js\"",

@@ -23,4 +24,3 @@ "test:e2e-jhipster1": "node scripts/clone-samples e2e-jhipster1 && mocha \"test/repository-test/jhipster-1-test.js\"",

"clone-samples": "node scripts/clone-samples.js"
},
"gitHead": "addd92b0bbc1260c5f76de7758d2cc1199db4776"
}
}

@@ -138,3 +138,4 @@ "use strict";

module.exports = {
CstPrettierPrinter,
createPrettierDoc
};
"use strict";
/* eslint-disable no-unused-vars */
const { line, softline } = require("prettier").doc.builders;
const { line } = require("prettier").doc.builders;
const {

@@ -6,0 +4,0 @@ rejectAndConcat,

"use strict";
/* eslint-disable no-unused-vars */

@@ -366,4 +365,3 @@ const { line, softline, hardline } = require("prettier").doc.builders;

const expression = this.visit(ctx.expression, {
addParenthesisToWrapStatement: true,
shouldIndentBinaryOperationInExpression: false
addParenthesisToWrapStatement: true
});

@@ -527,7 +525,7 @@

isBasicForStatement(ctx) {
isBasicForStatement() {
return "isBasicForStatement";
}
isLocalVariableDeclaration(ctx) {
isLocalVariableDeclaration() {
return "isLocalVariableDeclaration";

@@ -534,0 +532,0 @@ }

"use strict";
/* eslint-disable no-unused-vars */
const _ = require("lodash");
const { line, softline, hardline } = require("prettier").doc.builders;
const {
hasLeadingLineComments,
reject,

@@ -19,7 +19,3 @@ rejectAndConcat,

const { concat, join, group, indent } = require("./prettier-builder");
const {
printTokenWithComments,
getTokenLeadingComments,
getTokenTrailingComments
} = require("./comments");
const { printTokenWithComments } = require("./comments");

@@ -197,5 +193,19 @@ class ClassesPrettierVisitor {

if (hasLeadingLineComments(ctx.variableInitializer[0])) {
return group(
indent(
rejectAndJoin(hardline, [
rejectAndJoin(" ", [variableDeclaratorId, ctx.Equals[0]]),
variableInitializer
])
)
);
}
if (
// Array Initialisation
ctx.variableInitializer[0].children.arrayInitializer !== undefined ||
// Lambda expression
ctx.variableInitializer[0].children.expression[0].children
.lambdaExpression !== undefined ||
// Ternary Expression

@@ -248,7 +258,14 @@ (ctx.variableInitializer[0].children.expression[0].children

// Method Invocation
if (
const isMethodInvocation =
firstPrimary.children.primarySuffix !== undefined &&
firstPrimary.children.primarySuffix[0].children
.methodInvocationSuffix !== undefined
) {
.methodInvocationSuffix !== undefined;
const isUniqueUnaryExpression =
ctx.variableInitializer[0].children.expression[0].children
.ternaryExpression[0].children.binaryExpression[0].children
.unaryExpression.length === 1;
const isUniqueMethodInvocation =
isMethodInvocation && isUniqueUnaryExpression;
if (isUniqueMethodInvocation) {
return rejectAndJoin(" ", [

@@ -663,11 +680,6 @@ variableDeclaratorId,

const optionnalComma = ctx.Comma
? ctx.Comma.map(elt => concat([elt, " "]))
: [];
const optionalComma = ctx.Comma ? { ...ctx.Comma[0], image: "" } : "";
return putIntoCurlyBraces(
rejectAndJoinSeps(optionnalComma, [
enumConstantList,
enumBodyDeclarations
]),
rejectAndConcat([enumConstantList, optionalComma, enumBodyDeclarations]),
hardline,

@@ -681,3 +693,5 @@ ctx.LCurly[0],

const enumConstants = this.mapVisit(ctx.enumConstant);
const commas = ctx.Comma ? ctx.Comma.map(elt => concat([elt, line])) : [];
const commas = ctx.Comma
? ctx.Comma.map(elt => concat([elt, hardline]))
: [];

@@ -728,18 +742,14 @@ return group(rejectAndJoinSeps(commas, enumConstants));

return concat([
...getTokenLeadingComments(ctx.Semicolon[0]),
"",
...getTokenTrailingComments(ctx.Semicolon[0])
]);
return { ...ctx.Semicolon[0], image: "" };
}
isClassDeclaration(ctx) {
isClassDeclaration() {
return "isClassDeclaration";
}
identifyClassBodyDeclarationType(ctx) {
identifyClassBodyDeclarationType() {
return "identifyClassBodyDeclarationType";
}
isDims(ctx) {
isDims() {
return "isDims";

@@ -746,0 +756,0 @@ }

@@ -210,5 +210,3 @@ "use strict";

printTokenWithComments,
getTokenLeadingComments,
getTokenTrailingComments,
printNodeWithComments
};
"use strict";
/* eslint-disable no-unused-vars */
const _ = require("lodash");
const { ifBreak, line, softline, hardline } = require("prettier").doc.builders;
const { ifBreak, line, softline } = require("prettier").doc.builders;
const { concat, group, indent } = require("./prettier-builder");

@@ -35,3 +34,15 @@ const { printTokenWithComments } = require("./comments");

return rejectAndJoin(" ", [lambdaParameters, ctx.Arrow[0], lambdaBody]);
const isLambdaBodyABlock = ctx.lambdaBody[0].children.block !== undefined;
if (isLambdaBodyABlock) {
return rejectAndJoin(" ", [lambdaParameters, ctx.Arrow[0], lambdaBody]);
}
return group(
indent(
rejectAndJoin(line, [
rejectAndJoin(" ", [lambdaParameters, ctx.Arrow[0]]),
lambdaBody
])
)
);
}

@@ -135,16 +146,12 @@

return group(
rejectAndConcat([
group(
rejectAndConcat([
return indent(
group(
rejectAndConcat([
rejectAndJoin(line, [
binaryExpression,
indent(line),
concat([ctx.QuestionMark[0], " "]),
expression1
rejectAndJoin(" ", [ctx.QuestionMark[0], expression1]),
rejectAndJoin(" ", [ctx.Colon[0], expression2])
])
),
indent(line),
concat([ctx.Colon[0], " "]),
expression2
])
])
)
);

@@ -204,14 +211,5 @@ }

} else if (matchCategory(token, "'BinaryOperator'")) {
const binaryOperation = rejectAndJoin(line, [
token,
unaryExpression.shift()
]);
if (
params !== undefined &&
!params.shouldIndentBinaryOperationInExpression
) {
currentSegment.push(binaryOperation);
} else {
currentSegment.push(indent(binaryOperation));
}
currentSegment.push(
rejectAndJoin(line, [token, unaryExpression.shift()])
);
}

@@ -359,3 +357,4 @@ }

fqnOrRefType(ctx, params) {
const fqnOrRefTypePart = this.mapVisit(ctx.fqnOrRefTypePart);
const fqnOrRefTypePartFirst = this.visit(ctx.fqnOrRefTypePartFirst);
const fqnOrRefTypePartRest = this.mapVisit(ctx.fqnOrRefTypePartRest);
const dims = this.visit(ctx.dims);

@@ -371,4 +370,4 @@ const dots = ctx.Dot ? ctx.Dot : [];

rejectAndJoin(concat([softline, dots[0]]), [
fqnOrRefTypePart[0],
rejectAndJoinSeps(dots.slice(1), fqnOrRefTypePart.slice(1)),
fqnOrRefTypePartFirst,
rejectAndJoinSeps(dots.slice(1), fqnOrRefTypePartRest),
dims

@@ -379,8 +378,23 @@ ])

}
return rejectAndConcat([rejectAndJoinSeps(dots, fqnOrRefTypePart), dims]);
return rejectAndConcat([
rejectAndJoinSeps(dots, [fqnOrRefTypePartFirst, ...fqnOrRefTypePartRest]),
dims
]);
}
fqnOrRefTypePart(ctx) {
fqnOrRefTypePartFirst(ctx) {
const annotation = this.mapVisit(ctx.annotation);
const fqnOrRefTypeCommon = this.visit(ctx.fqnOrRefTypePartCommon);
return rejectAndJoin(" ", [
rejectAndJoin(" ", annotation),
fqnOrRefTypeCommon
]);
}
fqnOrRefTypePartRest(ctx) {
const annotation = this.mapVisit(ctx.annotation);
const fqnOrRefTypeCommon = this.visit(ctx.fqnOrRefTypePartCommon);
let fqnOrRefTypePart$methodTypeArguments = "";

@@ -397,2 +411,12 @@ if (

return rejectAndJoin(" ", [
rejectAndJoin(" ", annotation),
rejectAndConcat([
fqnOrRefTypePart$methodTypeArguments,
fqnOrRefTypeCommon
])
]);
}
fqnOrRefTypePartCommon(ctx) {
let keyWord = null;

@@ -414,17 +438,10 @@ if (ctx.Identifier) {

return rejectAndJoin(" ", [
rejectAndJoin(" ", annotation),
rejectAndConcat([
fqnOrRefTypePart$methodTypeArguments,
keyWord,
fqnOrRefTypePart$classTypeArguments
])
]);
return rejectAndConcat([keyWord, fqnOrRefTypePart$classTypeArguments]);
}
fqnOrRefTypePart$methodTypeArguments(ctx) {
fqnOrRefTypePartRest$methodTypeArguments(ctx) {
return this.visitSingle(ctx);
}
fqnOrRefTypePart$classTypeArguments(ctx) {
fqnOrRefTypePartCommon$classTypeArguments(ctx) {
return this.visitSingle(ctx);

@@ -434,5 +451,3 @@ }

parenthesisExpression(ctx) {
const expression = this.visit(ctx.expression, {
shouldIndentBinaryOperationInExpression: false
});
const expression = this.visit(ctx.expression);
return putIntoBraces(expression, softline, ctx.LBrace[0], ctx.RBrace[0]);

@@ -599,23 +614,23 @@ }

identifyNewExpressionType(ctx) {
identifyNewExpressionType() {
return "identifyNewExpressionType";
}
isLambdaExpression(ctx) {
isLambdaExpression() {
return "isLambdaExpression";
}
isCastExpression(ctx) {
isCastExpression() {
return "isCastExpression";
}
isPrimitiveCastExpression(ctx) {
isPrimitiveCastExpression() {
return "isPrimitiveCastExpression";
}
isReferenceTypeCastExpression(ctx) {
isReferenceTypeCastExpression() {
return "isReferenceTypeCastExpression";
}
isRefTypeInMethodRef(ctx) {
isRefTypeInMethodRef() {
return "isRefTypeInMethodRef";

@@ -622,0 +637,0 @@ }

"use strict";
/* eslint-disable no-unused-vars */

@@ -299,11 +298,11 @@ const { line, softline, hardline } = require("prettier").doc.builders;

identifyInterfaceBodyDeclarationType(ctx) {
identifyInterfaceBodyDeclarationType() {
return "identifyInterfaceBodyDeclarationType";
}
identifyAnnotationBodyDeclarationType(ctx) {
identifyAnnotationBodyDeclarationType() {
return "identifyAnnotationBodyDeclarationType";
}
isSimpleElementValueAnnotation(ctx) {
isSimpleElementValueAnnotation() {
return "isSimpleElementValueAnnotation";

@@ -310,0 +309,0 @@ }

"use strict";
/* eslint-disable no-unused-vars */
const { printTokenWithComments } = require("./comments");
class LexicalStructurePrettierVisitor {

@@ -5,0 +5,0 @@ literal(ctx) {

"use strict";
/* eslint-disable no-unused-vars */

@@ -4,0 +3,0 @@ const { buildFqn } = require("./printer-utils");

"use strict";
/* eslint-disable no-unused-vars */

@@ -230,3 +229,3 @@ const { line, hardline, indent, group } = require("prettier").doc.builders;

isModuleCompilationUnit(ctx) {
isModuleCompilationUnit() {
return "isModuleCompilationUnit";

@@ -233,0 +232,0 @@ }

@@ -582,7 +582,6 @@ "use strict";

for (let i = 0; i < minParts; i++) {
const identifierComparison = identifiersFirst[i].image.localeCompare(
identifiersSecond[i].image
);
if (identifierComparison !== 0) {
return identifierComparison;
if (identifiersFirst[i].image < identifiersSecond[i].image) {
return -1;
} else if (identifiersFirst[i].image > identifiersSecond[i].image) {
return 1;
}

@@ -589,0 +588,0 @@ }

"use strict";
/* eslint-disable no-unused-vars */

@@ -4,0 +3,0 @@ const _ = require("lodash");

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