Skip to content

Commit 5339db6

Browse files
committed
Merge remote-tracking branch 'fork/submit/stabilize-integration-ci' into HEAD
2 parents 2414743 + 62008a7 commit 5339db6

2 files changed

Lines changed: 51 additions & 1 deletion

File tree

mdl/visitor/visitor_javaaction.go

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ func (b *Builder) ExitCreateJavaActionStatement(ctx *parser.CreateJavaActionStat
5555
// Get return type
5656
if retType := ctx.JavaActionReturnType(); retType != nil {
5757
if dt := retType.DataType(); dt != nil {
58-
stmt.ReturnType = buildDataType(dt)
58+
stmt.ReturnType = buildJavaActionReturnType(dt)
5959
}
6060
}
6161

@@ -101,6 +101,35 @@ func (b *Builder) ExitCreateJavaActionStatement(ctx *parser.CreateJavaActionStat
101101
b.statements = append(b.statements, stmt)
102102
}
103103

104+
func buildJavaActionReturnType(ctx parser.IDataTypeContext) ast.DataType {
105+
dt := buildDataType(ctx)
106+
if isVoidReturnType(dt) {
107+
return ast.DataType{Kind: ast.TypeVoid}
108+
}
109+
return dt
110+
}
111+
112+
func isVoidReturnType(dt ast.DataType) bool {
113+
var name ast.QualifiedName
114+
switch dt.Kind {
115+
case ast.TypeVoid:
116+
return true
117+
case ast.TypeEntity:
118+
if dt.EntityRef == nil {
119+
return false
120+
}
121+
name = *dt.EntityRef
122+
case ast.TypeEnumeration:
123+
if dt.EnumRef == nil {
124+
return false
125+
}
126+
name = *dt.EnumRef
127+
default:
128+
return false
129+
}
130+
return name.Module == "" && strings.EqualFold(name.Name, "void")
131+
}
132+
104133
// extractJavaImports separates `import ...;` lines from Java code.
105134
// Lines matching the Java import statement pattern are returned as imports;
106135
// the remaining lines form the method body. This handles the common case

mdl/visitor/visitor_javaaction_test.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,27 @@ $$;`
300300
}
301301
}
302302

303+
func TestJavaAction_ExplicitVoidReturnType(t *testing.T) {
304+
input := `CREATE JAVA ACTION MyModule.DoStuff()
305+
RETURNS Void
306+
AS $$
307+
System.out.println("done");
308+
$$;`
309+
310+
prog, errs := Build(input)
311+
if len(errs) > 0 {
312+
for _, err := range errs {
313+
t.Errorf("Parse error: %v", err)
314+
}
315+
return
316+
}
317+
318+
stmt := prog.Statements[0].(*ast.CreateJavaActionStmt)
319+
if stmt.ReturnType.Kind != ast.TypeVoid {
320+
t.Fatalf("ReturnType.Kind = %v, want TypeVoid", stmt.ReturnType.Kind)
321+
}
322+
}
323+
303324
func TestJavaAction_TypeParamWithMixedParamTypes(t *testing.T) {
304325
// Mix ENTITY <pEntity> declaration, bare type param ref, and regular typed params
305326
input := `CREATE JAVA ACTION MyModule.ProcessEntity(

0 commit comments

Comments
 (0)