[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/dart-mode a9899a9 182/192: Fontify abstract methods
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/dart-mode a9899a9 182/192: Fontify abstract methods |
Date: |
Sun, 29 Aug 2021 11:02:14 -0400 (EDT) |
branch: elpa/dart-mode
commit a9899a9d9c9e6f046eceb868a7e6161c7d94a8d2
Author: Brady Trainor <mail@bradyt.net>
Commit: Brady Trainor <mail@bradyt.net>
Fontify abstract methods
---
dart-mode.el | 47 +++++++++++++++++++++-
.../interfaces-and-abstract-classes.dart.faceup | 2 +-
test/test.el | 1 -
3 files changed, 46 insertions(+), 4 deletions(-)
diff --git a/dart-mode.el b/dart-mode.el
index edffa20..0923fcb 100644
--- a/dart-mode.el
+++ b/dart-mode.el
@@ -268,6 +268,47 @@ For example, \"main\" in \"void main() async\" would be
matched."
(goto-char end))
(throw 'result nil))))
+(defun dart--abstract-method-func (limit)
+ "Font-lock matcher function for abstract methods.
+
+Matches function declarations before LIMIT that look like,
+
+ \" [^ ][^=]* lowercaseIdentifier([...]);\"
+
+For example, \"compareTo\" in \" int compareTo(num other);\" would be
+matched."
+ (catch 'result
+ (let (beg end)
+ (while (re-search-forward
+ (rx (group (eval (dart--identifier 'lower))) ?\() limit t)
+ (setq beg (match-beginning 1))
+ (setq end (match-end 1))
+ (condition-case nil
+ (progn
+ (up-list)
+ (when (> (point) limit)
+ (throw 'result nil))
+ (unless (= (char-after (point)) ?\;)
+ (throw 'result nil))
+ (goto-char beg)
+ (back-to-indentation)
+ (unless (= (current-column) 2)
+ (throw 'result nil))
+ (unless (string-match-p
+ " " (buffer-substring-no-properties
+ (point) beg))
+ (throw 'result nil))
+ (when (string-match-p
+ "=" (buffer-substring-no-properties
+ (point) beg))
+ (throw 'result nil))
+ (goto-char end)
+ (set-match-data (list beg end))
+ (throw 'result t))
+ (scan-error nil))
+ (goto-char end))
+ (throw 'result nil))))
+
(defun dart--declared-identifier-func (limit)
"Font-lock matcher function for declared identifiers.
@@ -465,7 +506,8 @@ untyped parameters. For example, in
(defvar dart-font-lock-keywords-1
`((,(regexp-opt dart--file-directives 'words) . font-lock-builtin-face)
(dart--function-declaration-func . font-lock-function-name-face)
- (,dart--operator-declaration-re . (1
font-lock-function-name-face))))
+ (,dart--operator-declaration-re . (1
font-lock-function-name-face))
+ (dart--abstract-method-func .
font-lock-function-name-face)))
(defvar dart-font-lock-keywords-2
`(,dart--async-keywords-re
@@ -479,7 +521,8 @@ untyped parameters. For example, in
(,(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--operator-declaration-re . (1 font-lock-function-name-face))))
+ (,dart--operator-declaration-re . (1 font-lock-function-name-face))
+ (dart--abstract-method-func . font-lock-function-name-face)))
(defvar dart-font-lock-keywords-3
(append
diff --git
a/test/faceup/language-samples/interfaces-and-abstract-classes.dart.faceup
b/test/faceup/language-samples/interfaces-and-abstract-classes.dart.faceup
index 4d7617c..221d320 100644
--- a/test/faceup/language-samples/interfaces-and-abstract-classes.dart.faceup
+++ b/test/faceup/language-samples/interfaces-and-abstract-classes.dart.faceup
@@ -3,7 +3,7 @@
»}
«b:abstract» «k:class» «t:Describable» {
- «t:void» describe();
+ «t:void» «f:describe»();
«t:void» «f:describeWithEmphasis»() {
print(«s:'========='»);
diff --git a/test/test.el b/test/test.el
index a2b029e..a6e1c84 100644
--- a/test/test.el
+++ b/test/test.el
@@ -23,7 +23,6 @@
(should (dart-font-lock-test-apps "faceup/language-samples/variables.dart")))
(ert-deftest dart-font-lock-abstract-method-test ()
- :expected-result :failed
(should (dart-font-lock-test-apps "faceup/issues/abstract-methods.dart")))
(ert-deftest dart-font-lock-covariant-test ()
- [nongnu] elpa/dart-mode 68f7f4f 132/192: Require cl for emacs 24.4, 24.5, (continued)
- [nongnu] elpa/dart-mode 68f7f4f 132/192: Require cl for emacs 24.4, 24.5, ELPA Syncer, 2021/08/29
- [nongnu] elpa/dart-mode caa7a19 124/192: Don't error out with revert-buffer, ELPA Syncer, 2021/08/29
- [nongnu] elpa/dart-mode 199709f 148/192: Removes cc-mode, ELPA Syncer, 2021/08/29
- [nongnu] elpa/dart-mode da244c6 144/192: Fixes no such file or directory, dartfmt.exe, ELPA Syncer, 2021/08/29
- [nongnu] elpa/dart-mode 9db2679 143/192: Fixes invalid file path format on Windows, ELPA Syncer, 2021/08/29
- [nongnu] elpa/dart-mode 06e2d4b 160/192: Respect font-lock-maximum-decoration, ELPA Syncer, 2021/08/29
- [nongnu] elpa/dart-mode 3082066 185/192: Don't font lock anchor in a string, ELPA Syncer, 2021/08/29
- [nongnu] elpa/dart-mode ad93bc1 165/192: Edit headers, ELPA Syncer, 2021/08/29
- [nongnu] elpa/dart-mode f6a1c9a79 171/192: Fix byte-compiling errors and warnings, ELPA Syncer, 2021/08/29
- [nongnu] elpa/dart-mode 1273ccb 191/192: Make changes to list of dart-mode keywords easier to diff, ELPA Syncer, 2021/08/29
- [nongnu] elpa/dart-mode a9899a9 182/192: Fontify abstract methods,
ELPA Syncer <=
- [nongnu] elpa/dart-mode c523992 004/192: Handle map indentation with identifiers., ELPA Syncer, 2021/08/29
- [nongnu] elpa/dart-mode 30f9326 007/192: Make constants better., ELPA Syncer, 2021/08/29
- [nongnu] elpa/dart-mode 5ce38b7 009/192: Add a couple known bugs., ELPA Syncer, 2021/08/29
- [nongnu] elpa/dart-mode 64a573f 010/192: Require 'cl when compiling., ELPA Syncer, 2021/08/29
- [nongnu] elpa/dart-mode b42c2ca 014/192: Another known bug., ELPA Syncer, 2021/08/29
- [nongnu] elpa/dart-mode 4d67ba8 017/192: Fix the closing comment., ELPA Syncer, 2021/08/29
- [nongnu] elpa/dart-mode 1473515 019/192: Bump to version 0.3 for release., ELPA Syncer, 2021/08/29
- [nongnu] elpa/dart-mode 06c2786 024/192: Bump version to 0.4., ELPA Syncer, 2021/08/29
- [nongnu] elpa/dart-mode 2410a15 025/192: Fix =>-style method indentation., ELPA Syncer, 2021/08/29
- [nongnu] elpa/dart-mode 9ee0bf1 028/192: Bump version to 0.5., ELPA Syncer, 2021/08/29