;ELC ;;; Compiled ;;; in Emacs version 28.0.50 ;;; with all optimizations. (byte-code "\300\301!\210\300\302!\207" [require dash yasnippet] 2) #@50 Turn parameter into local var in local function. (defalias 'js2r-localize-parameter #[0 "\301 \210\302 \303!>\205\304\262\203\305 \207\306 \207" [cl-struct-js2-name-node-tags js2r--guard js2-node-at-point type-of t js2r--localize-parameter-pull js2r--localize-parameter-push] 3 (#$ . 155) nil]) (defalias 'js2r--localize-parameter-push #[0 "\304 \305\306\"\206\f\307\310!\311!>\204\312\313\314D\"\210\211\315H\316!\311! >\2040\312\313\317D\"\210\320H\311!\n>\203A\321!\202D\307\322!\323!\324\311! >\204Y\312\313\317D\"\210\325H\326\324\211\203\210\211A\262\242\262\262T\262\n=\205z\211\211\203\204\211B\262\210\202_\266\211\237\262@\311\311! >\204\241\312\313\327D\"\210\330H8!\n>\204\310\312\313\331\311! >\204\300\312\313\327 D\"\210\330H8D\"\210\211\311! >\204\331\312\313\327D\"\210\330H8\320H\332\n%\207" [cl-struct-js2-node-tags cl-struct-js2-call-node-tags cl-struct-js2-name-node-tags cl-struct-js2-function-node-tags js2-node-at-point js2r--closest-node-where js2r--parent-is-call-node error "Place cursor on argument to localize" type-of signal wrong-type-argument js2-node 5 js2-node-string js2-call-node 6 js2r--local-fn-from-name-node "Can only localize parameter for local functions" js2r--function-usages nil 7 0 js2-function-node 20 js2-name-node js2r--localize-parameter] 16]) (defalias 'js2r--localize-parameter-pull #[0 "\301 \302!>\203\302!>\204\303\304\305D\"\210\211\306H\202\"\307\310!\311\312\"\206,\307\313!\314\"\2067\307\315\"\316!\317\320\321\322\"\"!\323\324\"\325 %\207" [cl-struct-js2-name-node-tags js2-node-at-point type-of signal wrong-type-argument js2-name-node 6 error "Place cursor on parameter to localize" js2r--closest-node-where js2r--is-local-function "Can only localize parameter in local functions" js2r--param-index-for "%S isn't a parameter to this function" js2r--function-usages -distinct mapcar make-closure #[257 "\301\300\"\207" [V0 js2r--argument] 4 "\n\n(fn IT)"] js2r--choose-one "Value: " js2r--localize-parameter] 13]) #@35 (fn FN USAGES INDEX NAME VALUE) (defalias 'js2r--localize-parameter #[1285 "\212\300!\210\212\301\302\211\203&\211A\262\242\262\262T\262\303\"\210\202\n\266)\304 \210\305\306\307\261\210\310\")\207" [js2r--goto-fn-body-beg 0 nil js2r--remove-argument-at-index newline-and-indent "var " " = " ";" js2r--remove-parameter-at-index] 12 (#$ . 2237)]) #@13 (fn NODE) (defalias 'js2r--parent-is-call-node #[257 "\302\211!>\204\303\304\305D\"\210\306H! >\205\307\207" [cl-struct-js2-node-tags cl-struct-js2-call-node-tags type-of signal wrong-type-argument js2-node 5 t] 6 (#$ . 2613)]) #@18 (fn NAME-NODE) (defalias 'js2r--local-fn-from-name-node #[257 "\300\301\302\303\304!\"\"\207" [-first js2-function-node-p -map js2-node-parent js2r--local-usages-of-name-node] 7 (#$ . 2857)]) #@16 (fn NAME FN) (defalias 'js2r--param-index-for #[514 "\302\303!>\204\304\305\306D\"\210\307H\310\302\211\203P\211A\262\242\262\262T\262\303! >\204:\304\305\311D\"\210\312H\232\205B\211\211\203L\211B\262\210\202\266\211\237\262@\207" [cl-struct-js2-function-node-tags cl-struct-js2-name-node-tags nil type-of signal wrong-type-argument js2-function-node 20 0 js2-name-node 6] 12 (#$ . 3058)]) #@24 (fn INDEX CALL-NODE) (defalias 'js2r--argument #[514 "\301\302!>\204\303\304\305D\"\210\306H8!\207" [cl-struct-js2-call-node-tags js2-node-string type-of signal wrong-type-argument js2-call-node 7] 8 (#$ . 3487)]) #@17 (fn INDEX FN) (defalias 'js2r--remove-parameter-at-index #[514 "\301\302!>\204\303\304\305D\"\210\306H8!\207" [cl-struct-js2-function-node-tags js2r--delete-node-in-params type-of signal wrong-type-argument js2-function-node 20] 8 (#$ . 3716)]) #@24 (fn INDEX CALL-NODE) (defalias 'js2r--remove-argument-at-index #[514 "\301\302!>\204\303\304\305D\"\210\306H8!\207" [cl-struct-js2-call-node-tags js2r--delete-node-in-params type-of signal wrong-type-argument js2-call-node 7] 8 (#$ . 3976)]) #@13 (fn NODE) (defalias 'js2r--delete-node-in-params #[257 "\301!b\210\302\303!>\204\304\305\306D\"\210\307H!\210\310\311!\203*\312\313!\203*\302\314!\207\310\313!\2053\302\315!\207" [cl-struct-js2-node-tags js2-node-abs-pos delete-char type-of signal wrong-type-argument js2-node 3 looking-back "(" looking-at ", " 2 -2] 6 (#$ . 4233)]) #@23 (fn PROMPT OPTIONS) (defalias 'js2r--choose-one #[514 "\211\205\211A\203\300\"\207\211@\207" [completing-read] 5 (#$ . 4585)]) #@44 Introduce a parameter in a local function. (defalias 'js2r-introduce-parameter #[0 "\301 \210\302 \203\303\304 \305 \"\207\306 \303\307!\307!\310!>\204(\311\312\313D\"\210\314H\\\262\"\207" [cl-struct-js2-node-tags js2r--guard use-region-p js2r--introduce-parameter-between region-beginning region-end js2r--closest-extractable-node js2-node-abs-pos type-of signal wrong-type-argument js2-node 3] 9 (#$ . 4726) nil]) #@16 (fn BEG END) (defalias 'js2r--introduce-parameter-between #[514 "\300\"\204 \301\302!\210\303\304\305 \"\211\204\301\306!\210\212\307\310!{\311!b\210\212\312\313\314\"\"\210)\315Z!\210c\210\314\"\210\316\317\320!\321 !%\266\203)\207" [js2r--single-complete-expression-between-p error "Can only introduce single, complete expressions as parameter" js2r--closest-node-where js2r--is-local-function js2-node-at-point "Can only introduce parameter in local functions" read-string "Parameter name: " js2r--function-usages -each -partial js2r--add-parameter delete-char query-replace nil js2-node-abs-pos js2r--fn-body-end] 13 (#$ . 5160)]) #@11 (fn FN) (defalias 'js2r--function-usages #[257 "\300\301\302!\"\207" [-map js2-node-parent js2r--function-usages-name-nodes] 5 (#$ . 5825)]) #@11 (fn FN) (defalias 'js2r--function-usages-name-nodes #[257 "\303!>\204\304\305\306D\"\210\211\307H\206[\303\211! >\204%\304\305\310D\"\210\311H!\n>\204G\304\305\312\303! >\204A\304\305\310D\"\210\311HD\"\210\303! >\204V\304\305\310D\"\210\211\311H\313H\314\315!\"\207" [cl-struct-js2-function-node-tags cl-struct-js2-node-tags cl-struct-js2-var-init-node-tags type-of signal wrong-type-argument js2-function-node 19 js2-node 5 js2-var-init-node 6 remove js2r--local-usages-of-name-node] 8 (#$ . 5975)]) #@18 (fn NAME NODE) (defalias 'js2r--add-parameter #[514 "\212\300!\210\301\302!\204\303c\210c)\207" [js2r--goto-closing-paren looking-back "(" ", "] 4 (#$ . 6506)]) #@13 (fn NODE) (defalias 'js2r--goto-closing-paren #[257 "\300!b\210\301\302!\210\303u\210\304 \210\303u\207" [js2-node-abs-pos search-forward "(" -1 forward-list] 3 (#$ . 6679)]) #@11 (fn FN) (defalias 'js2r--goto-fn-body-beg #[257 "\300!b\210\301\302!\207" [js2-node-abs-pos search-forward "{"] 3 (#$ . 6863)]) #@11 (fn FN) (defalias 'js2r--fn-body-end #[257 "\212\300!\210\301u\210\302 \210`)\207" [js2r--goto-fn-body-beg -1 forward-list] 3 (#$ . 7000)]) #@13 (fn NODE) (defalias 'js2r--is-local-function #[257 "\300!\206 \301!\207" [js2r--is-var-function-expression js2r--is-function-declaration] 3 (#$ . 7149)]) #@13 (fn NODE) (defalias 'js2r--is-method #[257 "\303!>\205\"\303\211! >\204\304\305\306D\"\210\307H!\n>\205\"\310\207" [cl-struct-js2-function-node-tags cl-struct-js2-node-tags cl-struct-js2-object-prop-node-tags type-of signal wrong-type-argument js2-node 5 t] 6 (#$ . 7314)]) #@13 (fn NODE) (defalias 'js2r--is-var-function-expression #[257 "\303!>\205\"\303\211! >\204\304\305\306D\"\210\307H!\n>\205\"\310\207" [cl-struct-js2-function-node-tags cl-struct-js2-node-tags cl-struct-js2-var-init-node-tags type-of signal wrong-type-argument js2-node 5 t] 6 (#$ . 7605)]) #@13 (fn NODE) (defalias 'js2r--is-assigned-function-expression #[257 "\303!>\205\"\303\211! >\204\304\305\306D\"\210\307H!\n>\205\"\310\207" [cl-struct-js2-function-node-tags cl-struct-js2-node-tags cl-struct-js2-assign-node-tags type-of signal wrong-type-argument js2-node 5 t] 6 (#$ . 7910)]) #@13 (fn NODE) (defalias 'js2r--is-function-declaration #[257 "\305!>\204\306\307\310D\"\210\211\311H\305! >\205>\305!\n>\205#\312?\205>\305! >\2050\312?\205>\305!\f>\205=\312?\207" [cl-struct-js2-node-tags cl-struct-js2-function-node-tags cl-struct-js2-assign-node-tags cl-struct-js2-var-init-node-tags cl-struct-js2-object-prop-node-tags type-of signal wrong-type-argument js2-node 5 t] 5 (#$ . 8218)]) #@56 Change from a list of arguments to a parameter object. (defalias 'js2r-arguments-to-object #[0 "\304 \210\305 \306\307!\203#\310!>\204'\310! >\204'\310!\n>\204'\311\312!\210\313!\211\203A\310! >\2059\314!\211\203@\211\262\210\210\310!>\203N\315!\207\316\317!!\207" [cl-struct-js2-function-node-tags cl-struct-js2-call-node-tags cl-struct-js2-new-node-tags cl-struct-js2-name-node-tags js2r--guard js2-node-at-point looking-at "(" type-of error "Place point right before the opening paren in the call or function" js2r--node-target js2r--local-fn-from-name-node js2r--arguments-to-object-for-function js2r--arguments-to-object-for-args-with-unknown-function js2r--node-args] 4 (#$ . 8641) nil]) #@22 (fn FUNCTION-NODE) (defalias 'js2r--arguments-to-object-for-function #[257 "\302!>\204\303\304\305D\"\210\211\306H\211\204\307\310!\210\212\311\312\313\314!\302!>\2042\303\304\305D\"\210\315H\\\316\314!\302!>\204L\303\304\305\nD\"\210\317H\\T\320\321\257C\322\323\324\325\"\"\326\327\326\211\203\230\211A\262\242\262\262T\262\302\211! >\204\207\303\304\330D\"\210\331H!>\204dB\262\202d\266\211\237\262\332\314\"\324\333\"\266\203\332\334\"\335!\324\336\337\"\"\266\202#!)\207" [cl-struct-js2-function-node-tags cl-struct-js2-node-tags type-of signal wrong-type-argument js2-function-node 20 error "No params to convert" js2r--execute-changes -concat :beg js2-node-abs-pos 23 :end 24 :contents "(params)" apply append mapcar #[257 "\300\301\302!!!\207" [js2r--local-usages-of-name-node js2r--local-name-node-at-point js2-node-abs-pos] 5 "\n\n(fn IT)"] nil 0 js2-node 5 -map #[257 "\300\301\302\303\257\207" [:beg :end :contents "params."] 7 "\n\n(fn IT)"] js2-name-node-name js2r--function-usages make-closure #[257 "\301\300\"\207" [V0 js2r--changes/arguments-to-object] 4 "\n\n(fn IT)"]] 16 (#$ . 9361)]) #@19 (fn NODE NAMES) (defalias 'js2r--changes/arguments-to-object #[514 "\300!\301\302!\303!\\\304\302!\305!\\T\306\307\"\257\207" [js2r--node-args :beg js2-node-abs-pos js2r--node-lp :end js2r--node-rp :contents js2r--create-object-with-arguments] 11 (#$ . 10537)]) #@13 (fn ARGS) (defalias 'js2r--arguments-to-object-for-args-with-unknown-function #[257 "\211\204\301\302!\210\303\304\303\211\203K\211A\262\242\262\262T\262\305\306T\307!>\203B\307!>\204<\310\311\312D\"\210\313H\202C\314#B\262\202 \266\211\237\262\315\316\"`\212\317 \210`)#\207" [cl-struct-js2-name-node-tags error "No arguments to convert" nil 0 format "${%d:%s}" type-of signal wrong-type-argument js2-name-node 6 "key" yas-expand-snippet js2r--create-object-with-arguments forward-list] 13 (#$ . 10819)]) #@19 (fn NAMES ARGS) (defalias 'js2r--create-object-with-arguments #[514 "\301\211\211G\302\301W\203K\262T\262\2118\262\2118\262\303\304\305\n!\n\305!\306!>\204=\307\310\311D\"\210\312H\\\262{#P\262\202\266\313\302\314O\315Q\207" [cl-struct-js2-node-tags nil 0 format " %s: %s,\n" js2-node-abs-pos type-of signal wrong-type-argument js2-node 3 "({\n" -2 "\n})"] 19 (#$ . 11363)]) #@85 Extract a function from the closest statement expression from the point. (fn NAME) (defalias 'js2r-extract-function #[257 "\300\301\302\303$\207" [js2r--extract-fn #[0 "\300 ?\205\f\301\302\303!!b\207" [js2r--looking-at-function-declaration js2-node-abs-pos js2r--closest js2-expr-stmt-node-p] 3] "%s(%s);" "function %s(%s) {\n%s\n}\n\n"] 6 (#$ . 11780) "sName of new function: "]) #@83 Extract a method from the closest statement expression from the point. (fn NAME) (defalias 'js2r-extract-method #[257 "\300\301\302\303$\207" [js2r--extract-fn #[0 "\300\301\302!!b\207" [js2-node-abs-pos js2r--closest js2-object-prop-node-p] 3] "this.%s(%s);" "%s: function (%s) {\n%s\n},\n\n"] 6 (#$ . 12171) "sName of new method: "]) #@59 (fn NAME GOTO-POSITION CALL-TEMPLATE FUNCTION-TEMPLATE) (defalias 'js2r--extract-fn #[1028 "\303 \210\304 \204\f\305\306!\210\212\307\310 \311 \"\312\313\"\312\314\"\315!\316\317\"\320\321\320\211\203J\211A\262\242\262\262T\262\322\"\203'B\262\202'\266\211\237\262\323\324\325\"!\324\326\316\327\"\"\330\331!>\204p\332\333\334\nD\"\210\335H\"\324\325\316\317\"\"\336\"\211@\330\"\337\340\341!\342#\320 @\210\343\f!@\344 @!\344!\331! >\204\263\332\333\345D\"\210\346H\\\262{b\210|\210\331!\n>\203\316\347c\210\203\342\211\350 \351R\262\352\353\261\210\354#c\210\344!b\210 \210`\354 $c\210\355`T\"\262\266\223)\207" [cl-struct-js2-block-node-tags cl-struct-js2-node-tags cl-struct-js2-return-node-tags js2r--guard use-region-p error "Mark the expressions to extract first" js2r--first-common-ancestor-in-region region-beginning region-end js2r--closest-node-where js2-block-node-p js2-function-node-p js2r--marked-expressions-in-block -mapcat js2r--name-node-decendants nil 0 js2r--local-to-fn-p -distinct -map js2-name-node-name js2r--var-init-node-target-name js2r--var-init-node-decendants -difference type-of signal wrong-type-argument js2-block-node 6 -intersection mapconcat identity reverse ", " last js2-node-abs-pos js2-node 3 "return " "\nreturn " ";" "var " " = " format indent-region] 29 (#$ . 12515)]) #@13 (fn NODE) (defalias 'js2r--var-init-node-target-name #[257 "\302\211!>\204\303\304\305D\"\210\306H! >\2042\303\304\307\302!>\204,\303\304\305D\"\210\306HD\"\210\302!>\204A\303\304\305D\"\210\211\306H\306H\207" [cl-struct-js2-var-init-node-tags cl-struct-js2-name-node-tags type-of signal wrong-type-argument js2-var-init-node 6 js2-name-node] 8 (#$ . 13924)]) (defalias 'js2r--function-around-region #[0 "\300\301\302\303 \304 \"\"\206\305\306!\207" [js2r--closest-node-where js2-function-node-p js2r--first-common-ancestor-in-region region-beginning region-end error "This only works when you mark stuff inside a function"] 5]) #@11 (fn FN) (defalias 'js2r--marked-expressions-in-block #[257 "\301\302\303!>\204\304\305\306D\"\210\307H\"\207" [cl-struct-js2-block-node-tags -select js2r--node-is-marked type-of signal wrong-type-argument js2-block-node 6] 7 (#$ . 14580)]) #@13 (fn NODE) (defalias 'js2r--node-is-marked #[257 "\301 \302!\303!>\204\304\305\306D\"\210\307H\\\262X\205%\310 \302!Y\207" [cl-struct-js2-node-tags region-beginning js2-node-abs-pos type-of signal wrong-type-argument js2-node 3 region-end] 8 (#$ . 14834)]) #@13 (fn NODE) (defalias 'js2r--name-node-decendants #[257 "\300\301\302!\"\207" [-select js2-name-node-p js2r--decendants] 5 (#$ . 15109)]) #@13 (fn NODE) (defalias 'js2r--var-init-node-decendants #[257 "\300\301\302!\"\207" [-select js2-var-init-node-p js2r--decendants] 5 (#$ . 15254)]) #@13 (fn NODE) (defalias 'js2r--decendants #[257 "\300C\301\302\303\"\"\210\211\242\207" [nil js2-visit-ast make-closure #[514 "\211?\205 \300\300\242B\240\207" [V0] 5 "\n\n(fn NODE END-P)"]] 7 (#$ . 15407)]) #@21 (fn FN NAME-NODE) (defalias 'js2r--local-to-fn-p #[514 "\301!>\204\302\303\304D\"\210\211\305H\306!\307\"=\207" [cl-struct-js2-name-node-tags type-of signal wrong-type-argument js2-name-node 6 js2-node-get-enclosing-scope js2-get-defining-scope] 7 (#$ . 15623)]) #@55 Toggle between function expression to arrow function. (defalias 'js2r-toggle-arrow-function-and-expression #[0 "\212\300 \210\301 \203\302 \202 \303 \203\304 \204\305 \202 \306\307!)\207" [js2r--find-closest-function js2r--arrow-function-p js2r--transform-arrow-function-to-expression js2r--function-start-p js2r--looking-at-function-declaration js2r--transform-function-expression-to-arrow error "Can only toggle between function expressions and arrow function"] 2 (#$ . 15904) nil]) (defalias 'js2r-toggle-function-expression-and-declaration #[0 "\212\300 \210\301 \203\302 \203\303 \210\304 \202#\305 \203 \306 \202#\307\310!)\207" [js2r--find-closest-function js2r--looking-at-var-function-expression js2r--arrow-function-p js2r--transform-arrow-function-to-expression js2r--transform-function-expression-to-declaration js2r--looking-at-function-declaration js2r--transform-function-declaration-to-expression error "Can only toggle between function declarations and free standing function expressions"] 2 nil nil]) (defalias 'js2r--arrow-function-p #[0 "\212\3001\301 \210\302\303!\205\304 ?0\202\210\305)\207" [(error) js2r--find-closest-function looking-at "(?[,[:space:][:word:]]*)?[[:space:]]*=>" js2r--point-inside-string-p nil] 2 nil nil]) (defalias 'js2r--transform-arrow-function-to-expression #[0 "\301 \205v\302\212\303 \210\304 \212\305\306!\210\211\307 \310!\311!>\204&\312\313\314D\"\210\315H\\\262\302\223\210)\316\317!\262\320c\210\203B\321 \210\202E\322c\210\305\306!\210\323\324!\210\325 \210\204Z\326u\210\327c\210\316\330!?\205q\325 \210\331c\210\325 \210\332!b\210\333c\262)\262\207" [cl-struct-js2-node-tags js2r--arrow-function-p nil js2r--find-closest-function make-marker search-forward "=>" js2-node-at-point js2-node-abs-pos type-of signal wrong-type-argument js2-node 3 looking-at "\\s-*(" "function " forward-list "(" delete-char -2 js2r--ensure-just-one-space -1 ")" "\\s-*{" "{ return " marker-position "; }"] 9]) (defalias 'js2r--transform-function-expression-to-arrow #[0 "\302 ?\205b\212\303 \210`\304 \305!>\204\306\307\310D\"\210\211\311H\262\312\211\313 \203,\314\315!\210\316\317!\210\320u\210`|\210`\262\321 \210`\262\322c\210\323 \210G\324U\205_ ?\205_\211b\210\325\324!\210b\210\326\324!\266\204)\207" [cl-struct-js2-function-node-tags js2r-always-insert-parens-around-arrow-function-params js2r--arrow-function-p js2r--find-closest-function js2-node-at-point type-of signal wrong-type-argument js2-function-node 20 nil js2r--looking-at-function-declaration error "Can not convert function declarations to arrow function" search-forward "(" -1 forward-list " => " js2r--ensure-just-one-space 1 backward-delete-char delete-char] 6]) (defalias 'js2r--function-start-p #[0 "\300\301!\211\205\f\302!`U\207" [js2r--closest js2-function-node-p js2-node-abs-pos] 3]) (defalias 'js2r--find-closest-function #[0 "\300 ?\205\301\302!\303!b\262\207" [js2r--function-start-p js2r--closest js2-function-node-p js2-node-abs-pos] 3]) (defalias 'js2r--looking-at-method #[0 "\300 \205\301\302!\207" [js2r--function-start-p looking-back ": ?"] 2]) (defalias 'js2r--looking-at-function-declaration #[0 "\300 \205\301\302!\207" [js2r--function-start-p looking-back "^ *"] 2]) (defalias 'js2r--looking-at-var-function-expression #[0 "\300 \205\301\302!\207" [js2r--function-start-p looking-back "^ *var[ \n]*[a-z_$]+[ \n]*=[ \n]*"] 2]) (defalias 'js2r--transform-function-expression-to-declaration #[0 "\300 \205&\301\302!\210\303 \210\303 \210\301\304!\210\305 \210\305 \210\306\307!\210\310 \210\301\311!\210\312c\207" [js2r--looking-at-var-function-expression delete-char 9 forward-list 1 backward-list delete-backward-char 3 back-to-indentation 4 "function "] 2]) (defalias 'js2r--transform-function-declaration-to-expression #[0 "\300 \205\301\302!\210\303c\210\304\305!\210\306u\210\307c\210\310 \210\310 \210\311c\207" [js2r--looking-at-function-declaration delete-char 9 "var " search-forward "(" -1 " = function " forward-list ";"] 2]) (provide 'js2r-functions)