Skip to content

Commit

Permalink
Include by value (result) modifier when hovering (#486)
Browse files Browse the repository at this point in the history
`BY VALUE` and `BY VALUE RESULT` are now present

closes #485
  • Loading branch information
MarkusAmshove authored Jun 27, 2024
1 parent d40ce83 commit a7690f9
Show file tree
Hide file tree
Showing 3 changed files with 139 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,15 @@ private VariableDeclarationFormat formatVariableDeclaration(INaturalModule modul
}
}

if (variable.findDescendantToken(SyntaxKind.VALUE) != null)
{
declaration += " BY VALUE";
if (variable.findDescendantToken(SyntaxKind.RESULT) != null)
{
declaration += " RESULT";
}
}

if (variable.findDescendantToken(SyntaxKind.OPTIONAL) != null)
{
declaration += " OPTIONAL";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ void hoverExternalSubroutines()
DEFINE DATA
LOCAL
END-DEFINE
PERFORM THE-E${}$XTERNAL-SUB 'AAA'
END
""", """
Expand Down Expand Up @@ -123,11 +123,11 @@ void hoverFunctions()
DEFINE DATA
LOCAL
END-DEFINE
IF F${}$UNC(<'A'>)
IGNORE
END-IF
END
""", """
**LIBONE.FUNC**
Expand All @@ -146,7 +146,48 @@ void hoverFunctions()
*Parameter:*
```natural
PARAMETER 1 P-PARAM (A10)
PARAMETER 1 P-PARAM (A10) BY VALUE
```""");
}

@Test
void includeParameterWithAllModifiers()
{
createOrSaveFile("LIBONE", "FUNC.NS7", """
DEFINE FUNCTION FUNC
RETURNS (L)
DEFINE DATA
PARAMETER
1 P-PARAM (A) DYNAMIC BY VALUE RESULT OPTIONAL
END-DEFINE
FUNC := TRUE
END-FUNCTION
""");

assertHover("""
DEFINE DATA
LOCAL
END-DEFINE
IF F${}$UNC(<'A'>)
IGNORE
END-IF
END
""", """
**LIBONE.FUNC**
*Result:*
```natural
RETURNS (L)
```
*Parameter:*
```natural
PARAMETER 1 P-PARAM (A) DYNAMIC BY VALUE RESULT OPTIONAL
```""");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,91 @@ void dynamicAlphanumericArraysShouldBeFormatted()
);
}

@Test
void byValueParameterShouldBeFormatted()
{
assertHover(
"""
DEFINE DATA
PARAMETER 1 #MY${}$PAR (A10) BY VALUE
END-DEFINE
END
""",
"""
```natural
PARAMETER 1 #MYPAR (A10) BY VALUE
```"""
);
}

@Test
void byValueResultParameterShouldBeFormatted()
{
assertHover(
"""
DEFINE DATA
PARAMETER 1 #MY${}$PAR (A10) BY VALUE RESULT
END-DEFINE
END
""",
"""
```natural
PARAMETER 1 #MYPAR (A10) BY VALUE RESULT
```"""
);
}

@Test
void dynamicByValueParameterShouldBeFormatted()
{
assertHover(
"""
DEFINE DATA
PARAMETER 1 #MY${}$PAR (A) DYNAMIC BY VALUE
END-DEFINE
END
""",
"""
```natural
PARAMETER 1 #MYPAR (A) DYNAMIC BY VALUE
```"""
);
}

@Test
void dynamicByValueResultParameterShouldBeFormatted()
{
assertHover(
"""
DEFINE DATA
PARAMETER 1 #MY${}$PAR (A) DYNAMIC BY VALUE RESULT
END-DEFINE
END
""",
"""
```natural
PARAMETER 1 #MYPAR (A) DYNAMIC BY VALUE RESULT
```"""
);
}

@Test
void dynamicByValueResultOptionalParameterShouldBeFormatted()
{
assertHover(
"""
DEFINE DATA
PARAMETER 1 #MY${}$PAR (A) DYNAMIC BY VALUE RESULT OPTIONAL
END-DEFINE
END
""",
"""
```natural
PARAMETER 1 #MYPAR (A) DYNAMIC BY VALUE RESULT OPTIONAL
```"""
);
}

@Test
void levelOneVariablesShouldBeHoveredCorrectlyEvenWhenHoveringTheReference()
{
Expand Down

0 comments on commit a7690f9

Please sign in to comment.