Skip to content

Commit 40c2db6

Browse files
committed
Introduce ToIndentParser and ToIndentScanner
Remove ScriptParsers
1 parent 162f8d6 commit 40c2db6

File tree

9 files changed

+315
-458
lines changed

9 files changed

+315
-458
lines changed

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import util.{SourceFile, ReadOnlyMap}
1010
import util.Spans._
1111
import util.CommentParsing._
1212
import util.Property.Key
13-
import parsing.Parsers.Parser
13+
import parsing.Parsers
1414
import reporting.ProperDefinitionNotFound
1515

1616
object Comments:
@@ -115,11 +115,11 @@ object Comments:
115115
final case class UseCase(code: String, codePos: Span, untpdCode: untpd.Tree, tpdCode: Option[tpd.DefDef]):
116116
def typed(tpdCode: tpd.DefDef): UseCase = copy(tpdCode = Some(tpdCode))
117117

118-
object UseCase:
119-
def apply(code: String, codePos: Span)(using Context): UseCase =
120-
val tree =
121-
val tree = new Parser(SourceFile.virtual("<usecase>", code)).localDef(codePos.start)
122-
tree match
118+
object UseCase {
119+
def apply(code: String, codePos: Span)(using Context): UseCase = {
120+
val tree = {
121+
val tree = Parsers.parser(SourceFile.virtual("<usecase>", code)).localDef(codePos.start)
122+
tree match {
123123
case tree: untpd.DefDef =>
124124
val newName = ctx.compilationUnit.freshNames.newName(tree.name, NameKinds.DocArtifactName)
125125
untpd.cpy.DefDef(tree)(name = newName)

compiler/src/dotty/tools/dotc/inlines/Inlines.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import SymDenotations.SymDenotation
1212
import config.Printers.inlining
1313
import ErrorReporting.errorTree
1414
import dotty.tools.dotc.util.{SourceFile, SourcePosition, SrcPos}
15-
import parsing.Parsers.Parser
15+
import parsing.Parsers
1616
import transform.{PostTyper, Inlining, CrossVersionChecks}
1717
import staging.StagingLevel
1818

@@ -322,8 +322,8 @@ object Inlines:
322322
ConstFold(underlyingCodeArg).tpe.widenTermRefExpr match
323323
case ConstantType(Constant(code: String)) =>
324324
val source2 = SourceFile.virtual("tasty-reflect", code)
325-
inContext(ctx.fresh.setNewTyperState().setTyper(new Typer(ctx.nestingLevel + 1)).setSource(source2)):
326-
val tree2 = new Parser(source2).block()
325+
inContext(ctx.fresh.setNewTyperState().setTyper(new Typer(ctx.nestingLevel + 1)).setSource(source2)) {
326+
val tree2 = Parsers.parser(source2).block()
327327
if ctx.reporter.allErrors.nonEmpty then
328328
ctx.reporter.allErrors.map((ErrorKind.Parser, _))
329329
else

compiler/src/dotty/tools/dotc/parsing/ParserPhase.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ class Parser extends Phase:
2626
val unit = ctx.compilationUnit
2727
unit.untpdTree =
2828
if (unit.isJava) new JavaParsers.JavaParser(unit.source).parse()
29-
else
30-
val p = new Parsers.Parser(unit.source)
29+
else {
30+
val p = Parsers.parser(unit.source)
3131
// p.in.debugTokenStream = true
3232
val tree = p.parse()
3333
if (p.firstXmlPos.exists && !firstXmlPos.exists)

0 commit comments

Comments
 (0)