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

Refactor Idea: Replace usages with const declaration #45

Open
hediet opened this issue Aug 12, 2022 · 5 comments
Open

Refactor Idea: Replace usages with const declaration #45

hediet opened this issue Aug 12, 2022 · 5 comments

Comments

@hediet
Copy link

hediet commented Aug 12, 2022

Replace usages with const declaration, when the cursor is at the const declaration.

image

@lgrammel
Copy link
Contributor

Nice idea! For my understanding, how would this be different from inline variable?

@hediet
Copy link
Author

hediet commented Aug 12, 2022

It is the opposite direction: I want to replace all duplicate expressions with the const at the cursor.

@lgrammel
Copy link
Contributor

Ah I see, this would be useful!

In the meantime, you can achieve the same by combining the following refactorings:

  1. Extract the right hand side of the const into a new variable (here: top + height - checkBoxHeight - margin)
  2. Inline the original const (here: bottomBoundary)
  3. Rename the new variable to the name of the original const (here: to bottomBoundary)

@lgrammel
Copy link
Contributor

lgrammel commented Nov 4, 2022

Just realized that one variant of the refactoring already exists, you should be able to go over top + height - checkboxHeight - margin and use "Replace with existing variable": https://p42.ai/documentation/code-assist/replace-expression-with-existing-variable

@hediet
Copy link
Author

hediet commented Nov 4, 2022

Just realized that one variant of the refactoring already exists, you should be able to go over top + height - checkboxHeight - margin and use "Replace with existing variable": https://p42.ai/documentation/code-assist/replace-expression-with-existing-variable

Then I can also just use copy&paste.

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

No branches or pull requests

2 participants