Function: js-jsx--context
js-jsx--context is a byte-compiled function defined in js.el.gz.
Signature
(js-jsx--context)
Documentation
Determine JSX context and move to enclosing JSX.
Source Code
;; Defined in /usr/src/emacs/lisp/progmodes/js.el.gz
;; When indenting, we want to know if the line is…
;;
;; - within a multiline JSXElement, or
;; - within a string in a JSXBoundaryElement, or
;; - within JSXText, or
;; - within a JSXAttribute’s multiline JSXExpressionContainer.
;;
;; In these cases, special XML-like indentation rules for JSX apply.
;; If JS is nested within JSX, then indentation calculations may be
;; combined, such that JS indentation is “relative” to the JSX’s.
;;
;; Therefore, functions below provide such contextual information, and
;; `js--proper-indentation' may call itself once recursively in order
;; to finish calculating that “relative” JS+JSX indentation.
(defun js-jsx--context ()
"Determine JSX context and move to enclosing JSX."
(let ((pos (point))
(parse-status (syntax-ppss))
(enclosing-tag-pos (js-jsx--enclosing-tag-pos)))
(when enclosing-tag-pos
(if (< pos (nth 1 enclosing-tag-pos))
(if (nth 3 parse-status)
(list 'string (nth 8 parse-status))
(list 'tag (nth 0 enclosing-tag-pos) (nth 1 enclosing-tag-pos)))
(list 'text (nth 0 enclosing-tag-pos) (nth 2 enclosing-tag-pos))))))