Skip to content

Commit

Permalink
Require no whitespace before the '(' of a loopbody definition (#197)
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastiaanspeck authored Dec 10, 2024
1 parent 06df102 commit 2489ca3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -186,15 +186,15 @@ private boolean requireWhitespaceBefore(final Token token) {
&& (this.tokenIs(token, "<<", "^<<")))
&& !this.tokenIs(token, ".", ",", ")", "}", "]")
&& !this.tokenIs(this.lastToken, "(", "{", "[")
&& !this.tokenIs(this.lastTextToken, "_proc"); // Except for _proc.
&& !this.tokenIs(this.lastTextToken, "_proc", "_loopbody"); // Except for _proc/_loopbody.
}

private boolean requireNoWhitespaceBefore(final Token token) {
final String lastTextTokenValue =
this.lastTextToken != null ? this.lastTextToken.getOriginalValue().toLowerCase() : null;
return !this.tokenIs(token, GenericTokenType.COMMENT)
&& (this.tokenIs(token, ")", "}", "]", ",")
|| this.tokenIs(this.lastTextToken, "@", "(", "{", "[", "_proc")
|| this.tokenIs(this.lastTextToken, "@", "(", "{", "[", "_proc", "_loopbody")
|| this.nodeIsSlot()
|| this.currentNode.is(MagikGrammar.ARGUMENTS)
|| this.currentNode.is(MagikGrammar.PARAMETERS)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,13 @@ void testProcDefinitionParameters(final String code) {
assertThat(edits).isEmpty();
}

@Test
void testLoopbdoyDefinitionParameters() {
final String code = "_loopbody(x, y, z)";
final List<TextEdit> edits = this.getEdits(code);
assertThat(edits).isEmpty();
}

// endregion

// region: Indenting.
Expand Down

0 comments on commit 2489ca3

Please sign in to comment.