未验证 提交 cd5083db 编写于 作者: P Phodal HUANG

feat: move fiels

上级 05975f0c
......@@ -3,6 +3,7 @@ package base
import (
"fmt"
"github.com/antlr/antlr4/runtime/Go/antlr"
"io/ioutil"
"os"
"path/filepath"
"strings"
......@@ -45,15 +46,27 @@ func handleNode() {
var imports map[string]JImport = node.GetImports()
fmt.Println(node.Pkg+"."+node.Name, imports, node.GetMethods(), fields)
if len(fields) == 0 {
removeAllImports(imports)
//removeAllImports(imports)
return
}
for index := range fields {
field := fields[index]
fmt.Println(field)
}
//for index := range fields {
//field := fields[index]
//errorLine := 0
//
//for index := range imports {
// imp := imports[index]
// ss := strings.Split(imp.Name, ".")
// lastField := ss[len(ss)-1]
//
// if (lastField == field.Name) {
// continue
// } else {
//
// }
//}
//}
}
func removeAllImports(imports map[string]JImport) {
......@@ -64,7 +77,21 @@ func removeAllImports(imports map[string]JImport) {
}
func removeImportByLineNum(imp JImport) {
fmt.Println(currentFile, imp)
removeLine(currentFile, imp.StartLine - 1)
}
func removeLine(path string, lineNumber int) {
file, err := ioutil.ReadFile(path)
if err != nil {
panic(err)
}
info, _ := os.Stat(path)
mode := info.Mode()
array := strings.Split(string(file), "\n")
array = append(array[:lineNumber], array[lineNumber+1:]...)
_ = ioutil.WriteFile(path, []byte(strings.Join(array, "\n")), mode)
}
func (j *JavaRefactorApp) javaFiles(codeDir string) []string {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册