-
Notifications
You must be signed in to change notification settings - Fork 185
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from scalacenter/refactor
Refactor
- Loading branch information
Showing
25 changed files
with
412 additions
and
362 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
--assumeStandardLibraryStripMargin true | ||
--alignTokens %;Infix,%%;Infix,%%%;Infix | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#!/usr/bin/env bash | ||
set -e | ||
|
||
echo "Running nailgun integration test..." | ||
|
||
cwd=$(pwd) | ||
cd cli/target/pack | ||
make install | ||
cd $cwd | ||
|
||
echoOriginalContents() { | ||
cat << EOF | ||
object app { | ||
def main() { | ||
println(1) | ||
} | ||
} | ||
EOF | ||
} | ||
|
||
echoExpectedContents() { | ||
cat << EOF | ||
object app { | ||
def main(): Unit = { | ||
println(1) | ||
} | ||
} | ||
EOF | ||
} | ||
original=target/original.scala | ||
expected=target/expected.scala | ||
|
||
mkdir -p target | ||
echoOriginalContents > ${original} | ||
echoExpectedContents > ${expected} | ||
./bin/scalafix_ng -i ${original} | ||
|
||
# Assert there is no diff | ||
diff ${original} ${expected} | ||
|
||
echo "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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#!/usr/bin/env bash | ||
set -e | ||
|
||
function assert-installed() { | ||
binary=$1 | ||
command -v ${binary} >/dev/null 2>&1 || { echo >&2 "Missing dependency ${binary}, exiting."; exit 1; } | ||
} | ||
|
||
NAILGUN="ng" | ||
if ! type "${NAILGUN}" > /dev/null; then | ||
NAILGUN="ng-nailgun" | ||
fi | ||
|
||
assert-installed $NAILGUN | ||
assert-installed scalafix_ng_server | ||
|
||
startNailgun() { | ||
echo "Starting nailgun..." | ||
scalafix_ng_server & | ||
sleep 1 | ||
$NAILGUN ng-alias scalafix scalafix.cli.Cli | ||
} | ||
|
||
|
||
if [ "$1" = "restart" ]; then | ||
$NAILGUN ng-stop || true | ||
sleep 1 | ||
startNailgun | ||
else | ||
$NAILGUN ng-stats &> /dev/null || startNailgun | ||
$NAILGUN scalafix "$@" | ||
fi |
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package scalafix.cli | ||
|
||
import scalafix.rewrite.ProcedureSyntax | ||
import scalafix.rewrite.Rewrite | ||
|
||
import java.io.InputStream | ||
import java.io.PrintStream | ||
|
||
import caseapp.core.ArgParser | ||
|
||
object ArgParserImplicits { | ||
def nameMap[T](t: sourcecode.Text[T]*): Map[String, T] = { | ||
t.map(x => x.source -> x.value).toMap | ||
} | ||
|
||
val rewriteMap: Map[String, Rewrite] = nameMap( | ||
ProcedureSyntax | ||
) | ||
implicit val rewriteRead: ArgParser[Rewrite] = ArgParser.instance[Rewrite] { | ||
str => | ||
rewriteMap.get(str) match { | ||
case Some(x) => Right(x) | ||
case _ => | ||
Left( | ||
s"invalid input $str, must be one of ${rewriteMap.keys.mkString(", ")}") | ||
} | ||
} | ||
|
||
implicit val inputStreamRead: ArgParser[InputStream] = | ||
ArgParser.instance[InputStream](x => Right(System.in)) | ||
|
||
implicit val printStreamRead: ArgParser[PrintStream] = | ||
ArgParser.instance[PrintStream](x => Right(System.out)) | ||
|
||
} |
Oops, something went wrong.