Skip to content

Commit b181814

Browse files
committed
.
1 parent 3a36a0f commit b181814

File tree

1 file changed

+0
-101
lines changed

1 file changed

+0
-101
lines changed

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

Lines changed: 0 additions & 101 deletions
Original file line numberDiff line numberDiff line change
@@ -1326,11 +1326,6 @@ object Scanners {
13261326
// Collect all content using the string part parser
13271327
getDedentedStringPartWithDelimiter(quoteCount, isInterpolated)
13281328

1329-
// For non-interpolated strings, we need to dedent the collected content
1330-
if (!isInterpolated && token == STRINGLIT) {
1331-
dedentCollectedString()
1332-
}
1333-
13341329
quoteCount
13351330
}
13361331

@@ -1357,7 +1352,6 @@ object Scanners {
13571352

13581353
if (foundQuotes == quoteCount && ch != '\'') {
13591354
// Found closing delimiter - exact match and not followed by another quote
1360-
nextChar()
13611355
setStrVal()
13621356
token = STRINGLIT
13631357
} else {
@@ -1421,101 +1415,6 @@ object Scanners {
14211415
}
14221416
end getDedentedStringPartWithDelimiter
14231417

1424-
/** Dedent a collected string by analyzing line structure and removing common indentation.
1425-
* This processes the content in `strVal`, validating indentation rules and removing
1426-
* the minimum common indentation from all non-empty lines.
1427-
*/
1428-
private def dedentCollectedString(): Unit = {
1429-
val content = strVal
1430-
if (content.isEmpty) return
1431-
1432-
val lines = scala.collection.mutable.ArrayBuffer[String]()
1433-
val lineIndents = scala.collection.mutable.ArrayBuffer[String]()
1434-
1435-
// Parse content into lines with their indentation
1436-
var i = 0
1437-
while (i < content.length) {
1438-
// Collect indentation for this line
1439-
val indentStart = i
1440-
while (i < content.length && (content(i) == ' ' || content(i) == '\t')) {
1441-
i += 1
1442-
}
1443-
val indent = content.substring(indentStart, i)
1444-
1445-
// Collect rest of line
1446-
val lineStart = i
1447-
while (i < content.length && content(i) != '\n') {
1448-
i += 1
1449-
}
1450-
val line = content.substring(lineStart, i)
1451-
1452-
lines += line
1453-
lineIndents += indent
1454-
1455-
// Skip the newline
1456-
if (i < content.length && content(i) == '\n') {
1457-
i += 1
1458-
}
1459-
}
1460-
1461-
// The last line's indentation is the closing indentation
1462-
if (lines.isEmpty) {
1463-
strVal = ""
1464-
return
1465-
}
1466-
1467-
val closingIndent = lineIndents.last
1468-
val closingIndentLen = closingIndent.length
1469-
1470-
// Check for mixed tabs/spaces in closing indent
1471-
var hasSpaces = false
1472-
var hasTabs = false
1473-
for (ch <- closingIndent) {
1474-
if (ch == ' ') hasSpaces = true
1475-
if (ch == '\t') hasTabs = true
1476-
}
1477-
1478-
// Validate and dedent all lines
1479-
val dedentedLines = scala.collection.mutable.ArrayBuffer[String]()
1480-
var hasError = false
1481-
1482-
for (i <- 0 until lines.length - 1 if !hasError) { // Skip last line (it's empty after closing delimiter)
1483-
val line = lines(i)
1484-
val indent = lineIndents(i)
1485-
1486-
// Check for mixed tabs and spaces
1487-
var lineHasSpaces = false
1488-
var lineHasTabs = false
1489-
for (ch <- indent) {
1490-
if (ch == ' ') lineHasSpaces = true
1491-
if (ch == '\t') lineHasTabs = true
1492-
}
1493-
1494-
if ((hasSpaces && lineHasTabs) || (hasTabs && lineHasSpaces)) {
1495-
error(em"dedented string literal cannot mix tabs and spaces in indentation")
1496-
token = ERROR
1497-
hasError = true
1498-
} else if (line.isEmpty) {
1499-
// Empty lines are allowed
1500-
dedentedLines += ""
1501-
} else {
1502-
// Non-empty lines must be indented at least as much as closing delimiter
1503-
if (!indent.startsWith(closingIndent)) {
1504-
error(em"line in dedented string literal must be indented at least as much as the closing delimiter")
1505-
token = ERROR
1506-
hasError = true
1507-
} else {
1508-
// Remove the closing indentation from this line
1509-
dedentedLines += indent.substring(closingIndentLen) + line
1510-
}
1511-
}
1512-
}
1513-
1514-
if (!hasError) {
1515-
strVal = dedentedLines.mkString("\n")
1516-
}
1517-
}
1518-
15191418
private def getRawStringLit(): Unit =
15201419
if (ch == '\"') {
15211420
nextRawChar()

0 commit comments

Comments
 (0)