[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/csharp-mode c44989a 331/459: Merge pull request #183 fr
From: |
ELPA Syncer |
Subject: |
[elpa] externals/csharp-mode c44989a 331/459: Merge pull request #183 from josteink/vscode-fontification |
Date: |
Sun, 22 Aug 2021 13:59:55 -0400 (EDT) |
branch: externals/csharp-mode
commit c44989ad48215746803c7acb6d87315fa8be8b9e
Merge: 97903a2 91c0f3c
Author: Jostein Kjønigsen <jostein@kjonigsen.net>
Commit: GitHub <noreply@github.com>
Merge pull request #183 from josteink/vscode-fontification
Richer font highlighting
---
csharp-mode-tests.el | 16 ++++----
csharp-mode.el | 106 ++++++++++++++++++++++++++++++++-------------------
2 files changed, 75 insertions(+), 47 deletions(-)
diff --git a/csharp-mode-tests.el b/csharp-mode-tests.el
index 1bf7b47..01eaa04 100644
--- a/csharp-mode-tests.el
+++ b/csharp-mode-tests.el
@@ -168,23 +168,23 @@
(ert-deftest fontification-of-using-statements ()
(assess-face-in-file= "./test-files/using-fontification.cs"
"using" 'font-lock-keyword-face
- "Reference" 'font-lock-type-face
- "Under_scored" 'font-lock-type-face
+ "Reference" 'font-lock-variable-name-face
+ "Under_scored" 'font-lock-variable-name-face
"WithNumbers09" 'font-lock-variable-name-face
- "Ok" 'font-lock-type-face
+ "Ok" 'font-lock-variable-name-face
"WithNumbers09" 'font-lock-variable-name-face
- "OkV2" 'font-lock-type-face
+ "OkV2" 'font-lock-variable-name-face
))
(ert-deftest fontification-of-namespace-statements ()
(assess-face-in-file= "./test-files/namespace-fontification.cs"
"namespace" 'font-lock-keyword-face
- "Reference" 'font-lock-type-face
- "Under_scored" 'font-lock-type-face
+ "Reference" 'font-lock-variable-name-face
+ "Under_scored" 'font-lock-variable-name-face
"WithNumbers09" 'font-lock-variable-name-face
- "Ok" 'font-lock-type-face
+ "Ok" 'font-lock-variable-name-face
"WithNumbers09" 'font-lock-variable-name-face
- "Ok" 'font-lock-type-face
+ "Ok" 'font-lock-variable-name-face
))
(defun list-repeat-once (mylist)
diff --git a/csharp-mode.el b/csharp-mode.el
index 50357c2..e5bb1fd 100644
--- a/csharp-mode.el
+++ b/csharp-mode.el
@@ -58,7 +58,7 @@
csharp (concat "[" c-alpha "_@]"))
(c-lang-defconst c-opt-type-suffix-key
- csharp "\\(\\?\\)")
+ csharp (concat "\\(\\[" (c-lang-const c-simple-ws) "*\\]\\|\\?\\)"))
(c-lang-defconst c-identifier-ops
csharp '((left-assoc ".")))
@@ -146,7 +146,8 @@
(c-lang-defconst c-other-kwds
csharp '("select" "from" "where" "join" "in" "on" "equals" "into"
- "orderby" "descending" "group" "nameof"))
+ "orderby" "ascending" "descending" "group" "nameof" "when"
+ "let" "by"))
(c-lang-defconst c-colon-type-list-kwds
csharp '("class" "struct" "interface"))
@@ -223,10 +224,25 @@
(cpp-macro .
c-lineup-dont-change)
(substatement-open . 0)))))
+(defun csharp--color-backwards (font-lock-face)
+ (let (id-end)
+ (goto-char (1+ (match-beginning 0)))
+ (while (and (or (eq (char-before) ?.)
+ (eq (char-before) ?\;))
+ (progn
+ (backward-char)
+ (if (eq (char-before) ?\?)
+ (backward-char))
+ (c-backward-syntactic-ws)
+ (setq id-end (point))
+ (< (skip-chars-backward
+ (c-lang-const c-symbol-chars))
+ 0))
+ (not (get-text-property (point) 'face)))
+ (c-put-font-lock-face (point) id-end font-lock-face)
+ (c-backward-syntactic-ws))))
+
(c-lang-defconst c-basic-matchers-before
- "Font lock matchers for basic keywords, labels, references and various
-other easily recognizable things that should be fontified before generic
-casts and declarations are fontified. Used on level 2 and higher."
csharp `(
;; Put warning face on unclosed strings
,@(if (version< emacs-version "27.0")
@@ -249,48 +265,61 @@ casts and declarations are fontified. Used on level 2
and higher."
,`(,(concat "\\<" (c-lang-const c-regular-keywords-regexp))
1 font-lock-keyword-face)
- ,@(when (c-lang-const c-opt-identifier-concat-key)
- `(,(c-make-font-lock-search-function
- ;; Search for identifiers preceded by ".". The anchored
- ;; matcher takes it from there.
- (concat (c-lang-const c-opt-identifier-concat-key)
- (c-lang-const c-simple-ws) "*"
- (concat "\\("
- ;; "[" c-upper "]"
- "[" (c-lang-const c-symbol-chars) "]*"
- "\\|"
- "\\)"))
- `((let (id-end)
- (goto-char (1+ (match-beginning 0)))
- (while (and (eq (char-before) ?.)
- (progn
- (backward-char)
- (c-backward-syntactic-ws)
- (setq id-end (point))
- (< (skip-chars-backward
- ,(c-lang-const c-symbol-chars))
- 0))
- (not (get-text-property (point) 'face)))
- (c-put-font-lock-face (point) id-end
- font-lock-variable-name-face)
- (c-backward-syntactic-ws)))
- nil
- (goto-char (match-end 0))))))
+ ;; chained statements
+ ,`(,(c-make-font-lock-search-function
+ (concat
+ (c-lang-const c-opt-identifier-concat-key)
+ (c-lang-const c-simple-ws) "*"
+ (concat "\\("
+ "[" (c-lang-const c-symbol-chars) "]*"
+ "\\)"))
+ `((csharp--color-backwards font-lock-variable-name-face)
+ nil
+ (goto-char (match-end 0)))))
(eval . (list "\\(!\\)[^=]" 1 c-negation-char-face-name))
))
+(defconst csharp--regex-type-name
+ "[A-Z][A-Za-z0-9_]*"
+ "Regex describing a type identifier in C#.")
+
+(defconst csharp--regex-type-name-matcher
+ (concat "\\(" csharp--regex-type-name "\\)")
+ "Regex matching a type identifier in C#.")
+
(c-lang-defconst c-basic-matchers-after
csharp (append
;; merge with cc-mode defaults
(c-lang-const c-basic-matchers-after)
+ ;; Hack: Last prop-identifier
+ `((,(concat "\\." csharp--regex-type-name-matcher)
+ 1 font-lock-variable-name-face t))
+ `((,(concat "^using\\s *" csharp--regex-type-name-matcher ";")
+ 1 font-lock-variable-name-face t))
+ `((,(concat "^namespace\\s *" csharp--regex-type-name-matcher" \\s
*")
+ 1 font-lock-variable-name-face t))
+
;; function names
- `(("\\.\\([A-Za-z0-9_]+\\)[<(]" 1 font-lock-function-name-face t))
+ `(("\\([A-Za-z0-9_]+\\)\\(<[a-zA-Z0-9, ]+>\\)?("
+ 1 font-lock-function-name-face t))
+
+ ;; class names with inheritance
+ `((,(concat "\\<" csharp--regex-type-name-matcher "\\s *:")
+ 1 font-lock-type-face t))
+
+ ;; Single identifier in attribute
+ `((,(concat "\\[" csharp--regex-type-name-matcher "\\][^;]")
+ 1 font-lock-variable-name-face t))
+
+ ;; Types after 'new'
+ `((,(concat "new\\s *" csharp--regex-type-name-matcher)
+ 1 font-lock-type-face t))
))
(defcustom csharp-font-lock-extra-types
- (list (concat "[" c-upper "]\\sw*[" c-lower "]\\sw"))
+ (list csharp--regex-type-name)
(c-make-font-lock-extra-types-blurb "C#" "csharp-mode" (concat))
:type 'c-extra-types-widget
:group 'c)
@@ -432,13 +461,12 @@ casts and declarations are fontified. Used on level 2
and higher."
"\\("
(concat "\\sw\\|\\s \\|[=\n\r*.:]\\|"
"\"[^\"]*\"\\|'[^']*'")
- "\\)*>")
+ "\\)*/?>")
0 ,c-doc-markup-face-name prepend nil)
+ ;; ("\\([a-zA-Z0-9_]+\\)=" 0 font-lock-variable-name-face prepend nil)
+ ;; ("\".*\"" 0 font-lock-string-face prepend nil)
("&\\(\\sw\\|[.:]\\)+;" ; XML entities.
- 0 ,c-doc-markup-face-name prepend nil)
- (,(lambda (limit)
- (c-find-invalid-doc-markup "[<>&]\\|{@" limit))
- 0 'font-lock-warning-face prepend nil)))
+ 0 ,c-doc-markup-face-name prepend nil)))
(defconst codedoc-font-lock-keywords
`((,(lambda (limit)
- [elpa] externals/csharp-mode 4da4c39 231/459: Fix fontification of namespaces to match using-statement rules., (continued)
- [elpa] externals/csharp-mode 4da4c39 231/459: Fix fontification of namespaces to match using-statement rules., ELPA Syncer, 2021/08/22
- [elpa] externals/csharp-mode 5e47b77 260/459: Fix error handling multiline compiler-directives., ELPA Syncer, 2021/08/22
- [elpa] externals/csharp-mode 20efdc8 262/459: Add support for highlighting function-invocation., ELPA Syncer, 2021/08/22
- [elpa] externals/csharp-mode d365498 307/459: Merge pull request #170 from josteink/compiler-fontifications, ELPA Syncer, 2021/08/22
- [elpa] externals/csharp-mode 72c1912 314/459: Name change of codedoc functions, ELPA Syncer, 2021/08/22
- [elpa] externals/csharp-mode ecc3f38 317/459: Add annotation-top-cont as a new syntax construct, ELPA Syncer, 2021/08/22
- [elpa] externals/csharp-mode 51ab628 319/459: Update README.org, ELPA Syncer, 2021/08/22
- [elpa] externals/csharp-mode be5af57 322/459: Fix optional type suffix regex, ELPA Syncer, 2021/08/22
- [elpa] externals/csharp-mode 217d3a7 324/459: Revert "Add nullable operator to concatenated identifiers", ELPA Syncer, 2021/08/22
- [elpa] externals/csharp-mode 97903a2 327/459: Merge pull request #179 from josteink/feature/compilation-mode-dotnetcore, ELPA Syncer, 2021/08/22
- [elpa] externals/csharp-mode c44989a 331/459: Merge pull request #183 from josteink/vscode-fontification,
ELPA Syncer <=
- [elpa] externals/csharp-mode 2697c95 332/459: Move bobp checking in one level, ELPA Syncer, 2021/08/22
- [elpa] externals/csharp-mode adc69a4 335/459: Merge pull request #187 from josteink/bugfix/185, ELPA Syncer, 2021/08/22
- [elpa] externals/csharp-mode fb1f7d5 338/459: Don't duplicate values and remove unneeded test, ELPA Syncer, 2021/08/22
- [elpa] externals/csharp-mode fc6f94f 339/459: Handle "nameof" entirely in c-basic-matchers-after., ELPA Syncer, 2021/08/22
- [elpa] externals/csharp-mode 77a7243 341/459: Finally adapt CC Mode namespace matcher function, ELPA Syncer, 2021/08/22
- [elpa] externals/csharp-mode eff5dec 345/459: Try improve compilation-mode support for dotnet test fails., ELPA Syncer, 2021/08/22
- [elpa] externals/csharp-mode 605b0e0 346/459: Add configuration option to font-locking of codedoc tags, ELPA Syncer, 2021/08/22
- [elpa] externals/csharp-mode 49ca95e 350/459: RIP Marmalade, ELPA Syncer, 2021/08/22
- [elpa] externals/csharp-mode 73c27c7 353/459: Update build.yml, ELPA Syncer, 2021/08/22
- [elpa] externals/csharp-mode 6e7922d 354/459: Update build.yml, ELPA Syncer, 2021/08/22