aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJackson Ray Hamilton2019-03-23 15:01:55 -0700
committerJackson Ray Hamilton2019-04-08 22:48:22 -0700
commit339be7c00790fb407cc8449fa8f59baa792cbe69 (patch)
tree603c9636ecdc7f94378a83288eb18351c38b2631
parent1a1ef2851844a9ae2edcfe0346fc457e90c24bc7 (diff)
downloademacs-339be7c00790fb407cc8449fa8f59baa792cbe69.tar.gz
emacs-339be7c00790fb407cc8449fa8f59baa792cbe69.zip
Finish replacing SGML-based JSX detection with js-mode’s parsing
This removes the last dependency on sgml-mode for JSX-related logic. * lisp/progmodes/js.el (js-jsx--start-tag-re) (js-jsx--end-tag-re): Remove. (js-jsx--looking-at-start-tag-p) (js-jsx--looking-back-at-end-tag-p): Reimplement using text properties, using syntax information which ought to be slightly more accurate than regexps since it was found by complete parsing.
-rw-r--r--lisp/progmodes/js.el14
1 files changed, 3 insertions, 11 deletions
diff --git a/lisp/progmodes/js.el b/lisp/progmodes/js.el
index af83e04df42..df2c41332e7 100644
--- a/lisp/progmodes/js.el
+++ b/lisp/progmodes/js.el
@@ -50,7 +50,6 @@
50(require 'imenu) 50(require 'imenu)
51(require 'moz nil t) 51(require 'moz nil t)
52(require 'json) 52(require 'json)
53(require 'sgml-mode)
54(require 'prog-mode) 53(require 'prog-mode)
55 54
56(eval-when-compile 55(eval-when-compile
@@ -2211,13 +2210,10 @@ testing for syntax only valid as JSX."
2211 (js--regexp-opt-symbol '("in" "instanceof"))) 2210 (js--regexp-opt-symbol '("in" "instanceof")))
2212 "Regexp matching operators that affect indentation of continued expressions.") 2211 "Regexp matching operators that affect indentation of continued expressions.")
2213 2212
2214(defconst js-jsx--start-tag-re
2215 (concat "<" sgml-name-re)
2216 "Regexp matching code that looks like a JSXOpeningElement.")
2217
2218(defun js-jsx--looking-at-start-tag-p () 2213(defun js-jsx--looking-at-start-tag-p ()
2219 "Non-nil if a JSXOpeningElement immediately follows point." 2214 "Non-nil if a JSXOpeningElement immediately follows point."
2220 (looking-at js-jsx--start-tag-re)) 2215 (let ((tag-beg (get-text-property (point) 'js-jsx-tag-beg)))
2216 (and tag-beg (memq (car tag-beg) '(open self-closing)))))
2221 2217
2222(defun js--looking-at-operator-p () 2218(defun js--looking-at-operator-p ()
2223 "Return non-nil if point is on a JavaScript operator, other than a comma." 2219 "Return non-nil if point is on a JavaScript operator, other than a comma."
@@ -2263,13 +2259,9 @@ testing for syntax only valid as JSX."
2263 (setq result nil))) 2259 (setq result nil)))
2264 result)) 2260 result))
2265 2261
2266(defconst js-jsx--end-tag-re
2267 (concat "</" sgml-name-re ">\\|/>")
2268 "Regexp matching a JSXClosingElement.")
2269
2270(defun js-jsx--looking-back-at-end-tag-p () 2262(defun js-jsx--looking-back-at-end-tag-p ()
2271 "Non-nil if a JSXClosingElement immediately precedes point." 2263 "Non-nil if a JSXClosingElement immediately precedes point."
2272 (looking-back js-jsx--end-tag-re (point-at-bol))) 2264 (get-text-property (point) 'js-jsx-tag-end))
2273 2265
2274(defun js--continued-expression-p () 2266(defun js--continued-expression-p ()
2275 "Return non-nil if the current line continues an expression." 2267 "Return non-nil if the current line continues an expression."