From ddd139e930436345ae678085d5b005ff4b26cb53 Mon Sep 17 00:00:00 2001 From: Phodal Huang Date: Tue, 15 Nov 2022 17:25:38 +0800 Subject: [PATCH] fix(ts): fix end comma in constructor --- .../src/main/antlr/TypeScriptParser.g4 | 2 +- .../ast/typescriptast/TypeScriptAnalyserTest.kt | 3 ++- ...eScriptBugTest.kt => TypeScriptRegressionTest.kt} | 12 +++++++++++- 3 files changed, 14 insertions(+), 3 deletions(-) rename chapi-ast-typescript/src/test/kotlin/chapi/ast/typescriptast/{TypeScriptBugTest.kt => TypeScriptRegressionTest.kt} (74%) diff --git a/chapi-ast-typescript/src/main/antlr/TypeScriptParser.g4 b/chapi-ast-typescript/src/main/antlr/TypeScriptParser.g4 index ebc89a4c..2686f7af 100644 --- a/chapi-ast-typescript/src/main/antlr/TypeScriptParser.g4 +++ b/chapi-ast-typescript/src/main/antlr/TypeScriptParser.g4 @@ -680,7 +680,7 @@ iteratorDefinition ; formalParameterList - : formalParameterArg (',' formalParameterArg)* (',' lastFormalParameterArg)? + : formalParameterArg (',' formalParameterArg)* (',' lastFormalParameterArg)? ','? ; formalParameterArg diff --git a/chapi-ast-typescript/src/test/kotlin/chapi/ast/typescriptast/TypeScriptAnalyserTest.kt b/chapi-ast-typescript/src/test/kotlin/chapi/ast/typescriptast/TypeScriptAnalyserTest.kt index eefd389f..7af8bd60 100644 --- a/chapi-ast-typescript/src/test/kotlin/chapi/ast/typescriptast/TypeScriptAnalyserTest.kt +++ b/chapi-ast-typescript/src/test/kotlin/chapi/ast/typescriptast/TypeScriptAnalyserTest.kt @@ -2,6 +2,7 @@ package chapi.ast.typescriptast import chapi.domain.core.DataStructType import org.junit.jupiter.api.Assertions.assertEquals +import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test import java.io.File @@ -69,7 +70,7 @@ class TypeScriptAnalyserTest { } @Test - @Ignore +// @Disabled fun someBug() { val dir = File("/Users/phodal/bug-ui-system") dir.walkTopDown().forEach { diff --git a/chapi-ast-typescript/src/test/kotlin/chapi/ast/typescriptast/TypeScriptBugTest.kt b/chapi-ast-typescript/src/test/kotlin/chapi/ast/typescriptast/TypeScriptRegressionTest.kt similarity index 74% rename from chapi-ast-typescript/src/test/kotlin/chapi/ast/typescriptast/TypeScriptBugTest.kt rename to chapi-ast-typescript/src/test/kotlin/chapi/ast/typescriptast/TypeScriptRegressionTest.kt index bd8cb524..2e4f632a 100644 --- a/chapi-ast-typescript/src/test/kotlin/chapi/ast/typescriptast/TypeScriptBugTest.kt +++ b/chapi-ast-typescript/src/test/kotlin/chapi/ast/typescriptast/TypeScriptRegressionTest.kt @@ -2,7 +2,7 @@ package chapi.ast.typescriptast import org.junit.jupiter.api.Test -class TypeScriptBugTest { +class TypeScriptRegressionTest { @Test internal fun backend_arrow_function() { @@ -37,4 +37,14 @@ import {EMPTY, Observable, of} from 'rxjs'; }""" TypeScriptAnalyser().analysis(code, "index.tsx") } + + @Test + fun end_with_dot() { + val code = """export class SomeComponent implements OnInit, ControlValueAccessor { + constructor( + private fb: FormBuilder, + ) { } +} """ + TypeScriptAnalyser().analysis(code, "index.tsx") + } }