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

Add crystal tool method_types for listing method parameter types #14696

Open
nobodywasishere opened this issue Jun 11, 2024 · 4 comments
Open

Comments

@nobodywasishere
Copy link
Contributor

Feature Request

This tool would output for every method with untyped parameters, the inferred type. For example:

def my_method(param)
 param.to_s
end

my_method(1)
$ crystal tool method_types file.cr

file.cr:1:1 - ::my_method
  - param : Int32
  - return : String

This would then allow people to write code without types at first, and then later on be able to fill them in. This could also be integrated into the vscode extension to allow viewing the inferred inline type (similar to other languages like Rust). Ideally, this would also have JSON output as well.

@yxhuvud
Copy link
Contributor

yxhuvud commented Jun 11, 2024

Would also be nice to be able to give it a line number, then it can be invoked manually on a specific method.

@straight-shoota
Copy link
Member

Prior art: oprypin/crystal@argtohtml...annotator~#diff-bc28f7dec1
This was used for #10575

@crimson-knight
Copy link

@yxhuvud what would be the point of giving it a line number for it to tell you the type?

@yxhuvud
Copy link
Contributor

yxhuvud commented Jun 11, 2024

@crimson-knight Then you can have a button in your editor to add it to a specific line.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants