From bd5bca59bc5544d55a7d918e72aca1dbe46b3a1c Mon Sep 17 00:00:00 2001 From: nikololiahim Date: Fri, 20 May 2022 20:56:30 +0300 Subject: [PATCH] enabled scalafix organize imports --- .scalafix.conf | 2 +- .../odin/analysis/EOOdinAnalyzer.scala | 3 +- .../odin/analysis/liskov/Analyzer.scala | 24 ++++----- .../mutualrec/advanced/Analyzer.scala | 3 +- .../mutualrec/advanced/CallGraph.scala | 3 +- .../analysis/mutualrec/naive/package.scala | 24 ++++----- .../naive/services/TopLevelObject.scala | 10 ++-- .../naive/services/TopLevelObjects.scala | 23 ++++----- .../unjustifiedassumptions/Analyzer.scala | 22 ++++---- .../odin/analysis/utils/Abstract.scala | 15 ++++-- .../polystat/odin/analysis/utils/Optics.scala | 11 ++-- .../analysis/utils/inlining/Inliner.scala | 12 +++-- .../analysis/utils/inlining/LocateCalls.scala | 3 +- .../utils/inlining/LocateMethods.scala | 3 +- .../utils/inlining/LocatorContext.scala | 5 +- .../analysis/utils/inlining/package.scala | 11 ++-- .../odin/analysis/utils/inlining/types.scala | 3 +- .../logicalextraction/ExtractLogic.scala | 3 +- .../utils/logicalextraction/SMTUtils.scala | 27 +++++----- .../analysis/DetectStateAccessTests.scala | 5 +- .../odin/analysis/LiskovPrincipleTests.scala | 7 +-- .../odin/analysis/MutualrecTests.scala | 10 ++-- .../analysis/UnjustifiedAssumptionTests.scala | 11 ++-- .../gens/MutualRecursionTestGen.scala | 5 +- .../inlining/InlineCallsTestCases.scala | 2 +- .../analysis/inlining/InliningTests.scala | 21 +++----- .../analysis/inlining/LocateCallsTests.scala | 4 +- .../inlining/SetLocatorsTestCases.scala | 3 +- build.sbt | 1 + project/Compiler.scala | 51 ++++++++++++------- .../org/polystat/odin/sandbox/programs.scala | 26 +++++++--- 31 files changed, 196 insertions(+), 157 deletions(-) diff --git a/.scalafix.conf b/.scalafix.conf index 72f558fc..baaea9cd 100644 --- a/.scalafix.conf +++ b/.scalafix.conf @@ -1,7 +1,7 @@ rules = [ ExplicitResultTypes, NoAutoTupling, - RemoveUnused, + OrganizeImports, DisableSyntax, LeakingImplicitClassVal, NoValInForComprehension, diff --git a/analysis/src/main/scala/org/polystat/odin/analysis/EOOdinAnalyzer.scala b/analysis/src/main/scala/org/polystat/odin/analysis/EOOdinAnalyzer.scala index 127c5438..e49dfde5 100644 --- a/analysis/src/main/scala/org/polystat/odin/analysis/EOOdinAnalyzer.scala +++ b/analysis/src/main/scala/org/polystat/odin/analysis/EOOdinAnalyzer.scala @@ -1,7 +1,8 @@ package org.polystat.odin.analysis import cats._ -import cats.data.{EitherNel, NonEmptyList} +import cats.data.EitherNel +import cats.data.NonEmptyList import cats.effect.Sync import cats.syntax.all._ import fs2.Stream diff --git a/analysis/src/main/scala/org/polystat/odin/analysis/liskov/Analyzer.scala b/analysis/src/main/scala/org/polystat/odin/analysis/liskov/Analyzer.scala index f37fc237..04b1f043 100644 --- a/analysis/src/main/scala/org/polystat/odin/analysis/liskov/Analyzer.scala +++ b/analysis/src/main/scala/org/polystat/odin/analysis/liskov/Analyzer.scala @@ -1,23 +1,17 @@ package org.polystat.odin.analysis.liskov import cats.data.EitherNel -import org.polystat.odin.analysis.utils.inlining.Inliner.{ - AnalysisInfo, - ObjectTreeForAnalysis -} -import org.polystat.odin.core.ast.EONamedBnd -import org.polystat.odin.parser.eo.Parser import cats.syntax.parallel._ -import org.polystat.odin.analysis.unjustifiedassumptions.Analyzer.{ - getMethodsInfo, - processMethod -} -import org.polystat.odin.analysis.utils.inlining.{ - Inliner, - MethodInfo, - MethodInfoForAnalysis -} +import org.polystat.odin.analysis.unjustifiedassumptions.Analyzer.getMethodsInfo +import org.polystat.odin.analysis.unjustifiedassumptions.Analyzer.processMethod +import org.polystat.odin.analysis.utils.inlining.Inliner +import org.polystat.odin.analysis.utils.inlining.Inliner.AnalysisInfo +import org.polystat.odin.analysis.utils.inlining.Inliner.ObjectTreeForAnalysis +import org.polystat.odin.analysis.utils.inlining.MethodInfo +import org.polystat.odin.analysis.utils.inlining.MethodInfoForAnalysis import org.polystat.odin.analysis.utils.logicalextraction.ExtractLogic.checkImplication +import org.polystat.odin.core.ast.EONamedBnd +import org.polystat.odin.parser.eo.Parser object Analyzer { diff --git a/analysis/src/main/scala/org/polystat/odin/analysis/mutualrec/advanced/Analyzer.scala b/analysis/src/main/scala/org/polystat/odin/analysis/mutualrec/advanced/Analyzer.scala index cdcb5840..a051cc47 100644 --- a/analysis/src/main/scala/org/polystat/odin/analysis/mutualrec/advanced/Analyzer.scala +++ b/analysis/src/main/scala/org/polystat/odin/analysis/mutualrec/advanced/Analyzer.scala @@ -1,7 +1,8 @@ package org.polystat.odin.analysis.mutualrec.advanced import cats.MonadError -import cats.data.{EitherNel, NonEmptyList => Nel} +import cats.data.EitherNel +import cats.data.{NonEmptyList => Nel} import cats.syntax.apply._ import cats.syntax.either._ import cats.syntax.flatMap._ diff --git a/analysis/src/main/scala/org/polystat/odin/analysis/mutualrec/advanced/CallGraph.scala b/analysis/src/main/scala/org/polystat/odin/analysis/mutualrec/advanced/CallGraph.scala index 2b7a1a5a..3ca31565 100644 --- a/analysis/src/main/scala/org/polystat/odin/analysis/mutualrec/advanced/CallGraph.scala +++ b/analysis/src/main/scala/org/polystat/odin/analysis/mutualrec/advanced/CallGraph.scala @@ -1,8 +1,9 @@ package org.polystat.odin.analysis.mutualrec.advanced -import scala.annotation.tailrec import org.polystat.odin.analysis.mutualrec.advanced.Program._ +import scala.annotation.tailrec + object CallGraph { type CallGraph = Map[MethodName, Set[MethodName]] diff --git a/analysis/src/main/scala/org/polystat/odin/analysis/mutualrec/naive/package.scala b/analysis/src/main/scala/org/polystat/odin/analysis/mutualrec/naive/package.scala index 279bd34b..b83b0ffe 100644 --- a/analysis/src/main/scala/org/polystat/odin/analysis/mutualrec/naive/package.scala +++ b/analysis/src/main/scala/org/polystat/odin/analysis/mutualrec/naive/package.scala @@ -4,23 +4,19 @@ import cats._ import cats.data.Chain import cats.effect._ import cats.implicits._ +import higherkindness.droste.data.Fix +import org.polystat.odin.analysis.mutualrec.naive.services.MethodAttribute import org.polystat.odin.analysis.mutualrec.naive.services.MethodAttribute.MethodInfo +import org.polystat.odin.analysis.mutualrec.naive.services.TopLevelObjects import org.polystat.odin.analysis.mutualrec.naive.services.TopLevelObjects.createTopLevelObjectsWithRefs -import higherkindness.droste.data.Fix -import org.polystat.odin.analysis.mutualrec.naive.services.{ - MethodAttribute, - TopLevelObjects -} +import org.polystat.odin.core.ast.EOArray +import org.polystat.odin.core.ast.EOBndExpr +import org.polystat.odin.core.ast.EOCopy +import org.polystat.odin.core.ast.EODot +import org.polystat.odin.core.ast.EOObj +import org.polystat.odin.core.ast.EOProg +import org.polystat.odin.core.ast.EOSimpleApp import org.polystat.odin.core.ast.astparams.EOExprOnly -import org.polystat.odin.core.ast.{ - EOArray, - EOBndExpr, - EOCopy, - EODot, - EOObj, - EOProg, - EOSimpleApp -} package object naive { diff --git a/analysis/src/main/scala/org/polystat/odin/analysis/mutualrec/naive/services/TopLevelObject.scala b/analysis/src/main/scala/org/polystat/odin/analysis/mutualrec/naive/services/TopLevelObject.scala index df2dab82..c2eccba3 100644 --- a/analysis/src/main/scala/org/polystat/odin/analysis/mutualrec/naive/services/TopLevelObject.scala +++ b/analysis/src/main/scala/org/polystat/odin/analysis/mutualrec/naive/services/TopLevelObject.scala @@ -1,14 +1,16 @@ package org.polystat.odin.analysis.mutualrec.naive.services import cats.data.OptionT -import cats.effect.Sync import cats.effect.Ref +import cats.effect.Sync import cats.implicits._ -import org.polystat.odin.analysis.mutualrec.naive.exceptions.DuplicatedMethodAttributes -import MethodAttribute.createMethodAttribute import higherkindness.droste.data.Fix +import org.polystat.odin.analysis.mutualrec.naive.exceptions.DuplicatedMethodAttributes +import org.polystat.odin.core.ast.EOBndExpr +import org.polystat.odin.core.ast.EOObj import org.polystat.odin.core.ast.astparams.EOExprOnly -import org.polystat.odin.core.ast.{EOBndExpr, EOObj} + +import MethodAttribute.createMethodAttribute trait TopLevelObject[F[_]] { def objName: String diff --git a/analysis/src/main/scala/org/polystat/odin/analysis/mutualrec/naive/services/TopLevelObjects.scala b/analysis/src/main/scala/org/polystat/odin/analysis/mutualrec/naive/services/TopLevelObjects.scala index 9cb3a427..27f499ed 100644 --- a/analysis/src/main/scala/org/polystat/odin/analysis/mutualrec/naive/services/TopLevelObjects.scala +++ b/analysis/src/main/scala/org/polystat/odin/analysis/mutualrec/naive/services/TopLevelObjects.scala @@ -3,24 +3,21 @@ package org.polystat.odin.analysis.mutualrec.naive.services import cats.data.OptionT import cats.effect.Sync import cats.implicits._ -import org.polystat.odin.analysis.mutualrec.naive.exceptions.{ - DecorateeNotFound, - UnsupportedDecoration -} -import TopLevelObject.createTopLevelObject import higherkindness.droste.data.Fix +import org.polystat.odin.analysis.mutualrec.naive.exceptions.DecorateeNotFound +import org.polystat.odin.analysis.mutualrec.naive.exceptions.UnsupportedDecoration +import org.polystat.odin.core.ast.EOApp +import org.polystat.odin.core.ast.EOBndExpr +import org.polystat.odin.core.ast.EOCopy +import org.polystat.odin.core.ast.EODecoration +import org.polystat.odin.core.ast.EOObj +import org.polystat.odin.core.ast.EOSimpleApp import org.polystat.odin.core.ast.astparams.EOExprOnly -import org.polystat.odin.core.ast.{ - EOApp, - EOBndExpr, - EOCopy, - EODecoration, - EOObj, - EOSimpleApp -} import scala.annotation.tailrec +import TopLevelObject.createTopLevelObject + trait TopLevelObjects[F[_]] { def objects: F[Vector[TopLevelObject[F]]] def add(objName: String, obj: EOObj[EOExprOnly]): F[Unit] diff --git a/analysis/src/main/scala/org/polystat/odin/analysis/unjustifiedassumptions/Analyzer.scala b/analysis/src/main/scala/org/polystat/odin/analysis/unjustifiedassumptions/Analyzer.scala index 065ede9b..6f28dbf9 100644 --- a/analysis/src/main/scala/org/polystat/odin/analysis/unjustifiedassumptions/Analyzer.scala +++ b/analysis/src/main/scala/org/polystat/odin/analysis/unjustifiedassumptions/Analyzer.scala @@ -1,22 +1,20 @@ package org.polystat.odin.analysis.unjustifiedassumptions -import org.polystat.odin.analysis.utils.logicalextraction.SMTUtils.Info -import cats.data.{EitherNel, NonEmptyList => Nel} +import cats.data.EitherNel +import cats.data.{NonEmptyList => Nel} import cats.syntax.align._ import cats.syntax.traverse._ import org.polystat.odin.analysis.utils.inlining.Inliner.AnalysisInfo -import org.polystat.odin.analysis.utils.inlining.{ - MethodInfoForAnalysis, - ObjectTree -} -import org.polystat.odin.analysis.utils.logicalextraction.ExtractLogic.{ - checkImplication, - extractInfo, - mkEqualsBndAttr -} +import org.polystat.odin.analysis.utils.inlining.MethodInfoForAnalysis +import org.polystat.odin.analysis.utils.inlining.ObjectTree +import org.polystat.odin.analysis.utils.logicalextraction.ExtractLogic.checkImplication +import org.polystat.odin.analysis.utils.logicalextraction.ExtractLogic.extractInfo +import org.polystat.odin.analysis.utils.logicalextraction.ExtractLogic.mkEqualsBndAttr import org.polystat.odin.analysis.utils.logicalextraction.SMTUtils +import org.polystat.odin.analysis.utils.logicalextraction.SMTUtils.Info import org.polystat.odin.core.ast._ -import smtlib.theories.Core.{And, True} +import smtlib.theories.Core.And +import smtlib.theories.Core.True import smtlib.theories.Ints.IntSort import smtlib.trees.Terms._ diff --git a/analysis/src/main/scala/org/polystat/odin/analysis/utils/Abstract.scala b/analysis/src/main/scala/org/polystat/odin/analysis/utils/Abstract.scala index daec73a4..c8061413 100644 --- a/analysis/src/main/scala/org/polystat/odin/analysis/utils/Abstract.scala +++ b/analysis/src/main/scala/org/polystat/odin/analysis/utils/Abstract.scala @@ -1,12 +1,19 @@ package org.polystat.odin.analysis.utils -import cats.{Applicative, Eval, Foldable, Id, Monoid} +import cats.Applicative +import cats.Eval +import cats.Foldable +import cats.Id +import cats.Monoid +import cats.implicits.catsSyntaxSemigroup +import cats.implicits.toFoldableOps +import cats.implicits.toFunctorOps import com.github.tarao.nonempty.collection.NonEmpty import higherkindness.droste.data.Fix -import Optics.{lenses, traversals} -import cats.implicits.{catsSyntaxSemigroup, toFoldableOps, toFunctorOps} -import org.polystat.odin.core.ast.astparams.EOExprOnly import org.polystat.odin.core.ast._ +import org.polystat.odin.core.ast.astparams.EOExprOnly + +import Optics.{lenses, traversals} object Abstract { diff --git a/analysis/src/main/scala/org/polystat/odin/analysis/utils/Optics.scala b/analysis/src/main/scala/org/polystat/odin/analysis/utils/Optics.scala index 8a0bea69..1a9de60f 100644 --- a/analysis/src/main/scala/org/polystat/odin/analysis/utils/Optics.scala +++ b/analysis/src/main/scala/org/polystat/odin/analysis/utils/Optics.scala @@ -1,14 +1,19 @@ package org.polystat.odin.analysis.utils import cats.Applicative -import cats.implicits.{catsSyntaxTuple2Semigroupal, toFunctorOps, toTraverseOps} +import cats.implicits.catsSyntaxTuple2Semigroupal +import cats.implicits.toFunctorOps +import cats.implicits.toTraverseOps import com.github.tarao.nonempty.collection.NonEmpty import higherkindness.droste.data.Fix +import monocle.Lens +import monocle.Optional +import monocle.Prism +import monocle.Traversal import monocle.macros.GenLens -import monocle.{Lens, Optional, Prism, Traversal} import org.polystat.odin.analysis.utils.inlining.types.CopyArgs -import org.polystat.odin.core.ast.astparams.EOExprOnly import org.polystat.odin.core.ast._ +import org.polystat.odin.core.ast.astparams.EOExprOnly object Optics { diff --git a/analysis/src/main/scala/org/polystat/odin/analysis/utils/inlining/Inliner.scala b/analysis/src/main/scala/org/polystat/odin/analysis/utils/inlining/Inliner.scala index 4b5a118e..849d2e37 100644 --- a/analysis/src/main/scala/org/polystat/odin/analysis/utils/inlining/Inliner.scala +++ b/analysis/src/main/scala/org/polystat/odin/analysis/utils/inlining/Inliner.scala @@ -1,23 +1,27 @@ package org.polystat.odin.analysis.utils.inlining -import cats.data.{EitherNel, NonEmptyList => Nel} +import cats.data.EitherNel +import cats.data.{NonEmptyList => Nel} import cats.syntax.align._ import cats.syntax.apply._ import cats.syntax.either._ import cats.syntax.functor._ import cats.syntax.parallel._ import higherkindness.droste.data.Fix +import monocle.Iso +import monocle.Lens +import monocle.Optional import monocle.macros.GenLens -import monocle.{Iso, Lens, Optional} import org.polystat.odin.analysis.utils.Abstract.modifyExpr -import LocatorContext.setLocators -import LocateMethods._ import org.polystat.odin.analysis.utils.Optics._ import org.polystat.odin.core.ast._ import org.polystat.odin.core.ast.astparams.EOExprOnly import scala.annotation.tailrec +import LocatorContext.setLocators +import LocateMethods._ + object Inliner { /* The following steps are performed here diff --git a/analysis/src/main/scala/org/polystat/odin/analysis/utils/inlining/LocateCalls.scala b/analysis/src/main/scala/org/polystat/odin/analysis/utils/inlining/LocateCalls.scala index 3a609002..bf88a446 100644 --- a/analysis/src/main/scala/org/polystat/odin/analysis/utils/inlining/LocateCalls.scala +++ b/analysis/src/main/scala/org/polystat/odin/analysis/utils/inlining/LocateCalls.scala @@ -6,10 +6,11 @@ import monocle.Iso import org.polystat.odin.analysis.utils.Abstract.foldAst import org.polystat.odin.analysis.utils.Optics._ import org.polystat.odin.analysis.utils.inlining -import types._ import org.polystat.odin.core.ast._ import org.polystat.odin.core.ast.astparams.EOExprOnly +import types._ + object LocateCalls { def hasNoReferencesToPhi(binds: Vector[EOBnd[Fix[EOExpr]]]): Boolean = { diff --git a/analysis/src/main/scala/org/polystat/odin/analysis/utils/inlining/LocateMethods.scala b/analysis/src/main/scala/org/polystat/odin/analysis/utils/inlining/LocateMethods.scala index 63bc6d92..0fef8953 100644 --- a/analysis/src/main/scala/org/polystat/odin/analysis/utils/inlining/LocateMethods.scala +++ b/analysis/src/main/scala/org/polystat/odin/analysis/utils/inlining/LocateMethods.scala @@ -4,10 +4,11 @@ import cats.data.{NonEmptyList => Nel} import cats.syntax.foldable._ import higherkindness.droste.data.Fix import org.polystat.odin.analysis.ObjectName -import LocateCalls._ import org.polystat.odin.core.ast._ import org.polystat.odin.core.ast.astparams.EOExprOnly +import LocateCalls._ + object LocateMethods { def parseParentName( diff --git a/analysis/src/main/scala/org/polystat/odin/analysis/utils/inlining/LocatorContext.scala b/analysis/src/main/scala/org/polystat/odin/analysis/utils/inlining/LocatorContext.scala index 174e125e..47ef44bf 100644 --- a/analysis/src/main/scala/org/polystat/odin/analysis/utils/inlining/LocatorContext.scala +++ b/analysis/src/main/scala/org/polystat/odin/analysis/utils/inlining/LocatorContext.scala @@ -1,9 +1,10 @@ package org.polystat.odin.analysis.utils.inlining -import cats.data.{EitherNel, NonEmptyList => Nel} +import cats.data.EitherNel +import cats.data.{NonEmptyList => Nel} import higherkindness.droste.data.Fix -import org.polystat.odin.analysis.utils.Optics._ import org.polystat.odin.analysis.utils.Abstract.modifyExprWithState +import org.polystat.odin.analysis.utils.Optics._ import org.polystat.odin.core.ast._ import org.polystat.odin.core.ast.astparams.EOExprOnly diff --git a/analysis/src/main/scala/org/polystat/odin/analysis/utils/inlining/package.scala b/analysis/src/main/scala/org/polystat/odin/analysis/utils/inlining/package.scala index 4b4ba343..1535008f 100644 --- a/analysis/src/main/scala/org/polystat/odin/analysis/utils/inlining/package.scala +++ b/analysis/src/main/scala/org/polystat/odin/analysis/utils/inlining/package.scala @@ -6,13 +6,16 @@ import cats.syntax.apply._ import cats.syntax.foldable._ import cats.syntax.functor._ import cats.syntax.traverse._ -import types._ +import monocle.Optional +import org.polystat.odin.analysis.ObjectName import org.polystat.odin.backend.eolang.ToEO.instances._ import org.polystat.odin.backend.eolang.ToEO.ops._ +import org.polystat.odin.core.ast.EOBndExpr +import org.polystat.odin.core.ast.EONamedBnd +import org.polystat.odin.core.ast.EOObj import org.polystat.odin.core.ast.astparams.EOExprOnly -import org.polystat.odin.core.ast.{EOBndExpr, EONamedBnd, EOObj} -import monocle.Optional -import org.polystat.odin.analysis.ObjectName + +import types._ sealed trait BndPlaceholder final case class MethodPlaceholder(name: EONamedBnd) extends BndPlaceholder diff --git a/analysis/src/main/scala/org/polystat/odin/analysis/utils/inlining/types.scala b/analysis/src/main/scala/org/polystat/odin/analysis/utils/inlining/types.scala index 016d333f..08aa2580 100644 --- a/analysis/src/main/scala/org/polystat/odin/analysis/utils/inlining/types.scala +++ b/analysis/src/main/scala/org/polystat/odin/analysis/utils/inlining/types.scala @@ -2,7 +2,8 @@ package org.polystat.odin.analysis.utils.inlining import com.github.tarao.nonempty.collection.NonEmpty import monocle.Optional -import org.polystat.odin.core.ast.{EOBnd, EOObj} +import org.polystat.odin.core.ast.EOBnd +import org.polystat.odin.core.ast.EOObj import org.polystat.odin.core.ast.astparams.EOExprOnly object types { diff --git a/analysis/src/main/scala/org/polystat/odin/analysis/utils/logicalextraction/ExtractLogic.scala b/analysis/src/main/scala/org/polystat/odin/analysis/utils/logicalextraction/ExtractLogic.scala index 188ba1ab..f6462cb6 100644 --- a/analysis/src/main/scala/org/polystat/odin/analysis/utils/logicalextraction/ExtractLogic.scala +++ b/analysis/src/main/scala/org/polystat/odin/analysis/utils/logicalextraction/ExtractLogic.scala @@ -2,7 +2,8 @@ package org.polystat.odin.analysis.utils.logicalextraction import ap.SimpleAPI import ap.SimpleAPI.FunctionalityMode -import cats.data.{EitherNel, NonEmptyList => Nel} +import cats.data.EitherNel +import cats.data.{NonEmptyList => Nel} import cats.syntax.either._ import cats.syntax.traverse._ import higherkindness.droste.data.Fix diff --git a/analysis/src/main/scala/org/polystat/odin/analysis/utils/logicalextraction/SMTUtils.scala b/analysis/src/main/scala/org/polystat/odin/analysis/utils/logicalextraction/SMTUtils.scala index 453d9dec..5e516a2a 100644 --- a/analysis/src/main/scala/org/polystat/odin/analysis/utils/logicalextraction/SMTUtils.scala +++ b/analysis/src/main/scala/org/polystat/odin/analysis/utils/logicalextraction/SMTUtils.scala @@ -1,22 +1,21 @@ package org.polystat.odin.analysis.utils.logicalextraction import org.polystat.odin.core.ast.EONamedBnd -import smtlib.theories.Core.{BoolSort, True} +import smtlib.theories.Core.BoolSort +import smtlib.theories.Core.True import smtlib.theories.Ints.IntSort import smtlib.trees.Commands.FunDef -import smtlib.trees.Terms.{ - Exists, - Forall, - FunctionApplication, - Identifier, - Let, - QualifiedIdentifier, - SNumeral, - SSymbol, - SimpleIdentifier, - SortedVar, - Term -} +import smtlib.trees.Terms.Exists +import smtlib.trees.Terms.Forall +import smtlib.trees.Terms.FunctionApplication +import smtlib.trees.Terms.Identifier +import smtlib.trees.Terms.Let +import smtlib.trees.Terms.QualifiedIdentifier +import smtlib.trees.Terms.SNumeral +import smtlib.trees.Terms.SSymbol +import smtlib.trees.Terms.SimpleIdentifier +import smtlib.trees.Terms.SortedVar +import smtlib.trees.Terms.Term import scala.annotation.tailrec diff --git a/analysis/src/test/scala/org/polystat/odin/analysis/DetectStateAccessTests.scala b/analysis/src/test/scala/org/polystat/odin/analysis/DetectStateAccessTests.scala index 4870c4d5..afef963f 100644 --- a/analysis/src/test/scala/org/polystat/odin/analysis/DetectStateAccessTests.scala +++ b/analysis/src/test/scala/org/polystat/odin/analysis/DetectStateAccessTests.scala @@ -1,10 +1,11 @@ package org.polystat.odin.analysis import cats.effect._ -import org.scalatest.wordspec.AnyWordSpec -import org.polystat.odin.parser.EoParser.sourceCodeEoParser import cats.effect.unsafe.implicits.global import org.polystat.odin.analysis.EOOdinAnalyzer.directStateAccessAnalyzer +import org.polystat.odin.parser.EoParser.sourceCodeEoParser +import org.scalatest.wordspec.AnyWordSpec + import EOOdinAnalyzer.OdinAnalysisResult._ class DetectStateAccessTests extends AnyWordSpec { diff --git a/analysis/src/test/scala/org/polystat/odin/analysis/LiskovPrincipleTests.scala b/analysis/src/test/scala/org/polystat/odin/analysis/LiskovPrincipleTests.scala index 810f5026..05325446 100644 --- a/analysis/src/test/scala/org/polystat/odin/analysis/LiskovPrincipleTests.scala +++ b/analysis/src/test/scala/org/polystat/odin/analysis/LiskovPrincipleTests.scala @@ -1,11 +1,12 @@ package org.polystat.odin.analysis import cats.effect._ -import org.scalatest.wordspec.AnyWordSpec -import EOOdinAnalyzer.liskovPrincipleViolationAnalyzer -import org.polystat.odin.parser.EoParser.sourceCodeEoParser import cats.effect.unsafe.implicits.global import org.polystat.odin.analysis.EOOdinAnalyzer.OdinAnalysisResult._ +import org.polystat.odin.parser.EoParser.sourceCodeEoParser +import org.scalatest.wordspec.AnyWordSpec + +import EOOdinAnalyzer.liskovPrincipleViolationAnalyzer class LiskovPrincipleTests extends AnyWordSpec { diff --git a/analysis/src/test/scala/org/polystat/odin/analysis/MutualrecTests.scala b/analysis/src/test/scala/org/polystat/odin/analysis/MutualrecTests.scala index 39ef219b..2dd37824 100644 --- a/analysis/src/test/scala/org/polystat/odin/analysis/MutualrecTests.scala +++ b/analysis/src/test/scala/org/polystat/odin/analysis/MutualrecTests.scala @@ -1,9 +1,11 @@ package org.polystat.odin.analysis import cats.data.NonEmptyList +import cats.effect.IO +import cats.effect.Sync import cats.effect.unsafe.implicits.global -import cats.effect.{IO, Sync} -import cats.parse.{Parser => P, Parser0 => P0} +import cats.parse.{Parser => P} +import cats.parse.{Parser0 => P0} import cats.syntax.functor._ import fs2.io.file.Files import org.polystat.odin.analysis.gens.MutualRecursionTestGen.genProgram @@ -12,7 +14,9 @@ import org.polystat.odin.analysis.mutualrec.advanced.CallGraph._ import org.polystat.odin.analysis.mutualrec.advanced.Program._ import org.polystat.odin.parser.eo.Parser import org.polystat.odin.utils.files -import org.scalacheck.{Gen, Prop, Test} +import org.scalacheck.Gen +import org.scalacheck.Prop +import org.scalacheck.Test import org.scalatest.Assertion import org.scalatest.wordspec.AnyWordSpec import org.scalatestplus.scalacheck.Checkers diff --git a/analysis/src/test/scala/org/polystat/odin/analysis/UnjustifiedAssumptionTests.scala b/analysis/src/test/scala/org/polystat/odin/analysis/UnjustifiedAssumptionTests.scala index 5555ba8e..c7fa1408 100644 --- a/analysis/src/test/scala/org/polystat/odin/analysis/UnjustifiedAssumptionTests.scala +++ b/analysis/src/test/scala/org/polystat/odin/analysis/UnjustifiedAssumptionTests.scala @@ -1,11 +1,12 @@ package org.polystat.odin.analysis import cats.effect._ -import org.scalatest.wordspec.AnyWordSpec -import EOOdinAnalyzer.unjustifiedAssumptionAnalyzer -import org.polystat.odin.parser.EoParser.sourceCodeEoParser import cats.effect.unsafe.implicits.global import org.polystat.odin.analysis.EOOdinAnalyzer.OdinAnalysisResult._ +import org.polystat.odin.parser.EoParser.sourceCodeEoParser +import org.scalatest.wordspec.AnyWordSpec + +import EOOdinAnalyzer.unjustifiedAssumptionAnalyzer class UnjustifiedAssumptionTests extends AnyWordSpec { @@ -274,10 +275,6 @@ class UnjustifiedAssumptionTests extends AnyWordSpec { "not find errors" should { runTests(testCasesWithoutErrors) } - -// "fail" should { -// assert(true) -// } } } diff --git a/analysis/src/test/scala/org/polystat/odin/analysis/gens/MutualRecursionTestGen.scala b/analysis/src/test/scala/org/polystat/odin/analysis/gens/MutualRecursionTestGen.scala index daafa85b..98bb5a99 100644 --- a/analysis/src/test/scala/org/polystat/odin/analysis/gens/MutualRecursionTestGen.scala +++ b/analysis/src/test/scala/org/polystat/odin/analysis/gens/MutualRecursionTestGen.scala @@ -5,12 +5,13 @@ import cats.effect.kernel.Sync import cats.effect.unsafe.implicits.global import cats.syntax.flatMap._ import fs2.Stream -import fs2.io.file.{Files, Path} +import fs2.io.file.Files +import fs2.io.file.Path import fs2.text.utf8 +import org.polystat.odin.analysis.ObjectName import org.polystat.odin.analysis.mutualrec.advanced.CallGraph._ import org.polystat.odin.analysis.mutualrec.advanced.Program._ import org.scalacheck.Gen -import org.polystat.odin.analysis.ObjectName import scala.util.Try diff --git a/analysis/src/test/scala/org/polystat/odin/analysis/inlining/InlineCallsTestCases.scala b/analysis/src/test/scala/org/polystat/odin/analysis/inlining/InlineCallsTestCases.scala index ffe17134..6bc20810 100644 --- a/analysis/src/test/scala/org/polystat/odin/analysis/inlining/InlineCallsTestCases.scala +++ b/analysis/src/test/scala/org/polystat/odin/analysis/inlining/InlineCallsTestCases.scala @@ -1,8 +1,8 @@ package org.polystat.odin.analysis.inlining import cats.data.EitherNel -import cats.syntax.either._ import cats.data.{NonEmptyList => Nel} +import cats.syntax.either._ object InlineCallsTestCases { diff --git a/analysis/src/test/scala/org/polystat/odin/analysis/inlining/InliningTests.scala b/analysis/src/test/scala/org/polystat/odin/analysis/inlining/InliningTests.scala index 65131910..538e9432 100644 --- a/analysis/src/test/scala/org/polystat/odin/analysis/inlining/InliningTests.scala +++ b/analysis/src/test/scala/org/polystat/odin/analysis/inlining/InliningTests.scala @@ -1,15 +1,17 @@ package org.polystat.odin.analysis.inlining +import cats.data.EitherNel +import cats.data.{NonEmptyList => Nel} +import cats.syntax.either._ +import org.polystat.odin.analysis.utils.inlining.Inliner +import org.polystat.odin.analysis.utils.inlining.LocatorContext import org.polystat.odin.backend.eolang.ToEO.instances._ import org.polystat.odin.backend.eolang.ToEO.ops._ import org.polystat.odin.parser.eo.Parser import org.scalatest.wordspec.AnyWordSpec + import SetLocatorsTestCases._ import InlineCallsTestCases._ -import cats.syntax.either._ -import cats.syntax.traverse._ -import cats.data.{EitherNel, NonEmptyList => Nel} -import org.polystat.odin.analysis.utils.inlining.{Inliner, LocatorContext} // import org.polystat.odin.core.ast._ class InliningTests extends AnyWordSpec { @@ -61,17 +63,6 @@ class InliningTests extends AnyWordSpec { .leftMap(Nel.one) .flatMap(Inliner.inlineAllCalls) .map(_.toEOPretty) - - println( - Parser - .parse(before) - .leftMap(Nel.one) - .flatMap(Inliner.createObjectTree) - .flatMap( - _.toList.traverse(kv => Inliner.zipWithInlinedMethod(kv._2)) - ) - ) - assert(obtained == expected) } diff --git a/analysis/src/test/scala/org/polystat/odin/analysis/inlining/LocateCallsTests.scala b/analysis/src/test/scala/org/polystat/odin/analysis/inlining/LocateCallsTests.scala index 8416f497..09f7a384 100644 --- a/analysis/src/test/scala/org/polystat/odin/analysis/inlining/LocateCallsTests.scala +++ b/analysis/src/test/scala/org/polystat/odin/analysis/inlining/LocateCallsTests.scala @@ -3,11 +3,11 @@ package org.polystat.odin.analysis.inlining import higherkindness.droste.data.Fix import org.polystat.odin.analysis.utils.inlining.LocateCalls.parseMethod import org.polystat.odin.analysis.utils.inlining.MethodInfo +import org.polystat.odin.backend.eolang.ToEO.instances._ +import org.polystat.odin.backend.eolang.ToEO.ops._ import org.polystat.odin.core.ast._ import org.polystat.odin.core.ast.astparams.EOExprOnly import org.polystat.odin.parser.eo.Parser -import org.polystat.odin.backend.eolang.ToEO.ops._ -import org.polystat.odin.backend.eolang.ToEO.instances._ object LocateCallsTests { diff --git a/analysis/src/test/scala/org/polystat/odin/analysis/inlining/SetLocatorsTestCases.scala b/analysis/src/test/scala/org/polystat/odin/analysis/inlining/SetLocatorsTestCases.scala index 6a429a61..0c6aa8fb 100644 --- a/analysis/src/test/scala/org/polystat/odin/analysis/inlining/SetLocatorsTestCases.scala +++ b/analysis/src/test/scala/org/polystat/odin/analysis/inlining/SetLocatorsTestCases.scala @@ -1,6 +1,7 @@ package org.polystat.odin.analysis.inlining -import cats.data.{EitherNel, NonEmptyList => Nel} +import cats.data.EitherNel +import cats.data.{NonEmptyList => Nel} import cats.syntax.either._ object SetLocatorsTestCases { diff --git a/build.sbt b/build.sbt index 73837d21..29ed2ace 100644 --- a/build.sbt +++ b/build.sbt @@ -19,6 +19,7 @@ ThisBuild / releaseVersionBump := sbtrelease.Version.Bump.Next ThisBuild / semanticdbEnabled := true ThisBuild / semanticdbVersion := scalafixSemanticdb.revision ThisBuild / scalafixScalaBinaryVersion := "2.13" +ThisBuild / scalafixDependencies += "com.github.liancheng" %% "organize-imports" % "0.6.0" lazy val noPublishSettings = Seq( publish := {}, diff --git a/project/Compiler.scala b/project/Compiler.scala index e38f1d27..47588320 100644 --- a/project/Compiler.scala +++ b/project/Compiler.scala @@ -11,32 +11,48 @@ object Compiler { "-feature", /* Emit warning and location for usages of features that should be imported * explicitly. */ - "-language:existentials", // Existential types (besides wildcard types) can be written and inferred - "-language:experimental.macros", // Allow macro definition (besides implementation and application) + "-language:existentials", /* Existential types (besides wildcard types) can + * be written and inferred */ + "-language:experimental.macros", /* Allow macro definition (besides + * implementation and application) */ "-language:higherKinds", // Allow higher-kinded types - "-language:implicitConversions", // Allow definition of implicit functions called views - "-unchecked", // Enable additional warnings where generated code depends on assumptions. - "-Xcheckinit", // Wrap field accessors to throw an exception on uninitialized access. + "-language:implicitConversions", /* Allow definition of implicit functions + * called views */ + "-unchecked", /* Enable additional warnings where generated code depends on + * assumptions. */ + "-Xcheckinit", /* Wrap field accessors to throw an exception on + * uninitialized access. */ "-Xfatal-warnings", // Fail the compilation if there are any warnings. // "-Xfuture", // Turn on future language features. - "-Xlint:adapted-args", // Warn if an argument list is modified to match the receiver. - "-Xlint:constant", // Evaluation of a constant arithmetic expression results in an error. + "-Xlint:adapted-args", /* Warn if an argument list is modified to match the + * receiver. */ + "-Xlint:constant", /* Evaluation of a constant arithmetic expression results + * in an error. */ "-Xlint:delayedinit-select", // Selecting member of DelayedInit. - "-Xlint:doc-detached", // A Scaladoc comment appears to be detached from its element. - "-Xlint:inaccessible", // Warn about inaccessible types in method signatures. + "-Xlint:doc-detached", /* A Scaladoc comment appears to be detached from its + * element. */ + "-Xlint:inaccessible", /* Warn about inaccessible types in method + * signatures. */ "-Xlint:infer-any", // Warn when a type argument is inferred to be `Any`. - "-Xlint:missing-interpolator", // A string literal appears to be missing an interpolator id. + "-Xlint:missing-interpolator", /* A string literal appears to be missing an + * interpolator id. */ "-Xlint:nullary-unit", // Warn when nullary methods return Unit. "-Xlint:option-implicit", // Option.apply used implicit view. - "-Xlint:package-object-classes", // Class or object defined in package object. - "-Xlint:poly-implicit-overload", // Parameterized overloaded implicit methods are not visible as view bounds. - "-Xlint:private-shadow", // A private field (or class parameter) shadows a superclass field. - "-Xlint:stars-align", // Pattern sequence wildcard must align with sequence component. - "-Xlint:type-parameter-shadow", // A local type parameter shadows a type already in scope. + "-Xlint:package-object-classes", /* Class or object defined in package + * object. */ + "-Xlint:poly-implicit-overload", /* Parameterized overloaded implicit + * methods are not visible as view bounds. */ + "-Xlint:private-shadow", /* A private field (or class parameter) shadows a + * superclass field. */ + "-Xlint:stars-align", /* Pattern sequence wildcard must align with sequence + * component. */ + "-Xlint:type-parameter-shadow", /* A local type parameter shadows a type + * already in scope. */ "-Xlint:adapted-args", /* Do not adapt an argument list (either by inserting () or creating a * tuple) to match the receiver. */ - "-Xlint:inaccessible", // Warn about inaccessible types in method signatures. + "-Xlint:inaccessible", /* Warn about inaccessible types in method + * signatures. */ "-Xlint:infer-any", // Warn when a type argument is inferred to be `Any`. "-Xlint:nullary-unit", // Warn when nullary methods return Unit. // "-Xlint:nullary-override", // Warn when non-nullary `def f()' overrides @@ -47,7 +63,8 @@ object Compiler { // "-Ypartial-unification", // Enable partial unification in type // constructor inference "-Ywarn-dead-code", // Warn when dead code is identified. - "-Ywarn-extra-implicit", // Warn when more than one implicit parameter section is defined. + "-Ywarn-extra-implicit", /* Warn when more than one implicit parameter + * section is defined. */ // "-Ywarn-nullary-override", // Warn when non-nullary `def f()' overrides // nullary `def f'. "-Ywarn-numeric-widen", // Warn when numerics are widened. diff --git a/sandbox/src/main/scala/org/polystat/odin/sandbox/programs.scala b/sandbox/src/main/scala/org/polystat/odin/sandbox/programs.scala index 53f699fc..37e01778 100644 --- a/sandbox/src/main/scala/org/polystat/odin/sandbox/programs.scala +++ b/sandbox/src/main/scala/org/polystat/odin/sandbox/programs.scala @@ -7,12 +7,19 @@ import org.polystat.odin.core.ast.astparams.EOExprOnly import org.polystat.odin.core.ast._ object programs { + val mutualRecursionExample: EOProg[EOExprOnly] = EOProg( EOMetas( pack = Some("sandbox"), metas = Vector( - EOAliasMeta(Some("stdout"), NonEmptyList("org", List("eolang", "io", "stdout"))), - EOAliasMeta(Some("sprintf"), NonEmptyList("org", List("eolang", "txt", "sprintf"))), + EOAliasMeta( + Some("stdout"), + NonEmptyList("org", List("eolang", "io", "stdout")) + ), + EOAliasMeta( + Some("sprintf"), + NonEmptyList("org", List("eolang", "txt", "sprintf")) + ), ) ), Vector( @@ -38,7 +45,9 @@ object programs { EODecoration, Fix[EOExpr]( EOCopy( - Fix[EOExpr](EODot(Fix[EOExpr](EOSimpleApp("x")), "write")), + Fix[EOExpr]( + EODot(Fix[EOExpr](EOSimpleApp("x")), "write") + ), NonEmpty[Vector[EOBnd[EOExprOnly]]]( EOAnonExpr(Fix[EOExpr](EOSimpleApp("v"))) ) @@ -60,7 +69,9 @@ object programs { EODecoration, Fix[EOExpr]( EOCopy( - Fix[EOExpr](EODot(Fix[EOExpr](EOSimpleApp("self")), "f")), + Fix[EOExpr]( + EODot(Fix[EOExpr](EOSimpleApp("self")), "f") + ), NonEmpty[Vector[EOBnd[EOExprOnly]]]( EOAnonExpr(Fix[EOExpr](EOSimpleApp("self"))), EOAnonExpr(Fix[EOExpr](EOSimpleApp("v"))) @@ -76,8 +87,6 @@ object programs { ) ) ), - - EOBndExpr( EOAnyNameBnd(LazyName("derived")), Fix[EOExpr]( @@ -97,7 +106,9 @@ object programs { EODecoration, Fix[EOExpr]( EOCopy( - Fix[EOExpr](EODot(Fix[EOExpr](EOSimpleApp("self")), "g")), + Fix[EOExpr]( + EODot(Fix[EOExpr](EOSimpleApp("self")), "g") + ), NonEmpty[Vector[EOBnd[EOExprOnly]]]( EOAnonExpr(Fix[EOExpr](EOSimpleApp("self"))), EOAnonExpr(Fix[EOExpr](EOSimpleApp("v"))) @@ -115,4 +126,5 @@ object programs { ), ) ) + }