[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/dart-mode 21abd77 152/192: Fontifies declared identifiers
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/dart-mode 21abd77 152/192: Fontifies declared identifiers |
Date: |
Sun, 29 Aug 2021 11:02:08 -0400 (EDT) |
branch: elpa/dart-mode
commit 21abd774a1e1a76a9d51b4b925d97a67b6890b83
Author: Brady Trainor <mail@bradyt.com>
Commit: Brady Trainor <mail@bradyt.com>
Fontifies declared identifiers
Declared identifiers are found in variable declarations and formal
parameters.
For example,
```
var abc;
String str;
void main(Map<int, bool> str2, [int n]) {}
bool get returnVal => this.x;
```
So then this function will fontify `abc`, `str`, `str2`, `n`,
`returnVal`.
Prevent fontification of functions as variables
If function fontification was turned off, functions were being
fontified as variables. This makes sure there is not an opening paren
after a variable.
---
dart-mode.el | 30 +++++++++++++++++++++++++++++-
1 file changed, 29 insertions(+), 1 deletion(-)
diff --git a/dart-mode.el b/dart-mode.el
index edea013..1f904e4 100644
--- a/dart-mode.el
+++ b/dart-mode.el
@@ -426,6 +426,33 @@ Returns nil if `dart-sdk-path' is nil."
(goto-char end))
(throw 'result nil))))
+(defun dart--declared-identifier-func (limit)
+ (catch 'result
+ (let (beg end)
+ (while (re-search-forward
+ (rx
+ (and (group (or (or "const" "final"
+ "bool" "double" "dynamic" "int" "num" "void"
+ "var"
+ "get" "set")
+ (eval (dart--identifier 'upper)))
+ (zero-or-one ?>))
+ (one-or-more (or space ?\C-j))
+ (group (eval (dart--identifier 'lower)))
+ (not (any ?\( alnum ?$ ?_))))
+ limit t)
+ (setq beg (match-beginning 2))
+ (setq end (match-end 2))
+ (when (not (member (match-string 2)
+ '("bool" "double" "dynamic" "int" "num" "void"
+ "var"
+ "get" "set")))
+ (set-match-data (list beg end))
+ (goto-char end)
+ (throw 'result t))
+ (goto-char (match-end 1)))
+ (throw 'result nil))))
+
(setq dart-font-lock-defaults
`((,dart--async-keywords-re
,(regexp-opt dart--keywords 'words)
@@ -436,7 +463,8 @@ Returns nil if `dart-sdk-path' is nil."
(,dart--metadata-re . font-lock-constant-face)
(,(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--function-declaration-func . font-lock-function-name-face)
+ (dart--declared-identifier-func .
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 a4126bd 121/192: Allow s 1.10, (continued)
- [nongnu] elpa/dart-mode a4126bd 121/192: Allow s 1.10, ELPA Syncer, 2021/08/29
- [nongnu] elpa/dart-mode 52034c7 110/192: Add a dart--get helper to make it easier to use JSON, ELPA Syncer, 2021/08/29
- [nongnu] elpa/dart-mode f3a7c7b 122/192: Properly tell flycheck when there are no errors, ELPA Syncer, 2021/08/29
- [nongnu] elpa/dart-mode 1153c53 134/192: Add ert-runner, ELPA Syncer, 2021/08/29
- [nongnu] elpa/dart-mode 2a95005 159/192: Fix typo in README, regarding M-/ fallback, ELPA Syncer, 2021/08/29
- [nongnu] elpa/dart-mode c30eaa9 140/192: Specify path to the dart-sdk inside of flutter, ELPA Syncer, 2021/08/29
- [nongnu] elpa/dart-mode d9a12e1 151/192: Fontifies function declarations, ELPA Syncer, 2021/08/29
- [nongnu] elpa/dart-mode aa628c9 138/192: Remove deprecated analysis server option, ELPA Syncer, 2021/08/29
- [nongnu] elpa/dart-mode 5d0a7cd 139/192: Use dart-sdk-path to find dartfmt., ELPA Syncer, 2021/08/29
- [nongnu] elpa/dart-mode 1879cb8 145/192: Update README for providing diff to dart-format on Windows, ELPA Syncer, 2021/08/29
- [nongnu] elpa/dart-mode 21abd77 152/192: Fontifies declared identifiers,
ELPA Syncer <=
- [nongnu] elpa/dart-mode ac14859 147/192: Normalize paths for dartanalyzer on Windows, ELPA Syncer, 2021/08/29
- [nongnu] elpa/dart-mode 9d72469 169/192: Don't set variables globally, ELPA Syncer, 2021/08/29
- [nongnu] elpa/dart-mode 591b6fe 170/192: Improve handling of strings, ELPA Syncer, 2021/08/29
- [nongnu] elpa/dart-mode f20f895 164/192: Move docs from README to Wiki, ELPA Syncer, 2021/08/29
- [nongnu] elpa/dart-mode 36fe2ce 166/192: Fontify identifiers after multi-nested types, ELPA Syncer, 2021/08/29
- [nongnu] elpa/dart-mode 57767bb 157/192: Makes current indentation logic more usable, ELPA Syncer, 2021/08/29
- [nongnu] elpa/dart-mode 90f1120 162/192: Require subr-x for string-empty-p, ELPA Syncer, 2021/08/29
- [nongnu] elpa/dart-mode 8983e17 186/192: Code in font-lock tests were copied from dart.dev site, ELPA Syncer, 2021/08/29
- [nongnu] elpa/dart-mode 07a9e76 189/192: Add failing font-lock test, ELPA Syncer, 2021/08/29
- [nongnu] elpa/dart-mode 3c089f3 183/192: Fix font lock for abstract method, ELPA Syncer, 2021/08/29