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

Rename structs, enums and components #7143

Merged
merged 4 commits into from
Jan 7, 2025

Conversation

hunger
Copy link
Member

@hunger hunger commented Dec 17, 2024

This adds renaming of structs... in a limited fashion though: You have to be in the declaration of the component/struct or enum you want to rename.

This PR handles significantly more corner cases than the old component renaming code we used to have and comes with a few more tests to cover those.

Up next and building on this code: Trigger renaming based on any use of any of these types.

@hunger hunger force-pushed the tobias/push-ownwstuqztlk branch 3 times, most recently from 2b38861 to e249c82 Compare December 20, 2024 10:11
@hunger hunger requested a review from ogoffart December 20, 2024 10:15
@hunger hunger force-pushed the tobias/push-ownwstuqztlk branch from e249c82 to 47188ce Compare December 20, 2024 10:19
@hunger hunger changed the title WIP: Rename structs Rename structs, enums and components Dec 20, 2024
Copy link
Member

@ogoffart ogoffart left a comment

Choose a reason for hiding this comment

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

Please add a test which contains different variation of - and _

tools/lsp/common/rename_component.rs Outdated Show resolved Hide resolved
Copy link
Member

@ogoffart ogoffart left a comment

Choose a reason for hiding this comment

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

Also would make sense to have a test that checks that symbols that shouldn't be replace don't get replaces.

enum XyZ { Foo }
struct Abc { Foo: Xyz } 

struct Foo { }

component T1 {
   property <Abc> Foo;
   function f() {
        Foo.Foo  == Xyz.Foo; 
   }
}

component T2 {
  function Foo(Foo: int) { Foo + 1; }
  function F() { Foo() }
}

component T3 {
   Foo := Rectangle { }
}

and so on.

hunger added a commit to hunger/slint that referenced this pull request Dec 20, 2024
Todo:

* More tests
  * as suggested by @ogoffart in slint-ui#7143
  * Rename based on InternalName and ExportName
hunger added a commit to hunger/slint that referenced this pull request Dec 21, 2024
Todo:

* More tests
  * as suggested by @ogoffart in slint-ui#7143
  * Rename based on InternalName and ExportName
@hunger hunger force-pushed the tobias/push-ownwstuqztlk branch from 47188ce to 9a8f323 Compare January 6, 2025 11:03
@hunger
Copy link
Member Author

hunger commented Jan 6, 2025

Thinking about this a bit more: I do need to normalize names when looking for places I need to change. I do not want to normalize when actually replacing the text though.

@hunger hunger force-pushed the tobias/push-ownwstuqztlk branch from 9a8f323 to 3412297 Compare January 6, 2025 15:47
@hunger
Copy link
Member Author

hunger commented Jan 6, 2025

New and improved: With tests for renaming types with names that normalize :-)

@hunger hunger force-pushed the tobias/push-ownwstuqztlk branch 2 times, most recently from db3db0c to 714610c Compare January 6, 2025 16:56
Copy link
Member

@ogoffart ogoffart left a comment

Choose a reason for hiding this comment

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

Maybe add a bunch of - and _ in the tests that have exports as well.

tools/lsp/common/rename_component.rs Outdated Show resolved Hide resolved
tools/lsp/common/rename_component.rs Outdated Show resolved Hide resolved
tools/lsp/common/rename_component.rs Show resolved Hide resolved
tools/lsp/common/rename_component.rs Outdated Show resolved Hide resolved
tools/lsp/common/rename_component.rs Show resolved Hide resolved
@hunger hunger force-pushed the tobias/push-ownwstuqztlk branch from 714610c to 7c6e6c3 Compare January 6, 2025 19:11
@hunger
Copy link
Member Author

hunger commented Jan 6, 2025

... and with export/import tests full of _ and - :-)

@ogoffart
Copy link
Member

ogoffart commented Jan 7, 2025

Nice feature

@hunger hunger force-pushed the tobias/push-ownwstuqztlk branch from 7c6e6c3 to 16f054b Compare January 7, 2025 14:47
@hunger
Copy link
Member Author

hunger commented Jan 7, 2025

The last push is just a rebase as Github would not let me merge the old state :-/

@hunger hunger merged commit 56697f2 into slint-ui:master Jan 7, 2025
37 checks passed
@hunger hunger deleted the tobias/push-ownwstuqztlk branch January 7, 2025 15:18
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.

2 participants