-
Notifications
You must be signed in to change notification settings - Fork 17
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
Nightly Safe Macros #98
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks ok to me (didn't test it yet), but would be nice to have actual tests for that.. I'd like to find time to add that either here or in Haxe (we have 3rd party tests there but not 3rd party compilation server tests yet)
|
||
static var counter:Int = 0; | ||
private static var writers = new Map<String, Type>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Uh, it's weird that this wasn't being used at all
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, the schema writer only seemed to have the old counter and caching system half implemented.
Tests for this would be nice (the existing functionality ones pass but the CI is knackered right now) but I'm not sure how I'd go about testing this language server stuff? Add some basic tests to check if two json parsers for the same type give instances of the same class instead of the old incrementing counter? |
Having done some debugging into the above redefinition stuff it appears the persistent map is getting emptied for hover requests function main() {
final p1 = new JsonParser<Array<String>>();
final p2 = new JsonParser<Array<String>>();
} Hovering over
However any hover requests will report that the parser was not found in the map and attempt to define another one, resulting in the redefinition.
If I remove the map check and just keep the (all with lastest nightly and vscode) |
Checking if there's something wrong on compiler side here.. 🤔 |
How exactly are you doing that? I cannot reproduce :/ |
I just tried again and its not happening for me now either... I'll check the proper project I first saw it in later on instead of just a small sample. |
I did spot some weird behavior, that went away by replacing |
I have noticed that if I have a static JsonParser and hover over it the type will show as Dynamic instead of the generated type, also occasionally on those static hovers I get nothing and a "cannot construct dynamic" message appears in the server output. Have not mentioned it before as I'm not sure if thats related to this or something else, but I'll try and narrow that one down as well. |
Yeah, it's the |
Uhhhh.. makes sense actually: https://github.com/HaxeFoundation/haxe/blob/development/src/typing/typeload.ml#L644-L648 |
I gave that merge ago and seems to work well, also tried it out on another project I was seeing occasional |
Right now this PR doesn't work properly because it relies on resolveType which has issues during display requests. isAlive should be changed Edit: PR has been merged on Haxe side so this |
Oops, forgot about this. When you said |
This attempts to update the reader and writer macros to play nicely with haxe nightlies completion.
The type of the reader / writer is hashed and used as part of the generated types name and it will avoid defining multiple classes for the same type, this is following the guidelines from this PR (HaxeFoundation/haxe#11159).
This seems to work nicely in my experience so far, previously completion use to fall apart around parsers but it seems to be holding up well so far.
The
defineType
call incopyType
still seems a bit dodgy, but I'm not sure why this function exists / when its exactly used yet.cc @kLabz in case they want to make sure I've not misunderstood that haxe PRs purpose.