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

fix: fix auto remove issue

上级 039b357c
......@@ -3,8 +3,6 @@ package base
import (
. "../../language/java"
. "./models"
"github.com/antlr/antlr4/runtime/Go/antlr"
"strings"
)
var node *JFullIdentifier;
......@@ -36,28 +34,10 @@ func (s *JavaRefactorListener) EnterImportDeclaration(ctx *ImportDeclarationCont
func (s *JavaRefactorListener) EnterClassDeclaration(ctx *ClassDeclarationContext) {
node.Type = "Class"
node.Name = ctx.IDENTIFIER().GetText()
if ctx.IMPLEMENTS() != nil {
context := ctx.TypeList()
startLine := ctx.TypeList().GetStart().GetLine()
stopLine := ctx.TypeList().GetStart().GetLine()
split := strings.Split(context.GetText(), ",")
for _, imp := range split {
field := &JField{imp, node.Pkg, startLine, stopLine}
node.AddField(*field)
}
}
if ctx.EXTENDS() != nil {
startLine := ctx.TypeType().GetStart().GetLine()
stopLine := ctx.TypeType().GetStart().GetLine()
field := &JField{ctx.TypeType().GetText(), node.Pkg, startLine, stopLine}
node.AddField(*field)
}
}
func (s *JavaRefactorListener) EnterInterfaceMethodDeclaration(ctx *InterfaceMethodDeclarationContext) {
//fmt.Println(ctx.TypeTypeOrVoid())
startLine := ctx.GetStart().GetLine()
startLinePosition := ctx.GetStart().GetTokenSource().GetCharPositionInLine()
stopLine := ctx.GetStop().GetLine()
......@@ -68,96 +48,28 @@ func (s *JavaRefactorListener) EnterInterfaceMethodDeclaration(ctx *InterfaceMet
node.AddMethod(*method)
}
func (s *JavaRefactorListener) EnterMethodDeclaration(ctx *MethodDeclarationContext) {
startLine := ctx.GetStart().GetLine()
startLinePosition := ctx.GetStart().GetTokenSource().GetCharPositionInLine()
stopLine := ctx.GetStop().GetLine()
stopLinePosition := ctx.GetStop().GetTokenSource().GetCharPositionInLine()
name := ctx.IDENTIFIER().GetText()
//XXX: find the start position of {, not public
method := &JFullMethod{name, startLine, startLinePosition, stopLine, stopLinePosition}
node.AddMethod(*method)
}
func (s *JavaRefactorListener) EnterFieldDeclaration(ctx *FieldDeclarationContext) {
declarators := ctx.VariableDeclarators()
variableName := declarators.GetParent().GetChild(0).(antlr.ParseTree).GetText()
startLine := ctx.GetStart().GetLine()
stopLine := ctx.GetStop().GetLine()
text := ctx.TypeType().GetText()
if variableName != "" && text != "" {
field := &JField{variableName, node.Pkg, startLine, stopLine}
node.AddField(*field)
}
}
func (s *JavaRefactorListener) EnterAnnotation(ctx *AnnotationContext) {
annotation := ctx.QualifiedName().GetText()
startLine := ctx.GetStart().GetLine()
stopLine := ctx.GetStop().GetLine()
field := &JField{annotation, node.Pkg, startLine, stopLine}
node.AddField(*field)
}
func (s *JavaRefactorListener) EnterTypeDeclaration(ctx *TypeDeclarationContext) {
startLine := ctx.GetStart().GetLine()
stopLine := ctx.GetStop().GetLine()
field := &JField{"", node.Pkg, startLine, stopLine}
if ctx.InterfaceDeclaration() != nil {
field.Name = ctx.InterfaceDeclaration().GetText()
node.AddField(*field)
}
if ctx.EnumDeclaration() != nil {
field.Name = ctx.EnumDeclaration().GetText()
node.AddField(*field)
}
if ctx.AnnotationTypeDeclaration() != nil {
field.Name = ctx.AnnotationTypeDeclaration().GetText()
node.AddField(*field)
}
}
func (s *JavaRefactorListener) EnterLocalTypeDeclaration(ctx *LocalTypeDeclarationContext) {
startLine := ctx.GetStart().GetLine()
stopLine := ctx.GetStop().GetLine()
field := &JField{"", node.Pkg, startLine, stopLine}
if ctx.ClassDeclaration() != nil {
field.Name = ctx.ClassDeclaration().GetText()
}
if ctx.InterfaceDeclaration() != nil {
field.Name = ctx.InterfaceDeclaration().GetText()
}
node.AddField(*field)
}
func (s *JavaRefactorListener) EnterInterfaceDeclaration(ctx *InterfaceDeclarationContext) {
node.Type = "Interface"
node.Name = ctx.IDENTIFIER().GetText()
}
func (s *JavaRefactorListener) EnterTypeType(ctx *TypeTypeContext) {
startLine := ctx.GetStart().GetLine()
stopLine := ctx.GetStop().GetLine()
field := &JField{node.Name, node.Pkg, startLine, stopLine}
field := &JField{ctx.GetText(), node.Pkg, startLine, stopLine}
node.AddField(*field)
}
if ctx.TypeList() != nil {
context := ctx.TypeList()
startLine := ctx.TypeList().GetStart().GetLine()
stopLine := ctx.TypeList().GetStart().GetLine()
func (s *JavaRefactorListener) EnterClassOrInterfaceType(ctx *ClassOrInterfaceTypeContext) {
identifiers := ctx.AllIDENTIFIER()
for index, _ := range identifiers {
context := ctx.IDENTIFIER(index)
name := context.GetText()
startLine := ctx.GetStart().GetLine()
stopLine := ctx.GetStop().GetLine()
split := strings.Split(context.GetText(), ",")
for _, imp := range split {
field := &JField{imp, node.Pkg, startLine, stopLine}
node.AddField(*field)
}
field := &JField{name, node.Pkg, startLine, stopLine}
node.AddField(*field)
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册