brackets-archive / bracketsIssues

Archive of issues in brackets.
0 stars 0 forks source link

[CLOSED] Refactoring Javascript #11526

Open core-ai-bot opened 2 years ago

core-ai-bot commented 2 years ago

Issue by boopeshmahendran Thursday Nov 02, 2017 at 07:36 GMT Originally opened as https://github.com/adobe/brackets/issues/13803


Hi All, We are planning to implement Refactoring feature (as of now JavaScript only) in Brackets. So we are trying to understand more useful features as part of refactoring. We are listing down some features here:-

  1. Rename named variables, functions, members This feature will help a user with renaming variables, function etc, within a restricted scope. Please check this #13047 for more details.

  2. Extract Selected Block

if (navigator.name.indexOf(“Opera”) != -1) { 
   Browser = “O”;
}
else if (navigator.name.indexOf(“Microsoft”) != -1) {
   Browser = “MSTE”;
}

The above snippet will be refactored to

var someVar = navigator.name;
if (someVar.indexOf(“Opera”) != -1) {
    Browser = “O”;
}
else if (someVar.indexOf(“Microsoft”) != -1) {
    Browser = “MSTE”;
}
  1. Code Generation

    • Wrap in try/catch
    • Create Getters/Setters
    • Wrap in Arrow function
    • Wrap in Condition
  2. Parameter wrapping

    • Multiple arguments to a single object This feature will allow a user to combine all arguments of a function to a single object. For example, see the below snippet
function select(start, end, steps, clear) { ... }

The above snippet will be refactored to

function select(options) {
    var start = options.start,
    end = options.end,
... }

This will change the function invocation part as well.

Please feel free to add more features and mention the features which would be the most useful to you. Looking forward to your feedback.

core-ai-bot commented 2 years ago

Comment by swmitra Thursday Nov 02, 2017 at 08:52 GMT


@petetnt@ficristo@zaggino@MarcelGerber@busykai@abose@saurabh95@peterflynn@ingorichter Can you please let us know your opinion about the usefulness of having these features built in to Brackets?

core-ai-bot commented 2 years ago

Comment by redmunds Thursday Nov 02, 2017 at 17:52 GMT


This sounds awesome, but would be better implemented as an extension (to keep Brackets core leaner for those that don't use it). If it's not possible to implement as an extension with current API, then where does it not work? In other words, what APIs need to be added to Brackets to make it work?

core-ai-bot commented 2 years ago

Comment by busykai Thursday Nov 02, 2017 at 18:48 GMT


+1 for the feature: I've been hearing this feedback many times. People felt that refactoring was something missing in Brackets. I also second@redmunds suggestion, it's better off as an extension.

core-ai-bot commented 2 years ago

Comment by ingorichter Friday Nov 03, 2017 at 06:50 GMT


+1 I agree with@redmunds and@busykai. It's easier to maintain in a separate extension.