branch: externals/csharp-mode commit 9616fd00058df1aada146cfd6104d2c4461c9988 Author: Jostein Kjønigsen <jost...@kjonigsen.net> Commit: Jostein Kjønigsen <jost...@kjonigsen.net>
Fix method-name fontification tests. Restore incorrectly removed utility function. --- csharp-mode-tests.el | 17 ++++++++++++++--- csharp-mode.el | 14 ++++++++++++++ test-files/fontification-test-compiler-directives.cs | 8 ++++---- 3 files changed, 32 insertions(+), 7 deletions(-) diff --git a/csharp-mode-tests.el b/csharp-mode-tests.el index 5c7fbf8..da233b5 100644 --- a/csharp-mode-tests.el +++ b/csharp-mode-tests.el @@ -70,6 +70,12 @@ ;; this replaces the manual test of ;; test-files/fontification-test-compiler-directives.cs, but file ;; has been kept around to assist manual testing/verification. + (assess-face-in-file= "test-files/fontification-test-compiler-directives.cs" + "strReference" 'font-lock-string-face + "strVerification" 'font-lock-string-face + "singleQuote" 'font-lock-string-face + "doubleQuote" 'font-lock-string-face) + (assess-face-in-text= "#region test\nbool bar = true;" ;; should not be interpreted as string because of trailing \! @@ -91,13 +97,18 @@ ))) (ert-deftest fontification-of-compiler-directives-after-comments () - ;; this replaces the manual test of - ;; test-files/fontification-test-compiler-directives-with-comments.cs, but file - ;; has been kept around to assist manual testing/verification. (assess-face-in-file= "./test-files/fontification-test-compiler-directives-with-comments.cs" "case1" 'font-lock-comment-face "case2" 'font-lock-comment-face)) +(ert-deftest fontification-of-method-names () + (assess-face-in-file= "./test-files/imenu-method-test.cs" + "OpenWebServicesAsync" 'font-lock-function-name-face + "ToString" 'font-lock-function-name-face + "Equals" 'font-lock-function-name-face + "AbstractMethod" 'font-lock-function-name-face + "UnsafeCopy" 'font-lock-function-name-face)) + (defun list-repeat-once (mylist) (append mylist mylist)) diff --git a/csharp-mode.el b/csharp-mode.el index dc169c2..617ec12 100644 --- a/csharp-mode.el +++ b/csharp-mode.el @@ -511,6 +511,20 @@ to work properly with code that includes attributes. ))) +(defun csharp-is-square-parentasis-block-p () + "Attempts to safely assess if the current point is at the opening of +a square parentasis block [ ... ]." + (let* ((start (point)) ;; variables used to hold our position, so that we know that + (end)) ;; our code isn't stuck trying to look for a non-existant sexp. + (and (eq (char-after) 91) ;; open square + (while (and (eq (char-after) 91) + (not (eq start end))) + (c-safe (c-forward-sexp 1)) + (setq end (point))) + (eq (char-before) 93))) ;; close square + ) + + ;; ================================================================== ;; end of csharp-mode utility and feature defuns ;; ================================================================== diff --git a/test-files/fontification-test-compiler-directives.cs b/test-files/fontification-test-compiler-directives.cs index ffbaba8..dad1549 100644 --- a/test-files/fontification-test-compiler-directives.cs +++ b/test-files/fontification-test-compiler-directives.cs @@ -7,17 +7,17 @@ public class Test string x; // reference - x += "foo"; + x += "strReference"; #region v1 verification - x += "foo"; + x += "strVerification"; #endregion #region t1 test' - x += "foo"; + x += "singleQuote"; #endregion #region t2 - test" - x += "foo"; + x += "doubleQuote"; #endregion } }