[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/treesit-fold 8fc88e29f5 089/417: Login update for Csharp c
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/treesit-fold 8fc88e29f5 089/417: Login update for Csharp comment |
Date: |
Mon, 1 Jul 2024 10:02:14 -0400 (EDT) |
branch: elpa/treesit-fold
commit 8fc88e29f5725b2ff3f593d245013ff3cc9c79d5
Author: Jen-Chieh Shen <jcs090218@gmail.com>
Commit: Jen-Chieh Shen <jcs090218@gmail.com>
Login update for Csharp comment
---
tree-sitter-fold-parsers.el | 7 +++----
tree-sitter-fold-summary.el | 8 +++++++-
tree-sitter-fold.el | 16 +++++++++++++---
3 files changed, 23 insertions(+), 8 deletions(-)
diff --git a/tree-sitter-fold-parsers.el b/tree-sitter-fold-parsers.el
index eeb1472b2e..077d6bf5ec 100644
--- a/tree-sitter-fold-parsers.el
+++ b/tree-sitter-fold-parsers.el
@@ -64,7 +64,7 @@
(switch_body . tree-sitter-fold-range-seq)
(anonymous_object_creation_expression . tree-sitter-fold-range-seq)
(initializer_expression . tree-sitter-fold-range-seq)
- (comment . (tree-sitter-fold-range-seq 1
-1))))
+ (comment .
tree-sitter-fold-range-csharp-comment)))
(defun tree-sitter-fold-parsers-css ()
"Rule sets for CSS."
@@ -73,9 +73,8 @@
(defun tree-sitter-fold-parsers-go ()
"Rule sets for Go."
- '((type_declaration . tree-sitter-fold-range-go-type-declaration)
- (function_declaration . tree-sitter-fold-range-go-method)
- (method_declaration . tree-sitter-fold-range-go-method)))
+ '((block . tree-sitter-fold-range-seq)
+ (comment . tree-sitter-fold-range-seq)))
(defun tree-sitter-fold-parsers-html ()
"Rule sets for HTML."
diff --git a/tree-sitter-fold-summary.el b/tree-sitter-fold-summary.el
index 802159f05f..086ffc6acd 100644
--- a/tree-sitter-fold-summary.el
+++ b/tree-sitter-fold-summary.el
@@ -106,6 +106,12 @@ type of content by checking the word boundary's existence."
(setq doc-str (s-replace-regexp "<[/]*[^>]+." "" doc-str))
(tree-sitter-fold-summary--generic doc-str (if type-triple "///" "//"))))
+(defun tree-sitter-fold-summary-csharp (doc-str)
+ "Extract summary for C# from DOC-STR."
+ (or (tree-sitter-fold-summary-javadoc doc-str)
+ (tree-sitter-fold-summary-csharp-vsdoc doc-str)
+ (tree-sitter-fold-summary-c-macro doc-str)))
+
(defun tree-sitter-fold-summary-javadoc (doc-str)
"Extract javadoc summary from DOC-STR."
(tree-sitter-fold-summary--generic doc-str "*"))
@@ -189,7 +195,7 @@ type of content by checking the word boundary's existence."
(bat-mode . tree-sitter-fold-summary-batch)
(c-mode . tree-sitter-fold-summary-c)
(c++-mode . tree-sitter-fold-summary-c)
- (csharp-mode . tree-sitter-fold-summary-csharp-vsdoc)
+ (csharp-mode . tree-sitter-fold-summary-csharp)
(go-mode . tree-sitter-fold-summary-go)
(java-mode . tree-sitter-fold-summary-javadoc)
(javascript-mode . tree-sitter-fold-summary-javadoc)
diff --git a/tree-sitter-fold.el b/tree-sitter-fold.el
index f3b5cfbd92..7fe2d368ca 100644
--- a/tree-sitter-fold.el
+++ b/tree-sitter-fold.el
@@ -321,6 +321,10 @@ If the current syntax node is not foldable, do nothing."
;; (@* "Languages" )
;;
+(defun tree-sitter-fold-multi-line (node)
+ "Return t, if content NODE is single line."
+ (string-match-p "\n" (tsc-node-text node)))
+
(defun tree-sitter-fold-range-seq (node offset)
"Return the fold range in sequence."
(let ((beg (1+ (tsc-node-start-position node)))
@@ -328,8 +332,14 @@ If the current syntax node is not foldable, do nothing."
(setq beg (+ beg (car offset)) end (+ end (cdr offset)))
(cons beg end)))
+(defun tree-sitter-fold-range-csharp-comment (node offset)
+ "Define fold range for C# comment."
+ (if (tree-sitter-fold-multi-line node)
+ (tree-sitter-fold-range-seq node (cons 1 -1))
+ nil))
+
(defun tree-sitter-fold-range-go-type-declaration (node offset)
- "Return the fold range for `type_declaration' NODE in Go language.
+ "Return the fold range for `type_declaration' NODE.
Only `struct_type' and `interface_type' nodes can be folded."
(when-let* ((type-spec-node (tsc-get-nth-child node 1))
;; the type_spec node is not named in the Go grammar
@@ -349,7 +359,7 @@ Only `struct_type' and `interface_type' nodes can be
folded."
(t nil))))
(defun tree-sitter-fold-range-go-method (node offset)
- "Return the fold range for `method_declaration' NODE in Go language."
+ "Return the fold range for `method_declaration' NODE."
(let* ((named-node (or (tsc-get-child-by-field node :result)
(tsc-get-child-by-field node :parameters)))
(beg (1+ (tsc-node-end-position named-node)))
@@ -358,7 +368,7 @@ Only `struct_type' and `interface_type' nodes can be
folded."
(cons beg end)))
(defun tree-sitter-fold-range-nix-function (node offset)
- "Return the fold range for `function' NODE in Nix express language."
+ "Return the fold range for `function' NODE."
(let ((beg (thread-first node
(tsc-get-child-by-field :formals)
(tsc-get-next-sibling)
- [nongnu] elpa/treesit-fold 045841504e 059/417: Simplify node alist, (continued)
- [nongnu] elpa/treesit-fold 045841504e 059/417: Simplify node alist, ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold 17d029c8bd 064/417: Update Cask, ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold 7a2cbb3c80 066/417: Add changelog, ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold e38981daf7 070/417: Enalbe compile, ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold dc670a048b 072/417: Add readme, ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold a5d413e45c 074/417: Complete Java, ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold de128eaf10 076/417: Add CSS, ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold 23bd9c2c05 077/417: Add CSS, ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold fef90261f5 082/417: Apply offset, ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold 76e0dd263e 088/417: Hide indicators when single line, ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold 8fc88e29f5 089/417: Login update for Csharp comment,
ELPA Syncer <=
- [nongnu] elpa/treesit-fold 809bc9a0db 090/417: Remove go decalaration, ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold 422cff043e 100/417: Fix comment line, ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold 2d2179292f 105/417: Fix doc string, ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold 5062bf22a8 112/417: Mark temp, ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold 959191660b 115/417: Simplify, ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold 7065c6b28f 122/417: Apply macro, ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold f49df1ea3d 124/417: Update doc, ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold 6f15c1735a 125/417: Support javascript comment, ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold eeb9c03bcc 127/417: Fix conitouse line, ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold c33e5e7e0c 128/417: Temporily disable csharp, ELPA Syncer, 2024/07/01