diff --git a/trial/cmd/root.go b/trial/cmd/root.go index eb5e5b6a44fd3d0e0b8f3ddc810c6ce90225b0e4..9dc97373939ab358de4c8cf08f896b7afaacec65 100644 --- a/trial/cmd/root.go +++ b/trial/cmd/root.go @@ -8,9 +8,9 @@ import ( var ( output io.Writer trialRootCmd = &cobra.Command{ - Use: "coca", + Use: "cots", Short: "A generator for Cobra based Applications", - Long: `coca`, + Long: `cots`, } ) diff --git a/trial/pkg/application/ts/ts_ident_app_test.go b/trial/pkg/application/ts/ts_ident_app_test.go index 19a1da0efa7122904ce775e1ea9b593fe249d376..5e2c1de27cdfd8ff227484c6e84837d0ad6ebeb9 100644 --- a/trial/pkg/application/ts/ts_ident_app_test.go +++ b/trial/pkg/application/ts/ts_ident_app_test.go @@ -9,8 +9,33 @@ func Test_TypeScriptConsoleLog(t *testing.T) { g := NewGomegaWithT(t) app := new(TypeScriptApiApp) - results := app.Analysis("console.log('hello, world')"); + results := app.Analysis("console.log('hello, world')") g.Expect(len(results.MethodCalls)).To(Equal(1)) g.Expect(results.MethodCalls[0].Class).To(Equal("console")) +} + +func Test_TypeScriptClassNode(t *testing.T) { + g := NewGomegaWithT(t) + + app := new(TypeScriptApiApp) + results := app.Analysis(` +interface IPerson { + name: string; +} + +class Person implements IPerson { + public publicString: string; + private privateString: string; + protected protectedString: string; + readonly readonlyString: string; + name: string; + + constructor(name: string) { + this.name = name; + } +} +`) + + g.Expect(results.Class).To(Equal("Person")) } \ No newline at end of file diff --git a/trial/pkg/ast/typescript_ident_listener.go b/trial/pkg/ast/typescript_ident_listener.go index b4f048c0c57f5414ab72488a4376ae12c35f5ce2..d5b38173ac01c93021a2dd0bb71806dd3b349598 100644 --- a/trial/pkg/ast/typescript_ident_listener.go +++ b/trial/pkg/ast/typescript_ident_listener.go @@ -21,6 +21,10 @@ func (s *TypeScriptIdentListener) EnterProgram(ctx *parser.ProgramContext) { } +func (s *TypeScriptIdentListener) EnterClassDeclaration(ctx *parser.ClassDeclarationContext) { + currentNode.Class = ctx.Identifier().GetText() +} + func (s *TypeScriptIdentListener) EnterArgumentsExpression(ctx *parser.ArgumentsExpressionContext) { if reflect.TypeOf(ctx.GetChild(0)).String() == "*parser.MemberDotExpressionContext" { memberDotExprCtx := ctx.GetChild(0).(*parser.MemberDotExpressionContext)