-
Notifications
You must be signed in to change notification settings - Fork 29
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
Fixed anonymous struct completion #23
Conversation
From that diff it looks like you accidentally reverted some changes I made in da80752. |
Also, this seems to stop working with the test case from HaxeFoundation/haxe#3907 if there is a space before the cursor after the opening Works: Doesn't work: |
static function calculateCompletionPosition(text:String, index:Int):CompletionPosition { | ||
text = text.substring(0, index); |
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.
This should also be removed.
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.
Ah, sorry. I'm not very used to the code base
@@ -36,7 +36,7 @@ class CompletionFeature { | |||
} | |||
|
|||
static var reFieldPart = ~/(\.|@(:?))(\w*)$/; | |||
static var reStructPart = ~/[(,]\s*{\s*((\s*\w+\s*:\s*["'\w()\.]+\s*,\s*)*\w*)$/; | |||
static var reStructPart = ~/[(,]\s*{(\s*(\s*\w+\s*:\s*["'\w()\.]+\s*,\s*)*\w*)$/; |
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.
I had to move the \s
into the capture group for the whitespace fix to actually work.
Thanks, seems to work nicely now! I don't particularly like that completion needs to be triggered manually here, maybe we can improve that in the future. |
I just noticed that the pattern has some serious flaws(I should have tested it on real code). For example when you have a structure containing other structures(it doesn't work recursively). Also when having operators in function it also doesn't work. Here some examples: test({
twoSquared: 2*2, // Breaks suggestion
person: new Person({firstName: "Bill", surname: "Gates"}) // Breaks also the suggestions for the following code
}); |
Even the compiler doesn't know that you're declaring a structure until it sees the |
Today I found out that the |
I've put some research into the data the language server spits out and it seemed like the extension never gets informations about the field names.
The reason for this is, that the extension asks the language server for top level completion. The fix was pretty easy, I just had to edit the function which checks wether to use top level completion.
This should fix https://github.com/vshaxe/haxe-languageserver/issues/21