From 366ecb605a1c4e8e963185e26c31d7abf9b29233 Mon Sep 17 00:00:00 2001 From: Carlo Sciolla Date: Tue, 8 Jan 2019 23:06:58 +0100 Subject: [PATCH] Support block indentation for abstract classes Fixes #83 --- plantuml-mode.el | 2 +- test/plantuml-indentation-test.el | 27 ++++++++++++++++++++++++++- 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/plantuml-mode.el b/plantuml-mode.el index 4b2ce7e..02f79da 100644 --- a/plantuml-mode.el +++ b/plantuml-mode.el @@ -342,7 +342,7 @@ Uses prefix (as PREFIX) to choose where to display it: (defvar plantuml-keywords-regexp (concat "^\\s *" (regexp-opt plantuml-keywords 'words) "\\|\\(<\\|<|\\|\\*\\|o\\)\\(\\.+\\|-+\\)\\|\\(\\.+\\|-+\\)\\(>\\||>\\|\\*\\|o\\)\\|\\.\\{2,\\}\\|-\\{2,\\}")) (defvar plantuml-builtins-regexp (regexp-opt plantuml-builtins 'words)) (defvar plantuml-preprocessors-regexp (concat "^\\s *" (regexp-opt plantuml-preprocessors 'words))) - (defvar plantuml-indent-regexp-start "^[ \t]*\\(\\(?:.*\\)?\s*\\(?:[<>.*a-z-|]+\\)?\s*\\(?:\\[[a-zA-Z]+\\]\\)?\s+if\s+.*\\|loop\s+.*\\|group\s+.*\\|par\s*$\\|opt\s+.*\\|alt\s+.*\\|else\\|note\s+over\\|note\sas\s.*\\|note\s+\\(\\(?:\\(?:button\\|left\\|right\\|top\\)\\)\\)\\(?:\s+of\\)?\\|\\(?:class\\|enum\\|package\\|database\\|frame\\|cloud\\|folder\\)\s+.*{\\|activate\s+.+\\)") + (defvar plantuml-indent-regexp-start "^[ \t]*\\(\\(?:.*\\)?\s*\\(?:[<>.*a-z-|]+\\)?\s*\\(?:\\[[a-zA-Z]+\\]\\)?\s+if\s+.*\\|loop\s+.*\\|group\s+.*\\|par\s*$\\|opt\s+.*\\|alt\s+.*\\|else\\|note\s+over\\|note\sas\s.*\\|note\s+\\(\\(?:\\(?:button\\|left\\|right\\|top\\)\\)\\)\\(?:\s+of\\)?\\|\\(?:\\(abstract \\)?class\\|enum\\|package\\|database\\|frame\\|cloud\\|folder\\)\s+.*{\\|activate\s+.+\\)") (defvar plantuml-indent-regexp-end "^[ \t]*\\(endif\\|else\\|end\\|end\s+note\\|.*}\\|deactivate\s+.+\\)") (setq plantuml-font-lock-keywords diff --git a/test/plantuml-indentation-test.el b/test/plantuml-indentation-test.el index 3860f2f..53a1cbb 100644 --- a/test/plantuml-indentation-test.el +++ b/test/plantuml-indentation-test.el @@ -306,8 +306,33 @@ package APackage { } ")) +(ert-deftest platuml-test-block-indentation/class () + "Test correct indentation of a class block" + (plantuml-test-indent-block + " +class Foo { ++bar() +} +" + " +class Foo { + +bar() +} +") + (plantuml-test-indent-block + " +abstract class Foo { ++bar() +} +" + " +abstract class Foo { + +bar() +} +")) + (ert-deftest plantuml-test-block-indentation/various-keywords () - "Test correct indentation of a package block." + "Test correct indentation of block keywords." (plantuml-test-indent-block " cloud \"mycloud\" {