Skip to content

Refactor willEditDocument in favor of SourceEdits #1105

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

Merged

Conversation

mustiikhalil
Copy link
Contributor

@mustiikhalil mustiikhalil commented Feb 29, 2024

The following PR refactors the willEditDocument in the SwiftLanguageServer into the DocumentManager focusing on using SourceEdit.

Things I am not sure of:

  • Is SourceEdit really the correct way to go about it?
  • Naming convention and if it aligns with the repository's demands

Closes #939

Copy link
Member

@ahoppen ahoppen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The overall design looks good to me. I’ve got a few mostly stylistic comments.

Copy link
Member

@ahoppen ahoppen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I’ve got a couple more nitpicky comments. Other than that we should use swiftlang/swift-syntax#2517 once that’s in and the PR is good to go 🚢

@mustiikhalil mustiikhalil force-pushed the issue-939-refactor-will-edit-doc branch 2 times, most recently from 25c4dde to 8aa915e Compare March 3, 2024 16:30
@mustiikhalil mustiikhalil marked this pull request as ready for review March 3, 2024 16:31
@MaxDesiatov MaxDesiatov changed the title Refactors willEditDocument in favor of SourceEdits Refactor willEditDocument in favor of SourceEdits Mar 3, 2024
@MaxDesiatov
Copy link
Contributor

@swift-ci test

@ahoppen
Copy link
Member

ahoppen commented Mar 4, 2024

@mustiikhalil Could you run swift-format on your changes? If you rebase it on top of current main, you should be able to run it by right-clicking on the Package in Xcode.

Also, would you mind squashing your commits?

Removes willEditDocument completion block in favor of a returning SourceEdits instead.
@mustiikhalil mustiikhalil force-pushed the issue-939-refactor-will-edit-doc branch from 8aa915e to f7f2cea Compare March 5, 2024 06:01
@mustiikhalil
Copy link
Contributor Author

mustiikhalil commented Mar 5, 2024

Sure! and done.

I've noticed a weird behavior with command format-source-code, it doesn't really update the source code if ran through Xcode. It might be my setup.

@ahoppen
Copy link
Member

ahoppen commented Mar 5, 2024

Hmm, weird. I’ve recently been running it from VS Code, which worked fine and I think I also saw it working in Xcode at some point. Maybe you didn’t give it permission to write to your source directory. Anyway, thanks for updating.

@ahoppen
Copy link
Member

ahoppen commented Mar 5, 2024

@swift-ci Please test

@ahoppen ahoppen enabled auto-merge March 5, 2024 07:05
@ahoppen
Copy link
Member

ahoppen commented Mar 5, 2024

@swift-ci Please test Windows

@ahoppen ahoppen merged commit 5471f7e into swiftlang:main Mar 5, 2024
@mustiikhalil mustiikhalil deleted the issue-939-refactor-will-edit-doc branch January 27, 2025 20:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Instead of having a willEditDocument closure in DocumentManager.edit return an array of edits
3 participants