Open obiwan87 opened 5 months ago
How about Specify type explicitly
? I don't need it often, but when I need it, it's really useful in other languages as well.
For instance, here in TypeScript when I am not fully sure of the type, and the type could be obfuscated from generics.
Like for this trivial example:
points_arr := make([]f32, 3 * n)
How about
Specify type explicitly
? I don't need it often, but when I need it, it's really useful in other languages as well.
Added it to the list ;-)
@Dima-369 Added support for "Specify type explicitly". I already found a little bug. The intention is not triggered at the end of an identifier, only at the beginning and in the middle of it
identifier := value
so if the cursor is after the "r" it won't trigger
Added support for "Specify type explicitly"
Cool, I tested with fmt.println()
and with a local proc in the same file, and it worked flawlessly! This is really useful, thanks!
But, it fails on os.args
, probably because it is defined like this.
// "Argv" arguments converted to Odin strings
args := _alloc_command_line_arguments()
It also fails on this: lines := strings.split("foo", "\n")
Yes, procedures with multiple values are not supported yet. Basically I wasn't sure how Odin handles multiple return values, when stored in only one variable. Would it be always safe to just infer the type of the first return argument?
os.args
: Yes, the builtin-stuff is not fully supported yet. I'll look into it in another ticket
how Odin handles multiple return values, when stored in only one variable. Would it be always safe to just infer the type of the first return argument?
I think so, yes.
Got ya.
There is so much more to this functionality. I thought about this feature this morning and there is a lot more to it that I haven't yet implemented. With composite types like procedures types maps and instantiated poly structs it should not work either.
Basically you have to analyze all the types a type might contain and import the package they're in, or use the import that is already defined in the current file.
Add refactoring handlers for: