wing icon indicating copy to clipboard operation
wing copied to clipboard

Add Macro Support For Getter and Setter Methods

Open hasanaburayyan opened this issue 2 years ago • 3 comments

Community Note

Please vote by adding a 👍 reaction to the issue to help us prioritize. If you are interested to work on this issue, please leave a comment.

Feature Spec

I want to be able to add a macro to a getter/setter method.

/**
 * Returns the number of elements in the map.
 * 
 * @macro Object.keys($self$).length
 */
public get size(): number {
  throw new Error("Macro");
}

Use Cases

Solves issue where we have to use normal methods like size() rather than simply invoke size on plain java objects. As done in this PR: https://github.com/winglang/wing/pull/1653/files#diff-02245bbbc2eb597dd86d8484abff67768e1e36b6af074525abb3fa3c1113ef32

Implementation Notes

No response

Component

Compiler

hasanaburayyan avatar Feb 24 '23 11:02 hasanaburayyan

Once this is implemented we should fix the Map API back to size rather than size() which I changed as part of: https://github.com/winglang/wing/pull/1653

hasanaburayyan avatar Feb 24 '23 11:02 hasanaburayyan

Once this is implemented we should fix the Map API back to size rather than size() which I changed as part of: #1653

I think we should actually keep it uniform across our container types, so it should be .len.

staycoolcall911 avatar Feb 26 '23 13:02 staycoolcall911

Hi,

This issue hasn't seen activity in 90 days. Therefore, we are marking this issue as stale for now. It will be closed after 7 days. Feel free to re-open this issue when there's an update or relevant information to be added. Thanks!

github-actions[bot] avatar May 09 '24 06:05 github-actions[bot]