From 25b8493ff223636324bb3bd5e1bf0b22303df3d1 Mon Sep 17 00:00:00 2001 From: Demis Balbach Date: Mon, 23 Dec 2019 13:16:33 +0100 Subject: [PATCH 1/7] Add import statement face --- php-face.el | 15 +++++++++++++++ php-mode.el | 9 +++++++++ 2 files changed, 24 insertions(+) diff --git a/php-face.el b/php-face.el index 4fc9542b..ad9d0866 100644 --- a/php-face.el +++ b/php-face.el @@ -206,6 +206,21 @@ :group 'php-faces :tag "PHP Class Declaration") +(defface php-class-declaration-spec '((t (:inherit php-keyword))) + "Face used to highlight class declaration specification keywords (implements, extends)" + :group 'php-faces + :tag "PHP Class Declaration Specification") + +(defface php-namespace-declaration '((t (:inherit php-keyword))) + "Face used to highlight namespace declaration keyword." + :group 'php-faces + :tag "PHP Namespace Declaration") + +(defface php-import-declaration '((t (:inherit php-keyword))) + "PHP Mode Face used to highlight import statements (use ... as ...)." + :group 'php-faces + :tag "PHP Import Statement") + (define-obsolete-face-alias 'php-annotations-annotation-face 'php-doc-annotation-tag "1.19.0") (provide 'php-face) diff --git a/php-mode.el b/php-mode.el index 9a90373b..0d756813 100644 --- a/php-mode.el +++ b/php-mode.el @@ -1494,6 +1494,15 @@ a completion list." ;; only add patterns here if you want to prevent cc-mode from applying ;; a different face. `( + ;; Class declaration specification keywords (implements, extends) + ("\\_<\\(?:implements\\|extends\\)\\_>" . 'php-class-declaration-spec) + ;; Namespace declaration + ("\\_" . 'php-namespace-declaration) + ;; import statement + ("\\_" . 'php-import-declaration) + ;; Class modifiers (abstract, final) + ("\\_<\\(abstract\\|final\\)\\_>\\s-+\\_" 1 'php-class-modifier) + ;; Highlight variables, e.g. 'var' in '$var' and '$obj->var', but ;; not in $obj->var() ("\\(->\\)\\(\\sw+\\)\\s-*(" (1 'php-object-op) (2 'php-method-call)) From 1c13765445044c20650e9013c2ed2ef6d4d6bb9a Mon Sep 17 00:00:00 2001 From: Demis Balbach Date: Mon, 23 Dec 2019 15:44:55 +0100 Subject: [PATCH 2/7] Add class modifiers --- php-face.el | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/php-face.el b/php-face.el index ad9d0866..019c68de 100644 --- a/php-face.el +++ b/php-face.el @@ -221,6 +221,11 @@ :group 'php-faces :tag "PHP Import Statement") +(defface php-class-modifier '((t (:inherit php-keyword))) + "PHP Mode Face used to highlight class modifiers (final, abstract)." + :group 'php-faces + :tag "PHP Class Modifier") + (define-obsolete-face-alias 'php-annotations-annotation-face 'php-doc-annotation-tag "1.19.0") (provide 'php-face) From a2b68dc06c3c2c1dbe84accbee4948e7567e9d93 Mon Sep 17 00:00:00 2001 From: Demis Balbach Date: Thu, 2 Jan 2020 09:26:22 +0100 Subject: [PATCH 3/7] rename php modifiers faces; added php-property-acess face --- php-face.el | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/php-face.el b/php-face.el index 019c68de..ce37677c 100644 --- a/php-face.el +++ b/php-face.el @@ -226,6 +226,16 @@ :group 'php-faces :tag "PHP Class Modifier") +(defface php-method-modifier '((t (:inherit php-keyword))) + "PHP Mode Face used to highlight method modifiers (final, abstract)." + :group 'php-faces + :tag "PHP Method Modifier") + +(defface php-visibility-modifier '((t (:inherit php-keyword))) + "PHP Mode Face used to highlight access keywords (public, protected, private)." + :group 'php-faces + :tag "PHP Visibility Modifier") + (define-obsolete-face-alias 'php-annotations-annotation-face 'php-doc-annotation-tag "1.19.0") (provide 'php-face) From 32f2b113bb3c046e6750a9c16795292915b37499 Mon Sep 17 00:00:00 2001 From: Demis Balbach Date: Thu, 2 Jan 2020 14:00:12 +0100 Subject: [PATCH 4/7] Add block statement face --- php-face.el | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/php-face.el b/php-face.el index ce37677c..44988f16 100644 --- a/php-face.el +++ b/php-face.el @@ -236,6 +236,11 @@ :group 'php-faces :tag "PHP Visibility Modifier") +(defface php-control-structure '((t (:inherit php-keyword))) + "PHP Mode Face used to highlight control structures (if, foreach, while, switch, catch...)." + :group 'php-faces + :tag "PHP Control Structure") + (define-obsolete-face-alias 'php-annotations-annotation-face 'php-doc-annotation-tag "1.19.0") (provide 'php-face) From 8c07fe330198a7af2b815892fb033024a1c596f7 Mon Sep 17 00:00:00 2001 From: USAMI Kenta Date: Mon, 23 Mar 2020 02:04:38 +0900 Subject: [PATCH 5/7] Improve test visibility --- tests/php-mode-test.el | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/tests/php-mode-test.el b/tests/php-mode-test.el index d41217cd..4b3598e9 100644 --- a/tests/php-mode-test.el +++ b/tests/php-mode-test.el @@ -158,10 +158,12 @@ file name and check that the faces of the fonts in the buffer match." (php-mode-test-process-magics)))) ,(if faces `(should (equal - (php-mode-test--parse-list-file - (concat (expand-file-name ,file php-mode-test-dir) - (if (eq t ,faces) ".faces" ,faces))) - (php-mode-test--buffer-face-list (current-buffer))))) + (cons ,file + (php-mode-test--parse-list-file + (concat (expand-file-name ,file php-mode-test-dir) + (if (eq t ,faces) ".faces" ,faces)))) + (cons ,file + (php-mode-test--buffer-face-list (current-buffer)))))) (goto-char (point-min)) (let ((case-fold-search nil)) ,@body))) @@ -421,14 +423,16 @@ style from Drupal." (with-php-mode-test ("language-constructs.php") (while (search-forward "ClassName" nil t) (backward-char) - (should (eq 'font-lock-type-face - (get-text-property (point) 'face))))) + (let ((token (symbol-at-point))) + (should (equal (list token 'font-lock-type-face) + (list token (get-text-property (point) 'face))))))) (with-php-mode-test ("language-constructs.php") (search-forward "Start:") (while (not (= (line-number-at-pos) (count-lines (point-min) (point-max)))) (forward-line 1) - (should (eq 'php-keyword - (get-text-property (point) 'face)))))) + (let ((token (symbol-at-point))) + (should (equal (list token 'php-keyword) + (list token (get-text-property (point) 'face)))))))) (ert-deftest php-mode-test-issue-178 () "Highligth as keyword and following symbol" From 0af47cdd8912fae813f08ff80b32a35f4c335cb6 Mon Sep 17 00:00:00 2001 From: USAMI Kenta Date: Mon, 23 Mar 2020 02:05:24 +0900 Subject: [PATCH 6/7] Remove test ceses from tests/language-constructs.php --- tests/language-constructs.php | 4 ---- 1 file changed, 4 deletions(-) diff --git a/tests/language-constructs.php b/tests/language-constructs.php index 693f6ece..ce3dc467 100644 --- a/tests/language-constructs.php +++ b/tests/language-constructs.php @@ -38,7 +38,6 @@ endwhile; eval(); exit(); -extends ClassName; final; finally; for; @@ -47,14 +46,12 @@ function; global; goto; if; -implements ClassName; include; include_once; instanceof ClassName; insteadof ClassName; isset(); list(); -namespace ClassName; new ClassName; print; private; @@ -68,7 +65,6 @@ function; throw; try; unset(); -use ClassName; var; while; xor; From 1e41ed31ac1e9c8724d0fa030b85b34858fb9fb4 Mon Sep 17 00:00:00 2001 From: USAMI Kenta Date: Mon, 23 Mar 2020 02:28:04 +0900 Subject: [PATCH 7/7] Apply modified faces to test --- tests/lang/class/anonymous-class.php.faces | 4 ++-- tests/lang/doc-comment/annotation.php.faces | 2 +- tests/lang/doc-comment/comments.php.24.faces | 2 +- tests/lang/doc-comment/comments.php.27.faces | 2 +- tests/lang/doc-comment/comments.php.faces | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/lang/class/anonymous-class.php.faces b/tests/lang/class/anonymous-class.php.faces index 050f7f11..415bcaa2 100644 --- a/tests/lang/class/anonymous-class.php.faces +++ b/tests/lang/class/anonymous-class.php.faces @@ -10,7 +10,7 @@ (" ") ("class" . php-class-declaration) (" () ") - ("extends" . php-keyword) + ("extends" . php-class-declaration-spec) (" ") ("IteratorAggregate" . font-lock-type-face) (" {\n ") @@ -23,7 +23,7 @@ (" ") ("class" . php-class-declaration) (" () ") - ("extends" . php-keyword) + ("extends" . php-class-declaration-spec) (" ") ("IteratorAggregate" . font-lock-type-face) (" {\n ") diff --git a/tests/lang/doc-comment/annotation.php.faces b/tests/lang/doc-comment/annotation.php.faces index ada1815c..283c5b2c 100644 --- a/tests/lang/doc-comment/annotation.php.faces +++ b/tests/lang/doc-comment/annotation.php.faces @@ -24,7 +24,7 @@ (" ") ("Child" . font-lock-type-face) (" ") - ("extends" . php-keyword) + ("extends" . php-class-declaration-spec) (" ") ("Parent_" . font-lock-type-face) ("\n{\n}\n")) diff --git a/tests/lang/doc-comment/comments.php.24.faces b/tests/lang/doc-comment/comments.php.24.faces index 09bfd78b..a411a2ff 100644 --- a/tests/lang/doc-comment/comments.php.24.faces +++ b/tests/lang/doc-comment/comments.php.24.faces @@ -62,7 +62,7 @@ ("@ORM\\Entity" php-doc-annotation-tag font-lock-doc-face) ("(repositoryClass=\"Emacs\\Repository\\MajorModeRepository\")\n */" . font-lock-doc-face) ("\n") - ("final" . php-keyword) + ("final" . php-class-modifier) (" ") ("class" . php-class-declaration) (" ") diff --git a/tests/lang/doc-comment/comments.php.27.faces b/tests/lang/doc-comment/comments.php.27.faces index 0efe359f..e48028c8 100644 --- a/tests/lang/doc-comment/comments.php.27.faces +++ b/tests/lang/doc-comment/comments.php.27.faces @@ -63,7 +63,7 @@ ("@ORM\\Entity" php-doc-annotation-tag font-lock-doc-face) ("(repositoryClass=\"Emacs\\Repository\\MajorModeRepository\")\n */" . font-lock-doc-face) ("\n") - ("final" . php-keyword) + ("final" . php-class-modifier) (" ") ("class" . php-class-declaration) (" ") diff --git a/tests/lang/doc-comment/comments.php.faces b/tests/lang/doc-comment/comments.php.faces index e3900a99..e6748c07 100644 --- a/tests/lang/doc-comment/comments.php.faces +++ b/tests/lang/doc-comment/comments.php.faces @@ -62,7 +62,7 @@ ("@ORM\\Entity" php-doc-annotation-tag font-lock-doc-face) ("(repositoryClass=\"Emacs\\Repository\\MajorModeRepository\")\n */" . font-lock-doc-face) ("\n") - ("final" . php-keyword) + ("final" . php-class-modifier) (" ") ("class" . php-class-declaration) (" ")