Repository: scalameta/scalameta
Pull request #2532 (2021-12-31 17:35:53)

Scaladoc: rename sequence parameters in plural
As started by #2489.


Patch:
diff --git a/scalameta/parsers/shared/src/main/scala/scala/meta/internal/parsers/ScaladocParser.scala b/scalameta/parsers/shared/src/main/scala/scala/meta/internal/parsers/ScaladocParser.scala
index ac0652464..fbe38973f 100644
--- a/scalameta/parsers/shared/src/main/scala/scala/meta/internal/parsers/ScaladocParser.scala
+++ b/scalameta/parsers/shared/src/main/scala/scala/meta/internal/parsers/ScaladocParser.scala
@@ -65,7 +65,7 @@ object ScaladocParser {
   private def codeBlockParser[_: P]: P[CodeBlock] = P {
     def code = codeLineParser.rep(1, sep = nl)
     def pattern = leadHspaces0 ~ codePrefix ~ nl ~ code ~ codeSuffix
-    pattern.map { x => CodeBlock(if (x.last.nonEmpty) x.toSeq else x.view.dropRight(1).toSeq) }
+    pattern.map { x => CodeBlock(if (x.last.nonEmpty) x else x.dropRight(1)) }
   }
 
   /*
@@ -122,7 +122,7 @@ object ScaladocParser {
     def part: P[TextPart] = P(!paraEnd ~ (codeExprParser | linkParser | wordParser))
     def sep = P(!end ~ nlHspaces0)
     def text = hspaces0 ~ part.rep(1, sep = sep)
-    text.map(x => Text(x.toSeq))
+    text.map(x => Text(x))
   }
 
   private def leadTextParser[_: P]: P[Text] = P((space | Start) ~ hspaces0 ~ textParser)
@@ -157,13 +157,13 @@ object ScaladocParser {
         (textParser ~ listBlockParser(indent + 1).?)
           .map { case (desc, list) => ListItem(desc, list) }
           .rep(1, sep = sep)
-          .map(x => ListBlock(prefix, x.toSeq))
+          .map(x => ListBlock(prefix, x))
     }
     startOrNl ~ listParser
   }
 
   private def tableParser[_: P]: P[Table] = P {
-    def toRow(x: Iterable[String]): Table.Row = Table.Row(x.toSeq)
+    def toRow(x: Seq[String]): Table.Row = Table.Row(x)
     def toAlign(x: String): Option[Table.Align] = {
       def isEnd(y: Char) = y match {
         case ':' => Some(true)
@@ -193,7 +193,7 @@ object ScaladocParser {
       // we'll trim the header later; we might need it if align is missing
       val rest = x.tail.map(_.map(_.trim))
       val alignRow = rest.head
-      val align = alignRow.flatMap(toAlign).toSeq
+      val align = alignRow.flatMap(toAlign)
       if (align.length != alignRow.length) {
         // determine alignment from the header row
         val head = x.head
@@ -217,9 +217,9 @@ object ScaladocParser {
             }
           }
         }
-        Table(toRow(headBuilder.result()), alignBuilder.result(), rest.toSeq.map(toRow))
+        Table(toRow(headBuilder.result()), alignBuilder.result(), rest.map(toRow))
       } else
-        Table(toRow(x.head.map(_.trim)), align, rest.tail.toSeq.map(toRow))
+        Table(toRow(x.head.map(_.trim)), align, rest.tail.map(toRow))
     }
 
     startOrNl ~ (delimLine ~ nl).? ~ tableSpaceSep ~ table ~ (nl ~ delimLine).?
@@ -236,9 +236,9 @@ object ScaladocParser {
 
   private def notTermEnd[_: P] = P(!(End | paraEnd))
   private def termsParser[_: P] = P(notTermEnd ~ termParser)
-  private def paraParser[_: P] = P((termsParser.rep(1)).map(x => Scaladoc.Paragraph(x.toSeq)))
+  private def paraParser[_: P] = P(termsParser.rep(1).map(x => Scaladoc.Paragraph(x)))
   private def paraSep[_: P] = P((nl ~ &(nl)).rep(1))
-  private def docParser[_: P] = P(paraParser.rep(sep = paraSep).map(x => Scaladoc(x.toSeq)))
+  private def docParser[_: P] = P(paraParser.rep(sep = paraSep).map(x => Scaladoc(x)))
 
   /** Contains all scaladoc parsers */
   private def parser[_: P]: P[Scaladoc] = P {
diff --git a/scalameta/trees/shared/src/main/scala/scala/meta/internal/Scaladoc.scala b/scalameta/trees/shared/src/main/scala/scala/meta/internal/Scaladoc.scala
index 27ce0144d..1d8d9239a 100644
--- a/scalameta/trees/shared/src/main/scala/scala/meta/internal/Scaladoc.scala
+++ b/scalameta/trees/shared/src/main/scala/scala/meta/internal/Scaladoc.scala
@@ -12,7 +12,7 @@ object Scaladoc {
   sealed abstract class Term
 
   /** A single paragraph of the document */
-  final case class Paragraph(term: Seq[Term])
+  final case class Paragraph(terms: Seq[Term])
 
   /* Text */
 
@@ -22,7 +22,7 @@ object Scaladoc {
   }
 
   /** A description or other inline text block */
-  final case class Text(part: Seq[TextPart]) extends Term
+  final case class Text(parts: Seq[TextPart]) extends Term
 
   /** A single word, without whitespace */
   final case class Word(value: String) extends TextPart {
@@ -62,12 +62,12 @@ object Scaladoc {
   final case class Table(
       header: Table.Row,
       align: Seq[Table.Align],
-      row: Seq[Table.Row]
+      rows: Seq[Table.Row]
   ) extends Term
 
   object Table {
 
-    final case class Row(col: Seq[String])
+    final case class Row(cols: Seq[String])
 
     sealed abstract class Align {
       def leftPad(pad: Int): Int
@@ -100,7 +100,7 @@ object Scaladoc {
   final case class ListItem(text: Text, nested: Option[ListBlock] = None)
 
   /** Represents a list block */
-  final case class ListBlock(prefix: String, item: Seq[ListItem]) extends Term
+  final case class ListBlock(prefix: String, items: Seq[ListItem]) extends Term
 
   /* Tags */
 


Test patch:
diff --git a/tests/shared/src/test/scala/scala/meta/tests/parsers/ScaladocParserSuite.scala b/tests/shared/src/test/scala/scala/meta/tests/parsers/ScaladocParserSuite.scala
index c7f519bd0..e46e0efdc 100644
--- a/tests/shared/src/test/scala/scala/meta/tests/parsers/ScaladocParserSuite.scala
+++ b/tests/shared/src/test/scala/scala/meta/tests/parsers/ScaladocParserSuite.scala
@@ -681,7 +681,7 @@ class ScaladocParserSuite extends FunSuite {
     assertNotEquals(parsedScaladocOpt, None: Option[Scaladoc])
     val parsedScaladocParas = parsedScaladocOpt.get.para
     assertEquals(parsedScaladocParas.length, 1)
-    val parsedScaladocTerms = parsedScaladocParas.head.term
+    val parsedScaladocTerms = parsedScaladocParas.head.terms
 
     assertEquals(
       parsedScaladocTerms.count {
@@ -715,7 +715,7 @@ class ScaladocParserSuite extends FunSuite {
     // Inherit doc does not merge
     parsedScaladocTerms.foreach {
       case t: Tag if t.tag.optDesc && t.desc.isDefined =>
-        assertEquals(t.desc.get.part.takeRight(words.length), words)
+        assertEquals(t.desc.get.parts.takeRight(words.length), words)
       case _ =>
     }
   }
@@ -987,8 +987,6 @@ class ScaladocParserSuite extends FunSuite {
        """.stripMargin
     )
 
-    val complexCodeBlockWords =
-      complexCodeBlock.flatMap(_.split("\\s+", 0).filter(_.nonEmpty)).map(Word.apply)
     val expectation = Option(
       Scaladoc(
         Seq(
@@ -1032,8 +1030,6 @@ class ScaladocParserSuite extends FunSuite {
        """.stripMargin
     )
 
-    val complexCodeBlockWords =
-      complexCodeBlock.flatMap(_.split("\\s+", 0)).filter(_.nonEmpty).map(Word.apply)
     val expectation = Option(
       Scaladoc(
         Seq(