refactor: rename core_domain

上级 178291c3
package trial
package core_domain
type CodeCall struct {
Package string
......
package trial
package core_domain
type CodeDataStruct struct {
Name string
......
package trial
package core_domain
type CodeFile struct {
FullName string
......
package trial
package core_domain
type CodeFunction struct {
Name string
......
package trial
package core_domain
import "github.com/phodal/coca/pkg/domain"
......
package trial
package core_domain
type CodeModule struct {
Packages []CodePackage
......
package trial
package core_domain
type CodePackage struct {
Name string
......
package trial
package core_domain
type CodePosition struct {
StartLine int
......
package trial
package core_domain
type CodeProject struct {
Modules []CodeModule
......
package trial
package core_domain
type CodeProperty struct {
Modifiers []string
......
......@@ -2,16 +2,16 @@ package cocago
import (
"fmt"
"github.com/phodal/coca/pkg/domain/trial"
"github.com/phodal/coca/pkg/domain/core_domain"
"go/ast"
"reflect"
)
func BuildPropertyField(name string, field *ast.Field) *trial.CodeProperty {
func BuildPropertyField(name string, field *ast.Field) *core_domain.CodeProperty {
var typeName string
var typeType string
var params []trial.CodeProperty
var results []trial.CodeProperty
var params []core_domain.CodeProperty
var results []core_domain.CodeProperty
switch x := field.Type.(type) {
case *ast.Ident:
typeType = "Identify"
......@@ -44,7 +44,7 @@ func BuildPropertyField(name string, field *ast.Field) *trial.CodeProperty {
fmt.Fprintf(output, "BuildPropertyField %s\n", reflect.TypeOf(x))
}
property := &trial.CodeProperty{
property := &core_domain.CodeProperty{
Modifiers: nil,
Name: name,
TypeType: typeType,
......@@ -71,8 +71,8 @@ func getStarExprName(starExpr ast.StarExpr) string {
}
}
func BuildFunction(x *ast.FuncDecl) *trial.CodeFunction {
codeFunc := &trial.CodeFunction{
func BuildFunction(x *ast.FuncDecl) *core_domain.CodeFunction {
codeFunc := &core_domain.CodeFunction{
Name: x.Name.String(),
}
......@@ -90,8 +90,8 @@ func BuildFunction(x *ast.FuncDecl) *trial.CodeFunction {
return codeFunc
}
func BuildFieldToProperty(fieldList []*ast.Field) []trial.CodeProperty {
var properties []trial.CodeProperty
func BuildFieldToProperty(fieldList []*ast.Field) []core_domain.CodeProperty {
var properties []core_domain.CodeProperty
for _, field := range fieldList {
property := BuildPropertyField(getFieldName(field), field)
properties = append(properties, *property)
......
......@@ -3,7 +3,7 @@ package cocago
import (
"bytes"
"fmt"
"github.com/phodal/coca/pkg/domain/trial"
"github.com/phodal/coca/pkg/domain/core_domain"
"go/ast"
"go/parser"
"go/token"
......@@ -14,7 +14,7 @@ import (
"reflect"
)
var currentPackage *trial.CodePackage
var currentPackage *core_domain.CodePackage
type CocagoParser struct {
}
......@@ -23,7 +23,7 @@ var debug = false
var output io.Writer
func NewCocagoParser() *CocagoParser {
currentPackage = &trial.CodePackage{}
currentPackage = &core_domain.CodePackage{}
output = os.Stdout
return &CocagoParser{}
}
......@@ -35,7 +35,7 @@ func (n *CocagoParser) SetOutput(isDebug bool) io.Writer {
return output
}
func (n *CocagoParser) ProcessFile(fileName string) trial.CodeFile {
func (n *CocagoParser) ProcessFile(fileName string) core_domain.CodeFile {
absPath, _ := filepath.Abs(fileName)
content, _ := ioutil.ReadFile(absPath)
......@@ -52,10 +52,10 @@ func (n *CocagoParser) ProcessFile(fileName string) trial.CodeFile {
return *codeFile
}
func (n *CocagoParser) Visitor(f *ast.File, fset *token.FileSet, fileName string) *trial.CodeFile {
var currentStruct trial.CodeDataStruct
var currentFile trial.CodeFile
var currentFunc *trial.CodeFunction
func (n *CocagoParser) Visitor(f *ast.File, fset *token.FileSet, fileName string) *core_domain.CodeFile {
var currentStruct core_domain.CodeDataStruct
var currentFile core_domain.CodeFile
var currentFunc *core_domain.CodeFunction
currentFile.FullName = fileName
var funcType = ""
......@@ -71,7 +71,7 @@ func (n *CocagoParser) Visitor(f *ast.File, fset *token.FileSet, fileName string
imp := BuildImport(x)
currentFile.Imports = append(currentFile.Imports, *imp)
case *ast.TypeSpec:
currentStruct = trial.CodeDataStruct{}
currentStruct = core_domain.CodeDataStruct{}
currentStruct.Name = x.Name.String()
case *ast.StructType:
AddStructType(currentStruct, x, &currentFile)
......@@ -97,14 +97,14 @@ func (n *CocagoParser) Visitor(f *ast.File, fset *token.FileSet, fileName string
return &currentFile
}
func BuildImport(x *ast.ImportSpec) *trial.CodeImport {
func BuildImport(x *ast.ImportSpec) *core_domain.CodeImport {
path := x.Path.Value
cleanPath := path[1 : len(path)-1]
asName := ""
if x.Name != nil {
asName = x.Name.String()
}
imp := &trial.CodeImport{
imp := &core_domain.CodeImport{
Source: cleanPath,
AsName: asName,
ImportName: "",
......@@ -114,17 +114,17 @@ func BuildImport(x *ast.ImportSpec) *trial.CodeImport {
return imp
}
func AddInterface(x *ast.InterfaceType, ident string, codeFile *trial.CodeFile) {
func AddInterface(x *ast.InterfaceType, ident string, codeFile *core_domain.CodeFile) {
properties := BuildFieldToProperty(x.Methods.List)
dataStruct := trial.CodeDataStruct{
dataStruct := core_domain.CodeDataStruct{
Name: ident,
ID: "",
MemberIds: nil,
InOutProperties: properties,
}
member := trial.CodeMember{
member := core_domain.CodeMember{
DataStructID: dataStruct.Name,
Type: "interface",
}
......@@ -133,11 +133,11 @@ func AddInterface(x *ast.InterfaceType, ident string, codeFile *trial.CodeFile)
codeFile.DataStructures = append(codeFile.DataStructures, dataStruct)
}
func AddNestedFunction(currentFunc *trial.CodeFunction, x *ast.FuncType) {
func AddNestedFunction(currentFunc *core_domain.CodeFunction, x *ast.FuncType) {
}
func AddFunctionDecl(currentStruct trial.CodeDataStruct, x *ast.FuncDecl, currentFile *trial.CodeFile) *trial.CodeFunction {
func AddFunctionDecl(currentStruct core_domain.CodeDataStruct, x *ast.FuncDecl, currentFile *core_domain.CodeFile) *core_domain.CodeFunction {
recv := ""
if x.Recv != nil {
recv = BuildReceiver(x, recv)
......@@ -155,7 +155,7 @@ func AddFunctionDecl(currentStruct trial.CodeDataStruct, x *ast.FuncDecl, curren
} else {
member := GetMemberFromFile(*currentFile, "default")
if member == nil {
member = &trial.CodeMember{
member = &core_domain.CodeMember{
DataStructID: "default",
Type: "method",
}
......@@ -182,7 +182,7 @@ func BuildReceiver(x *ast.FuncDecl, recv string) string {
return recv
}
func BuildMethodCall(codeFunc *trial.CodeFunction, item ast.Stmt) {
func BuildMethodCall(codeFunc *core_domain.CodeFunction, item ast.Stmt) {
switch it := item.(type) {
case *ast.ExprStmt:
BuildMethodCallExprStmt(it, codeFunc)
......@@ -191,11 +191,11 @@ func BuildMethodCall(codeFunc *trial.CodeFunction, item ast.Stmt) {
}
}
func BuildMethodCallExprStmt(it *ast.ExprStmt, codeFunc *trial.CodeFunction) {
func BuildMethodCallExprStmt(it *ast.ExprStmt, codeFunc *core_domain.CodeFunction) {
switch expr := it.X.(type) {
case *ast.CallExpr:
selector, selName := BuildExpr(expr.Fun.(ast.Expr))
call := trial.CodeCall{
call := core_domain.CodeCall{
Package: "",
Type: "",
Class: selector,
......@@ -204,7 +204,7 @@ func BuildMethodCallExprStmt(it *ast.ExprStmt, codeFunc *trial.CodeFunction) {
for _, arg := range expr.Args {
value, kind := BuildExpr(arg.(ast.Expr))
property := &trial.CodeProperty{
property := &core_domain.CodeProperty{
TypeName: value,
TypeType: kind,
}
......@@ -241,12 +241,12 @@ func BuildExpr(expr ast.Expr) (string, string) {
return "", ""
}
func createMember(codeDataStruct trial.CodeDataStruct) {
func createMember(codeDataStruct core_domain.CodeDataStruct) {
}
func GetMemberFromFile(file trial.CodeFile, recv string) *trial.CodeMember {
var identMember *trial.CodeMember
func GetMemberFromFile(file core_domain.CodeFile, recv string) *core_domain.CodeMember {
var identMember *core_domain.CodeMember
for _, member := range file.Members {
if member.DataStructID == recv {
identMember = member
......@@ -262,8 +262,8 @@ func getFieldName(field *ast.Field) string {
return field.Names[0].Name
}
func AddStructType(currentStruct trial.CodeDataStruct, x *ast.StructType, currentFile *trial.CodeFile) {
member := trial.CodeMember{
func AddStructType(currentStruct core_domain.CodeDataStruct, x *ast.StructType, currentFile *core_domain.CodeFile) {
member := core_domain.CodeMember{
DataStructID: currentStruct.Name,
Type: "struct",
}
......
......@@ -2,18 +2,18 @@ package processor
import (
"github.com/phodal/coca/pkg/adapter/cocafile"
"github.com/phodal/coca/pkg/domain/trial"
"github.com/phodal/coca/pkg/domain/core_domain"
"github.com/phodal/coca/trial/cocago"
"strings"
)
func ProcessPackage(path string, debug bool) []*trial.CodeFile {
func ProcessPackage(path string, debug bool) []*core_domain.CodeFile {
var GoFileFilter = func(path string) bool {
return strings.HasSuffix(path, ".go")
}
files := cocafile.GetFilesWithFilter(path, GoFileFilter)
filesData := make([]*trial.CodeFile, len(files))
filesData := make([]*core_domain.CodeFile, len(files))
parser := cocago.NewCocagoParser()
if debug {
parser.SetOutput(true)
......
......@@ -3,7 +3,7 @@ package pyapp
import (
"github.com/antlr/antlr4/runtime/Go/antlr"
parser "github.com/phodal/coca/languages/python"
"github.com/phodal/coca/pkg/domain/trial"
"github.com/phodal/coca/pkg/domain/core_domain"
"github.com/phodal/coca/trial/pkg/ast/pyast"
)
......@@ -21,7 +21,7 @@ func ProcessTsString(code string) *parser.PythonParser {
type PythonApiApp struct {
}
func (j *PythonApiApp) Analysis(code string, fileName string) *trial.CodeFile {
func (j *PythonApiApp) Analysis(code string, fileName string) *core_domain.CodeFile {
scriptParser := ProcessTsString(code)
context := scriptParser.Root()
......
......@@ -4,7 +4,7 @@ import (
. "github.com/onsi/gomega"
"github.com/phodal/coca/cocatest"
"github.com/phodal/coca/pkg/adapter/cocafile"
"github.com/phodal/coca/pkg/domain/trial"
"github.com/phodal/coca/pkg/domain/core_domain"
"io/ioutil"
"strings"
"testing"
......@@ -84,10 +84,10 @@ func Test_PythonClassWithDecorator(t *testing.T) {
codeFile := app.Analysis(string(file), "testdata/grammar/class_or_func_def_stmt.py")
g.Expect(len(codeFile.DataStructures)).To(Equal(1))
g.Expect(len(codeFile.DataStructures[0].Annotations.([]trial.PythonAnnotation))).To(Equal(1))
g.Expect(len(codeFile.DataStructures[0].Annotations.([]core_domain.PythonAnnotation))).To(Equal(1))
g.Expect(codeFile.Members[0].FunctionNodes[0].Name).To(Equal("bar"))
g.Expect(len(codeFile.Members[0].FunctionNodes[0].Annotations.([]trial.PythonAnnotation))).To(Equal(2))
g.Expect(len(codeFile.Members[0].FunctionNodes[0].Annotations.([]core_domain.PythonAnnotation))).To(Equal(2))
}
func Test_PythonImport(t *testing.T) {
......
......@@ -3,7 +3,7 @@ package ts
import (
"github.com/antlr/antlr4/runtime/Go/antlr"
parser "github.com/phodal/coca/languages/ts"
"github.com/phodal/coca/pkg/domain/trial"
"github.com/phodal/coca/pkg/domain/core_domain"
"github.com/phodal/coca/trial/pkg/ast/ts"
)
......@@ -21,7 +21,7 @@ func ProcessTsString(code string) *parser.TypeScriptParser {
type TypeScriptApiApp struct {
}
func (j *TypeScriptApiApp) Analysis(code string, fileName string) trial.CodeFile {
func (j *TypeScriptApiApp) Analysis(code string, fileName string) core_domain.CodeFile {
scriptParser := ProcessTsString(code)
context := scriptParser.Program()
......
......@@ -3,7 +3,7 @@ package ast_util
import (
"github.com/antlr/antlr4/runtime/Go/antlr"
"github.com/phodal/coca/pkg/domain"
"github.com/phodal/coca/pkg/domain/trial"
"github.com/phodal/coca/pkg/domain/core_domain"
)
func AddPosition(m *domain.JMethod, ctx *antlr.BaseParserRuleContext) {
......@@ -14,7 +14,7 @@ func AddPosition(m *domain.JMethod, ctx *antlr.BaseParserRuleContext) {
}
func AddFunctionPosition(m *trial.CodeFunction, ctx *antlr.BaseParserRuleContext) {
func AddFunctionPosition(m *core_domain.CodeFunction, ctx *antlr.BaseParserRuleContext) {
m.Position.StartLine = ctx.GetStart().GetLine()
m.Position.StartLinePosition = ctx.GetStart().GetColumn()
m.Position.StopLine = ctx.GetStop().GetLine()
......
......@@ -4,7 +4,7 @@ import (
"bytes"
"github.com/antlr/antlr4/runtime/Go/antlr"
parser "github.com/phodal/coca/languages/python"
"github.com/phodal/coca/pkg/domain/trial"
"github.com/phodal/coca/pkg/domain/core_domain"
"github.com/phodal/coca/trial/pkg/ast/ast_util"
"io"
"os"
......@@ -15,14 +15,14 @@ type PythonIdentListener struct {
parser.BasePythonParserListener
}
var currentCodeFile *trial.CodeFile
var currentDataStruct *trial.CodeDataStruct
var currentCodeFile *core_domain.CodeFile
var currentDataStruct *core_domain.CodeDataStruct
var debug = false
var output io.Writer
var hasEnterMember = false
func NewPythonIdentListener(fileName string) *PythonIdentListener {
currentCodeFile = &trial.CodeFile{}
currentCodeFile = &core_domain.CodeFile{}
currentCodeFile.FullName = fileName
output = os.Stdout
......@@ -39,7 +39,7 @@ func (s *PythonIdentListener) SetDebugOutput(isDebug bool) io.Writer {
func (s *PythonIdentListener) EnterImport_stmt(ctx *parser.Import_stmtContext) {
dotNames := ctx.Dotted_as_names().(*parser.Dotted_as_namesContext).AllDotted_as_name()
codeImport := &trial.CodeImport{}
codeImport := &core_domain.CodeImport{}
context := dotNames[0].(*parser.Dotted_as_nameContext)
codeImport.Source = context.Dotted_name().GetText()
if context.Name() != nil {
......@@ -55,7 +55,7 @@ func (s *PythonIdentListener) EnterImport_stmt(ctx *parser.Import_stmtContext) {
}
func (s *PythonIdentListener) EnterFrom_stmt(ctx *parser.From_stmtContext) {
codeImport := &trial.CodeImport{}
codeImport := &core_domain.CodeImport{}
codeImport.Source = ctx.From_stmt_source().GetText()
usageName := ctx.From_stmt_as_names().GetText()
......@@ -75,7 +75,7 @@ func (s *PythonIdentListener) EnterFrom_stmt(ctx *parser.From_stmtContext) {
func (s *PythonIdentListener) EnterClassdef(ctx *parser.ClassdefContext) {
hasEnterMember = true
dataStruct := &trial.CodeDataStruct{
dataStruct := &core_domain.CodeDataStruct{
Name: ctx.Name().GetText(),
ID: "",
MemberIds: nil,
......@@ -99,7 +99,7 @@ func (s *PythonIdentListener) ExitClassdef(ctx *parser.ClassdefContext) {
func (s *PythonIdentListener) EnterFuncdef(ctx *parser.FuncdefContext) {
hasEnterMember = true
function := trial.CodeFunction{
function := core_domain.CodeFunction{
Name: ctx.Name().GetText(),
}
......@@ -109,7 +109,7 @@ func (s *PythonIdentListener) EnterFuncdef(ctx *parser.FuncdefContext) {
function.Annotations = decorators
}
member := &trial.CodeMember{
member := &core_domain.CodeMember{
Name: ctx.Name().GetText(),
}
......@@ -125,14 +125,14 @@ func (s *PythonIdentListener) ExitFuncdef(ctx *parser.FuncdefContext) {
hasEnterMember = false
}
func BuildDecoratorsByIndex(node antlr.ParseTree, index int) []trial.PythonAnnotation {
func BuildDecoratorsByIndex(node antlr.ParseTree, index int) []core_domain.PythonAnnotation {
var nodes []parser.DecoratorContext
for i := 0; i < index; i++ {
context := node.GetParent().GetChild(i).(*parser.DecoratorContext)
nodes = append(nodes, *context)
}
var annotations []trial.PythonAnnotation
var annotations []core_domain.PythonAnnotation
for _, node := range nodes {
decorator := BuildDecorator(&node)
annotations = append(annotations, *decorator)
......@@ -141,10 +141,10 @@ func BuildDecoratorsByIndex(node antlr.ParseTree, index int) []trial.PythonAnnot
return annotations
}
func BuildDecorator(x *parser.DecoratorContext) *trial.PythonAnnotation {
func BuildDecorator(x *parser.DecoratorContext) *core_domain.PythonAnnotation {
text := x.Dotted_name().GetText()
annotation := &trial.PythonAnnotation{
annotation := &core_domain.PythonAnnotation{
Name: text,
}
......@@ -155,11 +155,11 @@ func BuildDecorator(x *parser.DecoratorContext) *trial.PythonAnnotation {
return annotation
}
func BuildArgList(context *parser.ArglistContext) []trial.CodeProperty {
var arguments []trial.CodeProperty
func BuildArgList(context *parser.ArglistContext) []core_domain.CodeProperty {
var arguments []core_domain.CodeProperty
for _, arg := range context.AllArgument() {
argContext := arg.(*parser.ArgumentContext)
argument := &trial.CodeProperty{
argument := &core_domain.CodeProperty{
Name: "",
TypeName: argContext.GetText(),
}
......@@ -169,6 +169,6 @@ func BuildArgList(context *parser.ArglistContext) []trial.CodeProperty {
return arguments
}
func (s *PythonIdentListener) GetCodeFileInfo() *trial.CodeFile {
func (s *PythonIdentListener) GetCodeFileInfo() *core_domain.CodeFile {
return currentCodeFile
}
......@@ -3,12 +3,12 @@ package ts
import (
"github.com/antlr/antlr4/runtime/Go/antlr"
"github.com/phodal/coca/languages/ts"
"github.com/phodal/coca/pkg/domain/trial"
"github.com/phodal/coca/pkg/domain/core_domain"
"github.com/phodal/coca/trial/pkg/ast/ast_util"
)
func BuildConstructorMethod(ctx *parser.ConstructorDeclarationContext) *trial.CodeFunction {
function := &trial.CodeFunction{
func BuildConstructorMethod(ctx *parser.ConstructorDeclarationContext) *core_domain.CodeFunction {
function := &core_domain.CodeFunction{
Name: "constructor",
}
......@@ -23,8 +23,8 @@ func BuildConstructorMethod(ctx *parser.ConstructorDeclarationContext) *trial.Co
return function
}
func BuildMemberMethod(ctx *parser.PropertyMemberDeclarationContext) *trial.CodeFunction {
function := &trial.CodeFunction{
func BuildMemberMethod(ctx *parser.PropertyMemberDeclarationContext) *core_domain.CodeFunction {
function := &core_domain.CodeFunction{
Name: ctx.PropertyName().GetText(),
}
function.Position.StartLine = ctx.GetStart().GetLine()
......@@ -47,9 +47,9 @@ func BuildImplements(typeList parser.IClassOrInterfaceTypeListContext) []string
return implements
}
func BuildMethodParameter(context *parser.ParameterListContext) ([]trial.CodeProperty) {
func BuildMethodParameter(context *parser.ParameterListContext) ([]core_domain.CodeProperty) {
childNode := context.GetChild(0)
var parameters []trial.CodeProperty = nil
var parameters []core_domain.CodeProperty = nil
switch x := childNode.(type) {
case *parser.RequiredParameterListContext:
......@@ -66,7 +66,7 @@ func BuildMethodParameter(context *parser.ParameterListContext) ([]trial.CodePro
}
case *parser.PredefinedTypeContext:
predefinedTypeContext := x
parameter := trial.CodeProperty{
parameter := core_domain.CodeProperty{
TypeName: "any",
TypeType: predefinedTypeContext.GetText(),
}
......@@ -76,13 +76,13 @@ func BuildMethodParameter(context *parser.ParameterListContext) ([]trial.CodePro
return parameters
}
func buildRestParameters(ctx *parser.RestParameterContext) trial.CodeProperty {
func buildRestParameters(ctx *parser.RestParameterContext) core_domain.CodeProperty {
context := ctx.GetChild(1).(*parser.RequiredParameterContext)
return buildRequiredParameter(context)
}
func buildRequireParameterList(listContext *parser.RequiredParameterListContext) []trial.CodeProperty {
var requireCodeParams []trial.CodeProperty = nil
func buildRequireParameterList(listContext *parser.RequiredParameterListContext) []core_domain.CodeProperty {
var requireCodeParams []core_domain.CodeProperty = nil
for _, requiredParameter := range listContext.AllRequiredParameter() {
paramCtx := requiredParameter.(*parser.RequiredParameterContext)
......@@ -93,13 +93,13 @@ func buildRequireParameterList(listContext *parser.RequiredParameterListContext)
return requireCodeParams
}
func buildRequiredParameter(paramCtx *parser.RequiredParameterContext) trial.CodeProperty {
func buildRequiredParameter(paramCtx *parser.RequiredParameterContext) core_domain.CodeProperty {
paramType := ""
if paramCtx.TypeAnnotation() != nil {
annotationContext := paramCtx.TypeAnnotation().(*parser.TypeAnnotationContext)
paramType = BuildTypeAnnotation(annotationContext)
}
parameter := trial.CodeProperty{
parameter := core_domain.CodeProperty{
TypeName: paramCtx.IdentifierOrPattern().GetText(),
TypeType: paramType,
}
......
......@@ -4,7 +4,7 @@ import (
"github.com/antlr/antlr4/runtime/Go/antlr"
parser "github.com/phodal/coca/languages/ts"
"github.com/phodal/coca/pkg/domain"
"github.com/phodal/coca/pkg/domain/trial"
"github.com/phodal/coca/pkg/domain/core_domain"
"github.com/phodal/coca/trial/pkg/ast/ast_util"
"strings"
)
......@@ -12,11 +12,11 @@ import (
var defaultClass = "default"
type TypeScriptIdentListener struct {
currentDataStruct *trial.CodeDataStruct
dataStructures []trial.CodeDataStruct
dataStructQueue []trial.CodeDataStruct
currentDataStruct *core_domain.CodeDataStruct
dataStructures []core_domain.CodeDataStruct
dataStructQueue []core_domain.CodeDataStruct
filePath string
codeFile trial.CodeFile
codeFile core_domain.CodeFile
parser.BaseTypeScriptParserListener
}
......@@ -27,11 +27,11 @@ func NewTypeScriptIdentListener(fileName string) *TypeScriptIdentListener {
return listener
}
func (s *TypeScriptIdentListener) GetNodeInfo() trial.CodeFile {
func (s *TypeScriptIdentListener) GetNodeInfo() core_domain.CodeFile {
isScriptCalls := s.currentDataStruct != nil && s.currentDataStruct.IsNotEmpty()
if isScriptCalls {
if len(s.currentDataStruct.Functions) < 1 {
function := &trial.CodeFunction{}
function := &core_domain.CodeFunction{}
function.Name = "default"
function.MethodCalls = append(function.MethodCalls, s.currentDataStruct.FunctionCalls...)
......@@ -47,7 +47,7 @@ func (s *TypeScriptIdentListener) GetNodeInfo() trial.CodeFile {
func (s *TypeScriptIdentListener) EnterImportFromBlock(ctx *parser.ImportFromBlockContext) {
replaceSingleQuote := UpdateImportStr(ctx.StringLiteral().GetText())
imp := &trial.CodeImport{Source: replaceSingleQuote}
imp := &core_domain.CodeImport{Source: replaceSingleQuote}
importName := ctx.GetChild(0).(antlr.ParseTree).GetText()
imp.ImportName = importName
s.codeFile.Imports = append(s.codeFile.Imports, *imp)
......@@ -61,18 +61,18 @@ func UpdateImportStr(importText string) string {
func (s *TypeScriptIdentListener) EnterImportAliasDeclaration(ctx *parser.ImportAliasDeclarationContext) {
replaceSingleQuote := UpdateImportStr(ctx.StringLiteral().GetText())
imp := &trial.CodeImport{Source: replaceSingleQuote}
imp := &core_domain.CodeImport{Source: replaceSingleQuote}
s.codeFile.Imports = append(s.codeFile.Imports, *imp)
}
func (s *TypeScriptIdentListener) EnterImportAll(ctx *parser.ImportAllContext) {
replaceSingleQuote := UpdateImportStr(ctx.StringLiteral().GetText())
imp := &trial.CodeImport{Source: replaceSingleQuote}
imp := &core_domain.CodeImport{Source: replaceSingleQuote}
s.codeFile.Imports = append(s.codeFile.Imports, *imp)
}
func (s *TypeScriptIdentListener) EnterInterfaceDeclaration(ctx *parser.InterfaceDeclarationContext) {
s.currentDataStruct = &trial.CodeDataStruct{
s.currentDataStruct = &core_domain.CodeDataStruct{
Type: "Interface",
Name: ctx.Identifier().GetText(),
}
......@@ -93,7 +93,7 @@ func (s *TypeScriptIdentListener) EnterInterfaceDeclaration(ctx *parser.Interfac
}
}
func BuildInterfaceTypeBody(ctx *parser.TypeMemberListContext, dataStruct *trial.CodeDataStruct) {
func BuildInterfaceTypeBody(ctx *parser.TypeMemberListContext, dataStruct *core_domain.CodeDataStruct) {
for _, typeMember := range ctx.AllTypeMember() {
typeMemberCtx := typeMember.(*parser.TypeMemberContext)
memberChild := typeMemberCtx.GetChild(0)
......@@ -104,7 +104,7 @@ func BuildInterfaceTypeBody(ctx *parser.TypeMemberListContext, dataStruct *trial
method := domain.NewJMethod()
method.Name = x.PropertyName().GetText()
function := trial.CodeFunction{
function := core_domain.CodeFunction{
Name: x.PropertyName().GetText(),
}
......@@ -115,21 +115,21 @@ func BuildInterfaceTypeBody(ctx *parser.TypeMemberListContext, dataStruct *trial
}
}
func BuildInterfacePropertySignature(signatureCtx *parser.PropertySignatureContext, dataStruct *trial.CodeDataStruct) {
func BuildInterfacePropertySignature(signatureCtx *parser.PropertySignatureContext, dataStruct *core_domain.CodeDataStruct) {
typeType := BuildTypeAnnotation(signatureCtx.TypeAnnotation().(*parser.TypeAnnotationContext))
typeValue := signatureCtx.PropertyName().(*parser.PropertyNameContext).GetText()
isArrowFunc := signatureCtx.Type_() != nil
if isArrowFunc {
function := &trial.CodeFunction{
function := &core_domain.CodeFunction{
Name: typeValue,
}
param := trial.CodeProperty{
param := core_domain.CodeProperty{
TypeName: "any",
TypeType: typeType,
}
returnType := trial.CodeProperty{
returnType := core_domain.CodeProperty{
TypeType: signatureCtx.Type_().GetText(),
}
function.Parameters = append(function.Parameters, param)
......@@ -137,7 +137,7 @@ func BuildInterfacePropertySignature(signatureCtx *parser.PropertySignatureConte
dataStruct.Functions = append(dataStruct.Functions, *function)
} else {
codeField := &trial.CodeField{}
codeField := &core_domain.CodeField{}
codeField.TypeType = typeType
codeField.TypeValue = typeValue
......@@ -150,7 +150,7 @@ func (s *TypeScriptIdentListener) ExitInterfaceDeclaration(ctx *parser.Interface
}
func (s *TypeScriptIdentListener) EnterClassDeclaration(ctx *parser.ClassDeclarationContext) {
s.currentDataStruct = &trial.CodeDataStruct{
s.currentDataStruct = &core_domain.CodeDataStruct{
Type: "Class",
Name: ctx.Identifier().GetText(),
}
......@@ -189,11 +189,11 @@ func (s *TypeScriptIdentListener) handleClassBodyElements(classTailContext *pars
}
}
func (s *TypeScriptIdentListener) HandlePropertyMember(propertyMemberCtx *parser.PropertyMemberDeclarationContext, dataStruct *trial.CodeDataStruct) {
func (s *TypeScriptIdentListener) HandlePropertyMember(propertyMemberCtx *parser.PropertyMemberDeclarationContext, dataStruct *core_domain.CodeDataStruct) {
callSignatureSizePos := 3
if propertyMemberCtx.PropertyName() != nil {
modifier := propertyMemberCtx.PropertyMemberBase().GetText()
codeField := trial.CodeField{
codeField := core_domain.CodeField{
TypeValue: propertyMemberCtx.PropertyName().GetText(),
}
codeField.Modifiers = append(codeField.Modifiers, modifier)
......@@ -224,12 +224,12 @@ func (s *TypeScriptIdentListener) exitClass() {
s.dataStructQueue = s.dataStructQueue[0 : len(s.dataStructQueue)-1]
s.currentDataStruct = &s.dataStructQueue[len(s.dataStructQueue)-1]
} else {
s.currentDataStruct = trial.NewDataStruct()
s.currentDataStruct = core_domain.NewDataStruct()
}
}
func (s *TypeScriptIdentListener) EnterFunctionDeclaration(ctx *parser.FunctionDeclarationContext) {
function := &trial.CodeFunction{
function := &core_domain.CodeFunction{
Name: ctx.Identifier().GetText(),
}
......@@ -239,12 +239,12 @@ func (s *TypeScriptIdentListener) EnterFunctionDeclaration(ctx *parser.FunctionD
ast_util.AddFunctionPosition(function, ctx.GetChild(0).GetParent().(*antlr.BaseParserRuleContext))
if s.currentDataStruct == nil {
s.currentDataStruct = &trial.CodeDataStruct{}
s.currentDataStruct = &core_domain.CodeDataStruct{}
}
s.currentDataStruct.Functions = append(s.currentDataStruct.Functions, *function)
}
func FillMethodFromCallSignature(callSignatureContext *parser.CallSignatureContext, function *trial.CodeFunction) {
func FillMethodFromCallSignature(callSignatureContext *parser.CallSignatureContext, function *core_domain.CodeFunction) {
if callSignatureContext.ParameterList() != nil {
parameterListContext := callSignatureContext.ParameterList().(*parser.ParameterListContext)
functionParameters := BuildMethodParameter(parameterListContext)
......
......@@ -4,7 +4,7 @@ import (
"encoding/json"
"github.com/phodal/coca/cmd/cmd_util"
"github.com/phodal/coca/pkg/adapter/cocafile"
"github.com/phodal/coca/pkg/domain/trial"
"github.com/phodal/coca/pkg/domain/core_domain"
"github.com/phodal/coca/trial/cocago"
"github.com/spf13/cobra"
)
......@@ -24,7 +24,7 @@ var analysisGoCmd = &cobra.Command{
Run: func(cmd *cobra.Command, args []string) {
importPath := analysisGoCmdConfig.Path
var results []trial.CodeFile
var results []core_domain.CodeFile
files := cocafile.GetFilesWithFilter(importPath, cocafile.GoFileFilter)
for _, file := range files {
parser := cocago.NewCocagoParser()
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册