scala-ide/scala-ide — pull request #342 by huitseeker (2013-03-08 14:36:50+00:00)
Title: Split monoline multiple (braced) imports to ease merging

In the immortal words of @paulp: "Can we please, please not do this:

import PatternMatchingStats._
import global.{phase, currentRun, Symbol,
Apply, Bind, CaseDef, ClassInfoType, Ident, Literal, Match,
Alternative, Constant, EmptyTree, Select, Star, This, Throw, Typed,
UnApply, (...)"

Let's simplify merges, by making our imports mono-line !

Thanksfully, in the IDE, we don't do *mutli-line* braced Imports, so it was
enough to filter them with the following one-liner:

`for i in `find ./ -type f -name "*.scala"`; do perl -nle 'if
(m/^import\s([^\n]+?){([^\n=]*?)}$/smg){my ($x,@y)=($1,split /\s?,\s?/,$2);
foreach $dep (@y){$dep =~ s/^\s+//; $dep =~ s/\s+$//; print "import $x$dep";}}
else {print $_;}' $i > $i.nu; mv $i.nu $i; done`

If you want to do this on a repo that contains multi-line braced imports, look
into unsetting the special variable '$/' of perl, and relax the condition on
the presence of new lines in the second capture group of the regex above. I
strongly advise against doing this automatically on such a repo, though.