Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Consider comments when searching for multiline annotations #499

Merged
merged 2 commits into from
Jul 15, 2019

Conversation

arturbosch
Copy link
Contributor

@arturbosch arturbosch commented Jun 22, 2019

Closes #498

Edit: Well after reading the property name again, do we want single parameter annotations also be on separate lines?
Imo the checks need a it.valueParameters.size > 1.

@shashachu
Copy link
Contributor

Closes #498

Edit: Well after reading the property name again, do we want single parameter annotations also be on separate lines?
Imo the checks need a it.valueParameters.size > 1.

https://kotlinlang.org/docs/reference/coding-conventions.html#annotation-formatting says

A single annotation without arguments may be placed on the same line as the corresponding declaration

so yes, it does seem like this should apply to multiple annotations or annotations with arguments.

@arturbosch
Copy link
Contributor Author

arturbosch commented Jul 7, 2019

Closes #498
Edit: Well after reading the property name again, do we want single parameter annotations also be on separate lines?
Imo the checks need a it.valueParameters.size > 1.

https://kotlinlang.org/docs/reference/coding-conventions.html#annotation-formatting says

A single annotation without arguments may be placed on the same line as the corresponding declaration

so yes, it does seem like this should apply to multiple annotations or annotations with arguments.

Yep, the statement is alright then with it.valueArgumentList != null. Fixed the typo.

@shashachu shashachu merged commit 1fc0836 into pinterest:master Jul 15, 2019
@arturbosch arturbosch deleted the fix-annotation branch July 15, 2019 17:29
sowmyav24 pushed a commit to sowmyav24/ktlint that referenced this pull request Jul 18, 2019
…#499)

* Consider comments when searching for multiline annotations

* Make sure the annotated statement is really not on the same line regardless of a comment
@ddulaney
Copy link

Hello! Sorry to be digging up an old PR, but is it possible to allow multiple annotations with comments? For example, this is failing:

@Annotation1 // comment 1
@Annotation2 // comment 2
class MyClass {
}

with this error:

Multiple annotations should not be placed on the same line as the annotated construct

@romtsn
Copy link
Collaborator

romtsn commented May 19, 2020

@ddulaney should be resolved by #740

@ddulaney
Copy link

Great, thanks! I'll wait for that to be merged & released 👍

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

AnnotationOnSeparateLine should respect comments
4 participants