Skip to content

Commit

Permalink
Add more rewrites
Browse files Browse the repository at this point in the history
  • Loading branch information
armanbilge committed Dec 2, 2023
1 parent 2dbc728 commit 567b05c
Show file tree
Hide file tree
Showing 8 changed files with 82 additions and 46 deletions.
3 changes: 2 additions & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -227,11 +227,12 @@ lazy val scalafix = tlScalafixProject
libraryDependencies += "org.typelevel" %%% "feral-lambda-http4s" % "0.2.4",
headerSources / excludeFilter := AllPassFilter
)
.inputConfigure(_.disablePlugins(ScalafixPlugin))
.outputSettings(
crossScalaVersions := Seq(Scala213),
headerSources / excludeFilter := AllPassFilter
)
.outputConfigure(_.dependsOn(lambdaHttp4s.jvm))
.outputConfigure(_.dependsOn(lambdaHttp4s.jvm).disablePlugins(ScalafixPlugin))
.testsSettings(
startYear := Some(2023),
crossScalaVersions := Seq(Scala212)
Expand Down

This file was deleted.

27 changes: 27 additions & 0 deletions scalafix/input/src/main/scala/example/V0_3_0Rewrites.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/* rule=V0_3_0Rewrites */

package example

import feral.lambda.LambdaEnv
import feral.lambda.ApiGatewayProxyLambdaEnv
import feral.lambda.DynamoDbStreamLambdaEnv
import feral.lambda.S3BatchLambdaEnv
import feral.lambda.SnsLambdaEnv
import feral.lambda.SqsLambdaEnv
import feral.lambda.events.APIGatewayProxyRequestEvent
import feral.lambda.events.APIGatewayProxyResponseEvent

class Foo[F[_], E] {

def bar(implicit env: LambdaEnv[F, E]): Unit = ???

}

object Handlers {
def handler1[F[_]](implicit env: ApiGatewayProxyLambdaEnv[F]): Unit = ???
def handler2[F[_]](implicit env: DynamoDbStreamLambdaEnv[F]): Unit = ???
def handler3[F[_]](implicit env: S3BatchLambdaEnv[F]): Unit = ???
def handler4[F[_]](implicit env: SnsLambdaEnv[F]): Unit = ???
def handler5[F[_]](implicit env: SqsLambdaEnv[F]): Unit = ???
def handler6(event: APIGatewayProxyRequestEvent): APIGatewayProxyResponseEvent = ???
}

This file was deleted.

19 changes: 19 additions & 0 deletions scalafix/output/src/main/scala/example/V0_3_0Rewrites.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package example

import feral.lambda.{ ApiGatewayProxyV2Invocation, DynamoDbStreamInvocation, Invocation, S3BatchInvocation, SnsInvocation, SqsInvocation }
import feral.lambda.events.{ ApiGatewayProxyEvent, ApiGatewayProxyResult }

class Foo[F[_], E] {

def bar(implicit env: Invocation[F, E]): Unit = ???

}

object Handlers {
def handler1[F[_]](implicit env: ApiGatewayProxyV2Invocation[F]): Unit = ???
def handler2[F[_]](implicit env: DynamoDbStreamInvocation[F]): Unit = ???
def handler3[F[_]](implicit env: S3BatchInvocation[F]): Unit = ???
def handler4[F[_]](implicit env: SnsInvocation[F]): Unit = ???
def handler5[F[_]](implicit env: SqsInvocation[F]): Unit = ???
def handler6(event: ApiGatewayProxyEvent): ApiGatewayProxyResult = ???
}
Original file line number Diff line number Diff line change
@@ -1 +1 @@
feral.scalafix.RenameLambdaEnvToInvocation
feral.scalafix.V0_3_0Rewrites

This file was deleted.

33 changes: 33 additions & 0 deletions scalafix/rules/src/main/scala/feral/scalafix/V0_3_0Rewrites.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* Copyright 2023 Typelevel
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package feral.scalafix

import scalafix.v1._

class V0_3_0Rewrites extends SemanticRule("V0_3_0Rewrites") {
override def fix(implicit doc: SemanticDocument): Patch =
Patch.replaceSymbols(
"feral.lambda.LambdaEnv" -> "feral.lambda.Invocation",
"feral.lambda.ApiGatewayProxyLambdaEnv" -> "feral.lambda.ApiGatewayProxyV2Invocation",
"feral.lambda.DynamoDbStreamLambdaEnv" -> "feral.lambda.DynamoDbStreamInvocation",
"feral.lambda.S3BatchLambdaEnv" -> "feral.lambda.S3BatchInvocation",
"feral.lambda.SnsLambdaEnv" -> "feral.lambda.SnsInvocation",
"feral.lambda.SqsLambdaEnv" -> "feral.lambda.SqsInvocation",
"feral.lambda.events.APIGatewayProxyRequestEvent" -> "feral.lambda.events.ApiGatewayProxyEvent",
"feral.lambda.events.APIGatewayProxyResponseEvent" -> "feral.lambda.events.ApiGatewayProxyResult"
)
}

0 comments on commit 567b05c

Please sign in to comment.