[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/treesit-fold 07da6590aa 348/417: feat: Add LLVM MIR suppor
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/treesit-fold 07da6590aa 348/417: feat: Add LLVM MIR support |
Date: |
Mon, 1 Jul 2024 10:03:03 -0400 (EDT) |
branch: elpa/treesit-fold
commit 07da6590aaf0b121dff97fe4bc12fa6486fadcde
Author: JenChieh <jcs090218@gmail.com>
Commit: Jen-Chieh Shen <jcs090218@gmail.com>
feat: Add LLVM MIR support
---
CHANGELOG.md | 1 +
ts-fold-parsers.el | 8 ++++++++
ts-fold-summary.el | 1 +
ts-fold-util.el | 7 +++++--
ts-fold.el | 14 ++++++++++++++
5 files changed, 29 insertions(+), 2 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index ef8c67b03b..c18154d950 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -11,6 +11,7 @@ Check [Keep a Changelog](http://keepachangelog.com/) for
recommendations on how
* Add `LLVM` support (#103)
* Add `ActionScript` support (#106)
* Add `Tablegen` support (#107)
+* Add `LLVM MIR` support (#108)
## 0.3.0
> Released Nov 29, 2023
diff --git a/ts-fold-parsers.el b/ts-fold-parsers.el
index 09a0841591..870f16d287 100644
--- a/ts-fold-parsers.el
+++ b/ts-fold-parsers.el
@@ -61,6 +61,7 @@
(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-llvm-mir-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")
@@ -377,6 +378,13 @@
. (lambda (node offset)
(ts-fold-range-line-comment node offset ";;")))))
+(defun ts-fold-parsers-llvm-mir ()
+ "Rule set for LLVM MIR."
+ '((basic_block . ts-fold-range-llvm-mir-label)
+ (comment
+ . (lambda (node offset)
+ (ts-fold-range-line-comment node offset ";;")))))
+
(defun ts-fold-parsers-lua ()
"Rule set for Lua."
'((expression_list . ts-fold-range-seq)
diff --git a/ts-fold-summary.el b/ts-fold-summary.el
index 8629c53223..ffd9b9ad15 100644
--- a/ts-fold-summary.el
+++ b/ts-fold-summary.el
@@ -260,6 +260,7 @@ type of content by checking the word boundary's existence."
(lisp-mode . ts-fold-summary-elisp)
(lisp-interaction-mode . ts-fold-summary-elisp)
(llvm-mode . ts-fold-summary-elisp)
+ (llvm-mir-mode . ts-fold-summary-elisp)
(lua-mode . ts-fold-summary-lua-doc)
(makefile-mode . ts-fold-summary-ruby-doc)
(makefile-automake-mode . ts-fold-summary-ruby-doc)
diff --git a/ts-fold-util.el b/ts-fold-util.el
index d360369028..5cf772d50d 100644
--- a/ts-fold-util.el
+++ b/ts-fold-util.el
@@ -96,8 +96,11 @@ Like function `s-count-matches' but faster."
(defun ts-fold--get-face (obj trim)
"Return face name from OBJ.
If argument TRIM is non-nil, trim the OBJ."
- (let ((obj (if trim (string-trim obj) obj)))
- (get-text-property 0 'face obj)))
+ (let* ((obj (if trim (string-trim obj) obj))
+ (len (length obj)))
+ (or (get-text-property 0 'face obj)
+ (and (<= 1 len)
+ (get-text-property 1 'face obj)))))
(defun ts-fold--is-face (obj lst-face &optional trim)
"Return non-nil if OBJ's face is define inside list LST-FACE.
diff --git a/ts-fold.el b/ts-fold.el
index 92f6ea932c..b3e53bcb22 100644
--- a/ts-fold.el
+++ b/ts-fold.el
@@ -102,6 +102,7 @@
(lisp-mode . ,(ts-fold-parsers-lisp))
(lisp-interaction-mode . ,(ts-fold-parsers-lisp))
(llvm-mode . ,(ts-fold-parsers-llvm))
+ (llvm-mir-mode . ,(ts-fold-parsers-llvm-mir))
(lua-mode . ,(ts-fold-parsers-lua))
(makefile-mode . ,(ts-fold-parsers-make))
(makefile-automake-mode . ,(ts-fold-parsers-make))
@@ -861,6 +862,19 @@ more information."
(end (tsc-node-end-position end)))
(ts-fold--cons-add (cons beg end) offset)))
+(defun ts-fold-range-llvm-mir-label (node offset)
+ "Define fold range for `label' in LLVM MIR.
+
+For arguments NODE and OFFSET, see function `ts-fold-range-seq' for
+more information."
+ (when-let* ((label (car (ts-fold-find-children node "label")))
+ (colon (tsc-get-next-sibling label))
+ (beg (tsc-node-end-position colon))
+ (beg (ts-fold--eol beg))
+ (end (ts-fold-range-llvm--find-last-instruction label))
+ (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 cde9c90b07 259/417: docs(README.md): Metnion YAML support, (continued)
- [nongnu] elpa/treesit-fold cde9c90b07 259/417: docs(README.md): Metnion YAML support, ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold 5ebe65e85d 262/417: docs: Fix more typo, ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold 8386b5b714 280/417: feat: Add Markdown support (#67), ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold 630b896b3f 277/417: feat: Add Haskell support (#65), ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold 08abd98ba4 272/417: feat: Add Dart support (#62), ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold d20c3663f9 380/417: Update desc, ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold 2bb351bcf3 385/417: feat: Add on fold hook, ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold c14893d4ff 343/417: perf: Use built-in function for indentation, ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold 858fb6fe1c 325/417: Update CHANGELOG.md, ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold 581af904c1 286/417: feat: Add GDScript support (#72), ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold 07da6590aa 348/417: feat: Add LLVM MIR support,
ELPA Syncer <=
- [nongnu] elpa/treesit-fold 03644fb5fa 341/417: fix(indicators): Rely on range itself, ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold 6ec049b140 310/417: feat: Add Make support (#90), ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold 75e72c658a 332/417: feat: Add Org support, ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold 9b25eeeb0b 404/417: chore: Update mouse face docstring, ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold 6b759ca36e 402/417: Update README.org (#4), ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold a9d4c2ec53 296/417: feat: Add XML support (#80), ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold 5c45efb2d5 316/417: Update CHANGELOG.md, ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold abb1c53bd4 336/417: Bump version for next release, ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold 544390c602 329/417: fix: Fold line comment with same indentation, ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold 7fdaf447cc 245/417: Change global mode to turn on with tree-sitter (#41), ELPA Syncer, 2024/07/01