Skip to content

Commit

Permalink
Merge pull request #432 from clementdessoude/feat/support-new-switch-…
Browse files Browse the repository at this point in the history
…rules

Feat: support new switch rules
  • Loading branch information
clementdessoude authored Nov 14, 2020
2 parents bcfa69c + 51f6b96 commit 112ce75
Show file tree
Hide file tree
Showing 22 changed files with 462 additions and 120 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/binaries.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
- name: Checkout the repository
uses: actions/checkout@v2
with:
path: 'prettier-java'
path: "prettier-java"
- uses: actions/setup-node@v1
with:
node-version: 10.x
Expand Down Expand Up @@ -49,8 +49,8 @@ jobs:
cd $GITHUB_WORKSPACE/prettier
pkg package.json -o $GITHUB_WORKSPACE/prettier-java-${GITHUB_REF##*/} --targets node10-linux-x64,node10-macos-x64,node10-win-x64
- name: Upload the artifacts
uses: skx/github-action-publish-binaries@master
uses: skx/github-action-publish-binaries@main
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
args: 'prettier-java-*'
args: "prettier-java-*"
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ yarn run

## Linking the java-parser to the printer

If you want to use the master java-parser for the prettier-plugin-java (printer), you will need to link it by running these commands in the root folder:
If you want to use the main java-parser for the prettier-plugin-java (printer), you will need to link it by running these commands in the root folder:

```bash
cd packages/java-parser
Expand Down
14 changes: 7 additions & 7 deletions RELEASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ upstream git@github.com:jhipster/prettier-java (fetch)
upstream git@github.com:jhipster/prettier-java (push)
```

Update `master` branch and `release` branch in your fork.
Update `main` branch and `release` branch in your fork.

```
git checkout release
git fetch upstream
git rebase upstream/release
git checkout master
git rebase upstream/master
git checkout main
git rebase upstream/main
```

Be sure your dependencies is up-to-dated:
Expand All @@ -31,22 +31,22 @@ Be sure your dependencies is up-to-dated:
yarn
```

In `master` branch, launch the release, and answer the questions. It will:
In `main` branch, launch the release, and answer the questions. It will:

- change the version (patch, minor or major, accordingly to what you choose)
- tag the version
- push master branch to upstream
- push main branch to upstream
- push the tag to upstream

```
yarn run lerna:version
```

Then, if everything looks OK, merge the master branch to the release branch locally, then push the release branch:
Then, if everything looks OK, merge the main branch to the release branch locally, then push the release branch:

```
git checkout release
git merge master
git merge main
git push upstream/release
```

Expand Down
99 changes: 75 additions & 24 deletions packages/java-parser/api.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ export abstract class JavaCstVisitor<IN, OUT> implements ICstVisitor<IN, OUT> {
variableDeclaratorId(ctx: VariableDeclaratorIdCtx, param?: IN): OUT;
variableInitializer(ctx: VariableInitializerCtx, param?: IN): OUT;
unannType(ctx: UnannTypeCtx, param?: IN): OUT;
unannPrimitiveTypeWithOptionalDimsSuffix(
ctx: UnannPrimitiveTypeWithOptionalDimsSuffixCtx,
param?: IN
): OUT;
unannPrimitiveType(ctx: UnannPrimitiveTypeCtx, param?: IN): OUT;
unannReferenceType(ctx: UnannReferenceTypeCtx, param?: IN): OUT;
unannClassOrInterfaceType(ctx: UnannClassOrInterfaceTypeCtx, param?: IN): OUT;
Expand Down Expand Up @@ -213,9 +217,10 @@ export abstract class JavaCstVisitor<IN, OUT> implements ICstVisitor<IN, OUT> {
assertStatement(ctx: AssertStatementCtx, param?: IN): OUT;
switchStatement(ctx: SwitchStatementCtx, param?: IN): OUT;
switchBlock(ctx: SwitchBlockCtx, param?: IN): OUT;
switchCase(ctx: SwitchCaseCtx, param?: IN): OUT;
switchBlockStatementGroup(ctx: SwitchBlockStatementGroupCtx, param?: IN): OUT;
switchLabel(ctx: SwitchLabelCtx, param?: IN): OUT;
enumConstantName(ctx: EnumConstantNameCtx, param?: IN): OUT;
switchRule(ctx: SwitchRuleCtx, param?: IN): OUT;
caseConstant(ctx: CaseConstantCtx, param?: IN): OUT;
whileStatement(ctx: WhileStatementCtx, param?: IN): OUT;
doStatement(ctx: DoStatementCtx, param?: IN): OUT;
forStatement(ctx: ForStatementCtx, param?: IN): OUT;
Expand All @@ -240,13 +245,14 @@ export abstract class JavaCstVisitor<IN, OUT> implements ICstVisitor<IN, OUT> {
resourceList(ctx: ResourceListCtx, param?: IN): OUT;
resource(ctx: ResourceCtx, param?: IN): OUT;
resourceInit(ctx: ResourceInitCtx, param?: IN): OUT;
yieldStatement(ctx: YieldStatementCtx, param?: IN): OUT;
variableAccess(ctx: VariableAccessCtx, param?: IN): OUT;
isBasicForStatement(ctx: IsBasicForStatementCtx, param?: IN): OUT;
isLocalVariableDeclaration(
ctx: IsLocalVariableDeclarationCtx,
param?: IN
): OUT;
constantExpression(ctx: ConstantExpressionCtx, param?: IN): OUT;
isClassicSwitchLabel(ctx: IsClassicSwitchLabelCtx, param?: IN): OUT;
expression(ctx: ExpressionCtx, param?: IN): OUT;
lambdaExpression(ctx: LambdaExpressionCtx, param?: IN): OUT;
lambdaParameters(ctx: LambdaParametersCtx, param?: IN): OUT;
Expand Down Expand Up @@ -386,6 +392,10 @@ export abstract class JavaCstVisitorWithDefaults<IN, OUT>
variableDeclaratorId(ctx: VariableDeclaratorIdCtx, param?: IN): OUT;
variableInitializer(ctx: VariableInitializerCtx, param?: IN): OUT;
unannType(ctx: UnannTypeCtx, param?: IN): OUT;
unannPrimitiveTypeWithOptionalDimsSuffix(
ctx: UnannPrimitiveTypeWithOptionalDimsSuffixCtx,
param?: IN
): OUT;
unannPrimitiveType(ctx: UnannPrimitiveTypeCtx, param?: IN): OUT;
unannReferenceType(ctx: UnannReferenceTypeCtx, param?: IN): OUT;
unannClassOrInterfaceType(ctx: UnannClassOrInterfaceTypeCtx, param?: IN): OUT;
Expand Down Expand Up @@ -536,9 +546,10 @@ export abstract class JavaCstVisitorWithDefaults<IN, OUT>
assertStatement(ctx: AssertStatementCtx, param?: IN): OUT;
switchStatement(ctx: SwitchStatementCtx, param?: IN): OUT;
switchBlock(ctx: SwitchBlockCtx, param?: IN): OUT;
switchCase(ctx: SwitchCaseCtx, param?: IN): OUT;
switchBlockStatementGroup(ctx: SwitchBlockStatementGroupCtx, param?: IN): OUT;
switchLabel(ctx: SwitchLabelCtx, param?: IN): OUT;
enumConstantName(ctx: EnumConstantNameCtx, param?: IN): OUT;
switchRule(ctx: SwitchRuleCtx, param?: IN): OUT;
caseConstant(ctx: CaseConstantCtx, param?: IN): OUT;
whileStatement(ctx: WhileStatementCtx, param?: IN): OUT;
doStatement(ctx: DoStatementCtx, param?: IN): OUT;
forStatement(ctx: ForStatementCtx, param?: IN): OUT;
Expand All @@ -563,13 +574,14 @@ export abstract class JavaCstVisitorWithDefaults<IN, OUT>
resourceList(ctx: ResourceListCtx, param?: IN): OUT;
resource(ctx: ResourceCtx, param?: IN): OUT;
resourceInit(ctx: ResourceInitCtx, param?: IN): OUT;
yieldStatement(ctx: YieldStatementCtx, param?: IN): OUT;
variableAccess(ctx: VariableAccessCtx, param?: IN): OUT;
isBasicForStatement(ctx: IsBasicForStatementCtx, param?: IN): OUT;
isLocalVariableDeclaration(
ctx: IsLocalVariableDeclarationCtx,
param?: IN
): OUT;
constantExpression(ctx: ConstantExpressionCtx, param?: IN): OUT;
isClassicSwitchLabel(ctx: IsClassicSwitchLabelCtx, param?: IN): OUT;
expression(ctx: ExpressionCtx, param?: IN): OUT;
lambdaExpression(ctx: LambdaExpressionCtx, param?: IN): OUT;
lambdaParameters(ctx: LambdaParametersCtx, param?: IN): OUT;
Expand Down Expand Up @@ -1179,10 +1191,21 @@ export interface UnannTypeCstNode extends CstNode {
}

export type UnannTypeCtx = {
unannPrimitiveType?: UnannPrimitiveTypeCstNode[];
unannPrimitiveTypeWithOptionalDimsSuffix?: UnannPrimitiveTypeWithOptionalDimsSuffixCstNode[];
unannReferenceType?: UnannReferenceTypeCstNode[];
};

export interface UnannPrimitiveTypeWithOptionalDimsSuffixCstNode
extends CstNode {
name: "unannPrimitiveTypeWithOptionalDimsSuffix";
children: UnannPrimitiveTypeWithOptionalDimsSuffixCtx;
}

export type UnannPrimitiveTypeWithOptionalDimsSuffixCtx = {
unannPrimitiveType: UnannPrimitiveTypeCstNode[];
dims?: DimsCstNode[];
};

export interface UnannPrimitiveTypeCstNode extends CstNode {
name: "unannPrimitiveType";
children: UnannPrimitiveTypeCtx;
Expand Down Expand Up @@ -2234,6 +2257,7 @@ export interface StatementWithoutTrailingSubstatementCstNode extends CstNode {

export type StatementWithoutTrailingSubstatementCtx = {
block?: BlockCstNode[];
yieldStatement?: YieldStatementCstNode[];
emptyStatement?: EmptyStatementCstNode[];
expressionStatement?: ExpressionStatementCstNode[];
assertStatement?: AssertStatementCstNode[];
Expand Down Expand Up @@ -2332,17 +2356,19 @@ export interface SwitchBlockCstNode extends CstNode {

export type SwitchBlockCtx = {
LCurly: IToken[];
switchCase?: SwitchCaseCstNode[];
switchBlockStatementGroup?: SwitchBlockStatementGroupCstNode[];
switchRule?: SwitchRuleCstNode[];
RCurly: IToken[];
};

export interface SwitchCaseCstNode extends CstNode {
name: "switchCase";
children: SwitchCaseCtx;
export interface SwitchBlockStatementGroupCstNode extends CstNode {
name: "switchBlockStatementGroup";
children: SwitchBlockStatementGroupCtx;
}

export type SwitchCaseCtx = {
export type SwitchBlockStatementGroupCtx = {
switchLabel: SwitchLabelCstNode[];
Colon: IToken[];
blockStatements?: BlockStatementsCstNode[];
};

Expand All @@ -2356,13 +2382,26 @@ export type SwitchLabelCtx = {
Default?: IToken[];
};

export interface EnumConstantNameCstNode extends CstNode {
name: "enumConstantName";
children: EnumConstantNameCtx;
export interface SwitchRuleCstNode extends CstNode {
name: "switchRule";
children: SwitchRuleCtx;
}

export type EnumConstantNameCtx = {
Identifier: IToken[];
export type SwitchRuleCtx = {
switchLabel: SwitchLabelCstNode[];
Arrow: IToken[];
throwStatement?: ThrowStatementCstNode[];
block?: BlockCstNode[];
expression?: ExpressionCstNode[];
};

export interface CaseConstantCstNode extends CstNode {
name: "caseConstant";
children: CaseConstantCtx;
}

export type CaseConstantCtx = {
ternaryExpression: TernaryExpressionCstNode[];
};

export interface WhileStatementCstNode extends CstNode {
Expand Down Expand Up @@ -2644,6 +2683,17 @@ export type ResourceInitCtx = {
expression: ExpressionCstNode[];
};

export interface YieldStatementCstNode extends CstNode {
name: "yieldStatement";
children: YieldStatementCtx;
}

export type YieldStatementCtx = {
Yield: IToken[];
expression: ExpressionCstNode[];
Semicolon: IToken[];
};

export interface VariableAccessCstNode extends CstNode {
name: "variableAccess";
children: VariableAccessCtx;
Expand Down Expand Up @@ -2676,13 +2726,14 @@ export type IsLocalVariableDeclarationCtx = {
variableDeclaratorId: VariableDeclaratorIdCstNode[];
};

export interface ConstantExpressionCstNode extends CstNode {
name: "constantExpression";
children: ConstantExpressionCtx;
export interface IsClassicSwitchLabelCstNode extends CstNode {
name: "isClassicSwitchLabel";
children: IsClassicSwitchLabelCtx;
}

export type ConstantExpressionCtx = {
expression: ExpressionCstNode[];
export type IsClassicSwitchLabelCtx = {
switchLabel: SwitchLabelCstNode[];
Colon: IToken[];
};

export interface ExpressionCstNode extends CstNode {
Expand Down Expand Up @@ -2863,12 +2914,12 @@ export type PrimaryPrefixCtx = {
literal?: LiteralCstNode[];
This?: IToken[];
Void?: IToken[];
numericType?: NumericTypeCstNode[];
Boolean?: IToken[];
unannPrimitiveTypeWithOptionalDimsSuffix?: UnannPrimitiveTypeWithOptionalDimsSuffixCstNode[];
fqnOrRefType?: FqnOrRefTypeCstNode[];
castExpression?: CastExpressionCstNode[];
parenthesisExpression?: ParenthesisExpressionCstNode[];
newExpression?: NewExpressionCstNode[];
switchStatement?: SwitchStatementCstNode[];
};

export interface PrimarySuffixCstNode extends CstNode {
Expand Down
2 changes: 1 addition & 1 deletion packages/java-parser/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"version": "0.8.2",
"description": "Java Parser in JavaScript",
"main": "src/index.js",
"repository": "https://github.com/jhipster/prettier-java/tree/master/packages/java-parser",
"repository": "https://github.com/jhipster/prettier-java/tree/main/packages/java-parser",
"license": "Apache-2.0",
"types": "./api.d.ts",
"dependencies": {
Expand Down
34 changes: 17 additions & 17 deletions packages/java-parser/scripts/clone-samples.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,72 +25,72 @@ const sampleRepos = [
},
{
repoUrl: "https://github.com/jhipster/jhipster",
branch: "master"
branch: "main"
},
{
repoUrl: "https://github.com/jhipster/jhipster-sample-app",
branch: "master"
branch: "main"
},
{
repoUrl: "https://github.com/jhipster/jhipster-online",
branch: "master"
branch: "main"
},
{
repoUrl: "https://github.com/jhipster/jhipster-sample-app-microservice",
branch: "master"
branch: "main"
},
{
repoUrl: "https://github.com/jhipster/jhipster-sample-app-gateway",
branch: "master"
branch: "main"
},
{
repoUrl: "https://github.com/jhipster/jhipster-sample-app-oauth2",
branch: "master"
branch: "main"
},
{
repoUrl: "https://github.com/jhipster/jhipster-sample-app-websocket",
branch: "master"
branch: "main"
},
{
repoUrl: "https://github.com/jhipster/jhipster-sample-app-noi18n",
branch: "master"
branch: "main"
},
{
repoUrl: "https://github.com/jhipster/jhipster-sample-app-nocache",
branch: "master"
branch: "main"
},
{
repoUrl: "https://github.com/jhipster/jhipster-sample-app-hazelcast",
branch: "master"
branch: "main"
},

{
repoUrl: "https://github.com/jhipster/jhipster-sample-app-elasticsearch",
branch: "master"
branch: "main"
},
{
repoUrl: "https://github.com/jhipster/jhipster-sample-app-dto",
branch: "master"
branch: "main"
},
{
repoUrl: "https://github.com/jhipster/jhipster-sample-app-couchbase",
branch: "master"
branch: "main"
},
{
repoUrl: "https://github.com/jhipster/jhipster-sample-app-cassandra",
branch: "master"
branch: "main"
},
{
repoUrl: "https://github.com/jhipster/jhipster-sample-app-mongodb",
branch: "master"
branch: "main"
},
{
repoUrl: "https://github.com/jhipster/jhipster-sample-app-gradle",
branch: "master"
branch: "main"
},
{
repoUrl: "https://github.com/jhipster/jhipster-sample-app-react",
branch: "master"
branch: "main"
}
];

Expand Down
Loading

0 comments on commit 112ce75

Please sign in to comment.