Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inline annotations #50

Closed
wants to merge 1 commit into from
Closed

Inline annotations #50

wants to merge 1 commit into from

Conversation

kimburgess
Copy link
Contributor

Add supports for normal annotation semantics when marking up routes defined by macros.

@[ActionController::TestAnnotation(test: "inline")]
get "/example" do
  # ...
end

Annotation a captured onto a throwaway type, then re-applied to the appropriate method when routes are drawn. As the original types are unused these will be dropped by the compiler.

Currently a limitation exists where the types of annotation need to be explicitly specified, however will continue searching for a solution to this. Until that is resolved, treat this as a proof of concept only.

@kimburgess kimburgess requested review from stakach and caspiano August 12, 2021 16:46
@@ -575,6 +579,7 @@ abstract class ActionController::Base
{% unless name %}
{% name = "ws" + path.gsub(/\/|\-|\~|\*|\:|\./, "_") %}
{% end %}
private struct ANN__{{name.id}}; end
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hahah wow this is great.

@kimburgess
Copy link
Contributor Author

Related: crystal-lang/crystal#9322

@caspiano
Copy link
Contributor

Closing in favour of c05553b

@caspiano caspiano closed this Apr 29, 2022
@caspiano caspiano deleted the feat/inline-annotations branch April 29, 2022 12:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants