[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/typescript-mode 8b2815514d 088/222: Simplify typescript--b
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/typescript-mode 8b2815514d 088/222: Simplify typescript--backward-to-parameter-list |
Date: |
Sun, 6 Feb 2022 16:59:20 -0500 (EST) |
branch: elpa/typescript-mode
commit 8b2815514df97c7357b50c0bee2b443ae3411514
Author: Louis-Dominique Dubeau <ldd@lddubeau.com>
Commit: Louis-Dominique Dubeau <ldd@lddubeau.com>
Simplify typescript--backward-to-parameter-list
---
typescript-mode.el | 104 +++++++++++++++++++++--------------------------------
1 file changed, 41 insertions(+), 63 deletions(-)
diff --git a/typescript-mode.el b/typescript-mode.el
index b7d480d33e..abb9af2a43 100644
--- a/typescript-mode.el
+++ b/typescript-mode.el
@@ -2058,69 +2058,47 @@ moved on success."
;; This handles the case of a function with return type annotation.
(save-excursion
(loop named search-loop
- do (progn
- (cond
- ;; Looking at the arrow of a function definition:
- ;; move back over the arrow.
- ((looking-back "=>" (- (point) 2))
- (backward-char 2)
- (typescript--backward-syntactic-ws)
- ;; Immediately handle a parenthesized list of
arguments. Otherwise, the
- ;; algorithm here will go astray.
- (when (eq (char-before) ?\))
- (condition-case nil
- (backward-sexp)
- (scan-error nil))))
- ;; Looking at the end of the parameters list
- ;; of a generic: move back over the list.
- ((eq (char-before) ?>)
- (backward-char)
- (typescript--backward-over-generic-parameter-list))
- ;; Looking at a union: skip over the character.
- ((eq (char-before) ?|)
- (backward-char))
- ;; General case: we just move back over the current
sexp.
- (t
- (condition-case nil
- (backward-sexp)
- (scan-error nil))))
- (typescript--backward-syntactic-ws)
- (let ((before (char-before)))
- ;; Check whether we are at "):".
- (when (and (eq before ?\:)
- (progn
- (backward-char)
- (skip-syntax-backward " ")
- (eq (char-before) ?\))))
- ;; Success! This the end of the parameter list.
- (cl-return-from search-loop (point)))
- ;; All the following cases are constructs that are
allowed to
- ;; appear between the opening brace of a function and
the
- ;; end of a parameter list.
- (unless
- (or
- ;; End of a generic.
- (eq before ?>)
- ;; Union of types
- (eq before ?|)
- ;; Dotted names
- (eq before ?.)
- ;; Typeguard (eg. foo is SomeClass)
- (looking-back "is" (- (point) 2))
- ;; Array shorthand
- (eq before ?\])
- ;; This is also dealing with dotted names. This
may come
- ;; into play if a jump back moves over an entire
dotted
- ;; name at once.
- ;;
- ;; The earlier test for dotted names comes into
play if the
- ;; logic moves over one part of a dotted name at
a time (which
- ;; is what `backward-sexp` normally does).
- (looking-back typescript--dotted-name-re nil)
- )
- ;; We did not encounter a valid construct, so
- ;; the search is unsuccessful.
- (cl-return-from search-loop nil))))))
+ do
+ (typescript--backward-syntactic-ws)
+ ;; Check whether we are at "):".
+ (when (and (eq (char-before) ?\:)
+ (progn
+ (backward-char)
+ (skip-syntax-backward " ")
+ (eq (char-before) ?\))))
+ ;; Success! This the end of the parameter list.
+ (cl-return-from search-loop (point)))
+ ;; If we recognize a structure that belongs in a return type
annotation,
+ ;; skip back over it, or fail.
+ (cond
+ ;; Arrow of a function definition, or typeguard (eg. foo is
SomeClass)
+ ((looking-back "=>\\|is" (- (point) 2))
+ (backward-char 2))
+ ;; End of the parameters list of a generic.
+ ((eq (char-before) ?>)
+ (backward-char)
+ (typescript--backward-over-generic-parameter-list))
+ ;; Union of types, or a dot in a dotted name.
+ ((memq (char-before) '(?| ?.))
+ (backward-char))
+ ((or
+ ;; End-delimiter of a delimited construct, for constructs
+ ;; not handled above.
+ (memq (char-before) '(?\) ?} ?\" ?\]))
+ ;; This is also dealing with dotted names. This may come
+ ;; into play if a jump back moves over an entire dotted
+ ;; name at once.
+ ;;
+ ;; The earlier test for dotted names comes into play if
the
+ ;; logic moves over one part of a dotted name at a time
(which
+ ;; is what `backward-sexp` normally does).
+ (looking-back typescript--dotted-name-re nil))
+ (condition-case nil
+ (backward-sexp)
+ (scan-error nil)))
+ ;; Otherwise, we failed to find a location.
+ (t
+ (cl-return-from search-loop nil)))))
;; This handles the case of a function without return type
annotation.
(progn
(typescript--backward-syntactic-ws)
- [nongnu] elpa/typescript-mode a2c2ff03e7 024/222: Add support for compilation-mode., (continued)
- [nongnu] elpa/typescript-mode a2c2ff03e7 024/222: Add support for compilation-mode., ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode 7526f138a0 032/222: Avoid capturing things we dont need for compilation-mode., ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode 666052f09f 033/222: Update readme., ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode 4235b47a38 060/222: Fix indent for lines which starts with tabs., ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode 52c08d0628 091/222: Add more fontification tests for regular expressions., ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode e25c7ddb8a 062/222: Fix indentation of funcs with return annotations., ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode 536e4da380 087/222: Fix bug with hanling array shorthand in return value types., ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode 70acbf9c3d 078/222: Change font-lock-test to also accept a list of locations, ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode a2167a133d 056/222: Fix errors with indentation when line has wide unicode chars., ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode 09bdb97c32 065/222: Fix an indentation bug., ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode 8b2815514d 088/222: Simplify typescript--backward-to-parameter-list,
ELPA Syncer <=
- [nongnu] elpa/typescript-mode f9cd0dd539 112/222: Try parse new error-format introduced in tsc 2.7+, ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode a1cdb7a1ec 121/222: Remove redundant regexp groups for jsdoc tags, ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode fd1c9daa4d 094/222: Add failing cases., ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode bd046e0fae 120/222: Add tags in usejsdoc.org, ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode 3c79132066 136/222: fix warnings from package-lint, ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode 000131df29 150/222: Update CI-settings, ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode b1d1948c15 123/222: Merge pull request #88 from Ptival/fix-indentation-method-calls-keywords, ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode 039d122384 156/222: add a test for simple tsx, ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode c766ec8009 159/222: Include symbol constituents in typescript--function-call-re, ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode 5e0b9ee095 168/222: Add a test that fails without the following indentation fix., ELPA Syncer, 2022/02/06