[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/dart-mode d6afa8c 153/192: Fontify identifiers following d
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/dart-mode d6afa8c 153/192: Fontify identifiers following declared identifiers |
Date: |
Sun, 29 Aug 2021 11:02:08 -0400 (EDT) |
branch: elpa/dart-mode
commit d6afa8c39a91d527b9fb74f3907a0e2a67a45d82
Author: Brady Trainor <mail@bradyt.com>
Commit: Brady Trainor <mail@bradyt.com>
Fontify identifiers following declared identifiers
Consider the following example.
```
double a, b, c;
int x = 0, y = 1, z = 2;
```
This commit will fontify `b`, `c`, `y`, `z`.
The docstring of `font-lock-keywords` clarifies how to use a MATCHER
together with a HIGHLIGHT, in particular a MATCH-ANCHORED.
---
dart-mode.el | 53 ++++++++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 52 insertions(+), 1 deletion(-)
diff --git a/dart-mode.el b/dart-mode.el
index 1f904e4..9d4bac8 100644
--- a/dart-mode.el
+++ b/dart-mode.el
@@ -453,6 +453,52 @@ Returns nil if `dart-sdk-path' is nil."
(goto-char (match-end 1)))
(throw 'result nil))))
+(defun dart--in-parenthesized-expression-or-formal-parameter-list-p ()
+ (save-excursion
+ (catch 'result
+ (condition-case nil
+ (backward-up-list)
+ (scan-error (throw 'result nil)))
+ (when (member (char-after (point)) '(?\[ ?\{))
+ (condition-case nil
+ (backward-up-list)
+ (scan-error (throw 'result nil))))
+ (throw 'result (= (char-after (point)) ?\()))))
+
+(defun dart--declared-identifier-anchor-func (limit)
+ (catch 'result
+ (let (data)
+ (while (dart--declared-identifier-func limit)
+ (setq data (match-data))
+ (unless (dart--in-parenthesized-expression-or-formal-parameter-list-p)
+ (set-match-data data)
+ (goto-char (match-end 0))
+ (throw 'result t))
+ (goto-char (match-end 0)))
+ (throw 'result nil))))
+
+(defun dart--declared-identifier-next-func (limit)
+ (catch 'result
+ (let ((depth (car (syntax-ppss))))
+ (while t
+ (cond
+ ((or (= (char-after (point)) ?\x3b) ; ?;
+ (< (car (syntax-ppss)) depth))
+ (throw 'result nil))
+ ((and (= (char-after (point)) ?\x2c) ; ?,
+ (= (car (syntax-ppss)) depth))
+ (if (looking-at (rx ?\x2c
+ (one-or-more space)
+ (group (eval (dart--identifier 'lower)))))
+ (progn (set-match-data (list (match-beginning 1)
+ (match-end 1)))
+ (goto-char (match-end 0))
+ (throw 'result t))
+ (throw 'result nil)))
+ ((< (point) (point-max))
+ (forward-char))
+ (t (throw 'result nil)))))))
+
(setq dart-font-lock-defaults
`((,dart--async-keywords-re
,(regexp-opt dart--keywords 'words)
@@ -464,7 +510,12 @@ Returns nil if `dart-sdk-path' is nil."
(,(regexp-opt dart--types 'words) . font-lock-type-face)
(,dart--types-re . font-lock-type-face)
(dart--function-declaration-func . font-lock-function-name-face)
- (dart--declared-identifier-func .
font-lock-variable-name-face))))
+ (dart--declared-identifier-func . font-lock-variable-name-face)
+ (dart--declared-identifier-anchor-func
+ . (dart--declared-identifier-next-func
+ nil
+ nil
+ (0 font-lock-variable-name-face))))))
(defun dart-fontify-region (beg end)
"Use fontify the region between BEG and END as Dart.
- [nongnu] elpa/dart-mode c51e750 163/192: Stop testing 24.3 on travis, (continued)
- [nongnu] elpa/dart-mode c51e750 163/192: Stop testing 24.3 on travis, ELPA Syncer, 2021/08/29
- [nongnu] elpa/dart-mode 735868e 154/192: Copy/paste multiline string syntax-propertize from python.el, ELPA Syncer, 2021/08/29
- [nongnu] elpa/dart-mode 9ad52e8 158/192: Search for sdk from flutter if no dart on path, ELPA Syncer, 2021/08/29
- [nongnu] elpa/dart-mode c568118 175/192: Move dart server code to a separate repo, ELPA Syncer, 2021/08/29
- [nongnu] elpa/dart-mode ae8a28b 161/192: Follow conventions in font-lock levels, ELPA Syncer, 2021/08/29
- [nongnu] elpa/dart-mode 327b9aa 167/192: Use conventions in commentary, docstrings, defvar vs setq, ELPA Syncer, 2021/08/29
- [nongnu] elpa/dart-mode 31861e8 173/192: Add mixin keyword, ELPA Syncer, 2021/08/29
- [nongnu] elpa/dart-mode 28ebbaf 176/192: Update tests, ELPA Syncer, 2021/08/29
- [nongnu] elpa/dart-mode ea60ffd 178/192: Move README back to markdown, ELPA Syncer, 2021/08/29
- [nongnu] elpa/dart-mode bbeadaa 181/192: Reorganize some keyword fontification, ELPA Syncer, 2021/08/29
- [nongnu] elpa/dart-mode d6afa8c 153/192: Fontify identifiers following declared identifiers,
ELPA Syncer <=
- [nongnu] elpa/dart-mode 9b65aae 187/192: Add failing tests for fontification of factories and generic methods, ELPA Syncer, 2021/08/29
- [nongnu] elpa/dart-mode a715dc6 177/192: Move license, ELPA Syncer, 2021/08/29
- [nongnu] elpa/dart-mode e820b09 155/192: Regex catches dollar signs now, ELPA Syncer, 2021/08/29
- [nongnu] elpa/dart-mode e5bd30d 184/192: Avoid false positives, ELPA Syncer, 2021/08/29
- [nongnu] elpa/dart-mode 9b1c871 001/192: Beginning of dart-mode., ELPA Syncer, 2021/08/29
- [nongnu] elpa/dart-mode f86416b 035/192: Handle indentation in constructors with initializer lists., ELPA Syncer, 2021/08/29