blob: 2710a5392817a6ae71b5b587d21031b3b6573535 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
|
package dotty.tools
package dottydoc
package js
package model
import scala.scalajs.{ js => sjs }
/** This file defines the interface for which to interact with the searchable
* index. To use the normal operations available on the traits on the JVM:
*
* {{{
* import dotty.tools.dottydoc.js.model.ops._
* val x: Package = ...
* }}}
*
* Please note that some of the actual fields have not been added to this
* interface, this is simply due to the fact that they're not necessary for
* search - YET. They could be added, for instance `comment` is missing.
*/
@sjs.native
trait Entity extends sjs.Any {
val kind: String = sjs.native
val name: String = sjs.native
val path: sjs.Array[String] = sjs.native
}
@sjs.native
trait Members extends sjs.Any {
val members: sjs.Array[Entity] = sjs.native
}
@sjs.native
trait Modifiers extends sjs.Any {
val modifiers: sjs.Array[String] = sjs.native
}
@sjs.native
trait Package extends Entity with Members
@sjs.native
trait Class extends Entity with Members with Modifiers
@sjs.native
trait CaseClass extends Entity with Members with Modifiers
@sjs.native
trait Object extends Class with Modifiers
@sjs.native
trait Trait extends Class
@sjs.native
trait Def extends Entity with Modifiers
@sjs.native
trait Val extends Def
@sjs.native
trait Var extends Def
object ops {
val EntitiesWithMembers =
"package" :: "case class" :: "class" :: "object" :: "trait" :: Nil
implicit class PackageOps(val p: Package) {
def children: sjs.Array[Entity with Members] =
p.members.collect {
case x if EntitiesWithMembers contains x.kind =>
x.asInstanceOf[Entity with Members]
}
}
}
|