From f0e3ce958574922f1e563ab7928ae74ebb8cc8ea Mon Sep 17 00:00:00 2001 From: Meriam Lachkar Date: Tue, 4 Aug 2020 11:51:42 +0200 Subject: [PATCH] Add missing documentation --- .../interfaces/ScalafixArgumentsImpl.scala | 1 - .../internal/interfaces/ScalafixResultImpl.scala | 5 ----- .../java/scalafix/interfaces/ScalafixOutput.java | 14 ++++++++++++-- .../java/scalafix/interfaces/ScalafixPatch.java | 11 +++++++++-- .../java/scalafix/interfaces/ScalafixResult.java | 9 +++++---- 5 files changed, 26 insertions(+), 14 deletions(-) diff --git a/scalafix-cli/src/main/scala/scalafix/internal/interfaces/ScalafixArgumentsImpl.scala b/scalafix-cli/src/main/scala/scalafix/internal/interfaces/ScalafixArgumentsImpl.scala index 991e3e0404..3ab0f801bc 100644 --- a/scalafix-cli/src/main/scala/scalafix/internal/interfaces/ScalafixArgumentsImpl.scala +++ b/scalafix-cli/src/main/scala/scalafix/internal/interfaces/ScalafixArgumentsImpl.scala @@ -37,7 +37,6 @@ final case class ScalafixArgumentsImpl(args: Args = Args.default) override def run(): Array[ScalafixError] = { val exit = MainOps.run(Array(), args) - println(s"exit $exit") ScalafixErrorImpl.fromScala(exit) } diff --git a/scalafix-cli/src/main/scala/scalafix/internal/interfaces/ScalafixResultImpl.scala b/scalafix-cli/src/main/scala/scalafix/internal/interfaces/ScalafixResultImpl.scala index 863da23ccb..d246a14e72 100644 --- a/scalafix-cli/src/main/scala/scalafix/internal/interfaces/ScalafixResultImpl.scala +++ b/scalafix-cli/src/main/scala/scalafix/internal/interfaces/ScalafixResultImpl.scala @@ -26,11 +26,6 @@ final case class ScalafixResultImpl( override def writeResult(): Array[ScalafixError] = { scalafixOutputs.flatMap(o => o.applyPatches()).toArray } - - override def writeResult(path: Path): Array[ScalafixError] = { - scalafixOutputs.flatMap(o => o.applyPatches()).toArray - } - } object ScalafixResultImpl { diff --git a/scalafix-interfaces/src/main/java/scalafix/interfaces/ScalafixOutput.java b/scalafix-interfaces/src/main/java/scalafix/interfaces/ScalafixOutput.java index 5fcc4f8252..d2fa6ae30a 100644 --- a/scalafix-interfaces/src/main/java/scalafix/interfaces/ScalafixOutput.java +++ b/scalafix-interfaces/src/main/java/scalafix/interfaces/ScalafixOutput.java @@ -41,23 +41,33 @@ public interface ScalafixOutput { */ Optional getUnifiedDiff(); - /** * * @return the output file after running scalafix if no error */ Optional getOutputFileFixed(); - /** * * @return scalafixPatches */ ScalafixPatch[] getPatches(); + /** + * + * @return apply all patches and write the result to file. + */ ScalafixError[] applyPatches(); + /** + * + * @return Optional containes the new file if no error. + */ Optional getOutputFixedWithSelectivePatches(ScalafixPatch[] patches); + /** + * + * @return apply selected patches to file + */ ScalafixError[] applySelectivePatches(ScalafixPatch[] patches); } diff --git a/scalafix-interfaces/src/main/java/scalafix/interfaces/ScalafixPatch.java b/scalafix-interfaces/src/main/java/scalafix/interfaces/ScalafixPatch.java index d6e60422ac..eb56fc8b9a 100644 --- a/scalafix-interfaces/src/main/java/scalafix/interfaces/ScalafixPatch.java +++ b/scalafix-interfaces/src/main/java/scalafix/interfaces/ScalafixPatch.java @@ -1,9 +1,16 @@ package scalafix.interfaces; public interface ScalafixPatch { - + /** + * Can be RemoveGlobalImport, RemoveImportee, AddGlobalImport, AddGlobalSymbol, ReplaceSymbol + * @return + */ String kind(); + /** + * + * @return Java UUID + */ String getId(); -} +} \ No newline at end of file diff --git a/scalafix-interfaces/src/main/java/scalafix/interfaces/ScalafixResult.java b/scalafix-interfaces/src/main/java/scalafix/interfaces/ScalafixResult.java index 4c7ee31ef8..cfb2aa6582 100644 --- a/scalafix-interfaces/src/main/java/scalafix/interfaces/ScalafixResult.java +++ b/scalafix-interfaces/src/main/java/scalafix/interfaces/ScalafixResult.java @@ -22,13 +22,14 @@ public interface ScalafixResult { Optional getMessageError(); /** - * G + * * @return ScalafixOutput[] for each file we store diagnostics and patches * */ ScalafixOutput[] getScalafixOutputs(); - + /** + * + * @return if no error, write result to file configured in {@link ScalafixArguments()} + */ ScalafixError[] writeResult(); - - ScalafixError[] writeResult(Path path); }