diff --git a/cmd/evaluate_test.go b/cmd/evaluate_test.go index a639aace59fba6ecbf8afc5eaeae33d4fb710cb8..497c0fd7c96591452c31dbdb7b6f052be2efe4ad 100644 --- a/cmd/evaluate_test.go +++ b/cmd/evaluate_test.go @@ -5,11 +5,9 @@ import ( ) func TestEvaluate(t *testing.T) { - abs := "../_fixtures/arch" - analysis := []cmdTestCase{{ name: "analysis", - cmd: "analysis -p " + abs, + cmd: "analysis -p ../_fixtures/arch", golden: "", }} runTestCmd(t, analysis) diff --git a/core/infrastructure/ast/full/java_full_listener.go b/core/infrastructure/ast/full/java_full_listener.go index 2380e940498d499e3e115ce966dbcf2d9237f58e..1529c126cf365231e2d4e2f1caaaff9d496a3c23 100644 --- a/core/infrastructure/ast/full/java_full_listener.go +++ b/core/infrastructure/ast/full/java_full_listener.go @@ -510,10 +510,27 @@ func (s *JavaFullListener) EnterMethodCall(ctx *parser.MethodCallContext) { callee := ctx.GetChild(0).(antlr.ParseTree).GetText() - jMethodCall.StartLine = ctx.GetStart().GetLine() - jMethodCall.StartLinePosition = ctx.GetStart().GetColumn() - jMethodCall.StopLine = ctx.GetStop().GetLine() - jMethodCall.StopLinePosition = jMethodCall.StartLinePosition + len(callee) + buildMethodCallLocation(&jMethodCall, ctx, callee) + buildMethodCallMethod(&jMethodCall, callee, targetType, ctx) + buildMethodCallParameters(&jMethodCall, ctx) + + addMethodCallToMap(jMethodCall) +} + +func buildMethodCallParameters(jMethodCall *domain.JMethodCall, ctx *parser.MethodCallContext) { + if ctx.ExpressionList() != nil { + var parameters []string + for _, expression := range ctx.ExpressionList().(*parser.ExpressionListContext).AllExpression() { + expressionCtx := expression.(*parser.ExpressionContext) + parameters = append(parameters, expressionCtx.GetText()) + } + jMethodCall.Parameters = parameters + } +} + +func buildMethodCallMethod(jMethodCall *domain.JMethodCall, callee string, targetType string, ctx *parser.MethodCallContext) { + methodName := callee + packageName := currentPkg fullType, callType := warpTargetFullType(targetType) if targetType == "super" || callee == "super" { @@ -522,9 +539,6 @@ func (s *JavaFullListener) EnterMethodCall(ctx *parser.MethodCallContext) { } jMethodCall.Type = callType - methodName := callee - packageName := currentPkg - if fullType != "" { packageName = removeTarget(fullType) methodName = callee @@ -556,20 +570,16 @@ func (s *JavaFullListener) EnterMethodCall(ctx *parser.MethodCallContext) { jMethodCall.Package = packageName jMethodCall.MethodName = methodName jMethodCall.Class = targetType +} - if ctx.ExpressionList() != nil { - var parameters []string - for _, expression := range ctx.ExpressionList().(*parser.ExpressionListContext).AllExpression() { - expressionCtx := expression.(*parser.ExpressionContext) - parameters = append(parameters, expressionCtx.GetText()) - } - jMethodCall.Parameters = parameters - } - - addMethodCall(jMethodCall) +func buildMethodCallLocation(jMethodCall *domain.JMethodCall, ctx *parser.MethodCallContext, callee string) { + jMethodCall.StartLine = ctx.GetStart().GetLine() + jMethodCall.StartLinePosition = ctx.GetStart().GetColumn() + jMethodCall.StopLine = ctx.GetStop().GetLine() + jMethodCall.StopLinePosition = jMethodCall.StartLinePosition + len(callee) } -func addMethodCall(jMethodCall domain.JMethodCall) { +func addMethodCallToMap(jMethodCall domain.JMethodCall) { methodCalls = append(methodCalls, jMethodCall) method := methodMap[getMethodMapName(currentMethod)] @@ -644,7 +654,7 @@ func (s *JavaFullListener) EnterExpression(ctx *parser.ExpressionContext) { StopLine: stopLine, StopLinePosition: stopLinePosition, } - addMethodCall(*jMethodCall) + addMethodCallToMap(*jMethodCall) } }