Repository: fortran-lang/fortls (language: python)

Issue:
Intent(inout) does not work with spaces between in and out
**Describe the bug**
`intent(in out)` is not parsed correctly. Edit REGEX expression.




Discussion / hints:

Fix patch:
diff --git a/fortls/regex_patterns.py b/fortls/regex_patterns.py
index 9df8f20b..9ee313f4 100644
--- a/fortls/regex_patterns.py
+++ b/fortls/regex_patterns.py
@@ -78,7 +78,7 @@ class FortranRegularExpressions:
     KEYWORD_LIST: Pattern = compile(
         r"[ ]*,[ ]*(PUBLIC|PRIVATE|ALLOCATABLE|"
         r"POINTER|TARGET|DIMENSION[ ]*\(|"
-        r"OPTIONAL|INTENT[ ]*\([ ]*(?:IN|OUT|INOUT)[ ]*\)|DEFERRED|NOPASS|"
+        r"OPTIONAL|INTENT[ ]*\([ ]*(?:IN|OUT|IN[ ]*OUT)[ ]*\)|DEFERRED|NOPASS|"
         r"PASS[ ]*\(\w*\)|SAVE|PARAMETER|EXTERNAL|"
         r"CONTIGUOUS)",
         I,


Test patch:
diff --git a/test/test_server_hover.py b/test/test_server_hover.py
index f1a573c9..dd2b355e 100644
--- a/test/test_server_hover.py
+++ b/test/test_server_hover.py
@@ -442,3 +442,23 @@ def test_var_name_asterisk():
         # "CHARACTER(KIND=4, LEN=100), DIMENSION(3,4)",
     ]
     validate_hover(results, ref_results)
+
+
+def test_intent():
+    string = write_rpc_request(1, "initialize", {"rootPath": str(test_dir)})
+    file_path = test_dir / "hover" / "intent.f90"
+    string += hover_req(file_path, 2, 31)
+    string += hover_req(file_path, 3, 29)
+    string += hover_req(file_path, 4, 34)
+    string += hover_req(file_path, 5, 35)
+    string += hover_req(file_path, 6, 35)
+    errcode, results = run_request(string, fortls_args=["-n", "1"])
+    assert errcode == 0
+    ref_results = [
+        """INTEGER(4), INTENT(IN)""",
+        """INTEGER, INTENT(OUT)""",
+        """INTEGER(4), INTENT(INOUT)""",
+        """INTEGER(4), INTENT(IN OUT)""",
+        """REAL, OPTIONAL, INTENT(IN)""",
+    ]
+    validate_hover(results, ref_results)
diff --git a/test/test_source/hover/intent.f90 b/test/test_source/hover/intent.f90
new file mode 100644
index 00000000..5e5d634a
--- /dev/null
+++ b/test/test_source/hover/intent.f90
@@ -0,0 +1,8 @@
+subroutine intent(arg1, arg2, arg3, arg4, arg5)
+    implicit none
+    integer(4), intent(in) :: arg1
+    integer, intent(out) :: arg2
+    integer(4), intent(inout) :: arg3
+    integer(4), intent(in out) :: arg4
+    real, optional, intent(in) :: arg5
+end subroutine intent
\ No newline at end of file