Skip to content

Commit

Permalink
fix(ts): fix some order issues
Browse files Browse the repository at this point in the history
  • Loading branch information
phodal committed Nov 17, 2022
1 parent 6d92ebb commit ded0de5
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 4 deletions.
2 changes: 1 addition & 1 deletion chapi-ast-typescript/src/main/antlr/TypeScriptLexer.g4
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ Import: 'import';

Implements: 'implements' ;
Let: 'let' ;
Private: 'private' ;
Private: 'private';
Public: 'public' ;
Interface: 'interface' ;
Package: 'package' ;
Expand Down
4 changes: 2 additions & 2 deletions chapi-ast-typescript/src/main/antlr/TypeScriptParser.g4
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ constructSignature
;

callSignature
: typeParameters? '(' parameterList? ','? ')' (':' (typePredicateWithOperatorTypeRef | typeRef))? eos?
: typeParameters? '(' parameterList? ','? ')' (':' (typePredicateWithOperatorTypeRef | typeRef))?
;

indexSignature
Expand Down Expand Up @@ -443,8 +443,8 @@ constructorDeclaration
propertyMemberDeclaration
: propertyMemberBase (getAccessor | setAccessor) # GetterSetterDeclarationExpression
| abstractDeclaration # AbstractMemberDeclaration
| propertyMemberBase propertyName '!'? '?'? typeAnnotation? initializer? # PropertyDeclarationExpression
| propertyMemberBase propertyName callSignature ( ('{' functionBody '}') | eos) # MethodDeclarationExpression
| propertyMemberBase propertyName '!'? '?'? typeAnnotation? initializer? # PropertyDeclarationExpression
;

abstractDeclaration
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ class TypeScriptFullIdentListener(node: TSIdentify) : TypeScriptAstListener() {
)
}
else -> {
println("handleClassBodyElements -> childElementType : ${childCtx.javaClass.simpleName}")
// println("handleClassBodyElements -> childElementType : ${childCtx.javaClass.simpleName}")
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package chapi.ast.typescriptast

import org.junit.jupiter.api.Disabled
import org.junit.jupiter.api.Test
import kotlin.test.assertEquals

class TypeScriptRegressionTest {

Expand Down Expand Up @@ -146,4 +147,19 @@ export type CaseQuery = (
);"""
TypeScriptAnalyser().analysis(code, "index.tsx")
}

@Test
fun private_issue() {
val code = """
export class PopupDirective {
private openPopup(): void {
}
}
"""
val codeFile = TypeScriptAnalyser().analysis(code, "index.tsx")
assertEquals(codeFile.DataStructures.size, 1)
assertEquals(codeFile.DataStructures[0].Functions.size, 1)
assertEquals(codeFile.DataStructures[0].Functions[0].Name, "openPopup")
}
}

0 comments on commit ded0de5

Please sign in to comment.