fix: fix api call not empty issue

上级 74643c80
......@@ -9,7 +9,7 @@ import (
func BuildAnalysisDeps(codePath string) ([]domain.JClassNode, map[string]domain.JIdentifier, []domain.JIdentifier) {
codePath = filepath.FromSlash(codePath)
identifierApp := new(analysis.JavaIdentifierApp)
identifierApp := analysis.NewJavaIdentifierApp()
identifiers := identifierApp.AnalysisPath(codePath)
var classes []string = nil
for _, node := range identifiers {
......
......@@ -16,6 +16,7 @@ type JavaApiApp struct {
func (j *JavaApiApp) AnalysisPath(codeDir string, parsedDeps []domain.JClassNode, identifiersMap map[string]domain.JIdentifier, diMap map[string]string) []domain.RestApi {
files := cocafile.GetJavaFiles(codeDir)
allApis = nil
for index := range files {
file := files[index]
......@@ -30,8 +31,9 @@ func (j *JavaApiApp) AnalysisPath(codeDir string, parsedDeps []domain.JClassNode
antlr.NewParseTreeWalker().Walk(listener, context)
allApis = listener.GetClassApis()
currentRestApis := listener.GetClassApis()
allApis = append(allApis, currentRestApis...)
}
return *&allApis
return allApis
}
......@@ -2,9 +2,8 @@ package api
import (
. "github.com/onsi/gomega"
"github.com/phodal/coca/core/context/analysis"
"github.com/phodal/coca/cocatest"
"github.com/phodal/coca/core/domain"
"path/filepath"
"testing"
)
......@@ -12,19 +11,7 @@ func TestJavaCallApp_AnalysisPath(t *testing.T) {
g := NewGomegaWithT(t)
codePath := "../../../_fixtures/call"
codePath = filepath.FromSlash(codePath)
identifierApp := new(analysis.JavaIdentifierApp)
identifiers := identifierApp.AnalysisPath(codePath)
var classes []string = nil
for _, node := range identifiers {
classes = append(classes, node.Package+"."+node.ClassName)
}
callApp := analysis.NewJavaFullApp()
callNodes := callApp.AnalysisPath(codePath, classes, identifiers)
identifiersMap := domain.BuildIdentifierMap(identifiers)
callNodes, identifiersMap, identifiers := cocatest.BuildAnalysisDeps(codePath)
diMap := domain.BuildDIMap(identifiers, identifiersMap)
app := new(JavaApiApp)
......
......@@ -306,7 +306,3 @@ func (s *JavaApiListener) AppendClasses(classes []models.JClassNode) {
func (s *JavaApiListener) GetClassApis() []models.RestApi {
return restApis
}
func (s *JavaApiListener) getCurrentApi() models.RestApi {
return currentRestApi
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册