diff --git a/cmd/analysis.go b/cmd/analysis.go index bc3463db1affa6120298b409e0cb25cca44def9e..21f1176947c887e9017d0b65017ac9c5377ee767 100644 --- a/cmd/analysis.go +++ b/cmd/analysis.go @@ -2,8 +2,8 @@ package cmd import ( "encoding/json" + "github.com/phodal/coca/cmd/cmd_util" "github.com/phodal/coca/core/context/analysis" - "github.com/phodal/coca/core/infrastructure/coca_file" "github.com/spf13/cobra" ) @@ -27,7 +27,7 @@ var analysisCmd = &cobra.Command{ iNodes := identifierApp.AnalysisPath(importPath) identModel, _ := json.MarshalIndent(iNodes, "", "\t") - coca_file.WriteToCocaFile("identify.json", string(identModel)) + cmd_util.WriteToCocaFile("identify.json", string(identModel)) var classes []string = nil @@ -39,7 +39,7 @@ var analysisCmd = &cobra.Command{ callNodes := callApp.AnalysisPath(importPath, classes, iNodes) cModel, _ := json.MarshalIndent(callNodes, "", "\t") - coca_file.WriteToCocaFile("deps.json", string(cModel)) + cmd_util.WriteToCocaFile("deps.json", string(cModel)) }, } diff --git a/cmd/api.go b/cmd/api.go index 30b8ff3c406614668406edcced2f7f5e9d1e7f7a..20396fe01a34c97105283b78708d5b00babaa140 100644 --- a/cmd/api.go +++ b/cmd/api.go @@ -9,7 +9,6 @@ import ( "github.com/phodal/coca/core/context/call" "github.com/phodal/coca/core/domain" "github.com/phodal/coca/core/infrastructure/ast" - "github.com/phodal/coca/core/infrastructure/coca_file" "github.com/spf13/cobra" "log" "os" @@ -46,7 +45,7 @@ var apiCmd = &cobra.Command{ apiPrefix := apiCmdConfig.AggregateApi parsedDeps = nil - depFile := coca_file.ReadFile(depPath) + depFile := cmd_util.ReadFile(depPath) if depFile == nil { log.Fatal("lost deps") } @@ -56,7 +55,7 @@ var apiCmd = &cobra.Command{ if *&apiCmdConfig.ForceUpdate { forceUpdateApi() } else { - apiContent := coca_file.ReadCocaFile("apis.json") + apiContent := cmd_util.ReadCocaFile("apis.json") if apiContent == nil { forceUpdateApi() } @@ -89,7 +88,7 @@ var apiCmd = &cobra.Command{ dotContent = replacePackage(dotContent) } - coca_file.WriteToCocaFile("api.dot", dotContent) + cmd_util.WriteToCocaFile("api.dot", dotContent) cmd_util.ConvertToSvg("api") }, } @@ -98,7 +97,7 @@ func forceUpdateApi() { app := new(api.JavaApiApp) restApis = app.AnalysisPath(apiCmdConfig.Path, parsedDeps, identifiersMap, diMap) cModel, _ := json.MarshalIndent(restApis, "", "\t") - coca_file.WriteToCocaFile("apis.json", string(cModel)) + cmd_util.WriteToCocaFile("apis.json", string(cModel)) } func replacePackage(content string) string { diff --git a/cmd/bs.go b/cmd/bs.go index 0d6d65f5ac72f340318e03f2a1631f27fd28f8f1..a52c0732011ac6110bfe0e8a25e31f9c88a00ee2 100644 --- a/cmd/bs.go +++ b/cmd/bs.go @@ -2,9 +2,9 @@ package cmd import ( "encoding/json" + "github.com/phodal/coca/cmd/cmd_util" bs2 "github.com/phodal/coca/core/context/bs" "github.com/phodal/coca/core/domain/bs_domain" - "github.com/phodal/coca/core/infrastructure/coca_file" "github.com/phodal/coca/core/infrastructure/string_helper" "github.com/spf13/cobra" "strings" @@ -39,7 +39,7 @@ var badsmellCmd = &cobra.Command{ bsModel, _ = json.MarshalIndent(sortSmells, "", "\t") } - coca_file.WriteToCocaFile("bs.json", string(bsModel)) + cmd_util.WriteToCocaFile("bs.json", string(bsModel)) }, } diff --git a/cmd/call.go b/cmd/call.go index 82c844df956598e55468396dba7573b33c221f35..ea92c67fd99fcbfe23e1717955aa234bb5f57700 100644 --- a/cmd/call.go +++ b/cmd/call.go @@ -6,7 +6,6 @@ import ( "github.com/phodal/coca/cmd/config" . "github.com/phodal/coca/core/context/call" "github.com/phodal/coca/core/domain" - "github.com/phodal/coca/core/infrastructure/coca_file" "github.com/spf13/cobra" "log" "strings" @@ -33,7 +32,7 @@ var callGraphCmd = &cobra.Command{ if dependence != "" { analyser := NewCallGraph() - file := coca_file.ReadFile(dependence) + file := cmd_util.ReadFile(dependence) if file == nil { log.Fatal("lost file:" + dependence) } @@ -45,7 +44,7 @@ var callGraphCmd = &cobra.Command{ content = strings.ReplaceAll(content, remove, "") } - coca_file.WriteToCocaFile("call.dot", content) + cmd_util.WriteToCocaFile("call.dot", content) cmd_util.ConvertToSvg("call") } }, diff --git a/cmd/cmd_util/file.go b/cmd/cmd_util/file.go index e2d2bf6f80790aec1725512940a6f743b719fe88..e7fda9ae0667db620c46508b3d030a4a0c629f46 100644 --- a/cmd/cmd_util/file.go +++ b/cmd/cmd_util/file.go @@ -5,14 +5,13 @@ import ( "fmt" "github.com/phodal/coca/cmd/config" "github.com/phodal/coca/core/domain" - "github.com/phodal/coca/core/infrastructure/coca_file" "log" "os/exec" ) func GetDepsFromJson(depPath string) []domain.JClassNode { var parsedDeps []domain.JClassNode - file := coca_file.ReadFile(depPath) + file := ReadFile(depPath) if file == nil { log.Fatal("lost file:" + depPath) } diff --git a/core/infrastructure/coca_file/file_helper.go b/cmd/cmd_util/file_rw_helper.go similarity index 97% rename from core/infrastructure/coca_file/file_helper.go rename to cmd/cmd_util/file_rw_helper.go index 22893fb04ab29dc0a948658cb5cdc4a4bd61010b..5401307bda0b4ce2c289fcc4b57454de1fa488e8 100644 --- a/core/infrastructure/coca_file/file_helper.go +++ b/cmd/cmd_util/file_rw_helper.go @@ -1,4 +1,4 @@ -package coca_file +package cmd_util import ( "fmt" diff --git a/cmd/concept.go b/cmd/concept.go index ecce6acf79747a2b2fbd8dbdc78a081b0a24079f..732725039f6227412db2303ebac47cb458b0e067 100644 --- a/cmd/concept.go +++ b/cmd/concept.go @@ -3,10 +3,10 @@ package cmd import ( "encoding/json" "github.com/olekukonko/tablewriter" + "github.com/phodal/coca/cmd/cmd_util" "github.com/phodal/coca/cmd/config" "github.com/phodal/coca/core/context/concept" "github.com/phodal/coca/core/domain" - "github.com/phodal/coca/core/infrastructure/coca_file" "github.com/spf13/cobra" "log" "os" @@ -24,7 +24,7 @@ var conceptCmd = &cobra.Command{ if dependence != "" { analyser := concept.NewConceptAnalyser() - file := coca_file.ReadFile(dependence) + file := cmd_util.ReadFile(dependence) if file == nil { log.Fatal("lost file:" + dependence) } diff --git a/cmd/count.go b/cmd/count.go index 4b0414e21de84c1d9b202f9ff267063cf8211227..214c741659d563eaee6f5b4bddc20b4d2c8766e5 100644 --- a/cmd/count.go +++ b/cmd/count.go @@ -3,10 +3,10 @@ package cmd import ( "encoding/json" "github.com/olekukonko/tablewriter" + "github.com/phodal/coca/cmd/cmd_util" "github.com/phodal/coca/cmd/config" "github.com/phodal/coca/core/context/count" "github.com/phodal/coca/core/domain" - "github.com/phodal/coca/core/infrastructure/coca_file" "github.com/phodal/coca/core/infrastructure/string_helper" "github.com/spf13/cobra" "log" @@ -35,7 +35,7 @@ var countCmd = &cobra.Command{ return } - file := coca_file.ReadFile(dependence) + file := cmd_util.ReadFile(dependence) if file == nil { log.Fatal("lost file:" + dependence) } diff --git a/cmd/evaluate.go b/cmd/evaluate.go index fad887c15ed0a816b8f48661bb5f25d732bfa3bc..99a5abad2fd2d2615087a440878543c678e2eb9f 100644 --- a/cmd/evaluate.go +++ b/cmd/evaluate.go @@ -4,10 +4,10 @@ import ( "encoding/json" "fmt" "github.com/olekukonko/tablewriter" + "github.com/phodal/coca/cmd/cmd_util" "github.com/phodal/coca/cmd/config" "github.com/phodal/coca/core/context/evaluate" "github.com/phodal/coca/core/domain" - "github.com/phodal/coca/core/infrastructure/coca_file" "github.com/spf13/cobra" "log" "os" @@ -30,13 +30,13 @@ var evaluateCmd = &cobra.Command{ dependence := *&evaluateConfig.DependencePath analyser := evaluate.NewEvaluateAnalyser() - file := coca_file.ReadFile(dependence) + file := cmd_util.ReadFile(dependence) if file == nil { log.Fatal("lost file:" + dependence) } var identifiers []domain.JIdentifier - identContent := coca_file.ReadCocaFile("identify.json") + identContent := cmd_util.ReadCocaFile("identify.json") _ = json.Unmarshal(identContent, &identifiers) _ = json.Unmarshal(file, &parsedDeps) @@ -44,7 +44,7 @@ var evaluateCmd = &cobra.Command{ result := analyser.Analysis(parsedDeps, identifiers) cModel, _ := json.MarshalIndent(result, "", "\t") - coca_file.WriteToCocaFile("evaluate.json", string(cModel)) + cmd_util.WriteToCocaFile("evaluate.json", string(cModel)) table := tablewriter.NewWriter(os.Stdout) table.SetHeader([]string{"Type", "Count", "Level", "Total", "Rate"}) diff --git a/cmd/git.go b/cmd/git.go index 30f52c3caf56b7879a58bef3ef6b1e404afca358..e526a1bdc6d6998f4e70dc434c02daf4ddf2a59c 100644 --- a/cmd/git.go +++ b/cmd/git.go @@ -4,8 +4,8 @@ import ( "encoding/json" "fmt" "github.com/olekukonko/tablewriter" + "github.com/phodal/coca/cmd/cmd_util" . "github.com/phodal/coca/core/context/git" - "github.com/phodal/coca/core/infrastructure/coca_file" "github.com/spf13/cobra" "io/ioutil" "log" @@ -33,7 +33,7 @@ var gitCmd = &cobra.Command{ message := getCommitMessage() commitMessages := BuildMessageByInput(message) cModel, _ := json.MarshalIndent(commitMessages, "", "\t") - coca_file.WriteToCocaFile("commits.json", string(cModel)) + cmd_util.WriteToCocaFile("commits.json", string(cModel)) if *&gitCmdConfig.ShowSummary { ShowChangeLogSummary(commitMessages) diff --git a/cmd/rcall.go b/cmd/rcall.go index 35b44e3fde3c65f737c6d2da775185c00aa8012b..ab3a87c7c3d0ea52f9a78ad931d85117afec9d1c 100644 --- a/cmd/rcall.go +++ b/cmd/rcall.go @@ -6,7 +6,6 @@ import ( "github.com/phodal/coca/cmd/cmd_util" "github.com/phodal/coca/cmd/config" "github.com/phodal/coca/core/context/rcall" - "github.com/phodal/coca/core/infrastructure/coca_file" "github.com/spf13/cobra" "log" "strings" @@ -36,7 +35,7 @@ var reverseCmd = &cobra.Command{ } analyser := rcall.NewRCallGraph() - file := coca_file.ReadFile(dependence) + file := cmd_util.ReadFile(dependence) if file == nil { log.Fatal("lost file:" + dependence) } @@ -50,7 +49,7 @@ var reverseCmd = &cobra.Command{ content = strings.ReplaceAll(content, remove, "") } - coca_file.WriteToCocaFile("rcall.dot", content) + cmd_util.WriteToCocaFile("rcall.dot", content) cmd_util.ConvertToSvg("call") }, } diff --git a/cmd/refactor.go b/cmd/refactor.go index 915ca44f700af7223da6d708d4d92212f15ccb08..1020c025afd26da6421f6accadf50b09c84d1aaa 100644 --- a/cmd/refactor.go +++ b/cmd/refactor.go @@ -2,11 +2,11 @@ package cmd import ( "encoding/json" + "github.com/phodal/coca/cmd/cmd_util" "github.com/phodal/coca/cmd/config" . "github.com/phodal/coca/core/context/refactor/move_class" . "github.com/phodal/coca/core/context/refactor/rename" . "github.com/phodal/coca/core/context/refactor/unused" - "github.com/phodal/coca/core/infrastructure/coca_file" "github.com/spf13/cobra" ) @@ -30,7 +30,7 @@ var refactorCmd = &cobra.Command{ } if dependence != "" && rename != "" { - file := coca_file.ReadFile(dependence) + file := cmd_util.ReadFile(dependence) if file == nil { return } diff --git a/cmd/suggest.go b/cmd/suggest.go index dd075bcd977fcbbbd738a723d706fd6056108413..37ab366ce5001e48bde168dd1cb8dc00c7fc1dcf 100644 --- a/cmd/suggest.go +++ b/cmd/suggest.go @@ -3,9 +3,9 @@ package cmd import ( "encoding/json" "github.com/olekukonko/tablewriter" + "github.com/phodal/coca/cmd/cmd_util" "github.com/phodal/coca/cmd/config" "github.com/phodal/coca/core/context/suggest" - "github.com/phodal/coca/core/infrastructure/coca_file" "github.com/spf13/cobra" "log" "os" @@ -21,7 +21,7 @@ var suggestCmd = &cobra.Command{ Long: ``, Run: func(cmd *cobra.Command, args []string) { parsedDeps = nil - depFile := coca_file.ReadFile(apiCmdConfig.DependencePath) + depFile := cmd_util.ReadFile(apiCmdConfig.DependencePath) if depFile == nil { log.Fatal("lost deps") } diff --git a/cmd/tbs.go b/cmd/tbs.go index 38594fbafed440355dc6b7475ec10a52265d753a..744472e4475bda8844a19bb5bba0f6275ab7ff41 100644 --- a/cmd/tbs.go +++ b/cmd/tbs.go @@ -4,11 +4,12 @@ import ( "encoding/json" "fmt" "github.com/olekukonko/tablewriter" + "github.com/phodal/coca/cmd/cmd_util" + "github.com/phodal/coca/core/adapter/coca_file" "github.com/phodal/coca/core/context/analysis" "github.com/phodal/coca/core/context/tbs" "github.com/phodal/coca/core/domain" "github.com/phodal/coca/core/infrastructure/ast" - "github.com/phodal/coca/core/infrastructure/coca_file" "github.com/spf13/cobra" "os" "strconv" @@ -43,7 +44,7 @@ var tbsCmd = &cobra.Command{ classNodes := analysisApp.AnalysisFiles(identifiers, files, classes) nodeContent, _ := json.MarshalIndent(classNodes, "", "\t") - coca_file.WriteToCocaFile("tdeps.json", string(nodeContent)) + cmd_util.WriteToCocaFile("tdeps.json", string(nodeContent)) app := tbs.NewTbsApp() result := app.AnalysisPath(classNodes, identifiersMap) @@ -60,7 +61,7 @@ var tbsCmd = &cobra.Command{ resultContent, _ = json.MarshalIndent(tbsMap, "", "\t") } - coca_file.WriteToCocaFile("tbs.json", string(resultContent)) + cmd_util.WriteToCocaFile("tbs.json", string(resultContent)) if len(result) <= 20 { table := tablewriter.NewWriter(os.Stdout) diff --git a/cmd/todo.go b/cmd/todo.go index 0dd6e5dad70f96dcfb780140f2967bcc6864a7ec..1d0928dfa5c3ddc48ac9d59c09663f564211788e 100644 --- a/cmd/todo.go +++ b/cmd/todo.go @@ -4,8 +4,8 @@ import ( "encoding/json" "fmt" "github.com/olekukonko/tablewriter" + "github.com/phodal/coca/cmd/cmd_util" "github.com/phodal/coca/core/context/todo" - "github.com/phodal/coca/core/infrastructure/coca_file" "github.com/spf13/cobra" "os" "strings" @@ -30,7 +30,7 @@ var todoCmd = &cobra.Command{ todos := app.AnalysisPath(path) simple, _ := json.MarshalIndent(todos, "", "\t") - coca_file.WriteToCocaFile("simple-todos.json", string(simple)) + cmd_util.WriteToCocaFile("simple-todos.json", string(simple)) fmt.Println("Todos Count", len(todos)) @@ -38,7 +38,7 @@ var todoCmd = &cobra.Command{ gitTodos := app.BuildWithGitHistory(todos) cModel, _ := json.MarshalIndent(todos, "", "\t") - coca_file.WriteToCocaFile("todos.json", string(cModel)) + cmd_util.WriteToCocaFile("todos.json", string(cModel)) table := tablewriter.NewWriter(os.Stdout) table.SetHeader([]string{"Date", "Author", "Messages", "FileName", "Line"}) diff --git a/core/infrastructure/coca_file/file_analysis_helper.go b/core/adapter/coca_file/file_analysis_helper.go similarity index 100% rename from core/infrastructure/coca_file/file_analysis_helper.go rename to core/adapter/coca_file/file_analysis_helper.go diff --git a/core/context/analysis/java_full_app.go b/core/context/analysis/java_full_app.go index cc94ad9f01b5b8104b8ba7f846371a1d188b5eb6..26984d4e0b8b86ace8608695b61861e898e55d60 100644 --- a/core/context/analysis/java_full_app.go +++ b/core/context/analysis/java_full_app.go @@ -3,9 +3,9 @@ package analysis import ( "fmt" "github.com/antlr/antlr4/runtime/Go/antlr" + "github.com/phodal/coca/core/adapter/coca_file" "github.com/phodal/coca/core/domain" "github.com/phodal/coca/core/infrastructure/ast/full" - "github.com/phodal/coca/core/infrastructure/coca_file" "path/filepath" ) diff --git a/core/context/analysis/java_identifier_app.go b/core/context/analysis/java_identifier_app.go index fd93561984d20e4de003686a2897a43d11d3f093..f4ecf5b8f41a5cd979e143c90f90eecab7a25422 100644 --- a/core/context/analysis/java_identifier_app.go +++ b/core/context/analysis/java_identifier_app.go @@ -2,9 +2,9 @@ package analysis import ( "github.com/antlr/antlr4/runtime/Go/antlr" + "github.com/phodal/coca/core/adapter/coca_file" "github.com/phodal/coca/core/domain" "github.com/phodal/coca/core/infrastructure/ast/identifier" - "github.com/phodal/coca/core/infrastructure/coca_file" ) diff --git a/core/context/api/java_api_app.go b/core/context/api/java_api_app.go index 8f3988524ac30c4245809896f4590f352b90c6db..31f75c48856a9f0f78a6081cfdf63538ff0b998b 100644 --- a/core/context/api/java_api_app.go +++ b/core/context/api/java_api_app.go @@ -3,9 +3,9 @@ package api import ( "fmt" "github.com/antlr/antlr4/runtime/Go/antlr" + "github.com/phodal/coca/core/adapter/coca_file" "github.com/phodal/coca/core/domain" "github.com/phodal/coca/core/infrastructure/ast/api" - "github.com/phodal/coca/core/infrastructure/coca_file" "path/filepath" ) diff --git a/core/context/arch/arch_app_test.go b/core/context/arch/arch_app_test.go index bf991652236d192d59b1c2096880542eed9b60fb..37a3427563dabc04a1ab28515f1c90da7de57993 100644 --- a/core/context/arch/arch_app_test.go +++ b/core/context/arch/arch_app_test.go @@ -3,10 +3,10 @@ package arch import ( "encoding/json" . "github.com/onsi/gomega" + "github.com/phodal/coca/cmd/cmd_util" "github.com/phodal/coca/core/context/analysis" "github.com/phodal/coca/core/context/arch/tequila" "github.com/phodal/coca/core/domain" - "github.com/phodal/coca/core/infrastructure/coca_file" "io" "path/filepath" "reflect" @@ -48,7 +48,7 @@ func TestConceptAnalyser_Analysis(t *testing.T) { g.Expect(len(graph.SubGraphs.SubGraphs)).To(Equal(3)) jsonContent, _ := json.MarshalIndent(results, "", "\t") - content := coca_file.ReadFile(filepath.FromSlash(codePath + "/" + "results.json")) + content := cmd_util.ReadFile(filepath.FromSlash(codePath + "/" + "results.json")) g.Expect(JSONBytesEqual(jsonContent, content)).To(Equal(true)) } diff --git a/core/context/bs/bad_smell_app.go b/core/context/bs/bad_smell_app.go index 413383c069de84200dec04714c96cbdc745f700b..b8f8ca0af9548e69d0dfd7cf2840fe845eb82565 100644 --- a/core/context/bs/bad_smell_app.go +++ b/core/context/bs/bad_smell_app.go @@ -4,9 +4,10 @@ import ( "encoding/json" "fmt" "github.com/antlr/antlr4/runtime/Go/antlr" + "github.com/phodal/coca/cmd/cmd_util" + "github.com/phodal/coca/core/adapter/coca_file" "github.com/phodal/coca/core/domain/bs_domain" "github.com/phodal/coca/core/infrastructure/ast/bs" - "github.com/phodal/coca/core/infrastructure/coca_file" "path/filepath" ) @@ -42,7 +43,7 @@ func (j *BadSmellApp) AnalysisPath(codeDir string, ignoreRules []string) []bs_do } bsModel, _ := json.MarshalIndent(nodeInfos, "", "\t") - coca_file.WriteToCocaFile("nodeInfos.json", string(bsModel)) + cmd_util.WriteToCocaFile("nodeInfos.json", string(bsModel)) bsList := AnalysisBadSmell(nodeInfos) diff --git a/core/context/call/call_graph_test.go b/core/context/call/call_graph_test.go index 70e56c6b329f41a64b9b099b2f3a5ef68e136c2f..f2a8771597b26673e21512eefc79759d4ed91456 100644 --- a/core/context/call/call_graph_test.go +++ b/core/context/call/call_graph_test.go @@ -3,9 +3,9 @@ package call_test import ( "encoding/json" . "github.com/onsi/gomega" + "github.com/phodal/coca/cmd/cmd_util" "github.com/phodal/coca/core/context/call" "github.com/phodal/coca/core/domain" - "github.com/phodal/coca/core/infrastructure/coca_file" "path/filepath" "testing" ) @@ -19,7 +19,7 @@ func Test_should_generate_correct_files(t *testing.T) { codePath := "../../../_fixtures/call/call_api_test.json" codePath = filepath.FromSlash(codePath) - file := coca_file.ReadFile(codePath) + file := cmd_util.ReadFile(codePath) _ = json.Unmarshal(file, &parsedDeps) dotContent := analyser.Analysis("com.phodal.pholedge.book.BookController.createBook", *&parsedDeps) diff --git a/core/context/concept/concept_analyser_test.go b/core/context/concept/concept_analyser_test.go index ea32b86db80af5c6d843024d6aad0cf63993b7e2..408fe180e2e3fcc069cc1072b921f43a696cf24f 100644 --- a/core/context/concept/concept_analyser_test.go +++ b/core/context/concept/concept_analyser_test.go @@ -2,8 +2,8 @@ package concept import ( "encoding/json" + "github.com/phodal/coca/cmd/cmd_util" "github.com/phodal/coca/core/domain" - "github.com/phodal/coca/core/infrastructure/coca_file" "log" "path/filepath" "testing" @@ -19,7 +19,7 @@ func TestConceptAnalyser_Analysis(t *testing.T) { codePath := "../../../_fixtures/call/call_api_test.json" codePath = filepath.FromSlash(codePath) - file := coca_file.ReadFile(codePath) + file := cmd_util.ReadFile(codePath) if file == nil { log.Fatal("lost file") } diff --git a/core/context/count/count_app_test.go b/core/context/count/count_app_test.go index 90aa8b14bd4de1ccf2877707757441e98dce3127..92fa4bc9cef5d0c52e85dbfee30a5a8818c5170d 100644 --- a/core/context/count/count_app_test.go +++ b/core/context/count/count_app_test.go @@ -3,8 +3,8 @@ package count import ( "encoding/json" . "github.com/onsi/gomega" + "github.com/phodal/coca/cmd/cmd_util" "github.com/phodal/coca/core/domain" - "github.com/phodal/coca/core/infrastructure/coca_file" "path/filepath" "testing" ) @@ -14,7 +14,7 @@ func TestBuildCallMap(t *testing.T) { var parsedDeps []domain.JClassNode codePath := "../../../_fixtures/count/call.json" codePath = filepath.FromSlash(codePath) - file := coca_file.ReadFile(codePath) + file := cmd_util.ReadFile(codePath) _ = json.Unmarshal(file, &parsedDeps) callMap := BuildCallMap(parsedDeps) diff --git a/core/context/evaluate/analyser_test.go b/core/context/evaluate/analyser_test.go index f200faecf763dc8dfd85f1d50b0be2bb5c4f6867..84f82d2a97cdadb16255d5032d95711a25c71829 100644 --- a/core/context/evaluate/analyser_test.go +++ b/core/context/evaluate/analyser_test.go @@ -3,10 +3,10 @@ package evaluate import ( "encoding/json" . "github.com/onsi/gomega" + "github.com/phodal/coca/cmd/cmd_util" "github.com/phodal/coca/core/context/analysis" "github.com/phodal/coca/core/context/evaluate/evaluator" "github.com/phodal/coca/core/domain" - "github.com/phodal/coca/core/infrastructure/coca_file" "path/filepath" "testing" ) @@ -18,7 +18,7 @@ func TestAnalyser_Analysis(t *testing.T) { analyser := NewEvaluateAnalyser() codePath := "../../../_fixtures/evaluate/service.json" codePath = filepath.FromSlash(codePath) - file := coca_file.ReadFile(codePath) + file := cmd_util.ReadFile(codePath) _ = json.Unmarshal(file, &parsedDeps) analyser.Analysis(parsedDeps, nil) @@ -33,7 +33,7 @@ func Test_Service_LifeCycle(t *testing.T) { analyser := NewEvaluateAnalyser() codePath := "../../../_fixtures/evaluate/service_lifecycle.json" codePath = filepath.FromSlash(codePath) - file := coca_file.ReadFile(codePath) + file := cmd_util.ReadFile(codePath) _ = json.Unmarshal(file, &parsedDeps) result := analyser.Analysis(parsedDeps, nil) @@ -50,7 +50,7 @@ func Test_Service_Same_Return_Type(t *testing.T) { analyser := NewEvaluateAnalyser() codePath := "../../../_fixtures/evaluate/service_same_return_type.json" codePath = filepath.FromSlash(codePath) - file := coca_file.ReadFile(codePath) + file := cmd_util.ReadFile(codePath) _ = json.Unmarshal(file, &parsedDeps) results := analyser.Analysis(parsedDeps, nil) @@ -65,7 +65,7 @@ func Test_Long_Parameters(t *testing.T) { analyser := NewEvaluateAnalyser() codePath := "../../../_fixtures/evaluate/service_long_parameters.json" codePath = filepath.FromSlash(codePath) - file := coca_file.ReadFile(codePath) + file := cmd_util.ReadFile(codePath) _ = json.Unmarshal(file, &parsedDeps) result := analyser.Analysis(parsedDeps, nil) diff --git a/core/context/rcall/rcall_graph.go b/core/context/rcall/rcall_graph.go index 8966ebf96ebc3614b74e794bd70794383eaa5c91..b839e6efde61266265d3b817be40ef818cf892d9 100644 --- a/core/context/rcall/rcall_graph.go +++ b/core/context/rcall/rcall_graph.go @@ -2,9 +2,9 @@ package rcall import ( "encoding/json" + "github.com/phodal/coca/cmd/cmd_util" "github.com/phodal/coca/core/context/call" "github.com/phodal/coca/core/domain" - "github.com/phodal/coca/core/infrastructure/coca_file" ) type RCallGraph struct { @@ -19,7 +19,7 @@ func (c RCallGraph) Analysis(funcName string, clzs []domain.JClassNode) string { rcallMap := BuildRCallMethodMap(clzs, projectMethodMap) mapJson, _ := json.MarshalIndent(rcallMap, "", "\t") - coca_file.WriteToCocaFile("rcallmap.json", string(mapJson)) + cmd_util.WriteToCocaFile("rcallmap.json", string(mapJson)) chain := c.buildRCallChain(funcName, rcallMap) diff --git a/core/context/rcall/rcall_graph_test.go b/core/context/rcall/rcall_graph_test.go index f99d1d32afe46b0be25f46f5249b2edc259e05b4..a06b8eed340c5c27c7fced3acd26926e04122d49 100644 --- a/core/context/rcall/rcall_graph_test.go +++ b/core/context/rcall/rcall_graph_test.go @@ -2,8 +2,8 @@ package rcall import ( "encoding/json" + "github.com/phodal/coca/cmd/cmd_util" "github.com/phodal/coca/core/domain" - "github.com/phodal/coca/core/infrastructure/coca_file" "log" "testing" @@ -15,7 +15,7 @@ func TestRCallGraph_Analysis(t *testing.T) { var parsedDeps []domain.JClassNode analyser := NewRCallGraph() - file := coca_file.ReadFile("../../../_fixtures/call/call_api_test.json") + file := cmd_util.ReadFile("../../../_fixtures/call/call_api_test.json") if file == nil { log.Fatal("lost file") } diff --git a/core/context/refactor/move_class/move_class_app.go b/core/context/refactor/move_class/move_class_app.go index c5377de20f2e7c66325beff3348c14e200a974a6..65c4e840240bb314e75c38604293f17e2789105e 100644 --- a/core/context/refactor/move_class/move_class_app.go +++ b/core/context/refactor/move_class/move_class_app.go @@ -4,9 +4,9 @@ import ( "bufio" "fmt" "github.com/antlr/antlr4/runtime/Go/antlr" + "github.com/phodal/coca/core/adapter/coca_file" base2 "github.com/phodal/coca/core/context/refactor/base" models2 "github.com/phodal/coca/core/context/refactor/base/models" - "github.com/phodal/coca/core/infrastructure/coca_file" "io" "io/ioutil" "log" diff --git a/core/context/refactor/rename/rename_method.go b/core/context/refactor/rename/rename_method.go index 5eea0e427589da162f90212dee225b82e517687e..4bf1bef3796f30e23a3ba84f4bbd62ff2c52b66e 100644 --- a/core/context/refactor/rename/rename_method.go +++ b/core/context/refactor/rename/rename_method.go @@ -1,9 +1,9 @@ package unused import ( + "github.com/phodal/coca/cmd/cmd_util" support3 "github.com/phodal/coca/core/context/refactor/rename/support" . "github.com/phodal/coca/core/domain" - "github.com/phodal/coca/core/infrastructure/coca_file" "io/ioutil" "log" "strings" @@ -25,7 +25,7 @@ func RenameMethodApp(deps []JClassNode, p string) *RemoveMethodApp { } func (j *RemoveMethodApp) Start() { - configBytes := coca_file.ReadFile(configPath) + configBytes := cmd_util.ReadFile(configPath) if configBytes == nil { return } diff --git a/core/context/refactor/unused/remove_unused_import.go b/core/context/refactor/unused/remove_unused_import.go index 35afb393a39e9e81a4b6dc8d8bd8c4a3ced38dcc..dddbeafe306db0b87445f5fb60ff81916a91a11f 100644 --- a/core/context/refactor/unused/remove_unused_import.go +++ b/core/context/refactor/unused/remove_unused_import.go @@ -3,9 +3,9 @@ package unused import ( "fmt" "github.com/antlr/antlr4/runtime/Go/antlr" + "github.com/phodal/coca/core/adapter/coca_file" base2 "github.com/phodal/coca/core/context/refactor/base" models2 "github.com/phodal/coca/core/context/refactor/base/models" - "github.com/phodal/coca/core/infrastructure/coca_file" "io/ioutil" "os" "path/filepath" diff --git a/core/context/refactor/unused_classes/unused_classes_app_test.go b/core/context/refactor/unused_classes/unused_classes_app_test.go index cf50b1c4f8e3a2fdbf3cc4a678428a5b75c8f00f..e625cc865a84cbc4d745377303f8b2686747c4f2 100644 --- a/core/context/refactor/unused_classes/unused_classes_app_test.go +++ b/core/context/refactor/unused_classes/unused_classes_app_test.go @@ -3,8 +3,8 @@ package unused_classes import ( "encoding/json" . "github.com/onsi/gomega" + "github.com/phodal/coca/cmd/cmd_util" "github.com/phodal/coca/core/domain" - "github.com/phodal/coca/core/infrastructure/coca_file" "path/filepath" "testing" ) @@ -16,7 +16,7 @@ func TestRefactoring(t *testing.T) { var parsedDeps []domain.JClassNode codePath := "../../../../_fixtures/count/call.json" codePath = filepath.FromSlash(codePath) - file := coca_file.ReadFile(codePath) + file := cmd_util.ReadFile(codePath) _ = json.Unmarshal(file, &parsedDeps) results := Refactoring(parsedDeps) diff --git a/core/context/suggest/suggest_app_test.go b/core/context/suggest/suggest_app_test.go index 99a4390a788e0d43f2986aa14e53541f4435ec48..c1f115de09eb1e880ede7e0cdb9b202b0623c3e0 100644 --- a/core/context/suggest/suggest_app_test.go +++ b/core/context/suggest/suggest_app_test.go @@ -2,8 +2,8 @@ package suggest import ( "encoding/json" + "github.com/phodal/coca/cmd/cmd_util" "github.com/phodal/coca/core/domain" - "github.com/phodal/coca/core/infrastructure/coca_file" "log" "path/filepath" "testing" @@ -18,7 +18,7 @@ func TestConceptAnalyser_Analysis(t *testing.T) { analyser := NewSuggestApp() codePath := "../../../_fixtures/suggest/factory/factory_suggest.json" codePath = filepath.FromSlash(codePath) - file := coca_file.ReadFile(codePath) + file := cmd_util.ReadFile(codePath) if file == nil { log.Fatal("lost file") } diff --git a/core/context/tbs/tbs_app_test.go b/core/context/tbs/tbs_app_test.go index 5b60f8ec0c35ea649619fe5d2cd6be8b75feecf2..f5c626727dab5455d36e893ea923df9a1da99c7f 100644 --- a/core/context/tbs/tbs_app_test.go +++ b/core/context/tbs/tbs_app_test.go @@ -2,10 +2,10 @@ package tbs import ( . "github.com/onsi/gomega" + "github.com/phodal/coca/core/adapter/coca_file" "github.com/phodal/coca/core/context/analysis" "github.com/phodal/coca/core/domain" "github.com/phodal/coca/core/infrastructure/ast" - "github.com/phodal/coca/core/infrastructure/coca_file" "path/filepath" "testing" ) diff --git a/core/context/todo/todo_app.go b/core/context/todo/todo_app.go index 646e0fc4e02c62c62002a0f900c49408468e9b02..d3c82870cbbb91555aeabc29f00f35d3c924c739 100644 --- a/core/context/todo/todo_app.go +++ b/core/context/todo/todo_app.go @@ -3,10 +3,10 @@ package todo import ( "fmt" "github.com/antlr/antlr4/runtime/Go/antlr" + "github.com/phodal/coca/core/adapter/coca_file" "github.com/phodal/coca/core/adapter/shell" "github.com/phodal/coca/core/context/git" "github.com/phodal/coca/core/context/todo/astitodo" - "github.com/phodal/coca/core/infrastructure/coca_file" . "github.com/phodal/coca/languages/java" "path/filepath" "strconv" diff --git a/core/infrastructure/ast/ident_helper.go b/core/infrastructure/ast/ident_helper.go index 27040eaa5fc3bb45f8d56544657141544d44a016..47f59ea3fb333f4949f6a08da44711f67f60126e 100644 --- a/core/infrastructure/ast/ident_helper.go +++ b/core/infrastructure/ast/ident_helper.go @@ -2,21 +2,21 @@ package ast import ( "encoding/json" + "github.com/phodal/coca/cmd/cmd_util" "github.com/phodal/coca/core/context/analysis" "github.com/phodal/coca/core/domain" - "github.com/phodal/coca/core/infrastructure/coca_file" ) func LoadIdentify(importPath string) []domain.JIdentifier { var identifiers []domain.JIdentifier - apiContent := coca_file.ReadCocaFile("identify.json") + apiContent := cmd_util.ReadCocaFile("identify.json") if apiContent == nil || string(apiContent) == "null" { identifierApp := new(analysis.JavaIdentifierApp) ident := identifierApp.AnalysisPath(importPath) identModel, _ := json.MarshalIndent(ident, "", "\t") - coca_file.WriteToCocaFile("identify.json", string(identModel)) + cmd_util.WriteToCocaFile("identify.json", string(identModel)) return *&ident } @@ -28,14 +28,14 @@ func LoadIdentify(importPath string) []domain.JIdentifier { func LoadTestIdentify(files []string) []domain.JIdentifier { var identifiers []domain.JIdentifier - apiContent := coca_file.ReadCocaFile("tidentify.json") + apiContent := cmd_util.ReadCocaFile("tidentify.json") if apiContent == nil || string(apiContent) == "null" { identifierApp := analysis.NewJavaIdentifierApp() ident := identifierApp.AnalysisFiles(files) identModel, _ := json.MarshalIndent(ident, "", "\t") - coca_file.WriteToCocaFile("tidentify.json", string(identModel)) + cmd_util.WriteToCocaFile("tidentify.json", string(identModel)) return *&ident }