diff --git a/_fixtures/grammar/HostDependentDownloadableContribution.java b/_fixtures/grammar/HostDependentDownloadableContribution.java new file mode 100644 index 0000000000000000000000000000000000000000..bc77b0e73eef266f1361d4c728cf449a7241c1b1 --- /dev/null +++ b/_fixtures/grammar/HostDependentDownloadableContribution.java @@ -0,0 +1,31 @@ +package cc.arduino.packages.contributions; + +import org.junit.Test; +import processing.app.Platform; + +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +public class HostDependentDownloadableContribution{ + + public void macOsXPositiveTest() { + HostDependentDownloadableContributionStub contribution = new HostDependentDownloadableContributionStub() { + @Override + public String getHost() { + return "x86_64-apple-darwin"; + } + }; + + Platform platform = new Platform() { + @Override + public String getOsName() { + return "Mac OS X"; + } + + @Override + public String getOsArch() { + return "x86_64"; + } + }; + } +} \ No newline at end of file diff --git a/core/adapter/call/java_call_app_test.go b/core/adapter/call/java_call_app_test.go index 6fc39c066b3239f19c3a240e8f256fbe31ad86ca..bca94aed94075d98ef020a71811e3a0cf5ed2e05 100644 --- a/core/adapter/call/java_call_app_test.go +++ b/core/adapter/call/java_call_app_test.go @@ -1,6 +1,7 @@ package call import ( + "fmt" . "github.com/onsi/gomega" "github.com/phodal/coca/core/adapter/identifier" "github.com/phodal/coca/core/models" @@ -76,7 +77,6 @@ func TestInterface(t *testing.T) { callNodes := getCallNodes(codePath) - g.Expect(true).To(Equal(true)) methodMap := make(map[string]models.JMethod) for _, c := range callNodes[0].Methods { methodMap[c.Name] = c @@ -84,4 +84,23 @@ func TestInterface(t *testing.T) { g.Expect(len(callNodes[0].Methods)).To(Equal(6)) g.Expect(methodMap["count"].Name).To(Equal("count")) +} + +func TestAnnotation(t *testing.T) { + g := NewGomegaWithT(t) + + codePath := "../../../_fixtures/grammar/HostDependentDownloadableContribution.java" + codePath = filepath.FromSlash(codePath) + + callNodes := getCallNodes(codePath) + + methodMap := make(map[string]models.JMethod) + for _, c := range callNodes[0].Methods { + methodMap[c.Name] = c + } + g.Expect(methodMap["macOsXPositiveTest"].Name).To(Equal("macOsXPositiveTest")) + + for _, call := range methodMap["macOsXPositiveTest"].MethodCalls { + fmt.Println(call.Class) + } } \ No newline at end of file diff --git a/core/adapter/call/java_call_listener.go b/core/adapter/call/java_call_listener.go index c74dbcc1cd3f807ae668dde890354c9b44cec92f..7b5fce314701a21c0bf9178ed721937f4afb0f8c 100644 --- a/core/adapter/call/java_call_listener.go +++ b/core/adapter/call/java_call_listener.go @@ -364,14 +364,17 @@ func getMethodMapName(method models.JMethod) string { func (s *JavaCallListener) EnterCreator(ctx *parser.CreatorContext) { variableName := ctx.GetParent().GetParent().GetChild(0).(antlr.ParseTree).GetText() - createdName := ctx.CreatedName().GetText() - localVars[variableName] = createdName + allIdentifiers := ctx.CreatedName().(*parser.CreatedNameContext).AllIDENTIFIER() + for _, identifier := range allIdentifiers { + createdName := identifier.GetText() + localVars[variableName] = createdName - if currentMethod.Name == "" { - return - } + if currentMethod.Name == "" { + return + } - buildCreatedCall(createdName, ctx) + buildCreatedCall(createdName, ctx) + } } func buildCreatedCall(createdName string, ctx *parser.CreatorContext) { diff --git a/core/domain/tbs/tbs_app_test.go b/core/domain/tbs/tbs_app_test.go index cf59824f42918a6266bd30a747f8c8232a3fac82..c63768993b3ab1c80b646d030ba8ccddae8e9e1f 100644 --- a/core/domain/tbs/tbs_app_test.go +++ b/core/domain/tbs/tbs_app_test.go @@ -1,7 +1,6 @@ package tbs import ( - "fmt" . "github.com/onsi/gomega" "github.com/phodal/coca/core/adapter" "github.com/phodal/coca/core/adapter/call"