From 6858ab704588e7dce0c824dbee79295451801331 Mon Sep 17 00:00:00 2001 From: Sriram Swaminarayan Date: Wed, 11 Sep 2024 14:04:38 -0600 Subject: [PATCH 1/3] Fixed indenting of labelled select statements #175 --- fprettify/__init__.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/fprettify/__init__.py b/fprettify/__init__.py index d6450a3..684e4c7 100644 --- a/fprettify/__init__.py +++ b/fprettify/__init__.py @@ -112,10 +112,10 @@ ENDDO_RE = re.compile(SOL_STR + r"END\s*DO(\s+\w+)?" + EOL_STR, RE_FLAGS) SELCASE_RE = re.compile( - SOL_STR + r"SELECT\s*(CASE|RANK|TYPE)\s*\(.*\)" + EOL_STR, RE_FLAGS) + SOL_STR + r"(\w+\s*:)?\s*SELECT\s*(CASE|RANK|TYPE)\s*\(.*\)" + EOL_STR, RE_FLAGS) CASE_RE = re.compile( SOL_STR + r"((CASE|RANK|TYPE\s+IS|CLASS\s+IS)\s*(\(.*\)|DEFAULT)|CLASS\s+DEFAULT)" + EOL_STR, RE_FLAGS) -ENDSEL_RE = re.compile(SOL_STR + r"END\s*SELECT" + EOL_STR, RE_FLAGS) +ENDSEL_RE = re.compile(SOL_STR + r"END\s*SELECT(\s+\w+)?" + EOL_STR, RE_FLAGS) ASSOCIATE_RE = re.compile(SOL_STR + r"ASSOCIATE\s*\(.*\)" + EOL_STR, RE_FLAGS) ENDASSOCIATE_RE = re.compile(SOL_STR + r"END\s*ASSOCIATE" + EOL_STR, RE_FLAGS) @@ -1154,11 +1154,11 @@ def add_whitespace_charwise(line, spacey, scope_parser, format_decl, filename, l line[:pos], RE_FLAGS) or re.search(SOL_STR + r"(\w+\s*:)?\s*DO\s+WHILE\s*$", line[:pos], RE_FLAGS) or - re.search(SOL_STR + r"(SELECT)?\s*CASE\s*$", + re.search(SOL_STR + r"(\w+\s*:)?\s*(SELECT)?\s*CASE\s*$", line[:pos], RE_FLAGS) or - re.search(SOL_STR + r"(SELECT)?\s*RANK\s*$", + re.search(SOL_STR + r"(\w+\s*:)?\s*(SELECT)?\s*RANK\s*$", line[:pos], RE_FLAGS) or - re.search(SOL_STR + r"SELECT\s*TYPE\s*$", + re.search(SOL_STR + r"(\w+\s*:)?\s*SELECT\s*TYPE\s*$", line[:pos], RE_FLAGS) or re.search(SOL_STR + r"CLASS\s*DEFAULT\s*$", line[:pos], RE_FLAGS) or From 577c316f3d71a578d8966f484b281888d328f996 Mon Sep 17 00:00:00 2001 From: Sriram Swaminarayan Date: Wed, 11 Sep 2024 14:09:56 -0600 Subject: [PATCH 2/3] Converted string to raw string to prevent waring at line 272 of __init__.py in python3 --- fprettify/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fprettify/__init__.py b/fprettify/__init__.py index 684e4c7..2f66ee3 100644 --- a/fprettify/__init__.py +++ b/fprettify/__init__.py @@ -269,7 +269,7 @@ def split(self, line): LR_OPS_RE = [REL_OP_RE, LOG_OP_RE, plusminus_parser(PLUSMINUS_RE), MULTDIV_RE, PRINT_RE] USE_RE = re.compile( - SOL_STR + "USE(\s+|(,.+?)?::\s*)\w+?((,.+?=>.+?)+|,\s*only\s*:.+?)?$" + EOL_STR, RE_FLAGS) + SOL_STR + r"USE(\s+|(,.+?)?::\s*)\w+?((,.+?=>.+?)+|,\s*only\s*:.+?)?$" + EOL_STR, RE_FLAGS) # markups to deactivate formatter NO_ALIGN_RE = re.compile(SOL_STR + r"&\s*[^\s*]+") From ca4d8c6a565290120d0737b00b113ce7deb405c0 Mon Sep 17 00:00:00 2001 From: Sriram Swaminarayan Date: Wed, 11 Sep 2024 15:05:48 -0600 Subject: [PATCH 3/3] Added space after ":" in named select statements --- fprettify/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fprettify/__init__.py b/fprettify/__init__.py index 2f66ee3..3cbcfc2 100644 --- a/fprettify/__init__.py +++ b/fprettify/__init__.py @@ -1308,7 +1308,7 @@ def add_whitespace_context(line, spacey): line = ''.join(line_parts) - for newre in [IF_RE, DO_RE, BLK_RE]: + for newre in [IF_RE, DO_RE, SELCASE_RE, BLK_RE]: if newre.search(line) and re.search(SOL_STR + r"\w+\s*:", line): line = ': '.join(_.strip() for _ in line.split(':', 1))