Skip to content

Commit adde57a

Browse files
committed
Remove snippet context feature
1 parent b2869dc commit adde57a

20 files changed

+42
-184
lines changed

library/src/scala/quoted/Exprs.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ object Exprs:
55
/** Matches literal sequence of literal constant value expressions and return a sequence of values.
66
*
77
* Usage:
8-
* ```scala sc:macrocompile
8+
* ```scala
99
* inline def sum(args: Int*): Int = ${ sumExpr('args) }
1010
* def sumExpr(argsExpr: Expr[Seq[Int]])(using Quotes): Expr[Int] = argsExpr match
1111
* case Varargs(Exprs(args)) => ???

library/src/scala/quoted/Varargs.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ object Varargs {
3535
/** Matches a literal sequence of expressions and return a sequence of expressions.
3636
*
3737
* Usage:
38-
* ```scala sc:macrocompile
38+
* ```scala
3939
* inline def sum(args: Int*): Int = ${ sumExpr('args) }
4040
* def sumExpr(argsExpr: Expr[Seq[Int]])(using Quotes): Expr[Int] = argsExpr match
4141
* case Varargs(argVarargs) => ???

scaladoc-testcases/src/tests/snippetCompilerTests.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ class A {
5555
class B { }
5656

5757
/**
58-
* ```scala sc:macrocompile
58+
* ```scala
5959
* import scala.quoted._
6060
* inline def sum(args: Int*): Int = ${ sumExpr('args) }
6161
* def sumExpr(argsExpr: Expr[Seq[Int]])(using Quotes): Expr[Int] = argsExpr match

scaladoc-testcases/src/tests/snippetTestcase1.scala

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package tests.snippetTestcase1
22

33
class SnippetTestcase1:
44
/**
5-
* SNIPPET(OUTERLINEOFFSET:8,OUTERCOLUMNOFFSET:6,INNERLINEOFFSET:5,INNERCOLUMNOFFSET:2)
5+
* SNIPPET(OUTERLINEOFFSET:7,OUTERCOLUMNOFFSET:6,INNERLINEOFFSET:4,INNERCOLUMNOFFSET:2)
66
* ERROR(LINE:8,COLUMN:8)
77
* ```scala sc:fail
88
* 2 + List()
@@ -11,19 +11,19 @@ class SnippetTestcase1:
1111
*/
1212
def a = 3
1313
/**
14-
* SNIPPET(OUTERLINEOFFSET:16,OUTERCOLUMNOFFSET:6,INNERLINEOFFSET:5,INNERCOLUMNOFFSET:2)
14+
* SNIPPET(OUTERLINEOFFSET:15,OUTERCOLUMNOFFSET:6,INNERLINEOFFSET:4,INNERCOLUMNOFFSET:2)
1515
* ```scala sc:compile sc-name:1
1616
* val xs: List[Int] = List()
1717
* ```
1818
*
19-
* SNIPPET(OUTERLINEOFFSET:21,OUTERCOLUMNOFFSET:6,INNERLINEOFFSET:5,INNERCOLUMNOFFSET:2)
19+
* SNIPPET(OUTERLINEOFFSET:20,OUTERCOLUMNOFFSET:6,INNERLINEOFFSET:4,INNERCOLUMNOFFSET:2)
2020
* ```scala sc:compile sc-compile-with:1 sc-name:2
2121
* val ys = xs.map(x => x * 2)
2222
* ```
2323
*
24-
* SNIPPET(OUTERLINEOFFSET:26,OUTERCOLUMNOFFSET:6,INNERLINEOFFSET:5,INNERCOLUMNOFFSET:2)
24+
* SNIPPET(OUTERLINEOFFSET:25,OUTERCOLUMNOFFSET:6,INNERLINEOFFSET:4,INNERCOLUMNOFFSET:2)
2525
* ```scala sc:compile sc-compile-with:2
2626
* xs ++ ys
2727
* ```
2828
*/
29-
def b = 3
29+
def b = 3

scaladoc-testcases/src/tests/snippetTestcase2.scala

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ trait Quotes2[A] {
77
type X
88
object Y {
99
/**
10-
* SNIPPET(OUTERLINEOFFSET:13,OUTERCOLUMNOFFSET:10,INNERLINEOFFSET:8,INNERCOLUMNOFFSET:6)
10+
* SNIPPET(OUTERLINEOFFSET:12,OUTERCOLUMNOFFSET:10,INNERLINEOFFSET:4,INNERCOLUMNOFFSET:2)
1111
* ERROR(LINE:13,COLUMN:12)
1212
* ```scala sc:fail
1313
* 2 + List()
@@ -19,7 +19,7 @@ trait Quotes2[A] {
1919
val z: zModule = ???
2020
trait zModule {
2121
/**
22-
* SNIPPET(OUTERLINEOFFSET:25,OUTERCOLUMNOFFSET:10,INNERLINEOFFSET:9,INNERCOLUMNOFFSET:6)
22+
* SNIPPET(OUTERLINEOFFSET:24,OUTERCOLUMNOFFSET:10,INNERLINEOFFSET:4,INNERCOLUMNOFFSET:2)
2323
* ERROR(LINE:25,COLUMN:12)
2424
* ```scala sc:fail
2525
* 2 + List()
@@ -33,7 +33,7 @@ trait Quotes2[A] {
3333
type X
3434
object Y {
3535
/**
36-
* SNIPPET(OUTERLINEOFFSET:39,OUTERCOLUMNOFFSET:10,INNERLINEOFFSET:7,INNERCOLUMNOFFSET:6)
36+
* SNIPPET(OUTERLINEOFFSET:38,OUTERCOLUMNOFFSET:10,INNERLINEOFFSET:4,INNERCOLUMNOFFSET:2)
3737
* ERROR(LINE:39,COLUMN:12)
3838
* ```scala sc:fail
3939
* 2 + List()
@@ -45,7 +45,7 @@ trait Quotes2[A] {
4545
val z: zModule = ???
4646
trait zModule {
4747
/**
48-
* SNIPPET(OUTERLINEOFFSET:51,OUTERCOLUMNOFFSET:10,INNERLINEOFFSET:8,INNERCOLUMNOFFSET:6)
48+
* SNIPPET(OUTERLINEOFFSET:50,OUTERCOLUMNOFFSET:10,INNERLINEOFFSET:4,INNERCOLUMNOFFSET:2)
4949
* ERROR(LINE:51,COLUMN:12)
5050
* ```scala sc:fail
5151
* 2 + List()
@@ -55,4 +55,4 @@ trait Quotes2[A] {
5555
type ZZ
5656
}
5757
}
58-
}
58+
}

scaladoc-testcases/src/tests/snippetTestcase3.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ package snippetTestcase3
55
class SnippetTestcase3:
66
/** Text on line 0.
77
*
8-
* SNIPPET(OUTERLINEOFFSET:11,OUTERCOLUMNOFFSET:6,INNERLINEOFFSET:5,INNERCOLUMNOFFSET:2)
8+
* SNIPPET(OUTERLINEOFFSET:10,OUTERCOLUMNOFFSET:6,INNERLINEOFFSET:4,INNERCOLUMNOFFSET:2)
99
* ERROR(LINE:11,COLUMN:8)
1010
* ```scala sc:fail
1111
* 2 + List()
@@ -15,7 +15,7 @@ class SnippetTestcase3:
1515
/**
1616
* Text on line 1.
1717
*
18-
* SNIPPET(OUTERLINEOFFSET:21,OUTERCOLUMNOFFSET:6,INNERLINEOFFSET:5,INNERCOLUMNOFFSET:2)
18+
* SNIPPET(OUTERLINEOFFSET:20,OUTERCOLUMNOFFSET:6,INNERLINEOFFSET:4,INNERCOLUMNOFFSET:2)
1919
* ERROR(LINE:21,COLUMN:8)
2020
* ```scala sc:fail
2121
* 2 + List()
@@ -26,10 +26,10 @@ class SnippetTestcase3:
2626
*
2727
* Text on line 2.
2828
*
29-
* SNIPPET(OUTERLINEOFFSET:32,OUTERCOLUMNOFFSET:6,INNERLINEOFFSET:5,INNERCOLUMNOFFSET:2)
29+
* SNIPPET(OUTERLINEOFFSET:31,OUTERCOLUMNOFFSET:6,INNERLINEOFFSET:4,INNERCOLUMNOFFSET:2)
3030
* ERROR(LINE:32,COLUMN:8)
3131
* ```scala sc:fail
3232
* 2 + List()
3333
* ```
3434
*/
35-
def c = 3
35+
def c = 3

scaladoc/src/dotty/tools/scaladoc/api.scala

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -251,12 +251,8 @@ case class TastyMemberSource(path: java.nio.file.Path, lineNumber: Int)
251251

252252
object SnippetCompilerData:
253253
case class Position(line: Int, column: Int)
254-
case class ClassInfo(tpe: Option[String], names: Seq[String], generics: Option[String])
255-
256254
case class SnippetCompilerData(
257255
packageName: String,
258-
classInfos: Seq[SnippetCompilerData.ClassInfo],
259-
imports: List[String],
260256
position: SnippetCompilerData.Position
261257
)
262258

scaladoc/src/dotty/tools/scaladoc/site/templates.scala

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,6 @@ case class TemplateFile(
8686
val arg = argOverride.fold(pathBasedArg)(pathBasedArg.overrideFlag(_))
8787
val compilerData = SnippetCompilerData(
8888
"staticsitesnippet",
89-
Seq(SnippetCompilerData.ClassInfo(None, Nil, None)),
90-
Nil,
9189
SnippetCompilerData.Position(configOffset - 1, 0)
9290
)
9391
ssctx.snippetChecker.checkSnippet(str, Some(compilerData), arg, lineOffset, sourceFile).collect {
@@ -124,7 +122,7 @@ case class TemplateFile(
124122
// Snippet compiler currently supports markdown only
125123
val parser: Parser = Parser.builder(defaultMarkdownOptions).build()
126124
val parsedMd = parser.parse(rendered).pipe { md =>
127-
FlexmarkSnippetProcessor.processSnippets(md, None, snippetCheckingFunc, withContext = false)(using ssctx.outerCtx)
125+
FlexmarkSnippetProcessor.processSnippets(md, None, snippetCheckingFunc)(using ssctx.outerCtx)
128126
}.pipe { md =>
129127
FlexmarkSectionWrapper(md)
130128
}

scaladoc/src/dotty/tools/scaladoc/snippets/FlexmarkSnippetProcessor.scala

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import dotty.tools.scaladoc.tasty.comments.markdown.ExtendedFencedCodeBlock
1111
import dotty.tools.scaladoc.tasty.comments.PreparsedComment
1212

1313
object FlexmarkSnippetProcessor:
14-
def processSnippets[T <: mdu.Node](root: T, preparsed: Option[PreparsedComment], checkingFunc: => SnippetChecker.SnippetCheckingFunc, withContext: Boolean)(using CompilerContext): T = {
14+
def processSnippets[T <: mdu.Node](root: T, preparsed: Option[PreparsedComment], checkingFunc: => SnippetChecker.SnippetCheckingFunc)(using CompilerContext): T = {
1515
lazy val cf: SnippetChecker.SnippetCheckingFunc = checkingFunc
1616

1717
val nodes = root.getDescendants().asScala.collect {
@@ -68,23 +68,15 @@ object FlexmarkSnippetProcessor:
6868

6969
val fullSnippet = Seq(snippetImports, snippet).mkString("\n").trim
7070
val snippetCompilationResult = cf(fullSnippet, lineOffset, argOverride) match {
71-
case Some(result @ SnippetCompilationResult(wrapped, _, _, messages)) if !withContext =>
71+
case Some(result @ SnippetCompilationResult(wrapped, _, _, messages)) =>
7272
node.setContentString(fullSnippet)
73-
val innerLineOffset = wrapped.innerLineOffset
74-
Some(result.copy(messages = result.messages.map {
75-
case m @ SnippetCompilerMessage(Some(pos), _, _) =>
76-
m.copy(position = Some(pos.copy(relativeLine = pos.relativeLine - innerLineOffset)))
77-
case m => m
78-
}))
79-
case result@Some(SnippetCompilationResult(wrapped, _, _, _)) =>
80-
node.setContentString(wrapped.snippet)
81-
result
73+
Some(result)
8274
case result =>
8375
node.setContentString(fullSnippet)
8476
result
8577
}
8678

87-
node.insertBefore(ExtendedFencedCodeBlock(id, node, snippetCompilationResult, withContext))
79+
node.insertBefore(ExtendedFencedCodeBlock(id, node, snippetCompilationResult))
8880
node.unlink()
8981
id.fold(snippetMap)(id =>
9082
val snippetAsImport = s"""|//{i:$id

scaladoc/src/dotty/tools/scaladoc/snippets/SelfTypePrinter.scala

Lines changed: 0 additions & 55 deletions
This file was deleted.

0 commit comments

Comments
 (0)