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

feat: add rename update support

上级 46a5e905
......@@ -99,7 +99,7 @@ func (s *JavaCallListener) EnterMethodCall(ctx *MethodCallContext) {
startLine := ctx.GetStart().GetLine()
startLinePosition := ctx.GetStart().GetColumn()
stopLine := ctx.GetStop().GetLine()
stopLinePosition := ctx.GetStop().GetColumn()
stopLinePosition := startLinePosition + len(callee)
fullType := warpTargetFullType(targetType)
if fullType != "" {
......
......@@ -59,20 +59,29 @@ func startParse(nodes []JClassNode, relates []RefactorChangeRelate) {
if pkgNode.Package+pkgNode.Class == oldInfo.Package+oldInfo.Class {
for _, method := range pkgNode.Methods {
fmt.Println(method.Name, oldInfo.Method)
if method.Name == oldInfo.Method {
updateSelfRefs(pkgNode, method, newInfo)
}
}
}
//
//for methodCall := range pkgNode.MethodCalls {
//
//}
for _, methodCall := range pkgNode.MethodCalls {
fmt.Println(methodCall.Package+methodCall.Class, oldInfo.Package+oldInfo.Class)
if pkgNode.Package+pkgNode.Class == oldInfo.Package+oldInfo.Class {
if methodCall.MethodName == oldInfo.Method {
updateSelfRefs(pkgNode, *methodCallToMethodModel(methodCall), newInfo)
}
}
}
}
}
}
func methodCallToMethodModel(call JMethodCall) *JMethod {
return &JMethod{call.MethodName, call.StartLine, call.StartLinePosition, call.StopLine, call.StopLinePosition}
}
func updateSelfRefs(node JClassNode, method JMethod, info *PackageClassInfo) {
path := node.Path
input, err := ioutil.ReadFile(path)
......@@ -85,7 +94,6 @@ func updateSelfRefs(node JClassNode, method JMethod, info *PackageClassInfo) {
for i, line := range lines {
if i == method.StartLine-1 {
newLine := line[:method.StartLinePosition] + info.Method + line[method.StopLinePosition:]
fmt.Println(newLine)
lines[i] = newLine
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册