未验证 提交 8c05762f 编写于 作者: P Phodal Huang

fefactor: move file helper to cmd

上级 9314a956
......@@ -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))
},
}
......
......@@ -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 {
......
......@@ -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))
},
}
......
......@@ -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")
}
},
......
......@@ -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)
}
......
......@@ -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)
}
......
......@@ -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)
}
......
......@@ -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"})
......
......@@ -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)
......
......@@ -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")
},
}
......
......@@ -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
}
......
......@@ -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")
}
......
......@@ -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)
......
......@@ -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"})
......
......@@ -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"
)
......
......@@ -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"
)
......
......@@ -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"
)
......
......@@ -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))
}
......
......@@ -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)
......
......@@ -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)
......
......@@ -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")
}
......
......@@ -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)
......
......@@ -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)
......
......@@ -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)
......
......@@ -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")
}
......
......@@ -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"
......
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
}
......
......@@ -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"
......
......@@ -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)
......
......@@ -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")
}
......
......@@ -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"
)
......
......@@ -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"
......
......@@ -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
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册