Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Scala 3.0.0-RC1 #457

Merged
merged 1 commit into from
Feb 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ jobs:
- "'++2.11.12 test'"
- "'++2.12.13 test' scripted"
- "'++2.13.4 test'"
- "'++3.0.0-M2 test'"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

munit dropped support, so we can still support M2 for Metals, but not give any guarantees

- "'++3.0.0-M3 test'"
- "'++3.0.0-RC1 test'"
steps:
- uses: actions/checkout@v2
- uses: olafurpg/setup-scala@v10
Expand Down
1 change: 1 addition & 0 deletions bin/test-release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ coursier fetch \
org.scalameta:mdoc_2.13:$version \
org.scalameta:mdoc_3.0.0-M2:$version \
org.scalameta:mdoc_3.0.0-M3:$version \
org.scalameta:mdoc_3.0.0-RC1:$version \
org.scalameta:mdoc-js_2.11:$version \
org.scalameta:mdoc-js_2.12.12:$version \
org.scalameta:mdoc-js_2.12:$version \
Expand Down
4 changes: 2 additions & 2 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ def scala212 = "2.12.13"
def scala212Legacy = "2.12.12"
def scala211 = "2.11.12"
def scala213 = "2.13.4"
def scala3 = List("3.0.0-M3", "3.0.0-M2")
def scala3 = List("3.0.0-RC1", "3.0.0-M3", "3.0.0-M2")

def scalajs = "1.3.0"
def scalajsBinaryVersion = "1"
Expand Down Expand Up @@ -113,7 +113,7 @@ lazy val sharedSettings = List(

val V = new {
val scalameta = "4.4.7"
val munit = "0.7.21"
val munit = "0.7.22"
val coursier = "1.0.2"
val scalacheck = "1.15.2"
}
Expand Down
12 changes: 1 addition & 11 deletions mdoc/src/main/scala-3/mdoc/internal/markdown/SectionInput.scala
Original file line number Diff line number Diff line change
Expand Up @@ -42,18 +42,8 @@ case class SectionInput(input : Input, mod : Modifier, context : MContext){
def show(tree : Tree, currentIdent : Int) = {
val str = tree.sourcePos(using ctx).start
val end = tree.sourcePos(using ctx).end
// workaround should be removed once support for 0.26.0 is dropped
val prefix = if (BuildInfo.scalaBinaryVersion == "0.26")
tree match {
case ext: ExtMethods if ext.tparams.nonEmpty =>
"extension ["
case _: ExtMethods =>
"extension ("
case _ => ""
}
else ""
val realIdent = " " * (currentIdent - wrapIdent.size)
prefix + sourceCode.substring(str, end).replace("\n", "\n" + realIdent)
sourceCode.substring(str, end).replace("\n", "\n" + realIdent)
}
def text = source.show(using driver.currentCtx)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package mdoc.internal.pprint

import scala.language.implicitConversions
import scala.quoted._
import scala.quoted.runtime.impl.printers.SyntaxHighlight

trait TPrint[T]{
def render: String
}

object TPrint {
inline given default[T]: TPrint[T] = ${ TypePrinter.typeString[T] }
}

object TypePrinter{

def typeString[T](using ctx: Quotes, tpe: Type[T]): Expr[TPrint[T]] = {
import ctx.reflect._

val valueType = TypeTree.of[T](using tpe).tpe.show(using Printer.TypeReprShortCode)

'{ new TPrint[T]{ def render: String = ${ Expr(valueType) } } }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package mdoc.internal.sourcecode

import scala.language.implicitConversions
import scala.quoted._

trait StatementMacro {
inline implicit def generate[T](v: => T): SourceStatement[T] = ${ Macros.text('v) }
inline def apply[T](v: => T): SourceStatement[T] = ${ Macros.text('v) }
}

object Macros{

def text[T: Type](v: Expr[T])(using ctx: Quotes): Expr[SourceStatement[T]] = {
import ctx.reflect.{_, given}
val txt = v.asTerm.pos.sourceCode.getOrElse("")
'{SourceStatement[T]($v, ${Expr(txt)})}
}
}