From 71f7e0e9a0a87a3962bbdbf904427818515fd57d Mon Sep 17 00:00:00 2001 From: Phodal HUANG Date: Tue, 29 Oct 2019 21:39:45 +0800 Subject: [PATCH] fix: any import issue --- refactor/base/JavaRefactorListener.go | 5 +++-- refactor/unused/remove_unused_import.go | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/refactor/base/JavaRefactorListener.go b/refactor/base/JavaRefactorListener.go index 9d034a8..144abdf 100644 --- a/refactor/base/JavaRefactorListener.go +++ b/refactor/base/JavaRefactorListener.go @@ -3,7 +3,6 @@ package base import ( . "../../language/java" . "./models" - "fmt" ) var node *JFullIdentifier; @@ -24,6 +23,9 @@ func (s *JavaRefactorListener) EnterPackageDeclaration(ctx *PackageDeclarationCo func (s *JavaRefactorListener) EnterImportDeclaration(ctx *ImportDeclarationContext) { importText := ctx.QualifiedName().GetText() + if ctx.MUL() != nil { + importText = importText + ".*" + } startLine := ctx.GetStart().GetLine() stopLine := ctx.GetStop().GetLine() @@ -99,7 +101,6 @@ func (s *JavaRefactorListener) EnterLambdaParameters(ctx *LambdaParametersContex func (s *JavaRefactorListener) EnterMethodCall(ctx *MethodCallContext) { text := ctx.IDENTIFIER().GetText() - fmt.Println(ctx.IDENTIFIER().GetText(), "......") startLine := ctx.GetStart().GetLine() stopLine := ctx.GetStop().GetLine() field := &JField{text, node.Pkg, startLine, stopLine} diff --git a/refactor/unused/remove_unused_import.go b/refactor/unused/remove_unused_import.go index 2a1d1c1..622b56f 100644 --- a/refactor/unused/remove_unused_import.go +++ b/refactor/unused/remove_unused_import.go @@ -62,11 +62,12 @@ func handleNode(node *JFullIdentifier) { for index := range imports { imp := imports[index] ss := strings.Split(imp.Name, ".") + fmt.Println(ss) lastField := ss[len(ss)-1] var isOk = false for _, field := range fields { - if field.Name == lastField { + if field.Name == lastField || lastField == "*" { isOk = true } } -- GitLab