scala-named-argument-compiler-plugin


License

License

MIT
Categories

Categories

Scala Languages
GroupId

GroupId

io.github.givesocialmovement
ArtifactId

ArtifactId

scala-named-argument-compiler-plugin_2.12
Last Version

Last Version

0.1.1
Release Date

Release Date

Type

Type

jar
Description

Description

scala-named-argument-compiler-plugin
scala-named-argument-compiler-plugin
Project URL

Project URL

https://github.com/GIVESocialMovement/scala-named-argument-compiler-plugin
Project Organization

Project Organization

io.github.givesocialmovement
Source Code Management

Source Code Management

https://github.com/GIVESocialMovement/scala-named-argument-compiler-plugin

Download scala-named-argument-compiler-plugin_2.12

How to add to project

<!-- https://jarcasting.com/artifacts/io.github.givesocialmovement/scala-named-argument-compiler-plugin_2.12/ -->
<dependency>
    <groupId>io.github.givesocialmovement</groupId>
    <artifactId>scala-named-argument-compiler-plugin_2.12</artifactId>
    <version>0.1.1</version>
</dependency>
// https://jarcasting.com/artifacts/io.github.givesocialmovement/scala-named-argument-compiler-plugin_2.12/
implementation 'io.github.givesocialmovement:scala-named-argument-compiler-plugin_2.12:0.1.1'
// https://jarcasting.com/artifacts/io.github.givesocialmovement/scala-named-argument-compiler-plugin_2.12/
implementation ("io.github.givesocialmovement:scala-named-argument-compiler-plugin_2.12:0.1.1")
'io.github.givesocialmovement:scala-named-argument-compiler-plugin_2.12:jar:0.1.1'
<dependency org="io.github.givesocialmovement" name="scala-named-argument-compiler-plugin_2.12" rev="0.1.1">
  <artifact name="scala-named-argument-compiler-plugin_2.12" type="jar" />
</dependency>
@Grapes(
@Grab(group='io.github.givesocialmovement', module='scala-named-argument-compiler-plugin_2.12', version='0.1.1')
)
libraryDependencies += "io.github.givesocialmovement" % "scala-named-argument-compiler-plugin_2.12" % "0.1.1"
[io.github.givesocialmovement/scala-named-argument-compiler-plugin_2.12 "0.1.1"]

Dependencies

compile (3)

Group / Artifact Type Version
org.scala-lang : scala-compiler jar 2.12.8
org.scala-lang : scala-compiler jar 2.12.8
org.scala-lang : scala-library jar 2.12.8

Project Modules

There are no modules declared in this project.

scala-named-argument-compiler-plugin

This compiler plugin enables you to enforce named arguments on on certain methods' invocations.

If you would like to enforce named arguments on all method invocations, then it is better to use scalastyle.

Usage

In your build.sbt, add:

resolvers += Resolver.bintrayRepo("givers", "maven")

scalacOptions ++= Seq(
  "-P:named-argument:annotation:framework.ForceNamedArgument"    // Enforce certain method invocations with named arguments
)

addCompilerPlugin("givers.scala.namedargument" %% "scala-named-argument-compiler-plugin" % "0.1.0")

Notice that -P:named-argument:annotation: (in scalacOptions) points the class framework.ForceNamedArgument (You can change this class to your liking).

With the scalacOptions above, please add the below class to your project:

package framework

import scala.annotation.StaticAnnotation

class ForceNamedArgument extends StaticAnnotation

Then, for any method that you would like to enforce named arguments, you can annotate the method with @ForceNamedArgument as shown below:

@framework.ForceNamedArgument
def toJson(showName: Boolean = true, showSecret: Boolean = false): JsValue = { ... }
io.github.givesocialmovement

GIVEasia

Where Givers code. Come say hi at https://gitter.im/GIVE-asia/Lobby

Versions

Version
0.1.1