branch: elpa/swift-mode commit 7169a3b9c020b4f20bc0fab09640348252ddaf06 Author: uk-ar <yuuki....@gmail.com> Commit: uk-ar <yuuki....@gmail.com>
Fix class when empty (no insts) --- swift-mode.el | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/swift-mode.el b/swift-mode.el index edea55f..a695e5b 100644 --- a/swift-mode.el +++ b/swift-mode.el @@ -107,8 +107,8 @@ (top-level-st ("import" type) (decl) - ("ACCESSMOD" "class" class-decl-exp "class-{" class-level-sts "}") - ("ACCESSMOD" "protocol" class-decl-exp "protocol-{" protocol-level-sts "}") + ("ACCESSMOD" "class" class-decl-exp "{" class-level-sts "}") + ("ACCESSMOD" "protocol" class-decl-exp "{" protocol-level-sts "}") ) (class-level-sts (class-level-st) (class-level-st ";" class-level-st)) @@ -278,11 +278,10 @@ We try to constraint those lookups by reasonable number of lines.") ((and (looking-at "\n\\|\/\/") (swift-smie--implicit-semi-p)) (if (eolp) (forward-char 1) (forward-comment 1)) ";") - - ((looking-at "{") (forward-char 1) - (if (looking-back "\\(class\\|protocol\\) [^{]+{" (line-beginning-position swift-smie--lookback-max-lines) t) - (concat (match-string 1) "-{") - "{")) + (t + (forward-comment (point)) + (cond + ((looking-at "{") (forward-char 1) "{") ((looking-at "}") (forward-char 1) "}") ((looking-at ",") (forward-char 1) ",") @@ -327,6 +326,7 @@ We try to constraint those lookups by reasonable number of lines.") "else")) (t tok)))) )) + )) (defun swift-smie--backward-token () (let ((pos (point))) @@ -336,10 +336,7 @@ We try to constraint those lookups by reasonable number of lines.") (swift-smie--implicit-semi-p)) ";") - ((eq (char-before) ?\{) (backward-char 1) - (if (looking-back "\\(class\\|protocol\\) [^{]+" (line-beginning-position swift-smie--lookback-max-lines) t) - (concat (match-string 1) "-{") - "{")) + ((eq (char-before) ?\{) (backward-char 1) "{") ((eq (char-before) ?\}) (backward-char 1) "}") ((eq (char-before) ?,) (backward-char 1) ",")