-
Notifications
You must be signed in to change notification settings - Fork 510
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Account for super keyword in SpacingAroundParensRule #373
Conversation
* When checking for unexpected spaces preceding a `(`, the rule was only checking elementType `IDENTIFIER`, so added a check for `SUPER_KEYWORD` * Updated lint and formatting tests
Fixes #369 |
@@ -23,7 +29,11 @@ class SpacingAroundParensRule : Rule("paren-spacing") { | |||
val nextLeaf = node.nextLeaf() | |||
val spacingBefore = if (node.elementType == LPAR) { | |||
prevLeaf is PsiWhiteSpace && !prevLeaf.textContains('\n') && | |||
prevLeaf.prevLeaf()?.elementType == IDENTIFIER && ( | |||
( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This formatting looks pretty wacky to me, but AS seems to agree it's correct.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's weird the this open paren is on a new line but the open paren on line 36 is not.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I agree. There's definitely bugs with the indent formatting rule but I can't always figure them out.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Test case?
/** | ||
* Ensures there are no extra spaces around parentheses. | ||
* | ||
* See https://kotlinlang.org/docs/reference/coding-conventions.html, "Horizontal Whitespace" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if you want, you can use the fragment: https://kotlinlang.org/docs/reference/coding-conventions.html#horizontal-whitespace
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah yes I was looking for that and just looked through it. will update.
@@ -23,7 +29,11 @@ class SpacingAroundParensRule : Rule("paren-spacing") { | |||
val nextLeaf = node.nextLeaf() | |||
val spacingBefore = if (node.elementType == LPAR) { | |||
prevLeaf is PsiWhiteSpace && !prevLeaf.textContains('\n') && | |||
prevLeaf.prevLeaf()?.elementType == IDENTIFIER && ( | |||
( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's weird the this open paren is on a new line but the open paren on line 36 is not.
Tests were added to the lint and format spec files. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice.
(
, the rule was only checking elementTypeIDENTIFIER
, so added a check forSUPER_KEYWORD