You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I need to enable the TypeChecked when compile my project. And I also want to customize the compile error output for certain types of compilation error, so I write a Type-Checking-Extension according to the doc. I build my project with maven and GMavenPlus-plugin. Both TypeCheck and type-checking-extension do not work. The compilation successed.
[INFO] Scanning for projects...
[INFO]
[INFO] -------------------< com.example:springboot_groovy >--------------------
[INFO] Building springboot_groovy 0.0.1-SNAPSHOT
[INFO] from pom.xml
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- resources:3.2.0:resources (default-resources) @ springboot_groovy ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Using 'UTF-8' encoding to copy filtered properties files.
[INFO] Copying 1 resource
[INFO] Copying 0 resource
[INFO]
[INFO] --- compiler:3.8.1:compile (default-compile) @ springboot_groovy ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 1 source file to C:\Users\jianh\Desktop\bendi_ht\springboot_groovy\target\classes
[INFO]
[INFO] --- gplus:3.0.2:compile (default) @ springboot_groovy ---
[INFO] Using isolated classloader, without GMavenPlus classpath.
[INFO] Using Groovy 3.0.8 to perform compile.
[INFO] Parallel parsing disabled.
[INFO] Compiled 6 files.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.922 s
[INFO] Finished at: 2024-07-24T15:19:20+08:00
[INFO] ------------------------------------------------------------------------
Here's a demo of my project: DemoController.groovy:
// a demo groovy source code with error!
import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.RestController
@RestController
class DemoController {
@GetMapping("/hello")
String sayHello() {
// use an undeclared variable
println robot
}
}
config.groovy
// I hope to enable TypeChecked and customized extension
import org.codehaus.groovy.control.CompilerConfiguration
import org.codehaus.groovy.control.customizers.ASTTransformationCustomizer
import groovy.transform.TypeChecked
def config = new CompilerConfiguration()
config.addCompilationCustomizers(
new ASTTransformationCustomizer(
TypeChecked,
extensions: ['CheckExtension.groovy'])
)
CheckExtension.groovy
// when meet an undeclared var which name is 'robot', then add customized error info
unresolvedVariable { var ->
if ('robot'==var.name) {
//customized compile error info
addStaticTypeError("Customize Error Info: hahaha", var)
}
}
The structure of my project is a little strange, however, I'm not allowed to change it:
Moreover, my real need is to customize the compile error output for calling a method with miss-matching numbers of parameters, e.g., a method definition with 2 params, but only give 1 when call this method.
In this condition, what should the customized extension be like? I've tried to read the doc, but that's really difficult for me...
The text was updated successfully, but these errors were encountered:
I need to enable the TypeChecked when compile my project. And I also want to customize the compile error output for certain types of compilation error, so I write a Type-Checking-Extension according to the doc. I build my project with maven and GMavenPlus-plugin. Both TypeCheck and type-checking-extension do not work. The compilation successed.
Here's a demo of my project:
DemoController.groovy:
config.groovy
CheckExtension.groovy
The structure of my project is a little strange, however, I'm not allowed to change it:
I use GMavenPlus plugin in the maven:
I wonder what's wrong with my config? Thanks!
Moreover, my real need is to customize the compile error output for calling a method with miss-matching numbers of parameters, e.g., a method definition with 2 params, but only give 1 when call this method.
In this condition, what should the customized extension be like? I've tried to read the doc, but that's really difficult for me...
The text was updated successfully, but these errors were encountered: