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

refactor: inline utils

上级 f39a6ec9
package unused
import (
"encoding/json"
. "coca/adapter/models"
. "coca/refactor/base/models"
"coca/refactor/rename/support"
. "coca/utils"
. "coca/utils/models"
"encoding/json"
"io/ioutil"
"log"
"strings"
)
var parsedChange []RefactorChangeRelate
var parsedChange []support.RefactorChangeRelate
var nodes []JMoveStruct
type RemoveMethodApp struct {
......@@ -44,17 +44,17 @@ func (j *RemoveMethodApp) Start() {
conf = string(configBytes)
parsedChange = ParseRelates(conf)
parsedChange = support.ParseRelates(conf)
startParse(parsedDeps, parsedChange)
}
func startParse(nodes []JClassNode, relates []RefactorChangeRelate) {
func startParse(nodes []JClassNode, relates []support.RefactorChangeRelate) {
for _, pkgNode := range nodes {
for _, related := range relates {
oldInfo := BuildMethodPackageInfo(related.OldObj)
newInfo := BuildMethodPackageInfo(related.NewObj)
oldInfo := support.BuildMethodPackageInfo(related.OldObj)
newInfo := support.BuildMethodPackageInfo(related.NewObj)
if pkgNode.Package+pkgNode.Class == oldInfo.Package+oldInfo.Class {
for _, method := range pkgNode.Methods {
......@@ -79,7 +79,7 @@ func methodCallToMethodModel(call JMethodCall) *JMethod {
return &JMethod{call.MethodName, call.Type, call.StartLine, call.StartLinePosition, call.StopLine, call.StopLinePosition, nil}
}
func updateSelfRefs(node JClassNode, method JMethod, info *PackageClassInfo) {
func updateSelfRefs(node JClassNode, method JMethod, info *support.PackageClassInfo) {
path := node.Path
input, err := ioutil.ReadFile(path)
if err != nil {
......
package utils
package support
import (
. "coca/utils/models"
"strings"
)
var relates []RefactorChangeRelate
......
package utils
package support
import (
. "coca/utils/models"
"strings"
)
......
package models
package support
type RefactorChangeRelate struct {
OldObj string
......
......@@ -44,27 +44,3 @@ func CopyFile(src, dst string) (int64, error) {
nBytes, err := io.Copy(destination, source)
return nBytes, err
}
func MoveFile(sourcePath, destPath string) error {
inputFile, err := os.Open(sourcePath)
if err != nil {
return fmt.Errorf("Couldn't open source file: %s", err)
}
outputFile, err := os.Create(destPath)
if err != nil {
inputFile.Close()
return fmt.Errorf("Couldn't open dest file: %s", err)
}
defer outputFile.Close()
_, err = io.Copy(outputFile, inputFile)
inputFile.Close()
if err != nil {
return fmt.Errorf("Writing to output file failed: %s", err)
}
// The copyFile was successful, so now delete the original file
err = os.Remove(sourcePath)
if err != nil {
return fmt.Errorf("Failed removing original file: %s", err)
}
return nil
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册