Skip to content

Commit 09e3f4e

Browse files
committed
Support significant indentation
1 parent 4cc6c06 commit 09e3f4e

19 files changed

+1345
-380
lines changed

compiler/src/dotty/tools/dotc/config/Config.scala

+3
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,9 @@ object Config {
157157
*/
158158
final val simplifyApplications = true
159159

160+
/** Always assume -indent */
161+
final val allowIndent = true
162+
160163
/** If set, prints a trace of all symbol completions */
161164
final val showCompletions = false
162165

compiler/src/dotty/tools/dotc/config/Printers.scala

+1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ object Printers {
2727
val hk: Printer = noPrinter
2828
val implicits: Printer = noPrinter
2929
val implicitsDetailed: Printer = noPrinter
30+
val lexical: Printer = noPrinter
3031
val inlining: Printer = noPrinter
3132
val interactiv: Printer = noPrinter
3233
val overload: Printer = noPrinter

compiler/src/dotty/tools/dotc/config/ScalaSettings.scala

+2
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ class ScalaSettings extends Settings.SettingGroup {
5050

5151
val newSyntax: Setting[Boolean] = BooleanSetting("-new-syntax", "Require `then` and `do` in control expressions")
5252
val oldSyntax: Setting[Boolean] = BooleanSetting("-old-syntax", "Require `(...)` around conditions")
53+
val indent: Setting[Boolean] = BooleanSetting("-indent", "allow significant indentation")
54+
val noindent: Setting[Boolean] = BooleanSetting("-noindent", "require classical {...} syntax, indentation is not significant")
5355

5456
/** Decompiler settings */
5557
val printTasty: Setting[Boolean] = BooleanSetting("-print-tasty", "Prints the raw tasty.") withAbbreviation "--print-tasty"

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

+1
Original file line numberDiff line numberDiff line change
@@ -420,6 +420,7 @@ object StdNames {
420420
val elem: N = "elem"
421421
val elems: N = "elems"
422422
val emptyValDef: N = "emptyValDef"
423+
val end: N = "end"
423424
val ensureAccessible : N = "ensureAccessible"
424425
val eq: N = "eq"
425426
val eqInstance: N = "eqInstance"

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

+2-9
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,6 @@ abstract class CharArrayReader { self =>
2727
/** The start offset of the current line */
2828
var lineStartOffset: Int = startFrom
2929

30-
/** The start offset of the line before the current one */
31-
var lastLineStartOffset: Int = startFrom
32-
3330
private[this] var lastUnicodeOffset = -1
3431

3532
/** Is last character a unicode escape \\uxxxx? */
@@ -112,12 +109,8 @@ abstract class CharArrayReader { self =>
112109
}
113110

114111
/** Handle line ends */
115-
private def potentialLineEnd(): Unit = {
116-
if (ch == LF || ch == FF) {
117-
lastLineStartOffset = lineStartOffset
118-
lineStartOffset = charOffset
119-
}
120-
}
112+
private def potentialLineEnd(): Unit =
113+
if (ch == LF || ch == FF) lineStartOffset = charOffset
121114

122115
def isAtEnd: Boolean = charOffset >= buf.length
123116

0 commit comments

Comments
 (0)