0

I have a relatively large Scala code base that does not use named parameters for any function/class calls. Rather than going in and manually entering it, which would be a very tedious process, I was looking at a formatter to do the job. The best I found is scalariform, but I'm not sure whether I can even write a rule for something so complex.

I'm curious if anyone has ran into a similar problem and found a powerful formatter.

stan
  • 4,885
  • 5
  • 49
  • 72
  • 1
    What exactly do you want to accomplish? Name everything that can be named? I'm not sure why you'd want to do that. Is the result still supposed to be readable? – Rex Kerr Jul 21 '13 at 22:06
  • @RexKerr: I'm doing this for readability. I don't want to name everything, I should've made that clear. Just calls with a huge list of parameters that would be a pain to read. – stan Jul 22 '13 at 01:55

1 Answers1

0

The Scala Refactoring library might be something you could use. You will need some knowledge of Scala's Abstract Syntax Tree representation.

Why do you want to use named parameters throughout your code base? I like IntelliJ's default which is to suggest to name boolean arguments (only).

0__
  • 66,707
  • 21
  • 171
  • 266
  • I should've stated that I want to do this selectively. I suppose that makes it even so much harder. There are lots of case classes with a dozen or so parameters, so I felt it would make sense to name the parameters for readability(not just to avoid bugs like Intellij does with boolean arguments). But I guess it's not worth the effort. – stan Jul 22 '13 at 01:59
  • @StanislavPalatnik if there are a dozen params, maybe you do need a refactor. But boolean params is a definite use case (it's the required style for scalac, a good idea). My other use case (that recently came up) is deprecated annotation. It takes two strings, and they must be in the correct order. [at] deprecated(since="2.10", message="Don't do it") is backward, but it's not too much to ask for a tool to sanity check and fix it. – som-snytt Jul 22 '13 at 05:53
  • Addendum, I totally don't get assembla. I have an account because of scala-ide, but I don't use it. I can't even find tickets on assembla. If scala-refactoring requires me to hunt up a password just to grab src, forget it. Who isn't on github? – som-snytt Jul 22 '13 at 05:59
  • It is on maven central, just add it to your dependency list – 0__ Jul 22 '13 at 22:50