-
Notifications
You must be signed in to change notification settings - Fork 196
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(vscode): static completions for
Json.
wrong/missing after other…
… expressions (#3137) I believe this is a regression from #3128. See the new test cases for the issues this covers. This issue is kinda specific to Json because it has its own tree-sitter node for a single identifier unlike others. Also renamed a symbol in the completion visitor because `location` was a bad/wrong name. ## Checklist - [x] Title matches [Winglang's style guide](https://docs.winglang.io/contributing/pull_requests#how-are-pull-request-titles-formatted) - [x] Description explains motivation and solution - [x] Tests added (always) - [ ] Docs updated (only required for features) - [ ] Added `pr/e2e-full` label if this feature requires end-to-end testing *By submitting this pull request, I confirm that my contribution is made under the terms of the [Monada Contribution License](https://docs.winglang.io/terms-and-policies/contribution-license.html)*.
- Loading branch information
1 parent
799fb95
commit 396c012
Showing
4 changed files
with
381 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
114 changes: 114 additions & 0 deletions
114
libs/wingc/src/lsp/snapshots/completions/parentheses_expression.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
--- | ||
source: libs/wingc/src/lsp/completions.rs | ||
--- | ||
- label: asBool | ||
kind: 2 | ||
documentation: | ||
kind: markdown | ||
value: "```wing\n asBool: (): bool\n```\n---\nConvert Json element to number if possible.\n\n### Returns\na string." | ||
sortText: ff|asBool | ||
insertText: asBool($0) | ||
insertTextFormat: 2 | ||
command: | ||
title: triggerParameterHints | ||
command: editor.action.triggerParameterHints | ||
- label: asNum | ||
kind: 2 | ||
documentation: | ||
kind: markdown | ||
value: "```wing\n asNum: (): num\n```\n---\nConvert Json element to number if possible.\n\n### Returns\na string." | ||
sortText: ff|asNum | ||
insertText: asNum($0) | ||
insertTextFormat: 2 | ||
command: | ||
title: triggerParameterHints | ||
command: editor.action.triggerParameterHints | ||
- label: asStr | ||
kind: 2 | ||
documentation: | ||
kind: markdown | ||
value: "```wing\n asStr: (): str\n```\n---\nConvert Json element to string if possible.\n\n### Returns\na string." | ||
sortText: ff|asStr | ||
insertText: asStr($0) | ||
insertTextFormat: 2 | ||
command: | ||
title: triggerParameterHints | ||
command: editor.action.triggerParameterHints | ||
- label: get | ||
kind: 2 | ||
documentation: | ||
kind: markdown | ||
value: "```wing\n get: (key: str): Json\n```\n---\nReturns a specified element from the Json.\n\n### Parameters\n - *key* - The key of the element to return.\n\n### Returns\nThe element associated with the specified key, or undefined if the key can't be found" | ||
sortText: ff|get | ||
insertText: get($0) | ||
insertTextFormat: 2 | ||
command: | ||
title: triggerParameterHints | ||
command: editor.action.triggerParameterHints | ||
- label: getAt | ||
kind: 2 | ||
documentation: | ||
kind: markdown | ||
value: "```wing\n getAt: (index: num): Json\n```\n---\nReturns a specified element at a given index from Json Array.\n\n### Parameters\n - *index* - The index of the element in the Json Array to return.\n\n### Returns\nThe element at given index in Json Array, or undefined if index is not valid" | ||
sortText: ff|getAt | ||
insertText: getAt($0) | ||
insertTextFormat: 2 | ||
command: | ||
title: triggerParameterHints | ||
command: editor.action.triggerParameterHints | ||
- label: tryAsBool | ||
kind: 2 | ||
documentation: | ||
kind: markdown | ||
value: "```wing\n tryAsBool: (): bool?\n```\n---\nConvert Json element to boolean if possible.\n\n### Returns\na string." | ||
sortText: ff|tryAsBool | ||
insertText: tryAsBool($0) | ||
insertTextFormat: 2 | ||
command: | ||
title: triggerParameterHints | ||
command: editor.action.triggerParameterHints | ||
- label: tryAsNum | ||
kind: 2 | ||
documentation: | ||
kind: markdown | ||
value: "```wing\n tryAsNum: (): num?\n```\n---\nConvert Json element to string if possible.\n\n### Returns\na string." | ||
sortText: ff|tryAsNum | ||
insertText: tryAsNum($0) | ||
insertTextFormat: 2 | ||
command: | ||
title: triggerParameterHints | ||
command: editor.action.triggerParameterHints | ||
- label: tryAsStr | ||
kind: 2 | ||
documentation: | ||
kind: markdown | ||
value: "```wing\n tryAsStr: (): str?\n```\n---\nConvert Json element to string if possible.\n\n### Returns\na string." | ||
sortText: ff|tryAsStr | ||
insertText: tryAsStr($0) | ||
insertTextFormat: 2 | ||
command: | ||
title: triggerParameterHints | ||
command: editor.action.triggerParameterHints | ||
- label: tryGet | ||
kind: 2 | ||
documentation: | ||
kind: markdown | ||
value: "```wing\n tryGet: (key: str): Json?\n```\n---\nOptionally returns an specified element from the Json.\n\n### Parameters\n - *key* - The key of the element to return.\n\n### Returns\nThe element associated with the specified key, or undefined if the key can't be found" | ||
sortText: ff|tryGet | ||
insertText: tryGet($0) | ||
insertTextFormat: 2 | ||
command: | ||
title: triggerParameterHints | ||
command: editor.action.triggerParameterHints | ||
- label: tryGetAt | ||
kind: 2 | ||
documentation: | ||
kind: markdown | ||
value: "```wing\n tryGetAt: (index: num): Json?\n```\n---\nOptionally returns a specified element at a given index from Json Array.\n\n### Parameters\n - *index* - The index of the element in the Json Array to return.\n\n### Returns\nThe element at given index in Json Array, or undefined if index is not valid" | ||
sortText: ff|tryGetAt | ||
insertText: tryGetAt($0) | ||
insertTextFormat: 2 | ||
command: | ||
title: triggerParameterHints | ||
command: editor.action.triggerParameterHints | ||
|
103 changes: 103 additions & 0 deletions
103
libs/wingc/src/lsp/snapshots/completions/static_json_after_expression.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
--- | ||
source: libs/wingc/src/lsp/completions.rs | ||
--- | ||
- label: deepCopy | ||
kind: 2 | ||
documentation: | ||
kind: markdown | ||
value: "```wing\nstatic deepCopy: (json: MutJson): Json\n```\n---\nCreates an immutable deep copy of the Json.\n\n### Parameters\n - *json* - to copy.\n\n### Returns\nthe immutable copy of the Json" | ||
sortText: ff|deepCopy | ||
insertText: deepCopy($0) | ||
insertTextFormat: 2 | ||
command: | ||
title: triggerParameterHints | ||
command: editor.action.triggerParameterHints | ||
- label: deepCopyMut | ||
kind: 2 | ||
documentation: | ||
kind: markdown | ||
value: "```wing\nstatic deepCopyMut: (json: Json): MutJson\n```\n---\nCreates a mutable deep copy of the Json.\n\n### Parameters\n - *json* - to copy.\n\n### Returns\nthe mutable copy of the Json" | ||
sortText: ff|deepCopyMut | ||
insertText: deepCopyMut($0) | ||
insertTextFormat: 2 | ||
command: | ||
title: triggerParameterHints | ||
command: editor.action.triggerParameterHints | ||
- label: delete | ||
kind: 2 | ||
documentation: | ||
kind: markdown | ||
value: "```wing\nstatic delete: (json: MutJson, key: str): void\n```\n---\nDeletes a key in a given Json.\n\n### Parameters\n - *json* - to delete key from.\n - *key* - the key to delete." | ||
sortText: ff|delete | ||
insertText: delete($0) | ||
insertTextFormat: 2 | ||
command: | ||
title: triggerParameterHints | ||
command: editor.action.triggerParameterHints | ||
- label: has | ||
kind: 2 | ||
documentation: | ||
kind: markdown | ||
value: "```wing\nstatic has: (json: Json, key: str): bool\n```\n---\nChecks if a Json object has a given key.\n\n### Parameters\n - *json* - The json object to inspect.\n - *key* - The key to check.\n\n### Returns\nBoolean value corresponding to whether the key exists" | ||
sortText: ff|has | ||
insertText: has($0) | ||
insertTextFormat: 2 | ||
command: | ||
title: triggerParameterHints | ||
command: editor.action.triggerParameterHints | ||
- label: keys | ||
kind: 2 | ||
documentation: | ||
kind: markdown | ||
value: "```wing\nstatic keys: (json: any): Array<str>\n```\n---\nReturns the keys from the Json object.\n\n### Parameters\n - *json* - to get keys from.\n\n### Returns\nthe keys from the Json object as string array" | ||
sortText: ff|keys | ||
insertText: keys($0) | ||
insertTextFormat: 2 | ||
command: | ||
title: triggerParameterHints | ||
command: editor.action.triggerParameterHints | ||
- label: parse | ||
kind: 2 | ||
documentation: | ||
kind: markdown | ||
value: "```wing\nstatic parse: (str: str): Json\n```\n---\nParse a string into a Json.\n\n### Parameters\n - *str* - to parse as Json.\n\n### Returns\nJson representation of the string" | ||
sortText: ff|parse | ||
insertText: parse($0) | ||
insertTextFormat: 2 | ||
command: | ||
title: triggerParameterHints | ||
command: editor.action.triggerParameterHints | ||
- label: stringify | ||
kind: 2 | ||
documentation: | ||
kind: markdown | ||
value: "```wing\nstatic stringify: (json: any, indent: num?): str\n```\n---\nFormats Json as string.\n\n### Parameters\n - *json* - to format as string.\n - *indent*\n\n### Returns\nstring representation of the Json\n\n### Remarks\n(JSON.stringify($args$))" | ||
sortText: ff|stringify | ||
insertText: stringify($0) | ||
insertTextFormat: 2 | ||
command: | ||
title: triggerParameterHints | ||
command: editor.action.triggerParameterHints | ||
- label: tryParse | ||
kind: 2 | ||
documentation: | ||
kind: markdown | ||
value: "```wing\nstatic tryParse: (str: str): Json?\n```\n---\nTry to parse a string into a Json.\n\n### Parameters\n - *str* - to parse as Json.\n\n### Returns\nJson representation of the string or undefined if string is not parsable" | ||
sortText: ff|tryParse | ||
insertText: tryParse($0) | ||
insertTextFormat: 2 | ||
command: | ||
title: triggerParameterHints | ||
command: editor.action.triggerParameterHints | ||
- label: values | ||
kind: 2 | ||
documentation: | ||
kind: markdown | ||
value: "```wing\nstatic values: (json: Json): Array<Json>\n```\n---\nReturns the values from the Json.\n\n### Parameters\n - *json* - to get values from.\n\n### Returns\nthe values from the Json as array of Json" | ||
sortText: ff|values | ||
insertText: values($0) | ||
insertTextFormat: 2 | ||
command: | ||
title: triggerParameterHints | ||
command: editor.action.triggerParameterHints | ||
|
Oops, something went wrong.