Skip to content
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

Force annotations onto their own lines for block expressions and parameter clauses #12

Closed
daniel-trinh opened this issue Mar 2, 2014 · 9 comments

Comments

@daniel-trinh
Copy link
Owner

Annotations for expressions in blocks and parameter clauses currently are placed on the same line:

def asdf(
  @annotation one: Int,
  @a @b(c) two: String
)

class A extends B {
  @SomeImportantAnnotation(param = true) override val param: Int = 1

  @NotSoImportantAnnotation(param = false) val description: String = "Not so important"
}

Instead, it should be formatted as..

def asdf(
  @annotation 
  one: Int,
  @a 
  @b(c) 
  two: String
)

class A extends B {
  @SomeImportantAnnotation(param = true) 
  override val param: Int = 1

  @NotSoImportantAnnotation(param = false) 
  val description: String = "Not so important"
}

This would most likely only affect parameters that are already placed on their own line, so
something like this wouldn't be affected:

def asdf(@annotation one: Int, @a @b(c) two: String)

stays as..

def asdf(@annotation one: Int, @a @b(c) two: String)

Implementation details note: this needs to be implemented without breaking the AlignParameters feature

See here for similar issue on original branch: scala-ide#91

bambuchaAdm added a commit to bambuchaAdm/scalariform that referenced this issue Mar 2, 2014
@bambuchaAdm
Copy link

Don't you think here

def asdf(
  @annotation 
  one: Int,
  @a @b(c) 
  two: String
)

better construction will be set second annotation @b(c) to next line ?

@daniel-trinh
Copy link
Owner Author

Yea, good catch, I'll fix the description

bambuchaAdm added a commit to bambuchaAdm/scalariform that referenced this issue Mar 4, 2014
Fix test formation glitches.
Add test for class annotation.
@bambuchaAdm
Copy link

Test for annotation are green. Maybe tommorrow, I will clean up tests. I think it will be quick.

@bambuchaAdm
Copy link

On making tests green, i ran into test for scala-ide#28.

Maybe we should introduce configuration parameter ?

@daniel-trinh
Copy link
Owner Author

Hmm, I think we should either keep it as is (force annotations onto their own line), or modify it so that it preserves newlines implicitly.

I'm not a fan of more configuration parameters, because there are much more interesting problems to solve than thinking about how to format Scala code -- having one reasonable default is good enough IMO.

@daniel-trinh
Copy link
Owner Author

@bambuchaAdm How's this feature looking? Scala 2.11 release is nearing, #4 and #12 are pretty useful features to try and include into a 0.15.0 non-snapshot release.

@ConnorDoyle
Copy link

I would love to see this change in scalariform. Without this fix, we have some lines that exceed 160 columns!

@patrikvarga
Copy link

+1, this is very annoying, especially that it is not conforming the Scala Style Guide and thus makes the following statement in the documentation invalid:
"Scalariform is compatible with the Scala Style Guide in the sense that, given the right preference settings, source code that is initially compiliant with the Style Guide will not become uncompliant after formatting."

@kiritsuku
Copy link
Collaborator

This issue was moved to scala-ide#185

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants