未验证 提交 d14e2ebf 编写于 作者: P Phodal Huang

fix: add multiple creator test

上级 af74af95
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
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
......@@ -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) {
......
package tbs
import (
"fmt"
. "github.com/onsi/gomega"
"github.com/phodal/coca/core/adapter"
"github.com/phodal/coca/core/adapter/call"
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册