Last active
August 29, 2015 14:20
-
-
Save jklukas/0222a2da435a12823055 to your computer and use it in GitHub Desktop.
Break long compound imports to multiple lines (Scala)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for x in $(gsed -n -E -e 's/.*(class|object|trait) ([[:alnum:]]*).*/\2/p' nacho-wire/src/main/scala/com/simple/nacho/wire/Json.scala); do | |
find nacho-service -name "*.scala" | \ | |
xargs sed -i '' '/^import/! s/\([^.[:alnum:]]\)\('$x'[[:punct:][:space:]]\)/\1wire.\2/g'; | |
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Invoke as: | |
# sed -f break-up-imports.sed file.scala | |
# Only act on import statements with at least 5 items | |
/import .*,.*,.*,.*,.*/ { | |
# Add a newline after the opening brace | |
s/{/{\ | |
/ | |
# Add a newline before closing brace | |
s/}/\ | |
}/ | |
# Add newlines between commas | |
s/, /,\ | |
/g | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment