Skip to content
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

[SR-5742] Refactoring action to convert imperative code to functional style #48312

Open
akyrtzi opened this issue Aug 23, 2017 · 1 comment
Open
Labels
compiler The Swift compiler in itself feature A feature request or implementation good first issue Good for newcomers refactoring Area → source tooling: refactoring source tooling Area: IDE support, SourceKit, and other source tooling

Comments

@akyrtzi
Copy link
Member

akyrtzi commented Aug 23, 2017

Previous ID SR-5742
Radar rdar://32751280
Original Reporter @akyrtzi
Type New Feature
Additional Detail from JIRA
Votes 1
Component/s Source Tooling
Labels New Feature, Refactoring, StarterProposal
Assignee kacperh (JIRA)
Priority Medium

md5: d8dd54b6f1cfe6d2981c48e99ab5db6d

Issue Description:

Implement action to change code such as this:

func foo(list : [String]) {
  var result = [String]()

  for element in list {
    if !element.isEmpty {
      result.append(element)
    }
  }
}

to

func foo(list : [String]) {
  var result = list.filter { !$0.isEmpty }
}
@swift-ci
Copy link
Collaborator

Comment by KacperHarasim (JIRA)

@nkcsgexi I'll take a look into this. Will partially implement detection of 3 patterns as part of this task: mapping, filtering and reducing. Started thinking about refactoring type and I see this as a range based refactoring. To make it happen user has to select variable initialization and the for loop, together. I believe we don't have one token that should be a base for cursor refactoring, hence my choosing of range refactor. Do you think it makes sense?

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@AnthonyLatsis AnthonyLatsis added compiler The Swift compiler in itself good first issue Good for newcomers source tooling Area: IDE support, SourceKit, and other source tooling feature A feature request or implementation and removed StarterProposal new feature labels Nov 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler The Swift compiler in itself feature A feature request or implementation good first issue Good for newcomers refactoring Area → source tooling: refactoring source tooling Area: IDE support, SourceKit, and other source tooling
Projects
None yet
Development

No branches or pull requests

3 participants