[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/sql-indent 1974564 10/13: recognize elseif in addition
From: |
Alex Harsanyi |
Subject: |
[elpa] externals/sql-indent 1974564 10/13: recognize elseif in addition to elif #81 |
Date: |
Thu, 20 Jun 2019 05:25:46 -0400 (EDT) |
branch: externals/sql-indent
commit 19745645855fefa8f2ffd7e70b41495b36a79fd2
Author: Alex Harsanyi <address@hidden>
Commit: Alex Harsányi <address@hidden>
recognize elseif in addition to elif #81
---
sql-indent-test.el | 5 +++++
sql-indent.el | 16 ++++++++--------
test-data/pr81-syn.eld | 48 ++++++++++++++++++++++++++++++++++++++++++++++++
test-data/pr81.sql | 17 +++++++++++++++++
4 files changed, 78 insertions(+), 8 deletions(-)
diff --git a/sql-indent-test.el b/sql-indent-test.el
index 00048e0..c95590d 100644
--- a/sql-indent-test.el
+++ b/sql-indent-test.el
@@ -402,4 +402,9 @@ information read from DATA-FILE (as generated by
"test-data/pr80.sql"
"test-data/pr80-syn.eld"))
+(ert-deftest sqlind-ert-pr81 ()
+ (sqlind-ert-check-file-syntax
+ "test-data/pr81.sql"
+ "test-data/pr81-syn.eld"))
+
;;; sql-indent-test.el ends here
diff --git a/sql-indent.el b/sql-indent.el
index b525474..d9d27af 100644
--- a/sql-indent.el
+++ b/sql-indent.el
@@ -309,7 +309,7 @@ But don't go before LIMIT."
(catch 'done
(while (> (point) (or limit (point-min)))
(when (re-search-backward
-
";\\|:=\\|\\_<\\(declare\\|begin\\|cursor\\|for\\|while\\|loop\\|if\\|then\\|else\\|elsif\\)\\_>\\|)"
+
";\\|:=\\|\\_<\\(declare\\|begin\\|cursor\\|for\\|while\\|loop\\|if\\|then\\|else\\|elsif\\|elseif\\)\\_>\\|)"
limit 'noerror)
(unless (sqlind-in-comment-or-string (point))
(let ((candidate-pos (match-end 0)))
@@ -321,6 +321,9 @@ But don't go before LIMIT."
((looking-at "cursor\\|for\\|while")
;; statement begins at the start of the keyword
(throw 'done (point)))
+ ((looking-at "else?if")
+ ;; statement begins at the start of the keyword
+ (throw 'done (point)))
((looking-at "then\\|else")
;; then and else start statements when they are inside
;; blocks, not expressions.
@@ -328,9 +331,6 @@ But don't go before LIMIT."
(when (looking-at ";")
;; Statement begins after the keyword
(throw 'done candidate-pos)))
- ((looking-at "elsif")
- ;; statement begins at the start of the keyword
- (throw 'done (point)))
((looking-at "if")
(when (sqlind-good-if-candidate)
;; statement begins at the start of the keyword
@@ -886,7 +886,7 @@ See also `sqlind-beginning-of-block'"
(defconst sqlind-start-block-regexp
(concat "\\(\\_<"
- (regexp-opt '("if" "then" "else" "elsif" "loop"
+ (regexp-opt '("if" "then" "else" "elsif" "elseif" "loop"
"begin" "declare" "create" "alter" "exception"
"procedure" "function" "end" "case") t)
"\\_>\\)\\|)\\|\\$\\$")
@@ -1310,7 +1310,7 @@ KIND is the symbol determining the type of the block
('if, 'loop,
(list 'block-end start-kind start-label)))
anchor))))
- ((memq block-kind '(else elsif))
+ ((memq block-kind '(else elsif elseif))
;; search the enclosing then context and refine form there. The
;; `cdr' in sqlind-syntax-of-line is used to remove the
;; block-start context for the else clause
@@ -1493,8 +1493,8 @@ not a statement-continuation POS is the same as the
;; create block start syntax if needed
((and (eq syntax-symbol 'in-block)
- (memq (nth 1 syntax) '(if elsif then case))
- (looking-at "\\(then\\|\\(els\\(e\\|if\\)\\)\\)\\_>"))
+ (memq (nth 1 syntax) '(if elsif elseif then case))
+ (looking-at "\\(then\\|\\(els\\(e\\|e?if\\)\\)\\)\\_>"))
(let ((what (intern (sqlind-match-string 0))))
;; the only invalid combination is a then statement in
;; an (in-block "then") context
diff --git a/test-data/pr81-syn.eld b/test-data/pr81-syn.eld
new file mode 100644
index 0000000..8e8abac
--- /dev/null
+++ b/test-data/pr81-syn.eld
@@ -0,0 +1,48 @@
+(((toplevel . 1))
+ ((select-clause . 5)
+ (nested-statement-continuation . 4)
+ (statement-continuation . 4))
+ ((select-clause . 5)
+ (nested-statement-continuation . 4)
+ (statement-continuation . 4))
+ (((block-start then)
+ . 1)
+ ((in-block if "")
+ . 1))
+ (((in-block then "")
+ . 70))
+ (((block-start elsif)
+ . 70)
+ ((in-block then "")
+ . 70))
+ (((in-block elsif "")
+ . 97))
+ (((block-end if "")
+ . 70)
+ ((in-block elsif "")
+ . 97))
+ ((toplevel . 1))
+ ((toplevel . 1))
+ ((select-clause . 139)
+ (nested-statement-continuation . 138)
+ (statement-continuation . 138))
+ ((select-clause . 139)
+ (nested-statement-continuation . 138)
+ (statement-continuation . 138))
+ (((block-start then)
+ . 135)
+ ((in-block if "")
+ . 135))
+ (((in-block then "")
+ . 204))
+ (((block-start elseif)
+ . 204)
+ ((in-block then "")
+ . 204))
+ (((in-block else "")
+ . 231))
+ (((block-end if "")
+ . 204)
+ ((in-block else "")
+ . 231))
+ ((toplevel . 1)))
\ No newline at end of file
diff --git a/test-data/pr81.sql b/test-data/pr81.sql
new file mode 100644
index 0000000..b554be0
--- /dev/null
+++ b/test-data/pr81.sql
@@ -0,0 +1,17 @@
+IF (SELECT ID
+ FROM SomeTable
+ WHERE SomeField > 0) IS NULL
+THEN
+ SET SomeVar = TRUE;
+ELSIF
+ SET SomeVar = FALSE;
+END IF;
+
+IF (SELECT ID
+ FROM SomeTable
+ WHERE SomeField > 0) IS NULL
+THEN
+ SET SomeVar = TRUE;
+ELSEIF
+ SET SomeVar = FALSE;
+END IF;
- [elpa] externals/sql-indent updated (87a6b4a -> 47e9ccb), Alex Harsanyi, 2019/06/20
- [elpa] externals/sql-indent 9d5f978 05/13: Fix regexp bug in `sqlind-good-if-candidate` (fixes #76), Alex Harsanyi, 2019/06/20
- [elpa] externals/sql-indent 31c29ed 12/13: Recognize more types of begin transaction statements (fixes #84), Alex Harsanyi, 2019/06/20
- [elpa] externals/sql-indent 2ca9610 09/13: don't be confused by drop function or procedure statements #80, Alex Harsanyi, 2019/06/20
- [elpa] externals/sql-indent f897c11 08/13: Apply advices of `checkdoc' (#77), Alex Harsanyi, 2019/06/20
- [elpa] externals/sql-indent dccd194 02/13: Recognize `select-join-condition` syntax inside nested statements #70 (#71), Alex Harsanyi, 2019/06/20
- [elpa] externals/sql-indent e7e7e85 11/13: Don't recognize select keywords in comments, fixes #83, Alex Harsanyi, 2019/06/20
- [elpa] externals/sql-indent 47e9ccb 13/13: Recognize left and right outer join statements #85, Alex Harsanyi, 2019/06/20
- [elpa] externals/sql-indent e511ced 01/13: `sqlind-search-backward` finds things at the same nesting level (#68) (#69), Alex Harsanyi, 2019/06/20
- [elpa] externals/sql-indent d9442ed 03/13: Recognize FULL JOIN, UNION ALL and EXCEPT keywords #73 (#74), Alex Harsanyi, 2019/06/20
- [elpa] externals/sql-indent 1974564 10/13: recognize elseif in addition to elif #81,
Alex Harsanyi <=
- [elpa] externals/sql-indent 9559ebe 07/13: Fix `sqlind-comment-end' regexp. (#79), Alex Harsanyi, 2019/06/20
- [elpa] externals/sql-indent ba2a690 06/13: also fix sqlind-end-statement-regexp, Alex Harsanyi, 2019/06/20
- [elpa] externals/sql-indent a6da8bd 04/13: Recognize more create keywords (#75), Alex Harsanyi, 2019/06/20