[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/treesit-fold e704add10d 340/417: fix(llvm): Fix folding fo
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/treesit-fold e704add10d 340/417: fix(llvm): Fix folding for LLVM's label |
Date: |
Mon, 1 Jul 2024 10:03:02 -0400 (EDT) |
branch: elpa/treesit-fold
commit e704add10d377aa28544fe15a05b7d81efbe590b
Author: Jen-Chieh <jcs090218@gmail.com>
Commit: Jen-Chieh <jcs090218@gmail.com>
fix(llvm): Fix folding for LLVM's label
---
ts-fold-parsers.el | 3 ++-
ts-fold.el | 21 +++++++++++++++++++++
2 files changed, 23 insertions(+), 1 deletion(-)
diff --git a/ts-fold-parsers.el b/ts-fold-parsers.el
index b08a7c2b2d..87a57459f9 100644
--- a/ts-fold-parsers.el
+++ b/ts-fold-parsers.el
@@ -58,6 +58,7 @@
(declare-function ts-fold-range-julia "ts-fold.el")
(declare-function ts-fold-range-kotlin-when "ts-fold.el")
(declare-function ts-fold-range-lisp-function "ts-fold.el")
+(declare-function ts-fold-range-llvm-label "ts-fold.el")
(declare-function ts-fold-range-lua-comment "ts-fold.el")
(declare-function ts-fold-range-lua-function "ts-fold.el")
(declare-function ts-fold-range-lua-if "ts-fold.el")
@@ -360,7 +361,7 @@
(defun ts-fold-parsers-llvm ()
"Rule set for LLVM."
'((function_body . ts-fold-range-seq)
- (label . ts-fold-range-asm-label)
+ (label . ts-fold-range-llvm-label)
(comment
. (lambda (node offset)
(ts-fold-range-line-comment node offset ";;")))))
diff --git a/ts-fold.el b/ts-fold.el
index e0f3e35d42..5434a16157 100644
--- a/ts-fold.el
+++ b/ts-fold.el
@@ -804,6 +804,27 @@ more information."
(end (1- (tsc-node-end-position node))))
(ts-fold--cons-add (cons beg end) offset)))
+(defun ts-fold-range-llvm--find-last-instruction (node)
+ "Find the last instruction node by starting NODE."
+ (let* ((iter-node (ts-fold--next-prev-node-skip-newline node t))
+ (last iter-node))
+ (while (and iter-node
+ (not (member (ts-fold-2str (tsc-node-type iter-node))
+ (ts-fold-listify '("label" "}")))))
+ (setq last iter-node
+ iter-node (ts-fold--next-prev-node-skip-newline iter-node t)))
+ last)) ; return last insturction node
+
+(defun ts-fold-range-llvm-label (node offset)
+ "Define fold range for `label' in LLVM.
+
+For arguments NODE and OFFSET, see function `ts-fold-range-seq' for
+more information."
+ (when-let* ((beg (tsc-node-end-position node))
+ (end (ts-fold-range-llvm--find-last-instruction node))
+ (end (tsc-node-end-position end)))
+ (ts-fold--cons-add (cons beg end) offset)))
+
(defun ts-fold-range-lua-comment (node offset)
"Define fold range for Lua comemnt.
- [nongnu] elpa/treesit-fold 56e6743bac 252/417: feat: Improve folding for C preproc operators (#46), (continued)
- [nongnu] elpa/treesit-fold 56e6743bac 252/417: feat: Improve folding for C preproc operators (#46), ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold 9d9e0c5cf7 257/417: Add more folding definitions (#51), ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold 54d12c9822 281/417: feat: Add TOML support (#68), ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold b1021c2acb 293/417: feat: Add Noir support (#77), ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold fe3e7610b1 403/417: fix: `treesit-fold-close-all` raises an wrong type error (#5), ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold 993db0aa02 383/417: feat: Enhance SQL folding, ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold 0b48d9b286 355/417: reordered the alists for alphabetical ordering, ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold 27c0fd0c7e 361/417: style: Place functions in alphabetic order, ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold e36498c9e1 323/417: docs: Apply new changes from line-reminder, ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold a6c75c8373 334/417: Bump version, ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold e704add10d 340/417: fix(llvm): Fix folding for LLVM's label,
ELPA Syncer <=
- [nongnu] elpa/treesit-fold 41c13ff0e2 416/417: 2 bug fix (#10), ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold eb714e2c21 408/417: feat: Add Gleam support (#8), ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold 14e3f13f67 415/417: feat: Enhance the Gleam support (#9), ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold 7833eb31ab 096/417: Function void, ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold ad0e036355 099/417: Core, ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold 862b571191 118/417: Remove def, ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold 44714c252a 126/417: Quote description, ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold a1b5e97fa0 132/417: Improve doc, ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold 49aff53680 136/417: Add comment, ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold 5e956f74dc 148/417: Support python comment and document string, ELPA Syncer, 2024/07/01