Files
emacsd/elpa/js2-mode-20190815.1327/js2-old-indent.elc

129 lines
16 KiB
Plaintext
Raw Normal View History

2019-10-09 20:36:55 +02:00
;ELC
;;; Compiled
;;; in Emacs version 26.1
;;; with all optimizations.
;;; This file uses dynamic docstrings, first added in Emacs 19.29.
;;; This file does not contain utf-8 non-ASCII characters,
;;; and so can be loaded in Emacs versions earlier than 23.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(byte-code "\300\301!\210\302\303\304\305\306\307\310\311\312\313& \210\302\314\315\316\306\307\310\317\312\320& \210\302\321\322\323\312\324\310\325\306\307& \207" [require sgml-mode custom-declare-variable js2-basic-offset (if (and (boundp 'c-basic-offset) (numberp c-basic-offset)) c-basic-offset 4) "Number of spaces to indent nested statements.\nSimilar to `c-basic-offset'." :group js2-mode :safe integerp :type integer js2-pretty-multiline-declarations t "Non-nil to line up multiline declarations vertically:\n\n var a = 10,\n b = 20,\n c = 30;\n\nIf the value is t, and the first assigned value in the\ndeclaration is a function/array/object literal spanning several\nlines, it won't be indented additionally:\n\n var o = { var bar = 2,\n foo: 3 vs. o = {\n }, foo: 3\n bar = 2; };\n\nIf the value is `all', it will always be indented additionally:\n\n var o = {\n foo: 3\n };\n\n var o = {\n foo: 3\n },\n bar = 2;\n\nIf the value is `dynamic', it will be indented additionally only\nif the declaration contains more than one variable:\n\n var o = {\n foo: 3\n };\n\n var o = {\n foo: 3\n },\n bar = 2;" symbolp symbol js2-indent-switch-body nil "When nil, case labels are indented on the same level as the\ncontaining switch statement. Otherwise, all lines inside\nswitch statement body are indented one additional level." boolean booleanp] 10)
#@88 Regular expression matching keywords that are optionally
followed by an opening brace.
(defconst js2-possibly-braceless-keywords-re "else[ ]+if\\|for[ ]+each\\|\\(?:catch\\|do\\|else\\|f\\(?:inally\\|or\\)\\|if\\|let\\|try\\|w\\(?:hile\\|ith\\)\\)" (#$ . 1927))
#@89 Regular expression matching operators that affect indentation
of continued expressions.
(defconst js2-indent-operator-re "[-+*/%<>&^|?:.]\\([^-+*/.]\\|$\\)\\|!?=\\|\\_<\\(in\\(?:stanceof\\)?\\)\\_>" (#$ . 2197))
#@60 Regular expression matching variable declaration keywords.
(defconst js2-declaration-keyword-re "\\_<\\(const\\|let\\|var\\)\\_>" (#$ . 2415))
#@49 Auxiliary function for `js2-re-search-forward'.
(defalias 'js2-re-search-forward-inner #[(regexp &optional bound count) "\305\211\n\306V\203h\307 \f\"\210\203\310`\"\202\311`!\312 8\2038\307\313\314\312 8!P\212\305\210`)\315#\210\202c\316 8\203D\305y\210\202c\317 8\204Y`Sf\320=\203`\305f\321=\203`\307\322!\210\202c\nS`\202*`\207" [saved-point parse count regexp bound nil 0 re-search-forward parse-partial-sexp syntax-ppss 3 "\\(\\=\\|[^\\]\\|^\\)" string t 7 4 47 42 "\\*/"] 5 (#$ . 2564)])
#@145 Search forward but ignore strings and comments.
Invokes `re-search-forward' but treats the buffer as if strings
and comments have been removed.
(defalias 'js2-re-search-forward #[(regexp &optional bound noerror count) "`\30610 \204\307\n \310#\202, \311W\203!\312\n [#\202, \311V\205,\307\n #0\202?b\210 ?\205>\313\314\f!!))\207" [saved-point count regexp bound err noerror (search-failed) js2-re-search-forward-inner 1 0 js2-re-search-backward-inner error error-message-string] 4 (#$ . 3088)])
#@50 Auxiliary function for `js2-re-search-backward'.
(defalias 'js2-re-search-backward-inner #[(regexp &optional bound count) "\304 \305V\203X\306\n \"\210\307`!\3108\203'\306\311\312\3108!P\313 \314#\210\202\3158\2035\3168b\210\202\3178\204J`Sf\320=\203Q\304f\321=\203Q\306\322!\210\202 S\211\202)`\207" [parse count regexp bound nil 0 re-search-backward syntax-ppss 3 "\\([^\\]\\|^\\)" string line-beginning-position t 7 8 4 47 42 "/\\*"] 6 (#$ . 3603)])
#@147 Search backward but ignore strings and comments.
Invokes `re-search-backward' but treats the buffer as if strings
and comments have been removed.
(defalias 'js2-re-search-backward #[(regexp &optional bound noerror count) "`\30610 \204\307\n \310#\202, \311W\203!\312\n [#\202, \311V\205,\307\n #0\202?b\210 ?\205>\313\314\f!!))\207" [saved-point count regexp bound err noerror (search-failed) js2-re-search-backward-inner 1 0 js2-re-search-forward-inner error error-message-string] 4 (#$ . 4085)])
#@61 Return non-nil if text after point is a non-comma operator.
(defalias 'js2-looking-at-operator-p #[nil "\302!\205L\303f\304=\203\212\305\306\303\307#\205\303f\310=)\205L\303f\311=\205-\212\312\313 8)\311=?\205L\303f\314=\205K\302\315 \316Q!\205K\212\317 \210`Sf\320>)?\207" [js2-indent-operator-re js2-mode-identifier-re looking-at nil 58 js2-re-search-backward "[?:{]\\|\\_<case\\_>" t 63 47 3 syntax-ppss 42 "\\* *\\(?:\\[\\|" " *(\\)" js2-backward-sws (44 125 123)] 4 (#$ . 4603)])
#@61 Return non-nil if the current line continues an expression.
(defalias 'js2-continued-expression-p #[nil "\212\300 \210\301 \203\302f\303>?\2067\304`[!\210`Sf\305>?\2027\304`[!\210o\204+\306u\210\301 \2057\306u\210\307\310!?)\207" [back-to-indentation js2-looking-at-operator-p nil (45 43) forward-comment (44 91 40) -1 looking-at "\\*\\|\\+\\+\\|--\\|/[/*]"] 2 (#$ . 5105)])
#@232 Return non-nil if word after point is `while' of a do-while
statement, else returns nil. A braceless do-while statement
spanning several lines requires that the start of the loop is
indented to the same column as the current line.
(defalias 'js2-end-of-do-while-loop-p #[nil "\212\301\302!\205U\212\303\304x\210\301\303!)\203!\212\305 \210\306v\210\301\307!)\202U\310\307\311 \312#\210\301\307!\206U\313 \310\314\304\312#\203@\313 U\2031\301\315!\205T\316\317\320 \312#?\205T\313 U))\207" [saved-indent looking-at "\\s-*\\_<while\\_>" "[ \n]*}" nil backward-list -1 "\\_<do\\_>" js2-re-search-backward point-at-bol t current-indentation "^[ ]*\\_<" "[ ]*\\_<do\\_>" js2-re-search-forward "\\_<while\\_>" point-at-eol] 4 (#$ . 5493) nil])
#@151 Return the declaration indentation column if the current line belongs
to a multiline declaration statement. See `js2-pretty-multiline-declarations'.
(defalias 'js2-multiline-decl-indentation #[nil "\306\211\212\307 \210\310\n!?\205s\310 !\203\311\225b\210\204go\204g`\212\312 \210`Sf\313=\206P`Sf\314=\204M\315\316!\210\310 !\312 \210\203M`Sf\314=?\206P\317\f!*\203g\3201^\321 0\202c\322\211)\210\202\310\n!\205s\311\225b\210iT+\207" [at-opening-bracket forward-sexp-function js2-declaration-keyword-re js2-indent-operator-re pos _ nil back-to-indentation looking-at 0 js2-backward-sws 44 59 skip-syntax-backward "." js2-same-line (scan-error) backward-sexp t] 2 (#$ . 6252)])
#@186 Return the proper indentation of current line if it is a control statement.
Returns an indentation if this line starts the body of a control
statement without braces, else returns nil.
(defalias 'js2-ctrl-statement-indentation #[nil "\304\212\305 \210\306e!?\205i\307\310!?\205i\311\312\304\313#\205i\307\314!?\205i\304u\210`Sf\315U\203B\31618\317 0\202<\210\202=\210\320\321 x\210`\305 \210\307\322!\203Q\323\225b\210\307\n!\205a\323\225 U\205a\324 ?)\205i\325 \\*\207" [forward-sexp-function pt js2-possibly-braceless-keywords-re js2-basic-offset nil back-to-indentation js2-same-line looking-at "{" js2-re-search-backward "[[:graph:]]" t "[{([]" 41 (error) backward-sexp " " point-at-bol "}[ ]*" 0 js2-end-of-do-while-loop-p current-indentation] 4 (#$ . 6958)])
#@127 Return non-nil if we think we're in an array comprehension.
In particular, return the buffer position of the first `for' kwd.
(defalias 'js2-indent-in-array-comp #[(parse-status) "A@`\211\205a\212\nb\210\305\306!\205`\307u\210\310 \210\305\311!\203<\312\313 \210\310 \210\312f\314U?\2058\305\315!\2058\316\224)\202` `V\205`\317\320 \321#\205`\322\n`\"\211@\307U\205Z\323\f8?)\205`\307\224)*\207" [parse-status end bracket forward-sexp-function state looking-at "\\[" 1 js2-forward-sws "[[{]" nil forward-sexp 44 "for" 0 re-search-forward "[^,]]* \\(for\\) " t parse-partial-sexp 8] 5 (#$ . 7747)])
(defalias 'js2-array-comp-indentation #[(parse-status for-kwd) "\302!\203\212 A@b\210\303u\210\304\305w\210i)\207\212b\210i)\207" [for-kwd parse-status js2-same-line 1 " " nil] 2])
#@213 Helper function for `js2-proper-indentation'.
Depending on the value of `js2-pretty-multiline-declarations',
move point to the end of a variable declaration keyword so that
indentation is aligned to that column.
(defalias 'js2-maybe-goto-declaration-keyword-end #[(bracket) "\306\267\202S\307 !\205T\310\225Tb\207\311\211\211\307 !\205Q\310\225\212 b\210\31214\311\313 \210)\3140\2026\210\311\211\203I\315 \210\316\314\307!)\262)\n\205Q\fTb+\207\311\207" [js2-pretty-multiline-declarations js2-declaration-keyword-re comma-p at-closing-bracket-p declaration-keyword-end bracket #s(hash-table size 2 test eq rehash-size 1.5 rehash-threshold 0.8125 purecopy t data (all 6 dynamic 17)) looking-at 0 nil (error) forward-sexp t js2-forward-sws "," forward-sexp-function inhibit-changing-match-data] 4 (#$ . 8553)])
#@53 Return the proper indentation for the current line.
(defalias 'js2-proper-indentation #[(parse-status) "\3062\f\212\307 \210\3108\203\311\306\312!\"\210\313\314!\211\2064\313\315!\2064\313\316!\2054\212\317 \210`Sf\320>)?\321 \f\205>\322 A@#\323\211$%#\203{&\324Y\203{\325#!\204{\326!\211$\203{`\212$b\210\327 )Y\203{\330$\"\202 \331 \206  \203\217 \203\217 '\\\202  \206 #\203\377#b\210\313\332!\203\360\212\333\323x\210\313\334!)\203\261\335 \210\307 \210\336#!\210\n\203\301i\202\322 \203\316i'\337_\\\202\322i'\\%(\203\353 \204\353\313\340!\203\353%'\\\202 %\202 \n\204\373\323u\210\341\323w\210i\202  \203'\202 \342.0\207" [parse-status at-closing-bracket same-indent-p continued-expr-p js2-pretty-multiline-declarations declaration-indent --cl-block-js2-proper-indentation-- back-to-indentation 4 throw js2--comment-indent looking-at "[]})]" "\\_<case\\_>[^:]" "\\_<default:" js2-backward-sws (44 123) js2-continued-expression-p js2-multiline-decl-indentation nil 170 js2-same-line js2-indent-in-array-comp point-at-bol js2-array-comp-indentation js2-ctrl-statement-indentation "[({[][ ]*\\(/[/*]\\|$\\)" " \n)" ")" backward-list js2-maybe-goto-declaration-keyword-end 2 "\\_<switch\\_>" " " 0 bracket beg indent js2-language-version js2-basic-offset js2-indent-switch-body] 5 (#$ . 9389)])
#@66 Indentation inside a multi-line block comment continuation line.
(defalias 'js2--comment-indent #[(parse-status) "\212\3018b\210\302\303!\203iT\202\304)\207" [parse-status 8 looking-at "/\\*" 0] 2 (#$ . 10761)])
#@52 Indent the current line as JavaScript source text.
(defalias 'js2-indent-line #[(&optional bounce-backwards) "\303\211\304\212\305\306 !)`\212\307 \210`)Z\310\n8?\205.\311\312\n!!\210 \211\313V\262\205. u+\207" [inhibit-point-motion-hooks offset parse-status nil t syntax-ppss point-at-bol back-to-indentation 3 indent-line-to js2-proper-indentation 0] 3 (#$ . 10984) nil])
#@509 Find where JSX starts.
Assume JSX appears in the following instances:
- Inside parentheses, when returned or as the first argument
to a function, and after a newline
- When assigned to variables or object properties, but only
on a single line
- As the N+1th argument to a function
This is an optimized version of (re-search-backward "[(,]
"
nil t), except set point to the end of the match. This logic
executes up to the number of lines in the file, so it should be
really fast to reduce that impact.
(defalias 'js2--jsx-find-before-tag #[nil "\301`eV\203\"\302\210`Sf\303=\204`Sf\304=\203`S\211\203)\207" [pos nil 0 40 44] 2 (#$ . 11373)])
(put 'js2--jsx-find-before-tag 'byte-optimizer 'byte-compile-inline-expand)
#@32 Find the end of a JSX element.
(defconst js2--jsx-end-tag-re (concat "</" sgml-name-re ">\\|/>") (#$ . 12114))
#@116 Find where JSX ends.
This complements the assumption of where JSX appears from
`js--jsx-before-tag-re', which see.
(defconst js2--jsx-after-tag-re "[),]" (#$ . 12232))
#@688 Determine if/how the current line should be indented as JSX.
Return `first' for the first JSXElement on its own line.
Return `nth' for subsequent lines of the first JSXElement.
Return `expression' for an embedded JS expression.
Return `after' for anything after the last JSXElement.
Return nil for non-JSX lines.
Currently, JSX indentation supports the following styles:
- Single-line elements (indented like normal JS):
var element = <div></div>;
- Multi-line elements (enclosed in parentheses):
function () {
return (
<div>
<div></div>
</div>
);
}
- Function arguments:
React.render(
<div></div>,
document.querySelector('.root')
);
(defalias 'js2--jsx-indented-element-p #[nil "`\306 \307\211\211\211\211\211\211\211\211\211\211 \212\307\210\204s\307!`eV\203O\310\210`Sf\311=\204G`Sf\312=\203.`S\211!\203.!)\211\203s\313\314!\204X\307f\315U\203l`b\210\202&\205]\306!\306!V\205]Y\205] \204\270\316\"\307\317#\211\203\270\313\314!\204\244\320#!\203\224\211\203\230 \203\346\306 !\306 !\fX\203\322 X\204\352\fV\205] W\205]\321\211\202\347\317\205]\204L b\210\307\210\322\323 8\n\203L\204L\n@\211Y\203E f\324U\203E\306 !V\203E b\210\3251-\307$\326 )0\2021\210\202<\203<\306 W\202=\317\203E\327\202\372\nA\211\204\376\206]U\203\\\330\202]\331.\207" [type paren parens after-tag-line tag-end-line tag-end-pos line-number-at-pos nil 0 40 44 forward-comment 1 60 re-search-forward t looking-at after 9 syntax-ppss 123 (error) forward-sexp expression first nth tag-start-line tag-start-pos before-tag-line before-tag-pos last-pos current-line current-pos pos js2--jsx-end-tag-re js2--jsx-after-tag-re forward-sexp-function] 14 (#$ . 12407)])
#@34 Execute BODY as if in sgml-mode.
(defalias 'js2--as-sgml '(macro . #[(&rest body) "\301\302\303\304BBE\207" [body with-syntax-table sgml-mode-syntax-table let (forward-sexp-function parse-sexp-lookup-properties)] 5 (#$ . 14235)]))
#@71 Indent the current line as JavaScript or SGML (whichever is farther).
(defalias 'js2--expression-in-sgml-indent-line #[nil "\306`\307\212\310\311 !)\312 8?\205W\212\313 \210` Y\203 \306\314 p\315\216\316!\210\306\211\317 .\211\204?\320\202W\321 !\\] \203T\212\322!)\202W\322!,\207" [indent-col savep inhibit-point-motion-hooks parse-status #1=#:buffer #2=#:table nil t syntax-ppss point-at-bol 3 back-to-indentation syntax-table #[nil "rq\210\302 !)\207" [#1# #2# set-syntax-table] 2] set-syntax-table sgml-calculate-indent noindent js2-proper-indentation indent-line-to sgml-mode-syntax-table parse-sexp-lookup-properties forward-sexp-function js2-basic-offset] 4 (#$ . 14473)])
#@125 Indent the current line as JSX (with SGML offsets).
i.e., customize JSX element indentation with `sgml-basic-offset'
et al.
(defalias 'js2-jsx-indent-line #[nil "\306 \211\307=\203\310 \202G\311=\204\312=\203)\313K\314\216\313\315M\210\316 *\202G\317=\203E\320 p\321\216\322\f!\210\323\211\324 -\202G\316 )\207" [indentation-type #1=#:old #2=#:buffer #3=#:table sgml-mode-syntax-table parse-sexp-lookup-properties js2--jsx-indented-element-p expression js2--expression-in-sgml-indent-line first after js2-continued-expression-p #[nil "\301M\207" [#1# js2-continued-expression-p] 2] ignore js2-indent-line nth syntax-table #[nil "rq\210\302 !)\207" [#2# #3# set-syntax-table] 2] set-syntax-table nil sgml-indent-line forward-sexp-function] 3 (#$ . 15188) nil])
(provide 'js2-old-indent)