ballerina-lang
ballerina-lang copied to clipboard
[Bug]: Source modifier task not working properly
Description
I'm trying to write a source modifier task for a compiler plugin. The requirement is something like the following:
- User can annotate an empty HTTP service with an annotation
- When the compiler plugin sees this annotation, it'll go ahead and generate some resource methods inside the service
- This should be do-able in both regular source files and test source files
e.g.,
// annotated service
@mediation:Service {
apiYaml: "",
openAPI: ""
}
service on new http:Listener(9999) {
}
The compiler plugin would modify the above service as follows when building/running the project.
@mediation:Service {
apiYaml: "",
openAPI: ""
}
service on new http:Listener(9999) {
resource function get greet(http:Request req) returns json {
return {"greeting": "Hello World from Greet!"};
}
}
However, when trying to do the above, ran into some inconsistent behaviour. Observations:
- When observability is enabled, the service would properly be modified only in regular source files (verified by running the project and sending a request to the generated resource). It doesn't get modified in test source files. (verified by running a test which makes a request to the generated resource and asserts the response).
- However, in the above case, it still worked properly for test sources as well when the
Dependencies.toml
wasn't present. i.e., deleted the file and ran the test - When observability was disabled, the service got modified properly in test sources. But now, it wasn't getting modified in regular source files.
Steps to Reproduce
No response
Affected Version(s)
Checked in following versions:
2201.1.0
2201.1.1
OS, DB, other environment details and versions
No response
Related area
Other
Related issue(s) (optional)
No response
Suggested label(s) (optional)
No response
Suggested assignee(s) (optional)
No response
We did fixes for code modifiers in 2201.2.1. Can you check if this fixed with Update 2 latest patch?
@pubudu91 Any update on this?
@pubudu91 Any update on this?
Sorry, missed this. IIRC, I tried this with 2201.2.x as Asma suggested and didn't come across this issue. Hence closing this.
This issue is NOT closed with a proper Reason/ label. Make sure to add proper reason label before closing. Please add or leave a comment with the proper reason label now.
- Reason/EngineeringMistake - The issue occurred due to a mistake made in the past.
- Reason/Regression - The issue has introduced a regression.
- Reason/MultipleComponentInteraction - Issue occured due to interactions in multiple components.
- Reason/Complex - Issue occurred due to complex scenario.
- Reason/Invalid - Issue is invalid.
- Reason/Other - None of the above cases.