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

feat: add basic import logic

上级 d92ea4bc
......@@ -11,6 +11,8 @@ import (
. "./models"
)
var currentFile string
type JavaRefactorApp struct {
}
......@@ -19,6 +21,7 @@ func (j *JavaRefactorApp) AnalysisPath(codeDir string) {
for index := range files {
file := files[index]
currentFile, _ = filepath.Abs(file)
displayName := filepath.Base(file)
fmt.Println("Start parse java call: " + displayName)
......@@ -32,14 +35,36 @@ func (j *JavaRefactorApp) AnalysisPath(codeDir string) {
antlr.NewParseTreeWalker().Walk(listener, context)
if node.Name != "" {
handleNode(node)
handleNode()
}
}
}
func handleNode(identifier *JFullIdentifier) {
fmt.Println(node.Pkg+"."+node.Name, node.GetImports(), node.GetMethods(), node.GetFields())
func handleNode() {
var fields map[string]JField = node.GetFields()
var imports map[string]JImport = node.GetImports()
fmt.Println(node.Pkg+"."+node.Name, imports, node.GetMethods(), fields)
if len(fields) == 0 {
removeAllImports(imports)
}
for index := range fields {
field := fields[index]
fmt.Println(field)
}
}
func removeAllImports(imports map[string]JImport) {
for index := range imports {
imp := imports[index]
removeImportByLineNum(imp)
}
}
func removeImportByLineNum(imp JImport) {
fmt.Println(currentFile, imp)
}
func (j *JavaRefactorApp) javaFiles(codeDir string) []string {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册