diff --git a/core/adapter/api/JavaApiListener.go b/core/adapter/api/JavaApiListener.go index 71d398070369bdcd0b6c3d8a79a705b6a4ab9a1d..eabb1979f97b1e8d8dbbd0980b26a9b2760264e3 100644 --- a/core/adapter/api/JavaApiListener.go +++ b/core/adapter/api/JavaApiListener.go @@ -38,7 +38,7 @@ var currentExtends = "" var currentImplements = "" var depInjectMap map[string]string -func NewJavaApiListener(ident map[string]models2.JIdentifier, diMap map[string]string) *JavaApiListener { +func NewJavaApiListener(jIdentMap map[string]models2.JIdentifier, diMap map[string]string) *JavaApiListener { isSpringRestController = false currentClz = "" currentPkg = "" @@ -47,7 +47,7 @@ func NewJavaApiListener(ident map[string]models2.JIdentifier, diMap map[string]s imports = nil - identMap = ident + identMap = jIdentMap depInjectMap = diMap params := make(map[string]string) diff --git a/core/adapter/identifier/JavaIdentifierApp.go b/core/adapter/identifier/JavaIdentifierApp.go index 478a781a025e777a797617c02fa5b35a11f05f40..da2682bed5bcd3c927e58fc6517891d38d6e426f 100644 --- a/core/adapter/identifier/JavaIdentifierApp.go +++ b/core/adapter/identifier/JavaIdentifierApp.go @@ -21,7 +21,7 @@ func (j *JavaIdentifierApp) AnalysisPath(codeDir string) []models.JIdentifier { context := parser.CompilationUnit() clzInfo := models.NewJIdentifier() - listener := new(JavaIdentifierListener) + listener := NewJavaIdentifierListener() listener.InitNode(clzInfo) antlr.NewParseTreeWalker().Walk(listener, context) diff --git a/core/adapter/identifier/JavaIdentifierListener.go b/core/adapter/identifier/JavaIdentifierListener.go index d3791d4bd4a1497eed5db4a02dfe4beca4a4bae4..4218f4c907f467fa1d22db0d6d9a7ace0c4aab30 100644 --- a/core/adapter/identifier/JavaIdentifierListener.go +++ b/core/adapter/identifier/JavaIdentifierListener.go @@ -14,6 +14,11 @@ var hasEnterClass = false var hasEnterMethod = false var imports []string +func NewJavaIdentifierListener() *JavaIdentifierListener { + hasEnterClass = false + return &JavaIdentifierListener{} +} + type JavaIdentifierListener struct { parser.BaseJavaParserListener } @@ -52,7 +57,7 @@ func (s *JavaIdentifierListener) EnterClassDeclaration(ctx *parser.ClassDeclarat } } -func (s *JavaIdentifierListener) ExitClassDeclaration(ctx *parser.ClassDeclarationContext) { +func (s *JavaIdentifierListener) ExitClassBody(ctx *parser.ClassBodyContext) { hasEnterClass = false } @@ -100,6 +105,7 @@ func (s *JavaIdentifierListener) ExitInterfaceMethodDeclaration(ctx *parser.Inte var isOverrideMethod = false func (s *JavaIdentifierListener) EnterMethodDeclaration(ctx *parser.MethodDeclarationContext) { + hasEnterClass = true hasEnterMethod = true startLine := ctx.GetStart().GetLine() @@ -169,6 +175,7 @@ func buildAnnotation(ctx *parser.AnnotationContext) models.Annotation { } func (s *JavaIdentifierListener) EnterInterfaceDeclaration(ctx *parser.InterfaceDeclarationContext) { + hasEnterClass = true node.Type = "Interface" node.ClassName = ctx.IDENTIFIER().GetText() }