Skip to content

Commit a2569c2

Browse files
committed
Factor WorksheetWrapper name to StdNames
1 parent dba854d commit a2569c2

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-6
lines changed

compiler/src/dotty/tools/dotc/core/StdNames.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -548,6 +548,7 @@ object StdNames {
548548
val wait_ : N = "wait"
549549
val withFilter: N = "withFilter"
550550
val withFilterIfRefutable: N = "withFilterIfRefutable$"
551+
val WorksheetWrapper: N = "WorksheetWrapper"
551552
val wrap: N = "wrap"
552553
val zero: N = "zero"
553554
val zip: N = "zip"

language-server/src/dotty/tools/languageserver/DottyLanguageServer.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -540,7 +540,7 @@ object DottyLanguageServer {
540540

541541
/** Wrap the source of a worksheet inside an `object`. */
542542
private def wrapWorksheet(source: String): String =
543-
s"""object Worksheet {
543+
s"""object ${StdNames.nme.WorksheetWrapper} {
544544
|$source
545545
|}""".stripMargin
546546

@@ -599,7 +599,7 @@ object DottyLanguageServer {
599599
* @see wrapWorksheet
600600
*/
601601
def isWorksheetWrapper(symbol: Symbol)(implicit ctx: Context): Boolean = {
602-
symbol.name.toString == "Worksheet$" &&
602+
symbol.name == StdNames.nme.WorksheetWrapper.moduleClassName &&
603603
symbol.owner == ctx.definitions.EmptyPackageClass
604604
}
605605

language-server/test/dotty/tools/languageserver/WorksheetTest.scala

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ package dotty.tools.languageserver
33
import org.junit.Test
44
import org.eclipse.lsp4j.{CompletionItemKind, DocumentHighlightKind, SymbolKind}
55

6+
import dotty.tools.dotc.core.StdNames.nme.WorksheetWrapper
7+
import dotty.tools.dotc.core.NameOps.NameDecorator
68
import dotty.tools.languageserver.util.Code._
79
import dotty.tools.languageserver.util.embedded.CodeMarker
810

@@ -168,17 +170,17 @@ class WorksheetTest {
168170
ws"""/** A class */ class ${m1}Foo${m2} { /** A method */ def ${m3}bar${m4} = 123 }
169171
val x = new ${m5}Foo${m6}
170172
x.${m7}bar${m8}""".withSource
171-
.hover(m1 to m2, hoverContent("Worksheet.Foo", "/** A class */"))
173+
.hover(m1 to m2, hoverContent(s"${WorksheetWrapper}.Foo", "/** A class */"))
172174
.hover(m3 to m4, hoverContent("Int", "/** A method */"))
173-
.hover(m5 to m6, hoverContent("Worksheet.Foo", "/** A class */"))
175+
.hover(m5 to m6, hoverContent(s"${WorksheetWrapper}.Foo", "/** A class */"))
174176
.hover(m7 to m8, hoverContent("Int", "/** A method */"))
175177
}
176178

177179
@Test def worksheetDocumentSymbol(): Unit = {
178180
ws"""class ${m1}Foo${m2} {
179181
def ${m3}bar${m4} = 123
180182
}""".withSource
181-
.documentSymbol(m1, (m1 to m2).symInfo("Foo", SymbolKind.Class, "Worksheet$"),
183+
.documentSymbol(m1, (m1 to m2).symInfo("Foo", SymbolKind.Class, WorksheetWrapper.moduleClassName.toString),
182184
(m3 to m4).symInfo("bar", SymbolKind.Method, "Foo"))
183185
}
184186

@@ -188,7 +190,7 @@ class WorksheetTest {
188190
def ${m3}bar${m4} = 123
189191
}""",
190192
code"""class ${m5}Baz${m6}"""
191-
).symbol("Foo", (m1 to m2).symInfo("Foo", SymbolKind.Class, "Worksheet$"))
193+
).symbol("Foo", (m1 to m2).symInfo("Foo", SymbolKind.Class, WorksheetWrapper.moduleClassName.toString))
192194
.symbol("bar", (m3 to m4).symInfo("bar", SymbolKind.Method, "Foo"))
193195
.symbol("Baz", (m5 to m6).symInfo("Baz", SymbolKind.Class))
194196
}

0 commit comments

Comments
 (0)