Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: move convert to ts ident convert
- Loading branch information
Showing
2 changed files
with
67 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package ast | ||
|
||
import ( | ||
"github.com/antlr/antlr4/runtime/Go/antlr" | ||
"github.com/phodal/coca/languages/ts" | ||
"github.com/phodal/coca/pkg/domain" | ||
) | ||
|
||
func BuildArgExpressCall(memberDotExprCtx *parser.MemberDotExpressionContext) domain.JMethodCall { | ||
call := domain.NewJMethodCall() | ||
call.Class = memberDotExprCtx.GetChild(0).(*parser.IdentifierExpressionContext).GetText() | ||
call.MethodName = memberDotExprCtx.IdentifierName().GetText() | ||
|
||
return call | ||
} | ||
|
||
func BuildConstructorMethod(ctx *parser.ConstructorDeclarationContext) domain.JMethod { | ||
method := domain.NewJMethod() | ||
method.Name = "constructor" | ||
|
||
method.AddPosition(ctx.GetChild(0).GetParent().(*antlr.BaseParserRuleContext)) | ||
|
||
if ctx.AccessibilityModifier() != nil { | ||
method.Modifiers = append(method.Modifiers, ctx.AccessibilityModifier().GetText()) | ||
} | ||
|
||
return method | ||
} | ||
|
||
func BuildMemberMethod(ctx *parser.PropertyMemberDeclarationContext) domain.JMethod { | ||
method := domain.NewJMethod() | ||
method.Name = ctx.PropertyName().GetText() | ||
|
||
method.StartLine = ctx.GetStart().GetLine() | ||
method.StartLinePosition = ctx.GetStart().GetColumn() | ||
method.StopLine = ctx.GetStop().GetLine() | ||
method.StopLinePosition = ctx.GetStop().GetColumn() | ||
|
||
return method | ||
} | ||
|
||
func BuildImplements(typeList parser.IClassOrInterfaceTypeListContext) []string { | ||
typeListContext := typeList.(*parser.ClassOrInterfaceTypeListContext) | ||
|
||
var implements []string = nil | ||
for _, typeType := range typeListContext.AllTypeReference() { | ||
typeRefs := typeType.(*parser.TypeReferenceContext).TypeName().GetText() | ||
implements = append(implements, typeRefs) | ||
} | ||
|
||
return implements | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters