emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/csharp-mode 8ec64b4 136/459: Merge pull request #57 fro


From: ELPA Syncer
Subject: [elpa] externals/csharp-mode 8ec64b4 136/459: Merge pull request #57 from josteink/imenu-fixes
Date: Sun, 22 Aug 2021 13:59:13 -0400 (EDT)

branch: externals/csharp-mode
commit 8ec64b453d47b26dfd66ceb19772cc4166cc86ff
Merge: 0a61f21 f367ef6
Author: Jostein Kjønigsen <jostein@kjonigsen.net>
Commit: Jostein Kjønigsen <jostein@kjonigsen.net>

    Merge pull request #57 from josteink/imenu-fixes
    
    Imenu fixes
---
 csharp-mode-tests.el              | 30 ++++++++++++++++++++++++++++++
 csharp-mode.el                    |  7 ++++++-
 test-files/imenu-comment-test.cs  | 16 ++++++++++++++++
 test-files/imenu-generics-test.cs | 19 +++++++++++++++++++
 4 files changed, 71 insertions(+), 1 deletion(-)

diff --git a/csharp-mode-tests.el b/csharp-mode-tests.el
index 0fb7661..e44803c 100644
--- a/csharp-mode-tests.el
+++ b/csharp-mode-tests.el
@@ -166,6 +166,36 @@
            (result         (csharp--imenu-remove-param-names-from-paramlist 
test-value)))
       (should (equal expected-value result)))))
 
+(ert-deftest imenu-parsing-supports-generic-parameters ()
+  (let* ((find-file-hook '()) ;; avoid vc-mode file-hooks when opening!
+         (buffer         (find-file-read-only 
"./test-files/imenu-generics-test.cs"))
+         (beginning-of-buffer)
+         (imenu-index    (csharp--imenu-create-index-helper nil "" t t)) ;; 
same line as in `csharp-imenu-create-index'.
+         (class-entry    (cadr imenu-index))
+         (class-entries  (cdr class-entry))
+         (imenu-items    (mapconcat 'car class-entries " ")))
+
+    ;; ("(top)" "method void NoGeneric(this IAppBuilder, params object[])" 
"method void OneGeneric<T>(this IAppBuilder, params object[])" "method void 
TwoGeneric<T1,T2>(this IAppBuilder, params object[])" "(bottom)")
+    (should (string-match-p "NoGeneric" imenu-items))
+    (should (string-match-p "OneGeneric<T>" imenu-items))
+    (should (string-match-p "TwoGeneric<T1,T2>" imenu-items))
+    (kill-buffer buffer)))
+
+(ert-deftest imenu-parsing-supports-comments ()
+  (let* ((find-file-hook '()) ;; avoid vc-mode file-hooks when opening!
+         (buffer         (find-file-read-only 
"./test-files/imenu-comment-test.cs"))
+         (beginning-of-buffer)
+         (imenu-index    (csharp--imenu-create-index-helper nil "" t t)) ;; 
same line as in `csharp-imenu-create-index'.
+         (class-entry    (cadr imenu-index))
+         (class-entries  (cdr class-entry))
+         (imenu-items    (mapconcat 'car class-entries " ")))
+
+    ;; ("(top)" "method void NoGeneric(this IAppBuilder, params object[])" 
"method void OneGeneric<T>(this IAppBuilder, params object[])" "method void 
TwoGeneric<T1,T2>(this IAppBuilder, params object[])" "(bottom)")
+    (should (string-match-p "HasNoComment" imenu-items))
+    (should (string-match-p "HasComment" imenu-items))
+    (should (string-match-p "HasCommentToo" imenu-items))
+    (kill-buffer buffer)))
+
 (defvar csharp-hook1 nil)
 (defvar csharp-hook2 nil)
 
diff --git a/csharp-mode.el b/csharp-mode.el
index 21ea1e5..e774a55 100644
--- a/csharp-mode.el
+++ b/csharp-mode.el
@@ -284,6 +284,8 @@
 ;;          - Fix all runtime warnings
 ;;          - Fix error with string-values in #region directives.
 ;;
+;;    0.8.12 2015 November 29nth
+;;          - Fix issues with imenu indexing.
 
 (require 'cc-mode)
 (require 'cl-lib)
@@ -1483,9 +1485,12 @@ Most other csharp functions are not instrumented.
          "\\(?:override[ \t\n\r\f\v]+\\)?"            ;; optional
          "\\([[:alpha:]_][^\t\(\n]+\\)"               ;; 2. return type - 
possibly generic
          "[ \t\n\r\f\v]+"
-         "\\([[:alpha:]_][[:alnum:]_]*\\)"            ;; 3. name of func
+         "\\([[:alpha:]_][[:alnum:]_]*"               ;; 3. begin name of func
+         "\\(?:<\\(?:[[:alpha:]][[:alnum:]]*[, ]?\\)*>\\)?"  ;; (with optional 
generic type parameter(s)
+         "\\)"                                        ;; 3. end of name of func
          "[ \t\n\r\f\v]*"
          "\\(\([^\)]*\)\\)"                           ;; 4. params w/parens
+         "\\(?:[ \t]*/[/*].*\\)?"                     ;; optional comment at 
end of line
          "[ \t\n\r\f\v]*"
          ))
 
diff --git a/test-files/imenu-comment-test.cs b/test-files/imenu-comment-test.cs
new file mode 100644
index 0000000..a7a959672
--- /dev/null
+++ b/test-files/imenu-comment-test.cs
@@ -0,0 +1,16 @@
+using System;
+
+public class MyClass
+{
+    public void HasComment() // test
+    {
+    }
+
+    public void HasNoComment()
+    {
+    }
+
+    public void HasCommentToo() /* test yes */
+    {
+    }
+}
diff --git a/test-files/imenu-generics-test.cs 
b/test-files/imenu-generics-test.cs
new file mode 100644
index 0000000..cd6fec1
--- /dev/null
+++ b/test-files/imenu-generics-test.cs
@@ -0,0 +1,19 @@
+using System;
+
+class ImenuMatcherTests
+{
+    private void OneGeneric<T>(this IAppBuilder builder, params object[] args)
+    {
+        Console.WriteLine("TODO: something");
+    }
+
+    private void TwoGeneric<T1,T2>(this IAppBuilder builder, params object[] 
args)
+    {
+        Console.WriteLine("TODO: something");
+    }
+
+    private void NoGeneric(this IAppBuilder builder, params object[] args)
+    {
+        Console.WriteLine("TODO: something");
+    }
+}



reply via email to

[Prev in Thread] Current Thread [Next in Thread]