From df54e592227ad53e2f4f80e1cf3edd1f741a5eec Mon Sep 17 00:00:00 2001 From: Phodal Huang Date: Thu, 16 Jan 2020 21:12:29 +0800 Subject: [PATCH] refactor: move package --- .../suggest/factory/factory_suggest.json | 953 +++++++++++------- cmd/api.go | 6 +- cmd/arch.go | 4 +- cmd/call.go | 4 +- cmd/cmd_util/deps_loader.go | 6 +- cmd/cmd_util/ident_helper.go | 14 +- cmd/concept.go | 4 +- cmd/count.go | 4 +- cmd/deps.go | 4 +- cmd/evaluate.go | 4 +- cmd/tbs.go | 4 +- cocatest/testhelper/generate.go | 6 +- pkg/application/analysis/java_full_app.go | 10 +- .../analysis/java_full_app_test.go | 3 +- .../analysis/java_identifier_app.go | 8 +- pkg/application/api/java_api_app.go | 4 +- pkg/application/api/java_api_app_test.go | 4 +- pkg/application/arch/arch_app.go | 10 +- pkg/application/call/call_graph.go | 8 +- pkg/application/call/call_graph_test.go | 6 +- pkg/application/concept/concept_analyser.go | 6 +- .../concept/concept_analyser_test.go | 4 +- pkg/application/count/count_app.go | 4 +- pkg/application/count/count_app_test.go | 4 +- pkg/application/deps/dep_app.go | 5 +- pkg/application/evaluate/analyser.go | 10 +- pkg/application/evaluate/analyser_test.go | 10 +- pkg/application/evaluate/evaluate.go | 10 +- .../evaluate/evaluator/controller.go | 4 +- pkg/application/evaluate/evaluator/empty.go | 6 +- .../evaluate/evaluator/null_exception.go | 7 +- pkg/application/evaluate/evaluator/service.go | 7 +- pkg/application/evaluate/evaluator/util.go | 6 +- pkg/application/rcall/rcall_graph.go | 8 +- pkg/application/rcall/rcall_graph_test.go | 6 +- .../refactor/rename/rename_method.go | 9 +- .../unusedclasses/unused_classes_app.go | 4 +- .../unusedclasses/unused_classes_app_test.go | 4 +- pkg/application/suggest/suggest_app.go | 6 +- pkg/application/suggest/suggest_app_test.go | 4 +- pkg/application/tbs/tbs_app.go | 11 +- pkg/application/tbs/tbs_app_test.go | 6 +- pkg/domain/core_domain/code_function.go | 5 +- .../{jdomain => core_domain}/jclass_node.go | 21 +- .../{jdomain => core_domain}/jidentifier.go | 14 +- pkg/domain/support_domain/suggest.go | 6 +- .../ast/api/java_api_listener.go | 10 +- .../ast/full/java_full_listener.go | 27 +- .../identifier/java_identifier_listener.go | 13 +- .../pkg/application/processor/process_test.go | 2 +- 50 files changed, 739 insertions(+), 566 deletions(-) rename pkg/domain/{jdomain => core_domain}/jclass_node.go (68%) rename pkg/domain/{jdomain => core_domain}/jidentifier.go (78%) diff --git a/_fixtures/suggest/factory/factory_suggest.json b/_fixtures/suggest/factory/factory_suggest.json index 4a1c4a4..728a06b 100755 --- a/_fixtures/suggest/factory/factory_suggest.json +++ b/_fixtures/suggest/factory/factory_suggest.json @@ -3,100 +3,174 @@ "Package": "factory", "Class": "Insect", "Type": "Class", - "Path": "_fixtures/suggest/factory/Bee.java", + "FilePath": "_fixtures/suggest/factory/Bee.java", "Fields": null, "Methods": [ { "Name": "Insect", "Type": "", - "StartLine": 4, - "StartLinePosition": 11, - "StopLine": 7, - "StopLinePosition": 4, "Parameters": [ { - "Name": "size", - "Type": "int" + "Modifiers": null, + "Name": "", + "TypeValue": "size", + "TypeType": "int", + "ReturnTypes": null, + "Parameters": null + }, + { + "Modifiers": null, + "Name": "", + "TypeValue": "height", + "TypeType": "int", + "ReturnTypes": null, + "Parameters": null + }, + { + "Modifiers": null, + "Name": "", + "TypeValue": "color", + "TypeType": "String", + "ReturnTypes": null, + "Parameters": null } ], "MethodCalls": [ - { - "Package": "factory", - "Type": "", - "Class": "Insect", - "MethodName": "this", - "StartLine": 5, - "StartLinePosition": 8, - "StopLine": 5, - "StopLinePosition": 12 - }, { "Package": "factory", "Type": "", "Class": "System.out", "MethodName": "println", - "StartLine": 6, - "StartLinePosition": 19, - "StopLine": 6, - "StopLinePosition": 26 + "Parameters": [ + { + "Modifiers": null, + "Name": "", + "TypeValue": "\"Constructor: Insect size, height\"", + "TypeType": "", + "ReturnTypes": null, + "Parameters": null + } + ], + "Position": { + "StartLine": 14, + "StartLinePosition": 19, + "StopLine": 14, + "StopLinePosition": 26 + } } ], "Override": false, "Annotations": null, - "IsConstructor": true + "IsConstructor": true, + "IsReturnNull": false, + "Modifiers": null, + "Creators": null, + "Position": { + "StartLine": 13, + "StartLinePosition": 11, + "StopLine": 15, + "StopLinePosition": 4 + } }, { "Name": "Insect", "Type": "", - "StartLine": 9, - "StartLinePosition": 11, - "StopLine": 11, - "StopLinePosition": 4, "Parameters": [ { - "Name": "size", - "Type": "int" - }, - { - "Name": "height", - "Type": "int" + "Modifiers": null, + "Name": "", + "TypeValue": "size", + "TypeType": "int", + "ReturnTypes": null, + "Parameters": null } ], "MethodCalls": [ + { + "Package": "factory", + "Type": "", + "Class": "Insect", + "MethodName": "this", + "Parameters": [ + { + "Modifiers": null, + "Name": "", + "TypeValue": "size", + "TypeType": "", + "ReturnTypes": null, + "Parameters": null + }, + { + "Modifiers": null, + "Name": "", + "TypeValue": "123", + "TypeType": "", + "ReturnTypes": null, + "Parameters": null + } + ], + "Position": { + "StartLine": 5, + "StartLinePosition": 8, + "StopLine": 5, + "StopLinePosition": 12 + } + }, { "Package": "factory", "Type": "", "Class": "System.out", "MethodName": "println", - "StartLine": 10, - "StartLinePosition": 19, - "StopLine": 10, - "StopLinePosition": 26 + "Parameters": [ + { + "Modifiers": null, + "Name": "", + "TypeValue": "\"Constructor: Insect size\"", + "TypeType": "", + "ReturnTypes": null, + "Parameters": null + } + ], + "Position": { + "StartLine": 6, + "StartLinePosition": 19, + "StopLine": 6, + "StopLinePosition": 26 + } } ], "Override": false, "Annotations": null, - "IsConstructor": true + "IsConstructor": true, + "IsReturnNull": false, + "Modifiers": null, + "Creators": null, + "Position": { + "StartLine": 4, + "StartLinePosition": 11, + "StopLine": 7, + "StopLinePosition": 4 + } }, { "Name": "Insect", "Type": "", - "StartLine": 13, - "StartLinePosition": 11, - "StopLine": 15, - "StopLinePosition": 4, "Parameters": [ { - "Name": "size", - "Type": "int" + "Modifiers": null, + "Name": "", + "TypeValue": "size", + "TypeType": "int", + "ReturnTypes": null, + "Parameters": null }, { - "Name": "height", - "Type": "int" - }, - { - "Name": "color", - "Type": "String" + "Modifiers": null, + "Name": "", + "TypeValue": "height", + "TypeType": "int", + "ReturnTypes": null, + "Parameters": null } ], "MethodCalls": [ @@ -105,80 +179,63 @@ "Type": "", "Class": "System.out", "MethodName": "println", - "StartLine": 14, - "StartLinePosition": 19, - "StopLine": 14, - "StopLinePosition": 26 + "Parameters": [ + { + "Modifiers": null, + "Name": "", + "TypeValue": "\"Constructor: Insect size, height\"", + "TypeType": "", + "ReturnTypes": null, + "Parameters": null + } + ], + "Position": { + "StartLine": 10, + "StartLinePosition": 19, + "StopLine": 10, + "StopLinePosition": 26 + } } ], "Override": false, "Annotations": null, - "IsConstructor": true - } - ], - "MethodCalls": [ - { - "Package": "factory", - "Type": "", - "Class": "Insect", - "MethodName": "this", - "StartLine": 5, - "StartLinePosition": 8, - "StopLine": 5, - "StopLinePosition": 12 - }, - { - "Package": "factory", - "Type": "", - "Class": "System.out", - "MethodName": "println", - "StartLine": 6, - "StartLinePosition": 19, - "StopLine": 6, - "StopLinePosition": 26 - }, - { - "Package": "factory", - "Type": "", - "Class": "System.out", - "MethodName": "println", - "StartLine": 10, - "StartLinePosition": 19, - "StopLine": 10, - "StopLinePosition": 26 - }, - { - "Package": "factory", - "Type": "", - "Class": "System.out", - "MethodName": "println", - "StartLine": 14, - "StartLinePosition": 19, - "StopLine": 14, - "StopLinePosition": 26 + "IsConstructor": true, + "IsReturnNull": false, + "Modifiers": null, + "Creators": null, + "Position": { + "StartLine": 9, + "StartLinePosition": 11, + "StopLine": 11, + "StopLinePosition": 4 + } } ], + "MethodCalls": null, "Extend": "", - "Implements": null + "Implements": null, + "Annotations": null, + "InnerClass": null, + "Imports": null }, { "Package": "", "Class": "Bee", "Type": "Class", - "Path": "_fixtures/suggest/factory/Bee.java", + "FilePath": "_fixtures/suggest/factory/Bee.java", "Fields": null, "Methods": [ { "Name": "Bee", "Type": "", - "StartLine": 19, - "StartLinePosition": 11, - "StopLine": 22, - "StopLinePosition": 4, "Parameters": [ { - "Name": "size", - "Type": "int" + "Modifiers": null, + "Name": "", + "TypeValue": "size", + "TypeType": "int", + "ReturnTypes": null, + "Parameters": null } ], "MethodCalls": [ @@ -187,41 +244,78 @@ "Type": "super", "Class": "Insect", "MethodName": "super", - "StartLine": 20, - "StartLinePosition": 8, - "StopLine": 20, - "StopLinePosition": 13 + "Parameters": [ + { + "Modifiers": null, + "Name": "", + "TypeValue": "size", + "TypeType": "", + "ReturnTypes": null, + "Parameters": null + } + ], + "Position": { + "StartLine": 20, + "StartLinePosition": 8, + "StopLine": 20, + "StopLinePosition": 13 + } }, { "Package": "factory", "Type": "", "Class": "System.out", "MethodName": "println", - "StartLine": 21, - "StartLinePosition": 19, - "StopLine": 21, - "StopLinePosition": 26 + "Parameters": [ + { + "Modifiers": null, + "Name": "", + "TypeValue": "\"Constructor: Bee size\"", + "TypeType": "", + "ReturnTypes": null, + "Parameters": null + } + ], + "Position": { + "StartLine": 21, + "StartLinePosition": 19, + "StopLine": 21, + "StopLinePosition": 26 + } } ], "Override": false, "Annotations": null, - "IsConstructor": true + "IsConstructor": true, + "IsReturnNull": false, + "Modifiers": null, + "Creators": null, + "Position": { + "StartLine": 19, + "StartLinePosition": 11, + "StopLine": 22, + "StopLinePosition": 4 + } }, { "Name": "Bee", "Type": "", - "StartLine": 24, - "StartLinePosition": 11, - "StopLine": 27, - "StopLinePosition": 4, "Parameters": [ { - "Name": "size", - "Type": "int" + "Modifiers": null, + "Name": "", + "TypeValue": "size", + "TypeType": "int", + "ReturnTypes": null, + "Parameters": null }, { - "Name": "height", - "Type": "int" + "Modifiers": null, + "Name": "", + "TypeValue": "height", + "TypeType": "int", + "ReturnTypes": null, + "Parameters": null } ], "MethodCalls": [ @@ -230,45 +324,94 @@ "Type": "super", "Class": "Insect", "MethodName": "super", - "StartLine": 25, - "StartLinePosition": 8, - "StopLine": 25, - "StopLinePosition": 13 + "Parameters": [ + { + "Modifiers": null, + "Name": "", + "TypeValue": "size", + "TypeType": "", + "ReturnTypes": null, + "Parameters": null + }, + { + "Modifiers": null, + "Name": "", + "TypeValue": "height", + "TypeType": "", + "ReturnTypes": null, + "Parameters": null + } + ], + "Position": { + "StartLine": 25, + "StartLinePosition": 8, + "StopLine": 25, + "StopLinePosition": 13 + } }, { "Package": "factory", "Type": "", "Class": "System.out", "MethodName": "println", - "StartLine": 26, - "StartLinePosition": 19, - "StopLine": 26, - "StopLinePosition": 26 + "Parameters": [ + { + "Modifiers": null, + "Name": "", + "TypeValue": "\"Constructor: Bee size, height\"", + "TypeType": "", + "ReturnTypes": null, + "Parameters": null + } + ], + "Position": { + "StartLine": 26, + "StartLinePosition": 19, + "StopLine": 26, + "StopLinePosition": 26 + } } ], "Override": false, "Annotations": null, - "IsConstructor": true + "IsConstructor": true, + "IsReturnNull": false, + "Modifiers": null, + "Creators": null, + "Position": { + "StartLine": 24, + "StartLinePosition": 11, + "StopLine": 27, + "StopLinePosition": 4 + } }, { "Name": "Bee", "Type": "", - "StartLine": 29, - "StartLinePosition": 11, - "StopLine": 32, - "StopLinePosition": 4, "Parameters": [ { - "Name": "size", - "Type": "int" + "Modifiers": null, + "Name": "", + "TypeValue": "size", + "TypeType": "int", + "ReturnTypes": null, + "Parameters": null }, { - "Name": "height", - "Type": "int" + "Modifiers": null, + "Name": "", + "TypeValue": "height", + "TypeType": "int", + "ReturnTypes": null, + "Parameters": null }, { - "Name": "color", - "Type": "String" + "Modifiers": null, + "Name": "", + "TypeValue": "color", + "TypeType": "String", + "ReturnTypes": null, + "Parameters": null } ], "MethodCalls": [ @@ -277,57 +420,118 @@ "Type": "super", "Class": "Insect", "MethodName": "super", - "StartLine": 30, - "StartLinePosition": 8, - "StopLine": 30, - "StopLinePosition": 13 + "Parameters": [ + { + "Modifiers": null, + "Name": "", + "TypeValue": "size", + "TypeType": "", + "ReturnTypes": null, + "Parameters": null + }, + { + "Modifiers": null, + "Name": "", + "TypeValue": "height", + "TypeType": "", + "ReturnTypes": null, + "Parameters": null + } + ], + "Position": { + "StartLine": 30, + "StartLinePosition": 8, + "StopLine": 30, + "StopLinePosition": 13 + } }, { "Package": "factory", "Type": "", "Class": "System.out", "MethodName": "println", - "StartLine": 31, - "StartLinePosition": 19, - "StopLine": 31, - "StopLinePosition": 26 + "Parameters": [ + { + "Modifiers": null, + "Name": "", + "TypeValue": "\"Constructor: Bee size, height, color\"", + "TypeType": "", + "ReturnTypes": null, + "Parameters": null + } + ], + "Position": { + "StartLine": 31, + "StartLinePosition": 19, + "StopLine": 31, + "StopLinePosition": 26 + } } ], "Override": false, "Annotations": null, - "IsConstructor": true + "IsConstructor": true, + "IsReturnNull": false, + "Modifiers": null, + "Creators": null, + "Position": { + "StartLine": 29, + "StartLinePosition": 11, + "StopLine": 32, + "StopLinePosition": 4 + } }, { "Name": "Bee", "Type": "", - "StartLine": 34, - "StartLinePosition": 11, - "StopLine": 46, - "StopLinePosition": 4, "Parameters": [ { - "Name": "size", - "Type": "int" + "Modifiers": null, + "Name": "", + "TypeValue": "size", + "TypeType": "int", + "ReturnTypes": null, + "Parameters": null }, { - "Name": "height", - "Type": "int" + "Modifiers": null, + "Name": "", + "TypeValue": "height", + "TypeType": "int", + "ReturnTypes": null, + "Parameters": null }, { - "Name": "color", - "Type": "String" + "Modifiers": null, + "Name": "", + "TypeValue": "color", + "TypeType": "String", + "ReturnTypes": null, + "Parameters": null }, { - "Name": "x", - "Type": "int" + "Modifiers": null, + "Name": "", + "TypeValue": "x", + "TypeType": "int", + "ReturnTypes": null, + "Parameters": null }, { - "Name": "y", - "Type": "int" + "Modifiers": null, + "Name": "", + "TypeValue": "y", + "TypeType": "int", + "ReturnTypes": null, + "Parameters": null }, { - "Name": "z", - "Type": "int" + "Modifiers": null, + "Name": "", + "TypeValue": "z", + "TypeType": "int", + "ReturnTypes": null, + "Parameters": null } ], "MethodCalls": [ @@ -336,290 +540,271 @@ "Type": "super", "Class": "Insect", "MethodName": "super", - "StartLine": 35, - "StartLinePosition": 8, - "StopLine": 35, - "StopLinePosition": 13 + "Parameters": [ + { + "Modifiers": null, + "Name": "", + "TypeValue": "size", + "TypeType": "", + "ReturnTypes": null, + "Parameters": null + }, + { + "Modifiers": null, + "Name": "", + "TypeValue": "height", + "TypeType": "", + "ReturnTypes": null, + "Parameters": null + } + ], + "Position": { + "StartLine": 35, + "StartLinePosition": 8, + "StopLine": 35, + "StopLinePosition": 13 + } }, { "Package": "factory", "Type": "", "Class": "System.out", "MethodName": "println", - "StartLine": 36, - "StartLinePosition": 19, - "StopLine": 36, - "StopLinePosition": 26 + "Parameters": [ + { + "Modifiers": null, + "Name": "", + "TypeValue": "\"Constructor: Bee size, height, color\"", + "TypeType": "", + "ReturnTypes": null, + "Parameters": null + } + ], + "Position": { + "StartLine": 36, + "StartLinePosition": 19, + "StopLine": 36, + "StopLinePosition": 26 + } }, { "Package": "factory", "Type": "", "Class": "System.out", "MethodName": "println", - "StartLine": 37, - "StartLinePosition": 19, - "StopLine": 37, - "StopLinePosition": 26 + "Parameters": [ + { + "Modifiers": null, + "Name": "", + "TypeValue": "\"Constructor: Bee size, height, color\"", + "TypeType": "", + "ReturnTypes": null, + "Parameters": null + } + ], + "Position": { + "StartLine": 37, + "StartLinePosition": 19, + "StopLine": 37, + "StopLinePosition": 26 + } }, { "Package": "factory", "Type": "", "Class": "System.out", "MethodName": "println", - "StartLine": 38, - "StartLinePosition": 19, - "StopLine": 38, - "StopLinePosition": 26 + "Parameters": [ + { + "Modifiers": null, + "Name": "", + "TypeValue": "\"Constructor: Bee size, height, color\"", + "TypeType": "", + "ReturnTypes": null, + "Parameters": null + } + ], + "Position": { + "StartLine": 38, + "StartLinePosition": 19, + "StopLine": 38, + "StopLinePosition": 26 + } }, { "Package": "factory", "Type": "", "Class": "System.out", "MethodName": "println", - "StartLine": 39, - "StartLinePosition": 19, - "StopLine": 39, - "StopLinePosition": 26 + "Parameters": [ + { + "Modifiers": null, + "Name": "", + "TypeValue": "\"Constructor: Bee size, height, color\"", + "TypeType": "", + "ReturnTypes": null, + "Parameters": null + } + ], + "Position": { + "StartLine": 39, + "StartLinePosition": 19, + "StopLine": 39, + "StopLinePosition": 26 + } }, { "Package": "factory", "Type": "", "Class": "System.out", "MethodName": "println", - "StartLine": 40, - "StartLinePosition": 19, - "StopLine": 40, - "StopLinePosition": 26 + "Parameters": [ + { + "Modifiers": null, + "Name": "", + "TypeValue": "\"Constructor: Bee size, height, color\"", + "TypeType": "", + "ReturnTypes": null, + "Parameters": null + } + ], + "Position": { + "StartLine": 40, + "StartLinePosition": 19, + "StopLine": 40, + "StopLinePosition": 26 + } }, { "Package": "factory", "Type": "", "Class": "System.out", "MethodName": "println", - "StartLine": 41, - "StartLinePosition": 19, - "StopLine": 41, - "StopLinePosition": 26 + "Parameters": [ + { + "Modifiers": null, + "Name": "", + "TypeValue": "\"Constructor: Bee size, height, color\"", + "TypeType": "", + "ReturnTypes": null, + "Parameters": null + } + ], + "Position": { + "StartLine": 41, + "StartLinePosition": 19, + "StopLine": 41, + "StopLinePosition": 26 + } }, { "Package": "factory", "Type": "", "Class": "System.out", "MethodName": "println", - "StartLine": 42, - "StartLinePosition": 19, - "StopLine": 42, - "StopLinePosition": 26 + "Parameters": [ + { + "Modifiers": null, + "Name": "", + "TypeValue": "\"Constructor: Bee size, height, color\"", + "TypeType": "", + "ReturnTypes": null, + "Parameters": null + } + ], + "Position": { + "StartLine": 42, + "StartLinePosition": 19, + "StopLine": 42, + "StopLinePosition": 26 + } }, { "Package": "factory", "Type": "", "Class": "System.out", "MethodName": "println", - "StartLine": 43, - "StartLinePosition": 19, - "StopLine": 43, - "StopLinePosition": 26 + "Parameters": [ + { + "Modifiers": null, + "Name": "", + "TypeValue": "\"Constructor: Bee size, height, color\"", + "TypeType": "", + "ReturnTypes": null, + "Parameters": null + } + ], + "Position": { + "StartLine": 43, + "StartLinePosition": 19, + "StopLine": 43, + "StopLinePosition": 26 + } }, { "Package": "factory", "Type": "", "Class": "System.out", "MethodName": "println", - "StartLine": 44, - "StartLinePosition": 19, - "StopLine": 44, - "StopLinePosition": 26 + "Parameters": [ + { + "Modifiers": null, + "Name": "", + "TypeValue": "\"Constructor: Bee size, height, color\"", + "TypeType": "", + "ReturnTypes": null, + "Parameters": null + } + ], + "Position": { + "StartLine": 44, + "StartLinePosition": 19, + "StopLine": 44, + "StopLinePosition": 26 + } }, { "Package": "factory", "Type": "", "Class": "System.out", "MethodName": "println", - "StartLine": 45, - "StartLinePosition": 19, - "StopLine": 45, - "StopLinePosition": 26 + "Parameters": [ + { + "Modifiers": null, + "Name": "", + "TypeValue": "\"Constructor: Bee size, height, color\"", + "TypeType": "", + "ReturnTypes": null, + "Parameters": null + } + ], + "Position": { + "StartLine": 45, + "StartLinePosition": 19, + "StopLine": 45, + "StopLinePosition": 26 + } } ], "Override": false, "Annotations": null, - "IsConstructor": true - } - ], - "MethodCalls": [ - { - "Package": "factory", - "Type": "super", - "Class": "Insect", - "MethodName": "super", - "StartLine": 20, - "StartLinePosition": 8, - "StopLine": 20, - "StopLinePosition": 13 - }, - { - "Package": "factory", - "Type": "", - "Class": "System.out", - "MethodName": "println", - "StartLine": 21, - "StartLinePosition": 19, - "StopLine": 21, - "StopLinePosition": 26 - }, - { - "Package": "factory", - "Type": "super", - "Class": "Insect", - "MethodName": "super", - "StartLine": 25, - "StartLinePosition": 8, - "StopLine": 25, - "StopLinePosition": 13 - }, - { - "Package": "factory", - "Type": "", - "Class": "System.out", - "MethodName": "println", - "StartLine": 26, - "StartLinePosition": 19, - "StopLine": 26, - "StopLinePosition": 26 - }, - { - "Package": "factory", - "Type": "super", - "Class": "Insect", - "MethodName": "super", - "StartLine": 30, - "StartLinePosition": 8, - "StopLine": 30, - "StopLinePosition": 13 - }, - { - "Package": "factory", - "Type": "", - "Class": "System.out", - "MethodName": "println", - "StartLine": 31, - "StartLinePosition": 19, - "StopLine": 31, - "StopLinePosition": 26 - }, - { - "Package": "factory", - "Type": "super", - "Class": "Insect", - "MethodName": "super", - "StartLine": 35, - "StartLinePosition": 8, - "StopLine": 35, - "StopLinePosition": 13 - }, - { - "Package": "factory", - "Type": "", - "Class": "System.out", - "MethodName": "println", - "StartLine": 36, - "StartLinePosition": 19, - "StopLine": 36, - "StopLinePosition": 26 - }, - { - "Package": "factory", - "Type": "", - "Class": "System.out", - "MethodName": "println", - "StartLine": 37, - "StartLinePosition": 19, - "StopLine": 37, - "StopLinePosition": 26 - }, - { - "Package": "factory", - "Type": "", - "Class": "System.out", - "MethodName": "println", - "StartLine": 38, - "StartLinePosition": 19, - "StopLine": 38, - "StopLinePosition": 26 - }, - { - "Package": "factory", - "Type": "", - "Class": "System.out", - "MethodName": "println", - "StartLine": 39, - "StartLinePosition": 19, - "StopLine": 39, - "StopLinePosition": 26 - }, - { - "Package": "factory", - "Type": "", - "Class": "System.out", - "MethodName": "println", - "StartLine": 40, - "StartLinePosition": 19, - "StopLine": 40, - "StopLinePosition": 26 - }, - { - "Package": "factory", - "Type": "", - "Class": "System.out", - "MethodName": "println", - "StartLine": 41, - "StartLinePosition": 19, - "StopLine": 41, - "StopLinePosition": 26 - }, - { - "Package": "factory", - "Type": "", - "Class": "System.out", - "MethodName": "println", - "StartLine": 42, - "StartLinePosition": 19, - "StopLine": 42, - "StopLinePosition": 26 - }, - { - "Package": "factory", - "Type": "", - "Class": "System.out", - "MethodName": "println", - "StartLine": 43, - "StartLinePosition": 19, - "StopLine": 43, - "StopLinePosition": 26 - }, - { - "Package": "factory", - "Type": "", - "Class": "System.out", - "MethodName": "println", - "StartLine": 44, - "StartLinePosition": 19, - "StopLine": 44, - "StopLinePosition": 26 - }, - { - "Package": "factory", - "Type": "", - "Class": "System.out", - "MethodName": "println", - "StartLine": 45, - "StartLinePosition": 19, - "StopLine": 45, - "StopLinePosition": 26 + "IsConstructor": true, + "IsReturnNull": false, + "Modifiers": null, + "Creators": null, + "Position": { + "StartLine": 34, + "StartLinePosition": 11, + "StopLine": 46, + "StopLinePosition": 4 + } } ], - "Extend": "", - "Implements": null + "MethodCalls": null, + "Extend": "factory.Insect", + "Implements": null, + "Annotations": null, + "InnerClass": null, + "Imports": null } ] \ No newline at end of file diff --git a/cmd/api.go b/cmd/api.go index e593d0b..9afd591 100644 --- a/cmd/api.go +++ b/cmd/api.go @@ -6,7 +6,7 @@ import ( "github.com/phodal/coca/cmd/config" "github.com/phodal/coca/pkg/application/api" "github.com/phodal/coca/pkg/application/call" - "github.com/phodal/coca/pkg/domain/jdomain" + "github.com/phodal/coca/pkg/domain/core_domain" "github.com/phodal/coca/pkg/domain/support_domain" "github.com/spf13/cobra" "log" @@ -31,8 +31,8 @@ var ( restApis []api_domain.RestAPI identifiers = cmd_util.LoadIdentify(apiCmdConfig.DependencePath) - identifiersMap = jdomain.BuildIdentifierMap(identifiers) - diMap = jdomain.BuildDIMap(identifiers, identifiersMap) + identifiersMap = core_domain.BuildIdentifierMap(identifiers) + diMap = core_domain.BuildDIMap(identifiers, identifiersMap) ) var apiCmd = &cobra.Command{ diff --git a/cmd/arch.go b/cmd/arch.go index 884ccce..65f698d 100644 --- a/cmd/arch.go +++ b/cmd/arch.go @@ -6,7 +6,7 @@ import ( "github.com/phodal/coca/cmd/config" "github.com/phodal/coca/pkg/application/arch" "github.com/phodal/coca/pkg/application/arch/tequila" - "github.com/phodal/coca/pkg/domain/jdomain" + "github.com/phodal/coca/pkg/domain/core_domain" "github.com/spf13/cobra" "os" "strings" @@ -27,7 +27,7 @@ var archCmd = &cobra.Command{ Long: ``, Run: func(cmd *cobra.Command, args []string) { identifiers = cmd_util.LoadIdentify(apiCmdConfig.DependencePath) - identifiersMap = jdomain.BuildIdentifierMap(identifiers) + identifiersMap = core_domain.BuildIdentifierMap(identifiers) parsedDeps := cmd_util.GetDepsFromJson(archCmdConfig.DependencePath) archApp := arch.NewArchApp() diff --git a/cmd/call.go b/cmd/call.go index c885450..a334a82 100644 --- a/cmd/call.go +++ b/cmd/call.go @@ -5,7 +5,7 @@ import ( "github.com/phodal/coca/cmd/cmd_util" "github.com/phodal/coca/cmd/config" . "github.com/phodal/coca/pkg/application/call" - "github.com/phodal/coca/pkg/domain/jdomain" + "github.com/phodal/coca/pkg/domain/core_domain" "github.com/spf13/cobra" "log" "strings" @@ -24,7 +24,7 @@ var callGraphCmd = &cobra.Command{ Short: "show call graph with specific method", Long: ``, Run: func(cmd *cobra.Command, args []string) { - var parsedDeps []jdomain.JClassNode + var parsedDeps []core_domain.JClassNode dependence := callCmdConfig.Path className := cmd.Flag("className").Value.String() diff --git a/cmd/cmd_util/deps_loader.go b/cmd/cmd_util/deps_loader.go index 435f584..aace7e5 100644 --- a/cmd/cmd_util/deps_loader.go +++ b/cmd/cmd_util/deps_loader.go @@ -2,11 +2,11 @@ package cmd_util import ( "encoding/json" - "github.com/phodal/coca/pkg/domain/jdomain" + "github.com/phodal/coca/pkg/domain/core_domain" ) -func GetDepsFromJson(depPath string) []jdomain.JClassNode { - var parsedDeps []jdomain.JClassNode +func GetDepsFromJson(depPath string) []core_domain.JClassNode { + var parsedDeps []core_domain.JClassNode file := ReadFile(depPath) _ = json.Unmarshal(file, &parsedDeps) diff --git a/cmd/cmd_util/ident_helper.go b/cmd/cmd_util/ident_helper.go index 86388e8..01a0006 100644 --- a/cmd/cmd_util/ident_helper.go +++ b/cmd/cmd_util/ident_helper.go @@ -3,19 +3,19 @@ package cmd_util import ( "encoding/json" "github.com/phodal/coca/pkg/application/analysis" - "github.com/phodal/coca/pkg/domain/jdomain" + "github.com/phodal/coca/pkg/domain/core_domain" ) -func LoadIdentify(importPath string) []jdomain.JIdentifier { +func LoadIdentify(importPath string) []core_domain.JIdentifier { return readIdentify(importPath, "identify.json", analysisByPath) } -func LoadTestIdentify(files []string) []jdomain.JIdentifier { +func LoadTestIdentify(files []string) []core_domain.JIdentifier { return readIdentify(files, "tidentify.json", analysisByFiles) } -func readIdentify(importPath interface{}, fileName string, analysisApp func(importPath interface{}) []jdomain.JIdentifier) []jdomain.JIdentifier { - var identifiers []jdomain.JIdentifier +func readIdentify(importPath interface{}, fileName string, analysisApp func(importPath interface{}) []core_domain.JIdentifier) []core_domain.JIdentifier { + var identifiers []core_domain.JIdentifier apiContent := ReadCocaFile(fileName) if apiContent == nil || string(apiContent) == "null" { @@ -30,13 +30,13 @@ func readIdentify(importPath interface{}, fileName string, analysisApp func(impo return identifiers } -func analysisByPath(importPath interface{}) []jdomain.JIdentifier { +func analysisByPath(importPath interface{}) []core_domain.JIdentifier { identifierApp := new(analysis.JavaIdentifierApp) ident := identifierApp.AnalysisPath(importPath.(string)) return ident } -func analysisByFiles(files interface{}) []jdomain.JIdentifier { +func analysisByFiles(files interface{}) []core_domain.JIdentifier { identifierApp := analysis.NewJavaIdentifierApp() ident := identifierApp.AnalysisFiles(files.([]string)) return ident diff --git a/cmd/concept.go b/cmd/concept.go index 082ad0d..d90eff0 100644 --- a/cmd/concept.go +++ b/cmd/concept.go @@ -5,12 +5,12 @@ import ( "github.com/phodal/coca/cmd/cmd_util" "github.com/phodal/coca/cmd/config" "github.com/phodal/coca/pkg/application/concept" - "github.com/phodal/coca/pkg/domain/jdomain" + "github.com/phodal/coca/pkg/domain/core_domain" "github.com/spf13/cobra" "strconv" ) -var parsedDeps []jdomain.JClassNode +var parsedDeps []core_domain.JClassNode var conceptCmd = &cobra.Command{ Use: "concept", diff --git a/cmd/count.go b/cmd/count.go index c8ef8f6..2fe145e 100644 --- a/cmd/count.go +++ b/cmd/count.go @@ -5,7 +5,7 @@ import ( "github.com/phodal/coca/cmd/cmd_util" "github.com/phodal/coca/cmd/config" "github.com/phodal/coca/pkg/application/count" - "github.com/phodal/coca/pkg/domain/jdomain" + "github.com/phodal/coca/pkg/domain/core_domain" "github.com/phodal/coca/pkg/infrastructure/string_helper" "github.com/spf13/cobra" "strconv" @@ -20,7 +20,7 @@ var ( countCmdConfig CountCmdConfig ) -var cparsedDeps []jdomain.JClassNode +var cparsedDeps []core_domain.JClassNode var countCmd = &cobra.Command{ Use: "count", diff --git a/cmd/deps.go b/cmd/deps.go index 880acc0..7c236e9 100644 --- a/cmd/deps.go +++ b/cmd/deps.go @@ -6,7 +6,7 @@ import ( "github.com/phodal/coca/pkg/adapter/cocafile" "github.com/phodal/coca/pkg/application/analysis" "github.com/phodal/coca/pkg/application/deps" - "github.com/phodal/coca/pkg/domain/jdomain" + "github.com/phodal/coca/pkg/domain/core_domain" "github.com/phodal/coca/pkg/domain/support_domain" "github.com/spf13/cobra" "path/filepath" @@ -21,7 +21,7 @@ var ( ) type DepApp interface { - AnalysisPath(path string, nodes []jdomain.JClassNode) []api_domain.JDependency + AnalysisPath(path string, nodes []core_domain.JClassNode) []api_domain.JDependency } var depsCmd = &cobra.Command{ diff --git a/cmd/evaluate.go b/cmd/evaluate.go index 2c524fb..694aa6a 100644 --- a/cmd/evaluate.go +++ b/cmd/evaluate.go @@ -7,7 +7,7 @@ import ( "github.com/phodal/coca/cmd/config" "github.com/phodal/coca/pkg/application/evaluate" "github.com/phodal/coca/pkg/application/evaluate/evaluator" - "github.com/phodal/coca/pkg/domain/jdomain" + "github.com/phodal/coca/pkg/domain/core_domain" "github.com/spf13/cobra" "log" "strconv" @@ -34,7 +34,7 @@ var evaluateCmd = &cobra.Command{ log.Fatal("lost file:" + dependence) } - var identifiers []jdomain.JIdentifier + var identifiers []core_domain.JIdentifier identContent := cmd_util.ReadCocaFile("identify.json") _ = json.Unmarshal(identContent, &identifiers) diff --git a/cmd/tbs.go b/cmd/tbs.go index cdf8d3b..b0e2bcd 100644 --- a/cmd/tbs.go +++ b/cmd/tbs.go @@ -7,7 +7,7 @@ import ( "github.com/phodal/coca/pkg/adapter/cocafile" "github.com/phodal/coca/pkg/application/analysis" "github.com/phodal/coca/pkg/application/tbs" - "github.com/phodal/coca/pkg/domain/jdomain" + "github.com/phodal/coca/pkg/domain/core_domain" "github.com/spf13/cobra" "strconv" ) @@ -29,7 +29,7 @@ var tbsCmd = &cobra.Command{ files := cocafile.GetJavaTestFiles(tbsCmdConfig.Path) identifiers := cmd_util.LoadTestIdentify(files) - identifiersMap := jdomain.BuildIdentifierMap(identifiers) + identifiersMap := core_domain.BuildIdentifierMap(identifiers) var classes []string = nil for _, node := range identifiers { diff --git a/cocatest/testhelper/generate.go b/cocatest/testhelper/generate.go index b6d4d56..d407541 100644 --- a/cocatest/testhelper/generate.go +++ b/cocatest/testhelper/generate.go @@ -2,11 +2,11 @@ package testhelper import ( "github.com/phodal/coca/pkg/application/analysis" - "github.com/phodal/coca/pkg/domain/jdomain" + "github.com/phodal/coca/pkg/domain/core_domain" "path/filepath" ) -func BuildAnalysisDeps(codePath string) ([]jdomain.JClassNode, map[string]jdomain.JIdentifier, []jdomain.JIdentifier) { +func BuildAnalysisDeps(codePath string) ([]core_domain.JClassNode, map[string]core_domain.JIdentifier, []core_domain.JIdentifier) { codePath = filepath.FromSlash(codePath) identifierApp := analysis.NewJavaIdentifierApp() @@ -19,7 +19,7 @@ func BuildAnalysisDeps(codePath string) ([]jdomain.JClassNode, map[string]jdomai callApp := analysis.NewJavaFullApp() callNodes := callApp.AnalysisPath(codePath, classes, identifiers) - identifiersMap := jdomain.BuildIdentifierMap(identifiers) + identifiersMap := core_domain.BuildIdentifierMap(identifiers) return callNodes, identifiersMap, identifiers } diff --git a/pkg/application/analysis/java_full_app.go b/pkg/application/analysis/java_full_app.go index 9a71209..7e959bd 100644 --- a/pkg/application/analysis/java_full_app.go +++ b/pkg/application/analysis/java_full_app.go @@ -4,7 +4,7 @@ import ( "fmt" "github.com/antlr/antlr4/runtime/Go/antlr" "github.com/phodal/coca/pkg/adapter/cocafile" - "github.com/phodal/coca/pkg/domain/jdomain" + "github.com/phodal/coca/pkg/domain/core_domain" "github.com/phodal/coca/pkg/infrastructure/ast" "github.com/phodal/coca/pkg/infrastructure/ast/full" "path/filepath" @@ -17,15 +17,15 @@ func NewJavaFullApp() JavaFullApp { return JavaFullApp{} } -func (j *JavaFullApp) AnalysisPath(codeDir string, classes []string, identNodes []jdomain.JIdentifier) []jdomain.JClassNode { +func (j *JavaFullApp) AnalysisPath(codeDir string, classes []string, identNodes []core_domain.JIdentifier) []core_domain.JClassNode { files := cocafile.GetJavaFiles(codeDir) return j.AnalysisFiles(identNodes, files, classes) } -func (j *JavaFullApp) AnalysisFiles(identNodes []jdomain.JIdentifier, files []string, classes []string) []jdomain.JClassNode { - var nodeInfos []jdomain.JClassNode +func (j *JavaFullApp) AnalysisFiles(identNodes []core_domain.JIdentifier, files []string, classes []string) []core_domain.JClassNode { + var nodeInfos []core_domain.JClassNode - var identMap = make(map[string]jdomain.JIdentifier) + var identMap = make(map[string]core_domain.JIdentifier) for _, ident := range identNodes { identMap[ident.GetClassFullName()] = ident } diff --git a/pkg/application/analysis/java_full_app_test.go b/pkg/application/analysis/java_full_app_test.go index 0172529..a6b3c5b 100644 --- a/pkg/application/analysis/java_full_app_test.go +++ b/pkg/application/analysis/java_full_app_test.go @@ -3,7 +3,6 @@ package analysis import ( . "github.com/onsi/gomega" "github.com/phodal/coca/pkg/domain/core_domain" - "github.com/phodal/coca/pkg/domain/jdomain" "path/filepath" "testing" ) @@ -37,7 +36,7 @@ func TestJavaCallListener_EnterConstructorDeclaration(t *testing.T) { g.Expect(len(callNodes[0].Methods)).To(Equal(3)) } -func getCallNodes(codePath string) []jdomain.JClassNode { +func getCallNodes(codePath string) []core_domain.JClassNode { identifierApp := NewJavaIdentifierApp() iNodes := identifierApp.AnalysisPath(codePath) var classes []string = nil diff --git a/pkg/application/analysis/java_identifier_app.go b/pkg/application/analysis/java_identifier_app.go index 40c395e..0ce1785 100644 --- a/pkg/application/analysis/java_identifier_app.go +++ b/pkg/application/analysis/java_identifier_app.go @@ -3,7 +3,7 @@ package analysis import ( "github.com/antlr/antlr4/runtime/Go/antlr" "github.com/phodal/coca/pkg/adapter/cocafile" - "github.com/phodal/coca/pkg/domain/jdomain" + "github.com/phodal/coca/pkg/domain/core_domain" "github.com/phodal/coca/pkg/infrastructure/ast" "github.com/phodal/coca/pkg/infrastructure/ast/identifier" ) @@ -16,13 +16,13 @@ func NewJavaIdentifierApp() JavaIdentifierApp { return JavaIdentifierApp{} } -func (j *JavaIdentifierApp) AnalysisPath(codeDir string) []jdomain.JIdentifier { +func (j *JavaIdentifierApp) AnalysisPath(codeDir string) []core_domain.JIdentifier { files := cocafile.GetJavaFiles(codeDir) return j.AnalysisFiles(files) } -func (j *JavaIdentifierApp) AnalysisFiles(files []string) []jdomain.JIdentifier { - var nodeInfos []jdomain.JIdentifier = nil +func (j *JavaIdentifierApp) AnalysisFiles(files []string) []core_domain.JIdentifier { + var nodeInfos []core_domain.JIdentifier = nil for _, file := range files { parser := ast.ProcessJavaFile(file) diff --git a/pkg/application/api/java_api_app.go b/pkg/application/api/java_api_app.go index a4b9b9d..b21fcbc 100644 --- a/pkg/application/api/java_api_app.go +++ b/pkg/application/api/java_api_app.go @@ -4,7 +4,7 @@ import ( "fmt" "github.com/antlr/antlr4/runtime/Go/antlr" "github.com/phodal/coca/pkg/adapter/cocafile" - "github.com/phodal/coca/pkg/domain/jdomain" + "github.com/phodal/coca/pkg/domain/core_domain" "github.com/phodal/coca/pkg/domain/support_domain" "github.com/phodal/coca/pkg/infrastructure/ast" "github.com/phodal/coca/pkg/infrastructure/ast/api" @@ -16,7 +16,7 @@ var allApis []api_domain.RestAPI type JavaApiApp struct { } -func (j *JavaApiApp) AnalysisPath(codeDir string, parsedDeps []jdomain.JClassNode, identifiersMap map[string]jdomain.JIdentifier, diMap map[string]string) []api_domain.RestAPI { +func (j *JavaApiApp) AnalysisPath(codeDir string, parsedDeps []core_domain.JClassNode, identifiersMap map[string]core_domain.JIdentifier, diMap map[string]string) []api_domain.RestAPI { files := cocafile.GetJavaFiles(codeDir) allApis = nil for index := range files { diff --git a/pkg/application/api/java_api_app_test.go b/pkg/application/api/java_api_app_test.go index d2c0302..8606c2f 100644 --- a/pkg/application/api/java_api_app_test.go +++ b/pkg/application/api/java_api_app_test.go @@ -3,7 +3,7 @@ package api import ( . "github.com/onsi/gomega" "github.com/phodal/coca/cocatest/testhelper" - "github.com/phodal/coca/pkg/domain/jdomain" + "github.com/phodal/coca/pkg/domain/core_domain" "testing" ) @@ -12,7 +12,7 @@ func TestJavaCallApp_AnalysisPath(t *testing.T) { codePath := "../../../_fixtures/call" callNodes, identifiersMap, identifiers := testhelper.BuildAnalysisDeps(codePath) - diMap := jdomain.BuildDIMap(identifiers, identifiersMap) + diMap := core_domain.BuildDIMap(identifiers, identifiersMap) app := new(JavaApiApp) restApis := app.AnalysisPath(codePath, callNodes, identifiersMap, diMap) diff --git a/pkg/application/arch/arch_app.go b/pkg/application/arch/arch_app.go index b77fab3..d7a3a59 100644 --- a/pkg/application/arch/arch_app.go +++ b/pkg/application/arch/arch_app.go @@ -2,7 +2,7 @@ package arch import ( "github.com/phodal/coca/pkg/application/arch/tequila" - "github.com/phodal/coca/pkg/domain/jdomain" + "github.com/phodal/coca/pkg/domain/core_domain" ) type ArchApp struct { @@ -12,7 +12,7 @@ func NewArchApp() ArchApp { return ArchApp{} } -func (a ArchApp) Analysis(deps []jdomain.JClassNode, identifiersMap map[string]jdomain.JIdentifier) *tequila.FullGraph { +func (a ArchApp) Analysis(deps []core_domain.JClassNode, identifiersMap map[string]core_domain.JIdentifier) *tequila.FullGraph { fullGraph := &tequila.FullGraph{ NodeList: make(map[string]string), RelationList: make(map[string]*tequila.Relation), @@ -44,7 +44,7 @@ func (a ArchApp) Analysis(deps []jdomain.JClassNode, identifiersMap map[string]j return fullGraph } -func addCallInField(clz jdomain.JClassNode, src string, fullGraph tequila.FullGraph) { +func addCallInField(clz core_domain.JClassNode, src string, fullGraph tequila.FullGraph) { for _, field := range clz.MethodCalls { dst := field.Package + "." + field.Class relation := &tequila.Relation{ @@ -57,7 +57,7 @@ func addCallInField(clz jdomain.JClassNode, src string, fullGraph tequila.FullGr } } -func addCallInMethod(clz jdomain.JClassNode, identifiersMap map[string]jdomain.JIdentifier, src string, fullGraph tequila.FullGraph) { +func addCallInMethod(clz core_domain.JClassNode, identifiersMap map[string]core_domain.JIdentifier, src string, fullGraph tequila.FullGraph) { for _, method := range clz.Methods { if method.Name == "main" { continue @@ -83,7 +83,7 @@ func addCallInMethod(clz jdomain.JClassNode, identifiersMap map[string]jdomain.J } } -func addExtend(clz jdomain.JClassNode, src string, fullGraph tequila.FullGraph) { +func addExtend(clz core_domain.JClassNode, src string, fullGraph tequila.FullGraph) { if clz.Extend != "" { relation := &tequila.Relation{ From: src, diff --git a/pkg/application/call/call_graph.go b/pkg/application/call/call_graph.go index fc3268e..f02601b 100644 --- a/pkg/application/call/call_graph.go +++ b/pkg/application/call/call_graph.go @@ -1,7 +1,7 @@ package call import ( - "github.com/phodal/coca/pkg/domain/jdomain" + "github.com/phodal/coca/pkg/domain/core_domain" "github.com/phodal/coca/pkg/domain/support_domain" "github.com/phodal/coca/pkg/infrastructure/jpackage" "strings" @@ -14,7 +14,7 @@ func NewCallGraph() CallGraph { return CallGraph{} } -func (c CallGraph) Analysis(funcName string, clzs []jdomain.JClassNode) string { +func (c CallGraph) Analysis(funcName string, clzs []core_domain.JClassNode) string { methodMap := BuildMethodMap(clzs) chain := BuildCallChain(funcName, methodMap, nil) dotContent := ToGraphviz(chain) @@ -56,7 +56,7 @@ func BuildCallChain(funcName string, methodMap map[string][]string, diMap map[st return "\n" } -func (c CallGraph) AnalysisByFiles(restApis []api_domain.RestAPI, deps []jdomain.JClassNode, diMap map[string]string) (string, []api_domain.CallAPI) { +func (c CallGraph) AnalysisByFiles(restApis []api_domain.RestAPI, deps []core_domain.JClassNode, diMap map[string]string) (string, []api_domain.CallAPI) { methodMap := BuildMethodMap(deps) var apiCallSCounts []api_domain.CallAPI @@ -88,7 +88,7 @@ func escapeStr(caller string) string { return strings.ReplaceAll(caller, "\"", "\\\"") } -func BuildMethodMap(clzs []jdomain.JClassNode) map[string][]string { +func BuildMethodMap(clzs []core_domain.JClassNode) map[string][]string { var methodMap = make(map[string][]string) for _, clz := range clzs { for _, method := range clz.Methods { diff --git a/pkg/application/call/call_graph_test.go b/pkg/application/call/call_graph_test.go index b87df4a..1894109 100644 --- a/pkg/application/call/call_graph_test.go +++ b/pkg/application/call/call_graph_test.go @@ -7,7 +7,7 @@ import ( "github.com/phodal/coca/cocatest/testhelper" "github.com/phodal/coca/pkg/application/api" "github.com/phodal/coca/pkg/application/call" - "github.com/phodal/coca/pkg/domain/jdomain" + "github.com/phodal/coca/pkg/domain/core_domain" "github.com/phodal/coca/pkg/domain/support_domain" "path/filepath" "testing" @@ -16,7 +16,7 @@ import ( func Test_ShouldBuildSuccessDataFromJson(t *testing.T) { g := NewGomegaWithT(t) - var parsedDeps []jdomain.JClassNode + var parsedDeps []core_domain.JClassNode analyser := call.NewCallGraph() codePath := "../../../_fixtures/call/call_api_test.json" codePath = filepath.FromSlash(codePath) @@ -44,7 +44,7 @@ func Test_ShouldBuildSuccessDataFromSourceData(t *testing.T) { codePath := "../../../_fixtures/examples/api" callNodes, identifiersMap, identifiers := testhelper.BuildAnalysisDeps(codePath) - diMap := jdomain.BuildDIMap(identifiers, identifiersMap) + diMap := core_domain.BuildDIMap(identifiers, identifiersMap) app := new(api.JavaApiApp) restApis := app.AnalysisPath(codePath, callNodes, identifiersMap, diMap) diff --git a/pkg/application/concept/concept_analyser.go b/pkg/application/concept/concept_analyser.go index 4eefa3f..39ed701 100644 --- a/pkg/application/concept/concept_analyser.go +++ b/pkg/application/concept/concept_analyser.go @@ -2,7 +2,7 @@ package concept import ( languages2 "github.com/phodal/coca/pkg/application/call/stop_words/languages" - "github.com/phodal/coca/pkg/domain/jdomain" + "github.com/phodal/coca/pkg/domain/core_domain" "github.com/phodal/coca/pkg/infrastructure/constants" "github.com/phodal/coca/pkg/infrastructure/string_helper" ) @@ -14,11 +14,11 @@ func NewConceptAnalyser() ConceptAnalyser { return ConceptAnalyser{} } -func (c ConceptAnalyser) Analysis(clzs *[]jdomain.JClassNode) string_helper.PairList { +func (c ConceptAnalyser) Analysis(clzs *[]core_domain.JClassNode) string_helper.PairList { return buildMethodsFromDeps(*clzs) } -func buildMethodsFromDeps(clzs []jdomain.JClassNode) string_helper.PairList { +func buildMethodsFromDeps(clzs []core_domain.JClassNode) string_helper.PairList { var methodsName []string var methodStr string for _, clz := range clzs { diff --git a/pkg/application/concept/concept_analyser_test.go b/pkg/application/concept/concept_analyser_test.go index 6b49deb..7efc03f 100644 --- a/pkg/application/concept/concept_analyser_test.go +++ b/pkg/application/concept/concept_analyser_test.go @@ -3,7 +3,7 @@ package concept import ( "encoding/json" "github.com/phodal/coca/cmd/cmd_util" - "github.com/phodal/coca/pkg/domain/jdomain" + "github.com/phodal/coca/pkg/domain/core_domain" "log" "path/filepath" "testing" @@ -14,7 +14,7 @@ import ( func TestConceptAnalyser_Analysis(t *testing.T) { g := NewGomegaWithT(t) - var parsedDeps []jdomain.JClassNode + var parsedDeps []core_domain.JClassNode analyser := NewConceptAnalyser() codePath := "../../../_fixtures/call/call_api_test.json" codePath = filepath.FromSlash(codePath) diff --git a/pkg/application/count/count_app.go b/pkg/application/count/count_app.go index a905960..f8489c1 100644 --- a/pkg/application/count/count_app.go +++ b/pkg/application/count/count_app.go @@ -1,10 +1,10 @@ package count import ( - "github.com/phodal/coca/pkg/domain/jdomain" + "github.com/phodal/coca/pkg/domain/core_domain" ) -func BuildCallMap(parserDeps []jdomain.JClassNode) map[string]int { +func BuildCallMap(parserDeps []core_domain.JClassNode) map[string]int { var projectMethods = make(map[string]string) for _, clz := range parserDeps { clz.BuildStringMethodMap(projectMethods) diff --git a/pkg/application/count/count_app_test.go b/pkg/application/count/count_app_test.go index 490e97e..a093a0f 100644 --- a/pkg/application/count/count_app_test.go +++ b/pkg/application/count/count_app_test.go @@ -4,14 +4,14 @@ import ( "encoding/json" . "github.com/onsi/gomega" "github.com/phodal/coca/cmd/cmd_util" - "github.com/phodal/coca/pkg/domain/jdomain" + "github.com/phodal/coca/pkg/domain/core_domain" "path/filepath" "testing" ) func TestBuildCallMap(t *testing.T) { g := NewGomegaWithT(t) - var parsedDeps []jdomain.JClassNode + var parsedDeps []core_domain.JClassNode codePath := "../../../_fixtures/count/call.json" codePath = filepath.FromSlash(codePath) file := cmd_util.ReadFile(codePath) diff --git a/pkg/application/deps/dep_app.go b/pkg/application/deps/dep_app.go index 881a9b0..77bd99e 100644 --- a/pkg/application/deps/dep_app.go +++ b/pkg/application/deps/dep_app.go @@ -3,7 +3,6 @@ package deps import ( "github.com/phodal/coca/pkg/adapter/cocafile" "github.com/phodal/coca/pkg/domain/core_domain" - "github.com/phodal/coca/pkg/domain/jdomain" "github.com/phodal/coca/pkg/domain/support_domain" "path/filepath" "strings" @@ -16,7 +15,7 @@ func NewDepApp() *DepAnalysisApp { return &DepAnalysisApp{} } -func (d *DepAnalysisApp) BuildImportMap(deps []jdomain.JClassNode) map[string]core_domain.CodeImport { +func (d *DepAnalysisApp) BuildImportMap(deps []core_domain.JClassNode) map[string]core_domain.CodeImport { var impMap = make(map[string]core_domain.CodeImport) for _, clz := range deps { for _, imp := range clz.Imports { @@ -27,7 +26,7 @@ func (d *DepAnalysisApp) BuildImportMap(deps []jdomain.JClassNode) map[string]co return impMap } -func (d *DepAnalysisApp) AnalysisPath(path string, nodes []jdomain.JClassNode) []api_domain.JDependency { +func (d *DepAnalysisApp) AnalysisPath(path string, nodes []core_domain.JClassNode) []api_domain.JDependency { path, _ = filepath.Abs(path) pomXmls := cocafile.GetFilesWithFilter(path, cocafile.PomXmlFilter) gradleFiles := cocafile.GetFilesWithFilter(path, cocafile.BuildGradleFilter) diff --git a/pkg/application/evaluate/analyser.go b/pkg/application/evaluate/analyser.go index 7b86238..8aba616 100644 --- a/pkg/application/evaluate/analyser.go +++ b/pkg/application/evaluate/analyser.go @@ -2,7 +2,7 @@ package evaluate import ( "github.com/phodal/coca/pkg/application/evaluate/evaluator" - "github.com/phodal/coca/pkg/domain/jdomain" + "github.com/phodal/coca/pkg/domain/core_domain" "gonum.org/v1/gonum/stat" ) @@ -13,12 +13,12 @@ func NewEvaluateAnalyser() Analyser { return Analyser{} } -func (a Analyser) Analysis(classNodes []jdomain.JClassNode, identifiers []jdomain.JIdentifier) evaluator.EvaluateModel { - var servicesNode []jdomain.JClassNode = nil +func (a Analyser) Analysis(classNodes []core_domain.JClassNode, identifiers []core_domain.JIdentifier) evaluator.EvaluateModel { + var servicesNode []core_domain.JClassNode = nil var evaluation Evaluation var result = evaluator.NewEvaluateModel() - var nodeMap = make(map[string]jdomain.JClassNode) + var nodeMap = make(map[string]core_domain.JClassNode) for _, node := range classNodes { nodeMap[node.Class] = node @@ -48,7 +48,7 @@ func (a Analyser) Analysis(classNodes []jdomain.JClassNode, identifiers []jdomai return result } -func SummaryMethodIdentifier(identifiers []jdomain.JIdentifier, result *evaluator.EvaluateModel) { +func SummaryMethodIdentifier(identifiers []core_domain.JIdentifier, result *evaluator.EvaluateModel) { var methodLengthArray []float64 var methodCountArray []float64 for _, ident := range identifiers { diff --git a/pkg/application/evaluate/analyser_test.go b/pkg/application/evaluate/analyser_test.go index 6881c2f..f9c96df 100644 --- a/pkg/application/evaluate/analyser_test.go +++ b/pkg/application/evaluate/analyser_test.go @@ -6,7 +6,7 @@ import ( "github.com/phodal/coca/cmd/cmd_util" "github.com/phodal/coca/cocatest/testhelper" "github.com/phodal/coca/pkg/application/evaluate/evaluator" - "github.com/phodal/coca/pkg/domain/jdomain" + "github.com/phodal/coca/pkg/domain/core_domain" "path/filepath" "testing" ) @@ -14,7 +14,7 @@ import ( func TestAnalyser_Analysis(t *testing.T) { g := NewGomegaWithT(t) - var parsedDeps []jdomain.JClassNode + var parsedDeps []core_domain.JClassNode analyser := NewEvaluateAnalyser() codePath := "../../../_fixtures/evaluate/service.json" codePath = filepath.FromSlash(codePath) @@ -29,7 +29,7 @@ func TestAnalyser_Analysis(t *testing.T) { func Test_Service_LifeCycle(t *testing.T) { g := NewGomegaWithT(t) - var parsedDeps []jdomain.JClassNode + var parsedDeps []core_domain.JClassNode analyser := NewEvaluateAnalyser() codePath := "../../../_fixtures/evaluate/service_lifecycle.json" codePath = filepath.FromSlash(codePath) @@ -46,7 +46,7 @@ func Test_Service_LifeCycle(t *testing.T) { func Test_Service_Same_Return_Type(t *testing.T) { g := NewGomegaWithT(t) - var parsedDeps []jdomain.JClassNode + var parsedDeps []core_domain.JClassNode analyser := NewEvaluateAnalyser() codePath := "../../../_fixtures/evaluate/service_same_return_type.json" codePath = filepath.FromSlash(codePath) @@ -61,7 +61,7 @@ func Test_Service_Same_Return_Type(t *testing.T) { func Test_Long_Parameters(t *testing.T) { g := NewGomegaWithT(t) - var parsedDeps []jdomain.JClassNode + var parsedDeps []core_domain.JClassNode analyser := NewEvaluateAnalyser() codePath := "../../../_fixtures/evaluate/service_long_parameters.json" codePath = filepath.FromSlash(codePath) diff --git a/pkg/application/evaluate/evaluate.go b/pkg/application/evaluate/evaluate.go index 40d797e..110c287 100644 --- a/pkg/application/evaluate/evaluate.go +++ b/pkg/application/evaluate/evaluate.go @@ -2,22 +2,22 @@ package evaluate import ( "github.com/phodal/coca/pkg/application/evaluate/evaluator" - "github.com/phodal/coca/pkg/domain/jdomain" + "github.com/phodal/coca/pkg/domain/core_domain" ) type Evaluator interface { - Evaluate(result *evaluator.EvaluateModel, node jdomain.JClassNode) - EvaluateList(evaluateModel *evaluator.EvaluateModel, nodes []jdomain.JClassNode, nodeMap map[string]jdomain.JClassNode, identifiers []jdomain.JIdentifier) + Evaluate(result *evaluator.EvaluateModel, node core_domain.JClassNode) + EvaluateList(evaluateModel *evaluator.EvaluateModel, nodes []core_domain.JClassNode, nodeMap map[string]core_domain.JClassNode, identifiers []core_domain.JIdentifier) } type Evaluation struct { Evaluator Evaluator } -func (o *Evaluation) Evaluate(result *evaluator.EvaluateModel, node jdomain.JClassNode) { +func (o *Evaluation) Evaluate(result *evaluator.EvaluateModel, node core_domain.JClassNode) { o.Evaluator.Evaluate(result, node) } -func (o *Evaluation) EvaluateList(evaluateModel *evaluator.EvaluateModel, nodes []jdomain.JClassNode, nodeMap map[string]jdomain.JClassNode, identifiers []jdomain.JIdentifier) { +func (o *Evaluation) EvaluateList(evaluateModel *evaluator.EvaluateModel, nodes []core_domain.JClassNode, nodeMap map[string]core_domain.JClassNode, identifiers []core_domain.JIdentifier) { o.Evaluator.EvaluateList(evaluateModel, nodes, nodeMap, identifiers) } diff --git a/pkg/application/evaluate/evaluator/controller.go b/pkg/application/evaluate/evaluator/controller.go index f2abae5..eb2ee8e 100644 --- a/pkg/application/evaluate/evaluator/controller.go +++ b/pkg/application/evaluate/evaluator/controller.go @@ -2,13 +2,13 @@ package evaluator import ( "fmt" - "github.com/phodal/coca/pkg/domain/jdomain" + "github.com/phodal/coca/pkg/domain/core_domain" ) type Controller struct { } -func (Controller) Evaluate(node jdomain.JClassNode) { +func (Controller) Evaluate(node core_domain.JClassNode) { fmt.Println("controller") } diff --git a/pkg/application/evaluate/evaluator/empty.go b/pkg/application/evaluate/evaluator/empty.go index dd225fb..37d04b3 100644 --- a/pkg/application/evaluate/evaluator/empty.go +++ b/pkg/application/evaluate/evaluator/empty.go @@ -1,17 +1,17 @@ package evaluator import ( - "github.com/phodal/coca/pkg/domain/jdomain" + "github.com/phodal/coca/pkg/domain/core_domain" ) type Empty struct { } -func (Empty) Evaluate(*EvaluateModel, jdomain.JClassNode) { +func (Empty) Evaluate(*EvaluateModel, core_domain.JClassNode) { } -func (Empty) EvaluateList(*EvaluateModel, []jdomain.JClassNode, map[string]jdomain.JClassNode, []jdomain.JIdentifier) { +func (Empty) EvaluateList(*EvaluateModel, []core_domain.JClassNode, map[string]core_domain.JClassNode, []core_domain.JIdentifier) { } \ No newline at end of file diff --git a/pkg/application/evaluate/evaluator/null_exception.go b/pkg/application/evaluate/evaluator/null_exception.go index 27e8f54..88cd917 100644 --- a/pkg/application/evaluate/evaluator/null_exception.go +++ b/pkg/application/evaluate/evaluator/null_exception.go @@ -2,17 +2,16 @@ import ( "github.com/phodal/coca/pkg/domain/core_domain" - "github.com/phodal/coca/pkg/domain/jdomain" ) type NullPointException struct { } -func (NullPointException) Evaluate(*EvaluateModel, jdomain.JClassNode) { +func (NullPointException) Evaluate(*EvaluateModel, core_domain.JClassNode) { } -func (n NullPointException) EvaluateList(evaluateModel *EvaluateModel, nodes []jdomain.JClassNode, nodeMap map[string]jdomain.JClassNode, identifiers []jdomain.JIdentifier) { +func (n NullPointException) EvaluateList(evaluateModel *EvaluateModel, nodes []core_domain.JClassNode, nodeMap map[string]core_domain.JClassNode, identifiers []core_domain.JIdentifier) { var nullableList []string = nil var nullableMap = make(map[string]string) for _, ident := range identifiers { @@ -37,6 +36,6 @@ func (n NullPointException) EvaluateList(evaluateModel *EvaluateModel, nodes []j evaluateModel.Nullable.Items = nullableList } -func buildMethodPath(ident jdomain.JIdentifier, method core_domain.JMethod) string { +func buildMethodPath(ident core_domain.JIdentifier, method core_domain.JMethod) string { return ident.Package + "." + ident.ClassName + "." + method.Name } diff --git a/pkg/application/evaluate/evaluator/service.go b/pkg/application/evaluate/evaluator/service.go index 125197f..3d81a85 100644 --- a/pkg/application/evaluate/evaluator/service.go +++ b/pkg/application/evaluate/evaluator/service.go @@ -2,7 +2,6 @@ package evaluator import ( "github.com/phodal/coca/pkg/domain/core_domain" - "github.com/phodal/coca/pkg/domain/jdomain" "github.com/phodal/coca/pkg/infrastructure/apriori" "github.com/phodal/coca/pkg/infrastructure/constants" "strings" @@ -11,11 +10,11 @@ import ( type Service struct { } -var serviceNodeMap map[string]jdomain.JClassNode +var serviceNodeMap map[string]core_domain.JClassNode var returnTypeMap map[string][]string var longParameterList []core_domain.JMethod -func (s Service) EvaluateList(evaluateModel *EvaluateModel, nodes []jdomain.JClassNode, nodeMap map[string]jdomain.JClassNode, identifiers []jdomain.JIdentifier) { +func (s Service) EvaluateList(evaluateModel *EvaluateModel, nodes []core_domain.JClassNode, nodeMap map[string]core_domain.JClassNode, identifiers []core_domain.JIdentifier) { serviceNodeMap = nodeMap longParameterList = nil returnTypeMap = make(map[string][]string) @@ -50,7 +49,7 @@ func findRelatedMethodParameters(model *EvaluateModel, list []core_domain.JMetho } } -func (s Service) Evaluate(result *EvaluateModel, node jdomain.JClassNode) { +func (s Service) Evaluate(result *EvaluateModel, node core_domain.JClassNode) { var methodNameArray [][]string for _, method := range node.Methods { methodNameArray = append(methodNameArray, SplitCamelcase(method.Name)) diff --git a/pkg/application/evaluate/evaluator/util.go b/pkg/application/evaluate/evaluator/util.go index 75cd2c2..3586eb1 100644 --- a/pkg/application/evaluate/evaluator/util.go +++ b/pkg/application/evaluate/evaluator/util.go @@ -1,16 +1,16 @@ package evaluator import ( - "github.com/phodal/coca/pkg/domain/jdomain" + "github.com/phodal/coca/pkg/domain/core_domain" ) type Util struct { } -func (Util) Evaluate(result *EvaluateModel, node jdomain.JClassNode) { +func (Util) Evaluate(result *EvaluateModel, node core_domain.JClassNode) { } -func (s Util) EvaluateList(evaluateModel *EvaluateModel, nodes []jdomain.JClassNode, nodeMap map[string]jdomain.JClassNode, identifiers []jdomain.JIdentifier) { +func (s Util) EvaluateList(evaluateModel *EvaluateModel, nodes []core_domain.JClassNode, nodeMap map[string]core_domain.JClassNode, identifiers []core_domain.JIdentifier) { } diff --git a/pkg/application/rcall/rcall_graph.go b/pkg/application/rcall/rcall_graph.go index 18aba95..4cdc1e0 100644 --- a/pkg/application/rcall/rcall_graph.go +++ b/pkg/application/rcall/rcall_graph.go @@ -2,7 +2,7 @@ package rcall import ( "github.com/phodal/coca/pkg/application/call" - "github.com/phodal/coca/pkg/domain/jdomain" + "github.com/phodal/coca/pkg/domain/core_domain" ) type RCallGraph struct { @@ -12,7 +12,7 @@ func NewRCallGraph() RCallGraph { return RCallGraph{} } -func (c RCallGraph) Analysis(funcName string, clzs []jdomain.JClassNode, writeCallback func(rcallMap map[string][]string)) string { +func (c RCallGraph) Analysis(funcName string, clzs []core_domain.JClassNode, writeCallback func(rcallMap map[string][]string)) string { var projectMethodMap = BuildProjectMethodMap(clzs) rcallMap := BuildRCallMethodMap(clzs, projectMethodMap) @@ -26,7 +26,7 @@ func (c RCallGraph) Analysis(funcName string, clzs []jdomain.JClassNode, writeCa return dotContent } -func BuildProjectMethodMap(clzs []jdomain.JClassNode) map[string]int { +func BuildProjectMethodMap(clzs []core_domain.JClassNode) map[string]int { var maps = make(map[string]int) for _, clz := range clzs { for _, method := range clz.Methods { @@ -37,7 +37,7 @@ func BuildProjectMethodMap(clzs []jdomain.JClassNode) map[string]int { return maps } -func BuildRCallMethodMap(parserDeps []jdomain.JClassNode, projectMaps map[string]int) map[string][]string { +func BuildRCallMethodMap(parserDeps []core_domain.JClassNode, projectMaps map[string]int) map[string][]string { var methodMap = make(map[string][]string) for _, clz := range parserDeps { for _, method := range clz.Methods { diff --git a/pkg/application/rcall/rcall_graph_test.go b/pkg/application/rcall/rcall_graph_test.go index 4d85fbf..b13851e 100644 --- a/pkg/application/rcall/rcall_graph_test.go +++ b/pkg/application/rcall/rcall_graph_test.go @@ -3,7 +3,7 @@ package rcall import ( "encoding/json" "github.com/phodal/coca/cmd/cmd_util" - "github.com/phodal/coca/pkg/domain/jdomain" + "github.com/phodal/coca/pkg/domain/core_domain" "log" "testing" @@ -17,7 +17,7 @@ func MockWriteCallMap(rcallMap map[string][]string) { func TestRCallGraph_Analysis(t *testing.T) { g := NewGomegaWithT(t) - var parsedDeps []jdomain.JClassNode + var parsedDeps []core_domain.JClassNode analyser := NewRCallGraph() file := cmd_util.ReadFile("../../../_fixtures/call/call_api_test.json") if file == nil { @@ -39,7 +39,7 @@ edge [dir="back"]; func TestRCallGraph_Constructor(t *testing.T) { g := NewGomegaWithT(t) - var parsedDeps []jdomain.JClassNode + var parsedDeps []core_domain.JClassNode analyser := NewRCallGraph() file := cmd_util.ReadFile("../../../_fixtures/rcall/constructor_call.json") if file == nil { diff --git a/pkg/application/refactor/rename/rename_method.go b/pkg/application/refactor/rename/rename_method.go index 4f33cc3..c9a5ef9 100644 --- a/pkg/application/refactor/rename/rename_method.go +++ b/pkg/application/refactor/rename/rename_method.go @@ -3,7 +3,6 @@ package unused import ( "github.com/phodal/coca/pkg/application/refactor/rename/support" "github.com/phodal/coca/pkg/domain/core_domain" - "github.com/phodal/coca/pkg/domain/jdomain" "io/ioutil" "log" "strings" @@ -14,9 +13,9 @@ var parsedChange []support.RefactorChangeRelate type RemoveMethodApp struct { } -var parsedDeps []jdomain.JClassNode +var parsedDeps []core_domain.JClassNode -func RenameMethodApp(deps []jdomain.JClassNode) *RemoveMethodApp { +func RenameMethodApp(deps []core_domain.JClassNode) *RemoveMethodApp { parsedDeps = deps return &RemoveMethodApp{} } @@ -26,7 +25,7 @@ func (j *RemoveMethodApp) Refactoring(conf string) { startParse(parsedDeps, parsedChange) } -func startParse(nodes []jdomain.JClassNode, relates []support.RefactorChangeRelate) { +func startParse(nodes []core_domain.JClassNode, relates []support.RefactorChangeRelate) { for _, pkgNode := range nodes { for _, related := range relates { oldInfo := support.BuildMethodPackageInfo(related.OldObj) @@ -67,7 +66,7 @@ func methodCallToMethodModel(call core_domain.CodeCall) core_domain.JMethod { } } -func updateSelfRefs(node jdomain.JClassNode, method core_domain.JMethod, info *support.PackageClassInfo) { +func updateSelfRefs(node core_domain.JClassNode, method core_domain.JMethod, info *support.PackageClassInfo) { path := node.FilePath input, err := ioutil.ReadFile(path) if err != nil { diff --git a/pkg/application/refactor/unusedclasses/unused_classes_app.go b/pkg/application/refactor/unusedclasses/unused_classes_app.go index bcbe5dc..136fa6b 100644 --- a/pkg/application/refactor/unusedclasses/unused_classes_app.go +++ b/pkg/application/refactor/unusedclasses/unused_classes_app.go @@ -1,14 +1,14 @@ package unusedclasses import ( - "github.com/phodal/coca/pkg/domain/jdomain" + "github.com/phodal/coca/pkg/domain/core_domain" "sort" "strings" ) var analysisPackage = "" -func Refactoring(parsedDeps []jdomain.JClassNode) []string { +func Refactoring(parsedDeps []core_domain.JClassNode) []string { sourceClasses := make(map[string]string) targetClasses := make(map[string]string) diff --git a/pkg/application/refactor/unusedclasses/unused_classes_app_test.go b/pkg/application/refactor/unusedclasses/unused_classes_app_test.go index ea6cc20..e89fbe0 100644 --- a/pkg/application/refactor/unusedclasses/unused_classes_app_test.go +++ b/pkg/application/refactor/unusedclasses/unused_classes_app_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" . "github.com/onsi/gomega" "github.com/phodal/coca/cmd/cmd_util" - "github.com/phodal/coca/pkg/domain/jdomain" + "github.com/phodal/coca/pkg/domain/core_domain" "path/filepath" "testing" ) @@ -13,7 +13,7 @@ func TestRefactoring(t *testing.T) { g := NewGomegaWithT(t) - var parsedDeps []jdomain.JClassNode + var parsedDeps []core_domain.JClassNode codePath := "../../../../_fixtures/count/call.json" codePath = filepath.FromSlash(codePath) file := cmd_util.ReadFile(codePath) diff --git a/pkg/application/suggest/suggest_app.go b/pkg/application/suggest/suggest_app.go index d2a3c10..7544ce6 100644 --- a/pkg/application/suggest/suggest_app.go +++ b/pkg/application/suggest/suggest_app.go @@ -1,7 +1,7 @@ package suggest import ( - "github.com/phodal/coca/pkg/domain/jdomain" + "github.com/phodal/coca/pkg/domain/core_domain" "github.com/phodal/coca/pkg/domain/support_domain" ) @@ -12,7 +12,7 @@ func NewSuggestApp() SuggestApp { return SuggestApp{} } -func (a SuggestApp) AnalysisPath(deps []jdomain.JClassNode) []api_domain.Suggest { +func (a SuggestApp) AnalysisPath(deps []core_domain.JClassNode) []api_domain.Suggest { var suggests []api_domain.Suggest for _, clz := range deps { if clz.Type == "Class" { @@ -27,7 +27,7 @@ func (a SuggestApp) AnalysisPath(deps []jdomain.JClassNode) []api_domain.Suggest return suggests } -func factorySuggest(clz jdomain.JClassNode, suggests []api_domain.Suggest) []api_domain.Suggest { +func factorySuggest(clz core_domain.JClassNode, suggests []api_domain.Suggest) []api_domain.Suggest { var constructorCount = 0 var longestParaConstructorMethod = clz.Methods[0] diff --git a/pkg/application/suggest/suggest_app_test.go b/pkg/application/suggest/suggest_app_test.go index 013e7dd..e44ce59 100644 --- a/pkg/application/suggest/suggest_app_test.go +++ b/pkg/application/suggest/suggest_app_test.go @@ -3,7 +3,7 @@ package suggest import ( "encoding/json" "github.com/phodal/coca/cmd/cmd_util" - "github.com/phodal/coca/pkg/domain/jdomain" + "github.com/phodal/coca/pkg/domain/core_domain" "log" "path/filepath" "testing" @@ -14,7 +14,7 @@ import ( func TestConceptAnalyser_Analysis(t *testing.T) { g := NewGomegaWithT(t) - var parsedDeps []jdomain.JClassNode + var parsedDeps []core_domain.JClassNode analyser := NewSuggestApp() codePath := "../../../_fixtures/suggest/factory/factory_suggest.json" codePath = filepath.FromSlash(codePath) diff --git a/pkg/application/tbs/tbs_app.go b/pkg/application/tbs/tbs_app.go index e096f63..e6af450 100644 --- a/pkg/application/tbs/tbs_app.go +++ b/pkg/application/tbs/tbs_app.go @@ -2,7 +2,6 @@ package tbs import ( "github.com/phodal/coca/pkg/domain/core_domain" - "github.com/phodal/coca/pkg/domain/jdomain" "github.com/phodal/coca/pkg/infrastructure/constants" ) @@ -20,9 +19,9 @@ type TestBadSmell struct { Line int } -func (a TbsApp) AnalysisPath(deps []jdomain.JClassNode, identifiersMap map[string]jdomain.JIdentifier) []TestBadSmell { +func (a TbsApp) AnalysisPath(deps []core_domain.JClassNode, identifiersMap map[string]core_domain.JIdentifier) []TestBadSmell { var results []TestBadSmell = nil - callMethodMap := jdomain.BuildCallMethodMap(deps) + callMethodMap := core_domain.BuildCallMethodMap(deps) for _, clz := range deps { for _, method := range clz.Methods { if !method.IsJunitTest() { @@ -70,7 +69,7 @@ func (a TbsApp) AnalysisPath(deps []jdomain.JClassNode, identifiersMap map[strin return results } -func checkAssert(hasAssert bool, clz jdomain.JClassNode, method core_domain.JMethod, results *[]TestBadSmell, testType *string) { +func checkAssert(hasAssert bool, clz core_domain.JClassNode, method core_domain.JMethod, results *[]TestBadSmell, testType *string) { if !hasAssert { *testType = "UnknownTest" tbs := TestBadSmell{ @@ -85,7 +84,7 @@ func checkAssert(hasAssert bool, clz jdomain.JClassNode, method core_domain.JMet } } -func updateMethodCallsForSelfCall(method core_domain.JMethod, clz jdomain.JClassNode, callMethodMap map[string]core_domain.JMethod) []core_domain.CodeCall { +func updateMethodCallsForSelfCall(method core_domain.JMethod, clz core_domain.JClassNode, callMethodMap map[string]core_domain.JMethod) []core_domain.CodeCall { currentMethodCalls := method.MethodCalls for _, methodCall := range currentMethodCalls { if methodCall.Class == clz.Class { @@ -115,7 +114,7 @@ func checkRedundantAssertionTest(path string, call core_domain.CodeCall, method } } -func checkDuplicateAssertTest(clz jdomain.JClassNode, results *[]TestBadSmell, methodCallMap map[string][]core_domain.CodeCall, method core_domain.JMethod, testType *string) { +func checkDuplicateAssertTest(clz core_domain.JClassNode, results *[]TestBadSmell, methodCallMap map[string][]core_domain.CodeCall, method core_domain.JMethod, testType *string) { var isDuplicateAssert = false for _, methodCall := range methodCallMap { if len(methodCall) >= constants.DuplicatedAssertionLimitLength { diff --git a/pkg/application/tbs/tbs_app_test.go b/pkg/application/tbs/tbs_app_test.go index 1ccb097..27933bf 100644 --- a/pkg/application/tbs/tbs_app_test.go +++ b/pkg/application/tbs/tbs_app_test.go @@ -5,7 +5,7 @@ import ( "github.com/phodal/coca/cmd/cmd_util" "github.com/phodal/coca/pkg/adapter/cocafile" "github.com/phodal/coca/pkg/application/analysis" - "github.com/phodal/coca/pkg/domain/jdomain" + "github.com/phodal/coca/pkg/domain/core_domain" "path/filepath" "testing" ) @@ -139,11 +139,11 @@ func buildTbsResult(codePath string) []TestBadSmell { return result } -func BuildTestAnalysisResultsByPath(codePath string) (map[string]jdomain.JIdentifier, []jdomain.JClassNode) { +func BuildTestAnalysisResultsByPath(codePath string) (map[string]core_domain.JIdentifier, []core_domain.JClassNode) { files := cocafile.GetJavaTestFiles(codePath) identifiers := cmd_util.LoadTestIdentify(files) - identifiersMap := jdomain.BuildIdentifierMap(identifiers) + identifiersMap := core_domain.BuildIdentifierMap(identifiers) var classes []string = nil for _, node := range identifiers { diff --git a/pkg/domain/core_domain/code_function.go b/pkg/domain/core_domain/code_function.go index c6bea09..9b58ff3 100644 --- a/pkg/domain/core_domain/code_function.go +++ b/pkg/domain/core_domain/code_function.go @@ -1,7 +1,6 @@ package core_domain import ( - "github.com/phodal/coca/pkg/domain/jdomain" "github.com/phodal/coca/pkg/infrastructure/string_helper" "strings" ) @@ -36,7 +35,7 @@ type JMethod struct { IsConstructor bool IsReturnNull bool Modifiers []string - Creators []jdomain.JClassNode + Creators []JClassNode Position CodePosition } @@ -56,7 +55,7 @@ func (m *JMethod) IsGetterSetter() bool { return strings.HasPrefix(m.Name, "set") || strings.HasPrefix(m.Name, "get") } -func (m *JMethod) BuildFullMethodName(node jdomain.JClassNode) string { +func (m *JMethod) BuildFullMethodName(node JClassNode) string { return node.Package + "." + node.Class + "." + m.Name } diff --git a/pkg/domain/jdomain/jclass_node.go b/pkg/domain/core_domain/jclass_node.go similarity index 68% rename from pkg/domain/jdomain/jclass_node.go rename to pkg/domain/core_domain/jclass_node.go index caa5d53..8546817 100644 --- a/pkg/domain/jdomain/jclass_node.go +++ b/pkg/domain/core_domain/jclass_node.go @@ -1,7 +1,6 @@ -package jdomain +package core_domain import ( - "github.com/phodal/coca/pkg/domain/core_domain" "strings" ) @@ -10,14 +9,14 @@ type JClassNode struct { Class string Type string FilePath string - Fields []core_domain.CodeField - Methods []core_domain.JMethod - MethodCalls []core_domain.CodeCall + Fields []CodeField + Methods []JMethod + MethodCalls []CodeCall Extend string Implements []string - Annotations []core_domain.CodeAnnotation + Annotations []CodeAnnotation InnerClass []JClassNode - Imports []core_domain.CodeImport + Imports []CodeImport } func NewClassNode() *JClassNode { @@ -32,8 +31,8 @@ func (j *JClassNode) IsServiceClass() bool { return strings.Contains(strings.ToLower(j.Class), "service") } -func (j *JClassNode) SetMethodFromMap(methodMap map[string]core_domain.JMethod) { - var methodsArray []core_domain.JMethod +func (j *JClassNode) SetMethodFromMap(methodMap map[string]JMethod) { + var methodsArray []JMethod for _, value := range methodMap { methodsArray = append(methodsArray, value) } @@ -51,8 +50,8 @@ func (j *JClassNode) IsNotEmpty() bool { return len(j.Methods) > 0 || len(j.MethodCalls) > 0 } -func BuildCallMethodMap(deps []JClassNode) map[string]core_domain.JMethod { - var callMethodMap = make(map[string]core_domain.JMethod) +func BuildCallMethodMap(deps []JClassNode) map[string]JMethod { + var callMethodMap = make(map[string]JMethod) for _, clz := range deps { for _, method := range clz.Methods { callMethodMap[method.BuildFullMethodName(clz)] = method diff --git a/pkg/domain/jdomain/jidentifier.go b/pkg/domain/core_domain/jidentifier.go similarity index 78% rename from pkg/domain/jdomain/jidentifier.go rename to pkg/domain/core_domain/jidentifier.go index ccd1d32..4e70f55 100644 --- a/pkg/domain/jdomain/jidentifier.go +++ b/pkg/domain/core_domain/jidentifier.go @@ -1,8 +1,6 @@ -package jdomain +package core_domain -import "github.com/phodal/coca/pkg/domain/core_domain" - -var methods []core_domain.JMethod +var methods []JMethod type JIdentifier struct { Package string @@ -11,8 +9,8 @@ type JIdentifier struct { ExtendsName string Extends []string Implements []string - Methods []core_domain.JMethod - Annotations []core_domain.CodeAnnotation + Methods []JMethod + Annotations []CodeAnnotation } func NewJIdentifier() *JIdentifier { @@ -21,11 +19,11 @@ func NewJIdentifier() *JIdentifier { return identifier } -func (identifier *JIdentifier) AddMethod(method core_domain.JMethod) { +func (identifier *JIdentifier) AddMethod(method JMethod) { methods = append(methods, method) } -func (identifier *JIdentifier) GetMethods() []core_domain.JMethod { +func (identifier *JIdentifier) GetMethods() []JMethod { return methods } diff --git a/pkg/domain/support_domain/suggest.go b/pkg/domain/support_domain/suggest.go index f116b21..1b5114e 100644 --- a/pkg/domain/support_domain/suggest.go +++ b/pkg/domain/support_domain/suggest.go @@ -1,7 +1,7 @@ package api_domain import ( - "github.com/phodal/coca/pkg/domain/jdomain" + "github.com/phodal/coca/pkg/domain/core_domain" "strings" ) @@ -15,7 +15,7 @@ type Suggest struct { Line int } -func NewSuggest(clz jdomain.JClassNode, pattern, reason string) Suggest { +func NewSuggest(clz core_domain.JClassNode, pattern, reason string) Suggest { return Suggest{ File: clz.FilePath, Package: clz.Package, @@ -25,7 +25,7 @@ func NewSuggest(clz jdomain.JClassNode, pattern, reason string) Suggest { } } -func MergeSuggest(clz jdomain.JClassNode, currentSuggestList []Suggest) Suggest { +func MergeSuggest(clz core_domain.JClassNode, currentSuggestList []Suggest) Suggest { var suggest = NewSuggest(clz, "", "") for _, s := range currentSuggestList { if !strings.Contains(suggest.Pattern, s.Pattern) { diff --git a/pkg/infrastructure/ast/api/java_api_listener.go b/pkg/infrastructure/ast/api/java_api_listener.go index 0c552d1..8d3be82 100644 --- a/pkg/infrastructure/ast/api/java_api_listener.go +++ b/pkg/infrastructure/ast/api/java_api_listener.go @@ -3,13 +3,13 @@ package api import ( "github.com/antlr/antlr4/runtime/Go/antlr" "github.com/phodal/coca/languages/java" - "github.com/phodal/coca/pkg/domain/jdomain" + "github.com/phodal/coca/pkg/domain/core_domain" "github.com/phodal/coca/pkg/domain/support_domain" "reflect" "strings" ) -var jClassNodes []jdomain.JClassNode +var jClassNodes []core_domain.JClassNode var hasEnterClass = false var isSpringRestController = false @@ -22,11 +22,11 @@ var restAPIs []api_domain.RestAPI var currentClz string var currentPkg string -var identMap map[string]jdomain.JIdentifier +var identMap map[string]core_domain.JIdentifier var imports []string var currentImplements = "" -func NewJavaAPIListener(jIdentMap map[string]jdomain.JIdentifier, diMap map[string]string) *JavaAPIListener { +func NewJavaAPIListener(jIdentMap map[string]core_domain.JIdentifier, diMap map[string]string) *JavaAPIListener { isSpringRestController = false currentClz = "" currentPkg = "" @@ -300,7 +300,7 @@ func buildMethodParameters(requestBodyClass string) { currentRestAPI.MethodParams = params } -func (s *JavaAPIListener) AppendClasses(classes []jdomain.JClassNode) { +func (s *JavaAPIListener) AppendClasses(classes []core_domain.JClassNode) { jClassNodes = classes } diff --git a/pkg/infrastructure/ast/full/java_full_listener.go b/pkg/infrastructure/ast/full/java_full_listener.go index 39e5ebd..d4d965d 100644 --- a/pkg/infrastructure/ast/full/java_full_listener.go +++ b/pkg/infrastructure/ast/full/java_full_listener.go @@ -4,7 +4,6 @@ import ( "github.com/antlr/antlr4/runtime/Go/antlr" "github.com/phodal/coca/languages/java" "github.com/phodal/coca/pkg/domain/core_domain" - "github.com/phodal/coca/pkg/domain/jdomain" "github.com/phodal/coca/pkg/infrastructure/ast/common_listener" "reflect" "strconv" @@ -30,25 +29,25 @@ var creatorMethodMap = make(map[string]core_domain.JMethod) var methodQueue []core_domain.JMethod var classStringQueue []string -var identMap map[string]jdomain.JIdentifier +var identMap map[string]core_domain.JIdentifier var isOverrideMethod = false -var classNodeQueue []jdomain.JClassNode +var classNodeQueue []core_domain.JClassNode -var currentNode *jdomain.JClassNode -var classNodes []jdomain.JClassNode -var creatorNodes []jdomain.JClassNode -var currentCreatorNode jdomain.JClassNode +var currentNode *core_domain.JClassNode +var classNodes []core_domain.JClassNode +var creatorNodes []core_domain.JClassNode +var currentCreatorNode core_domain.JClassNode var fileName = "" var hasEnterClass = false -func NewJavaFullListener(nodes map[string]jdomain.JIdentifier, file string) *JavaFullListener { +func NewJavaFullListener(nodes map[string]core_domain.JIdentifier, file string) *JavaFullListener { identMap = nodes imports = nil fileName = file currentPkg = "" classNodes = nil - currentNode = jdomain.NewClassNode() + currentNode = core_domain.NewClassNode() classStringQueue = nil classNodeQueue = nil methodQueue = nil @@ -73,7 +72,7 @@ type JavaFullListener struct { parser.BaseJavaParserListener } -func (s *JavaFullListener) GetNodeInfo() []jdomain.JClassNode { +func (s *JavaFullListener) GetNodeInfo() []core_domain.JClassNode { return classNodes } @@ -100,7 +99,7 @@ func (s *JavaFullListener) exitBody() { } if currentNode.Class == "" { - currentNode = jdomain.NewClassNode() + currentNode = core_domain.NewClassNode() initClass() return } @@ -119,7 +118,7 @@ func (s *JavaFullListener) exitBody() { currentNode = &classNodeQueue[len(classNodeQueue)-1] } } else { - currentNode = jdomain.NewClassNode() + currentNode = core_domain.NewClassNode() } initClass() @@ -445,7 +444,7 @@ func (s *JavaFullListener) EnterCreator(ctx *parser.CreatorContext) { currentType = "CreatorClass" text := ctx.CreatedName().GetText() - creatorNode := &jdomain.JClassNode{ + creatorNode := &core_domain.JClassNode{ Package: currentPkg, Class: text, Type: "CreatorClass", @@ -473,7 +472,7 @@ func (s *JavaFullListener) ExitCreator(ctx *parser.CreatorContext) { if currentType == "CreatorClass" { currentType = "" } - currentCreatorNode = *jdomain.NewClassNode() + currentCreatorNode = *core_domain.NewClassNode() if classNodeQueue == nil || len(classNodeQueue) < 1 { return diff --git a/pkg/infrastructure/ast/identifier/java_identifier_listener.go b/pkg/infrastructure/ast/identifier/java_identifier_listener.go index ea36863..4be34ea 100644 --- a/pkg/infrastructure/ast/identifier/java_identifier_listener.go +++ b/pkg/infrastructure/ast/identifier/java_identifier_listener.go @@ -4,14 +4,13 @@ import ( "github.com/antlr/antlr4/runtime/Go/antlr" "github.com/phodal/coca/languages/java" "github.com/phodal/coca/pkg/domain/core_domain" - "github.com/phodal/coca/pkg/domain/jdomain" common_listener2 "github.com/phodal/coca/pkg/infrastructure/ast/common_listener" "reflect" "strings" ) -var currentNode *jdomain.JIdentifier -var nodes []jdomain.JIdentifier +var currentNode *core_domain.JIdentifier +var nodes []core_domain.JIdentifier var currentMethod core_domain.JMethod var hasEnterClass = false @@ -19,7 +18,7 @@ var imports []string func NewJavaIdentifierListener() *JavaIdentifierListener { nodes = nil - currentNode = jdomain.NewJIdentifier() + currentNode = core_domain.NewJIdentifier() currentMethod = core_domain.NewJMethod() return &JavaIdentifierListener{} } @@ -70,7 +69,7 @@ func (s *JavaIdentifierListener) ExitClassBody(ctx *parser.ClassBodyContext) { currentNode.Methods = currentNode.GetMethods() nodes = append(nodes, *currentNode) } - currentNode = jdomain.NewJIdentifier() + currentNode = core_domain.NewJIdentifier() } func (s *JavaIdentifierListener) ExitInterfaceDeclaration(ctx *parser.InterfaceDeclarationContext) { @@ -79,7 +78,7 @@ func (s *JavaIdentifierListener) ExitInterfaceDeclaration(ctx *parser.InterfaceD currentNode.Methods = currentNode.GetMethods() nodes = append(nodes, *currentNode) } - currentNode = jdomain.NewJIdentifier() + currentNode = core_domain.NewJIdentifier() } func (s *JavaIdentifierListener) EnterConstructorDeclaration(ctx *parser.ConstructorDeclarationContext) { @@ -219,6 +218,6 @@ func (s *JavaIdentifierListener) EnterExpression(ctx *parser.ExpressionContext) } } -func (s *JavaIdentifierListener) GetNodes() []jdomain.JIdentifier { +func (s *JavaIdentifierListener) GetNodes() []core_domain.JIdentifier { return nodes } diff --git a/trial/pkg/application/processor/process_test.go b/trial/pkg/application/processor/process_test.go index 8f7ce5f..364a20b 100644 --- a/trial/pkg/application/processor/process_test.go +++ b/trial/pkg/application/processor/process_test.go @@ -10,5 +10,5 @@ func Test_ProcessPackage(t *testing.T) { g := NewGomegaWithT(t) results := ProcessPackage("../../../../pkg/domain", true) - g.Expect(len(results)).To(Equal(25)) + g.Expect(len(results)).To(Equal(23)) } \ No newline at end of file -- GitLab