Skip to content

Commit

Permalink
chore: upgrade chevrotain to v9.0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
clementdessoude committed Jun 19, 2021
1 parent d35e8bb commit d0adffb
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 51 deletions.
2 changes: 1 addition & 1 deletion packages/java-parser/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"license": "Apache-2.0",
"types": "./api.d.ts",
"dependencies": {
"chevrotain": "6.5.0",
"chevrotain": "9.0.2",
"lodash": "4.17.21"
},
"scripts": {
Expand Down
6 changes: 3 additions & 3 deletions packages/java-parser/src/parser.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"use strict";
const { Parser, isRecognitionException } = require("chevrotain");
const { CstParser, isRecognitionException } = require("chevrotain");
const { allTokens, tokens: t } = require("./tokens");
const lexicalStructure = require("./productions/lexical-structure");
const typesValuesVariables = require("./productions/types-values-and-variables");
Expand Down Expand Up @@ -36,7 +36,7 @@ const { shouldNotFormat } = require("./comments");
* TODO: document guide lines for using back tracking
*
*/
class JavaParser extends Parser {
class JavaParser extends CstParser {
constructor() {
super(allTokens, {
maxLookahead: 1,
Expand Down Expand Up @@ -77,8 +77,8 @@ class JavaParser extends Parser {
}

cstPostNonTerminal(ruleCstResult, ruleName) {
super.cstPostNonTerminal(ruleCstResult, ruleName);
if (this.isBackTracking() === false) {
super.cstPostNonTerminal(ruleCstResult, ruleName);
this.mostEnclosiveCstNodeByStartOffset[
ruleCstResult.location.startOffset
] = ruleCstResult;
Expand Down
8 changes: 1 addition & 7 deletions packages/java-parser/src/productions/expressions.js
Original file line number Diff line number Diff line change
Expand Up @@ -309,12 +309,7 @@ function defineRules($, t) {
$.SUBRULE($.annotation);
});

$.OPTION({
NAME: "$methodTypeArguments",
DEF: () => {
$.SUBRULE2($.typeArguments);
}
});
$.OPTION(() => $.SUBRULE2($.typeArguments));

$.SUBRULE($.fqnOrRefTypePartCommon);
});
Expand All @@ -335,7 +330,6 @@ function defineRules($, t) {
}

$.OPTION2({
NAME: "$classTypeArguments",
// unrestricted typeArguments here would create an ambiguity with "LessThan" operator
// e.g: "var x = a < b;"
// The "<" would be parsed as the beginning of a "typeArguments"
Expand Down
35 changes: 4 additions & 31 deletions packages/prettier-plugin-java/src/printers/expressions.js
Original file line number Diff line number Diff line change
Expand Up @@ -453,23 +453,11 @@ class ExpressionsPrettierVisitor {
const annotation = this.mapVisit(ctx.annotation);
const fqnOrRefTypeCommon = this.visit(ctx.fqnOrRefTypePartCommon);

let fqnOrRefTypePart$methodTypeArguments = "";
if (
ctx.$methodTypeArguments &&
ctx.$methodTypeArguments[0].children &&
ctx.$methodTypeArguments[0].children.typeArguments
) {
fqnOrRefTypePart$methodTypeArguments = this.visit(
ctx.$methodTypeArguments
);
}
const typeArguments = this.visit(ctx.typeArguments);

return rejectAndJoin(" ", [
rejectAndJoin(" ", annotation),
rejectAndConcat([
fqnOrRefTypePart$methodTypeArguments,
fqnOrRefTypeCommon
])
rejectAndConcat([typeArguments, fqnOrRefTypeCommon])
]);
}

Expand All @@ -481,24 +469,9 @@ class ExpressionsPrettierVisitor {
keyWord = ctx.Super[0];
}

let fqnOrRefTypePart$classTypeArguments = "";
if (
ctx.$classTypeArguments &&
ctx.$classTypeArguments[0].children &&
ctx.$classTypeArguments[0].children.typeArguments
) {
fqnOrRefTypePart$classTypeArguments = this.visit(ctx.$classTypeArguments);
}

return rejectAndConcat([keyWord, fqnOrRefTypePart$classTypeArguments]);
}

fqnOrRefTypePartRest$methodTypeArguments(ctx) {
return this.visitSingle(ctx);
}
const typeArguments = this.visit(ctx.typeArguments);

fqnOrRefTypePartCommon$classTypeArguments(ctx) {
return this.visitSingle(ctx);
return rejectAndConcat([keyWord, typeArguments]);
}

parenthesisExpression(ctx) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,5 +185,9 @@ public void longFullyQualifiedName() {
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);
}

public void t() {
var t = ImmutableMap.<R, V>of<T>::a();
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -245,4 +245,8 @@ public void unannTypePrimitiveWithMethodReferenceSuffix(String[] args) {
)
.toArray(double[][]::new);
}

public void t() {
var t = ImmutableMap.<R, V>of<T>::a();
}
}
30 changes: 21 additions & 9 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,16 @@
lodash "^4.17.13"
to-fast-properties "^2.0.0"

"@chevrotain/types@^9.0.2":
version "9.0.2"
resolved "https://registry.yarnpkg.com/@chevrotain/types/-/types-9.0.2.tgz#477bb3b973b91ff47377399d1e9f4410be6c0141"
integrity sha512-lo1dQPX7DQffJb26eaYLEy4/jUTFmsGKa43mDvMNAHwItEgUQHUkTZR0iAkHG0aJv8ejM/KqYpRVSNetrOK8qw==

"@chevrotain/utils@^9.0.2":
version "9.0.2"
resolved "https://registry.yarnpkg.com/@chevrotain/utils/-/utils-9.0.2.tgz#6f28fd41d2168c21e441e1a4ad6a0097e4d351f5"
integrity sha512-iTju1VpbGruWagXS/XswuqeimOCRNeDvrXLlWHYsHp1qTU8sJfAfLiX5vs7DNxB1px6N8VWVI0SD8vMUksNBYw==

"@eslint/eslintrc@^0.4.2":
version "0.4.2"
resolved "https://registry.yarnpkg.com/@eslint/eslintrc/-/eslintrc-0.4.2.tgz#f63d0ef06f5c0c57d76c4ab5f63d3835c51b0179"
Expand Down Expand Up @@ -1826,12 +1836,14 @@ check-error@^1.0.2:
resolved "https://registry.yarnpkg.com/check-error/-/check-error-1.0.2.tgz#574d312edd88bb5dd8912e9286dd6c0aed4aac82"
integrity sha1-V00xLt2Iu13YkS6Sht1sCu1KrII=

chevrotain@6.5.0:
version "6.5.0"
resolved "https://registry.yarnpkg.com/chevrotain/-/chevrotain-6.5.0.tgz#dcbef415516b0af80fd423cc0d96b28d3f11374e"
integrity sha512-BwqQ/AgmKJ8jcMEjaSnfMybnKMgGTrtDKowfTP3pX4jwVy0kNjRsT/AP6h+wC3+3NC+X8X15VWBnTCQlX+wQFg==
chevrotain@9.0.2:
version "9.0.2"
resolved "https://registry.yarnpkg.com/chevrotain/-/chevrotain-9.0.2.tgz#7cc462262fec8ee293d96b756085ac71b8804bf1"
integrity sha512-6ZjgUdGvU4j1n1b2hTjb79Vr2V+qNtmP7f8FVt79+kdAYcUj2QfYNwI8ycCVsgHD/dIeO5Vr1hckkkfliVQTfg==
dependencies:
regexp-to-ast "0.4.0"
"@chevrotain/types" "^9.0.2"
"@chevrotain/utils" "^9.0.2"
regexp-to-ast "0.5.0"

chokidar@3.5.1:
version "3.5.1"
Expand Down Expand Up @@ -6250,10 +6262,10 @@ redent@^3.0.0:
indent-string "^4.0.0"
strip-indent "^3.0.0"

regexp-to-ast@0.4.0:
version "0.4.0"
resolved "https://registry.yarnpkg.com/regexp-to-ast/-/regexp-to-ast-0.4.0.tgz#f3dbcb42726cd71902ba50193f63eab5325cd7cb"
integrity sha512-4qf/7IsIKfSNHQXSwial1IFmfM1Cc/whNBQqRwe0V2stPe7KmN1U0tWQiIx6JiirgSrisjE0eECdNf7Tav1Ntw==
regexp-to-ast@0.5.0:
version "0.5.0"
resolved "https://registry.yarnpkg.com/regexp-to-ast/-/regexp-to-ast-0.5.0.tgz#56c73856bee5e1fef7f73a00f1473452ab712a24"
integrity sha512-tlbJqcMHnPKI9zSrystikWKwHkBqu2a/Sgw01h3zFjvYrMxEDYHzzoMZnUrbIfpTFEsoRnnviOXNCzFiSc54Qw==

regexpp@^3.1.0:
version "3.1.0"
Expand Down

0 comments on commit d0adffb

Please sign in to comment.