Fixed false positive warning for script statements in preamble.
This commit is contained in:
parent
566f7921e5
commit
4800ceb34f
@ -1,6 +1,5 @@
|
||||
package groowt.view.component.web.transpile;
|
||||
|
||||
import groovy.transform.Field;
|
||||
import groowt.view.component.compiler.ComponentTemplateCompileException;
|
||||
import groowt.view.component.compiler.ComponentTemplateCompileUnit;
|
||||
import groowt.view.component.compiler.ComponentTemplateCompilerConfiguration;
|
||||
@ -32,8 +31,6 @@ public class DefaultGroovyTranspiler implements GroovyTranspiler {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(DefaultGroovyTranspiler.class);
|
||||
|
||||
private static final ClassNode FIELD_ANNOTATION = ClassHelper.make(Field.class);
|
||||
|
||||
protected TranspilerConfiguration getConfiguration(
|
||||
ClassLoaderComponentClassNodeResolver classLoaderComponentClassNodeResolver
|
||||
) {
|
||||
@ -122,7 +119,10 @@ public class DefaultGroovyTranspiler implements GroovyTranspiler {
|
||||
}
|
||||
|
||||
final BlockStatement preambleBlock = convertResult.blockStatement();
|
||||
if (preambleBlock != null) {
|
||||
if (!(preambleBlock == null
|
||||
|| preambleBlock.isEmpty()
|
||||
|| preambleBlock.getStatements().getFirst() instanceof ReturnStatement)
|
||||
) {
|
||||
logger.warn(
|
||||
"{} contains script statements which are not supported. Currently, only classes and"
|
||||
+ " methods are supported. The rest will be ignored.",
|
||||
|
@ -89,4 +89,14 @@ public abstract class GroovyTranspilerTests {
|
||||
this.doTranspile("<GroovyTranspilerTests.Greeter target='World' />");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void withPackageInPreamble() {
|
||||
this.doTranspile("""
|
||||
---
|
||||
package test
|
||||
---
|
||||
Hello, World!
|
||||
""".stripIndent().trim());
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user