Code Monkey home page Code Monkey logo

Comments (5)

lgrammel avatar lgrammel commented on June 19, 2024

Awesome, thanks for sharing the refactoring idea! This is somewhat similar to extract so it should be doable. How would you imagine the interaction, i.e. where would you want to trigger the refactoring?

from js-assistant.

lgrammel avatar lgrammel commented on June 19, 2024

Just realized that this is already possible with a refactoring combo:

  1. Extract variable with flip(sourceNumber) into e.g. targetNumber2
  2. Inline variable targetNumber
  3. Rename targetNumber2 to targetNumber

from js-assistant.

lgrammel avatar lgrammel commented on June 19, 2024

v1.112.0 now has a "replace with existing variable" refactoring that can be invoked on an expression. If there is a variable with the same expression, the expression will be replaced with the variable.

@hediet you said this would be a "second step after extracting a constant", which indicates to me that extract constant did not work as expected. The P42 extract constant should already extract all occurrences. Was there a specific case where the refactoring did not find all occurrences as expected?

from js-assistant.

hediet avatar hediet commented on June 19, 2024

The P42 extract constant should already extract all occurrences.

Oh, I was not aware of this. I used the typescript one, as it was suggested first I think.
I really recommend hiding the obsolete typescript refactorings by default (and adding a setting to show them again)!

from js-assistant.

lgrammel avatar lgrammel commented on June 19, 2024

I really recommend hiding the obsolete typescript refactorings by default (and adding a setting to show them again)!

I agree, you convinced me this is the best way to proceed.

The typescript extract const refactoring is not fully replaced by the JavaScript Assistant yet, I need to add an option to extract a single occurrence and to determine the target scope.

from js-assistant.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.