Skip to content
This repository has been archived by the owner on Mar 9, 2021. It is now read-only.

Automatic convert setters and getters to properties #30

Open
hazzik opened this issue Nov 15, 2013 · 2 comments
Open

Automatic convert setters and getters to properties #30

hazzik opened this issue Nov 15, 2013 · 2 comments

Comments

@hazzik
Copy link
Contributor

hazzik commented Nov 15, 2013

Sharpen should have a feature which is able to automatic identify setters and getters and convert them to properties.

Following rules apply:

  • If a method name is starting with "get" or "is"; and it returns something; and it does not have any arguments then it is a getter
  • If a method name starts with "set" or "is"; and it does not return anything; and it accepts one argument then it is a setter
  • The property name will be a method name without leading "is", "get" or "set"
@PerfectCarl
Copy link

Agreed. That would be a great addition!

@lilith
Copy link
Contributor

lilith commented May 28, 2015

I would add 2 more conditions:

  1. Both Get and Set are of the same data type (before merging them into a single property)
  2. We don't do this for Set methods if they call external functions. Explicit Set methods are good for things that have side effects or throw exceptions.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants