-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update presentation compiler to a829a6a (#18347)
[Cherry-picked 70be2df]
- Loading branch information
Showing
6 changed files
with
372 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
256 changes: 256 additions & 0 deletions
256
presentation-compiler/test/dotty/tools/pc/tests/hover/HoverDocSuite.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,256 @@ | ||
package dotty.tools.pc.tests.hover | ||
|
||
import dotty.tools.pc.base.BaseHoverSuite | ||
|
||
import org.junit.Test | ||
import dotty.tools.pc.utils.MockEntries | ||
import scala.meta.pc.SymbolDocumentation | ||
|
||
class HoverDocSuite extends BaseHoverSuite: | ||
|
||
override protected def mockEntries: MockEntries = new MockEntries: | ||
override def documentations: Set[SymbolDocumentation] = Set( | ||
ScalaMockDocumentation("java/lang/String#substring().", "substring", List(MockParam("beginIndex"))), | ||
ScalaMockDocumentation("java/util/Collections#emptyList().", "emptyList"), | ||
ScalaMockDocumentation("_empty_/Alpha.apply().", "apply", List(MockParam("x"))), | ||
ScalaMockDocumentation("_empty_/Alpha#", "init", List(MockParam("x"))), | ||
ScalaMockDocumentation("scala/collection/LinearSeqOps#headOption().", "headOption"), | ||
) | ||
|
||
@Test def `doc` = | ||
check( | ||
"""object a { | ||
| <<java.util.Collections.empty@@List[Int]>> | ||
|} | ||
|""".stripMargin, | ||
"""|**Expression type**: | ||
|```scala | ||
|java.util.List[Int] | ||
|``` | ||
|**Symbol signature**: | ||
|```scala | ||
|final def emptyList[T](): java.util.List[T] | ||
|``` | ||
|Found documentation for java/util/Collections#emptyList(). | ||
|""".stripMargin, | ||
) | ||
|
||
@Test def `doc-parent` = | ||
check( | ||
"""|object a { | ||
| <<List(12).hea@@dOption>> | ||
|} | ||
|""".stripMargin, | ||
// Assert that the docstring is extracted. | ||
"""|```scala | ||
|override def headOption: Option[Int] | ||
|``` | ||
|Found documentation for scala/collection/LinearSeqOps#headOption(). | ||
|""".stripMargin, | ||
|
||
) | ||
|
||
@Test def `java-method` = | ||
check( | ||
"""|object a { | ||
| <<"".substri@@ng(1)>> | ||
|} | ||
""".stripMargin, | ||
"""|```scala | ||
|def substring(beginIndex: Int): String | ||
|``` | ||
|Found documentation for java/lang/String#substring(). | ||
|""".stripMargin | ||
) | ||
|
||
@Test def `object` = | ||
check( | ||
"""| | ||
|/** | ||
| * Doc about object | ||
| */ | ||
|object Alpha { | ||
| def apply(x: Int) = x + 1 | ||
|} | ||
| | ||
|object Main { | ||
| val x = <<Alp@@ha(2)>> | ||
|} | ||
|""".stripMargin, | ||
"""|```scala | ||
|def apply(x: Int): Int | ||
|``` | ||
|Found documentation for _empty_/Alpha.apply(). | ||
|""".stripMargin, | ||
) | ||
|
||
@Test def `object1` = | ||
check( | ||
"""| | ||
|/** | ||
| * Doc about object | ||
| */ | ||
|object Alpha { | ||
| /** | ||
| * Doc about method | ||
| */ | ||
| def apply(x: Int) = x + 1 | ||
|} | ||
| | ||
|object Main { | ||
| val x = <<Alp@@ha(2)>> | ||
|} | ||
|""".stripMargin, | ||
"""|```scala | ||
|def apply(x: Int): Int | ||
|``` | ||
|Found documentation for _empty_/Alpha.apply(). | ||
|""".stripMargin, | ||
) | ||
|
||
@Test def `case-class` = | ||
check( | ||
"""| | ||
|/** | ||
| * Doc about case class | ||
| * | ||
| */ | ||
|case class Alpha(x: Int) | ||
| | ||
|/** | ||
| * Doc about object | ||
| */ | ||
|object Alpha { | ||
| /** | ||
| * Doc about method | ||
| */ | ||
| def apply(x: Int) = x + 1 | ||
|} | ||
| | ||
|object Main { | ||
| val x = <<Alp@@ha(2)>> | ||
|} | ||
|""".stripMargin, | ||
"""|```scala | ||
|def apply(x: Int): Int | ||
|``` | ||
|Found documentation for _empty_/Alpha.apply(). | ||
|""".stripMargin, | ||
) | ||
|
||
@Test def `case-class1` = | ||
check( | ||
"""| | ||
|/** | ||
| * Doc about case class | ||
| * | ||
| */ | ||
|case class Alpha(x: Int) | ||
| | ||
|/** | ||
| * Doc about object | ||
| */ | ||
|object Alpha { | ||
| def apply(x: Int) = x + 1 | ||
|} | ||
| | ||
|object Main { | ||
| val x = <<Alp@@ha(2)>> | ||
|} | ||
|""".stripMargin, | ||
"""|```scala | ||
|def apply(x: Int): Int | ||
|``` | ||
|Found documentation for _empty_/Alpha.apply(). | ||
| | ||
|""".stripMargin, | ||
) | ||
|
||
@Test def `case-class2` = | ||
check( | ||
"""| | ||
|/** | ||
| * Doc about case class | ||
| * | ||
| */ | ||
|case class Alpha(x: Int) | ||
| | ||
|object Alpha { | ||
| def apply(x: Int) = x + 1 | ||
|} | ||
| | ||
|object Main { | ||
| val x = <<Alp@@ha(2)>> | ||
|} | ||
|""".stripMargin, | ||
"""|```scala | ||
|def apply(x: Int): Int | ||
|``` | ||
|Found documentation for _empty_/Alpha.apply(). | ||
|""".stripMargin, | ||
) | ||
|
||
@Test def `case-class3` = | ||
check( | ||
"""| | ||
|/** | ||
| * Doc about case class | ||
| * | ||
| */ | ||
|case class Alpha(x: Int) | ||
| | ||
| | ||
|object Main { | ||
| val x = <<Alp@@ha(2)>> | ||
|} | ||
|""".stripMargin, | ||
"""|```scala | ||
|def apply(x: Int): Alpha | ||
|``` | ||
|Found documentation for _empty_/Alpha.apply(). | ||
|""".stripMargin, | ||
) | ||
|
||
@Test def `class` = | ||
check( | ||
"""| | ||
|/** | ||
| * Doc about class | ||
| * | ||
| */ | ||
|class Alpha(x: Int) | ||
| | ||
|object Alpha { | ||
| def apply(x: Int) = x + 1 | ||
|} | ||
| | ||
|object Main { | ||
| val x = <<Alp@@ha(2)>> | ||
|} | ||
|""".stripMargin, | ||
"""|```scala | ||
|def apply(x: Int): Int | ||
|``` | ||
|Found documentation for _empty_/Alpha.apply(). | ||
|""".stripMargin, | ||
) | ||
|
||
@Test def `universal-apply` = | ||
check( | ||
"""| | ||
|/** | ||
| * Doc about class | ||
| * | ||
| */ | ||
|class Alpha(x: Int) | ||
| | ||
|object Main { | ||
| val x = <<Alp@@ha(2)>> | ||
|} | ||
|""".stripMargin, | ||
"""|```scala | ||
|def this(x: Int): Alpha | ||
|``` | ||
|Found documentation for _empty_/Alpha# | ||
|""".stripMargin, | ||
) |
Oops, something went wrong.