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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

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 2 times, most recently from 394d702 to 2b38861 Compare December 18, 2024 12:29
@hunger hunger force-pushed the tobias/push-ownwstuqztlk branch from 2b38861 to e249c82 Compare December 20, 2024 10:11
@hunger hunger requested a review from ogoffart December 20, 2024 10:15
... but only when directly on the name of the struct
when it is declared.
@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 _

input.child_token(SyntaxKind::Identifier)
}

fn main_identifier_text(input: &i_slint_compiler::parser::SyntaxNode) -> String {
Copy link
Member

Choose a reason for hiding this comment

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

Looks like i_slint_compiler::parser::identifier_text Only that it normalize _ and -, which i think should be done.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah! I was almost sure there was something.... I was looking for something like that starting with parse_ though :-)

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
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