~ubuntu-branches/debian/sid/scala/sid

« back to all changes in this revision

Viewing changes to src/reflect/scala/reflect/api/Universe.scala

  • Committer: Package Import Robot
  • Author(s): Emmanuel Bourg, Mehdi Dogguy, Lucas Satabin, Frank S. Thomas, Emmanuel Bourg
  • Date: 2015-06-05 23:52:59 UTC
  • mfrom: (1.2.11)
  • Revision ID: package-import@ubuntu.com-20150605235259-wk00vgk83dh8o19g
Tags: 2.10.5-1
* Team upload.

[ Mehdi Dogguy ]
* New upstream release (Closes: #744278).

[ Lucas Satabin ]
* Update patches
* Update the clean target
* Update paths of elements to install
* Update watch file

[ Frank S. Thomas ]
* Remove myself from Uploaders.

[ Emmanuel Bourg ]
* The package has been adopted by the Java Team (Closes: #754935)
* Patched the build to avoid downloading libraries from the Internet
* Replaced the minified JavaScript files with unobfuscated ones
* No longer build scala-partest.jar until diffutils is packaged or replaced
* debian/watch: Fixed the versions matched (x.y.z instead of x.y.z..z)
* debian/rules:
  - Added the missing get-orig-source target (Closes: #724704)
  - Improved the clean target
* debian/control:
  - Build depend on scala (>= 2.10) and bnd
  - Use canonical URLs for the Vcs-* fields
  - Standards-Version updated to 3.9.6 (no changes)
* Switch to debhelper level 9

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
package scala.reflect
 
2
package api
 
3
 
 
4
/**
 
5
 * <span class="badge badge-red" style="float: right;">EXPERIMENTAL</span>
 
6
 *
 
7
 * `Universe` provides a complete set of reflection operations which make it possible for one
 
8
 * to reflectively inspect Scala type relations, such as membership or subtyping.
 
9
 *
 
10
 * [[scala.reflect.api.Universe]] has two specialized sub-universes for different scenarios.
 
11
 * [[scala.reflect.api.JavaUniverse]] adds operations that link symbols and types to the underlying
 
12
 * classes and runtime values of a JVM instance-- this can be thought of as the `Universe` that
 
13
 * should be used for all typical use-cases of Scala reflection. [[scala.reflect.macros.Universe]]
 
14
 * adds operations which allow macros to access selected compiler data structures and operations--
 
15
 * this type of `Universe` should only ever exist within the implementation of a Scala macro.
 
16
 *
 
17
 * `Universe` can be thought of as the entry point to Scala reflection. It mixes-in, and thus provides
 
18
 * an interface to the following main types:
 
19
 *
 
20
 *   - [[scala.reflect.api.Types#Type Types]] represent types
 
21
 *   - [[scala.reflect.api.Symbols#Symbol Symbols]] represent definitions
 
22
 *   - [[scala.reflect.api.Trees#Tree Trees]] represent abstract syntax trees
 
23
 *   - [[scala.reflect.api.Names#Name Names]] represent term and type names
 
24
 *   - [[scala.reflect.api.Annotations#Annotation Annotations]] represent annotations
 
25
 *   - [[scala.reflect.api.Positions#Position Positions]] represent source positions of tree nodes
 
26
 *   - [[scala.reflect.api.FlagSets#FlagSet FlagSet]] represent sets of flags that apply to symbols and
 
27
 *     definition trees
 
28
 *   - [[scala.reflect.api.Constants#Constant Constants]] represent compile-time constants.
 
29
 *
 
30
 * To obtain a `Universe` to use with Scala runtime reflection, simply make sure to use or import
 
31
 * `scala.reflect.runtime.universe._`
 
32
 *   {{{
 
33
 *   scala> import scala.reflect.runtime.universe._
 
34
 *   import scala.reflect.runtime.universe._
 
35
 *
 
36
 *   scala> typeOf[List[Int]]
 
37
 *   res0: reflect.runtime.universe.Type = scala.List[Int]
 
38
 *
 
39
 *   scala> typeOf[Either[String, Int]]
 
40
 *   res1: reflect.runtime.universe.Type = scala.Either[String,Int]
 
41
 *   }}}
 
42
 *
 
43
 * To obtain a `Universe` for use within a Scala macro, use [[scala.reflect.macros.Context#universe]]. For example:
 
44
 * {{{
 
45
 *  def printf(format: String, params: Any*): Unit = macro impl
 
46
 *  def impl(c: Context)(format: c.Expr[String], params: c.Expr[Any]*): c.Expr[Unit] = {
 
47
 *    import c.universe._
 
48
 *    ...
 
49
 *  }
 
50
 * }}}
 
51
 *
 
52
 * For more information about `Universe`s, see the [[http://docs.scala-lang.org/overviews/reflection/environment-universes-mirrors.html Reflection Guide: Universes]]
 
53
 *
 
54
 *  @groupprio Universe -1
 
55
 *  @group ReflectionAPI
 
56
 *
 
57
 *  @contentDiagram hideNodes "*Api"
 
58
 */
 
59
abstract class Universe extends Symbols
 
60
                           with Types
 
61
                           with FlagSets
 
62
                           with Scopes
 
63
                           with Names
 
64
                           with Trees
 
65
                           with Constants
 
66
                           with Annotations
 
67
                           with Positions
 
68
                           with Exprs
 
69
                           with TypeTags
 
70
                           with TagInterop
 
71
                           with StandardDefinitions
 
72
                           with StandardNames
 
73
                           with BuildUtils
 
74
                           with Mirrors
 
75
                           with Printers
 
76
                           with Importers
 
77
{
 
78
  /** Use `reify` to produce the abstract syntax tree representing a given Scala expression.
 
79
   *
 
80
   * For example:
 
81
   *
 
82
   * {{{
 
83
   * val five = reify{ 5 }         // Literal(Constant(5))
 
84
   * reify{ 5.toString }           // Apply(Select(Literal(Constant(5)), TermName("toString")), List())
 
85
   * reify{ five.splice.toString } // Apply(Select(five, TermName("toString")), List())
 
86
   * }}}
 
87
   *
 
88
   * The produced tree is path dependent on the Universe `reify` was called from.
 
89
   *
 
90
   * Use [[scala.reflect.api.Exprs#Expr.splice]] to embed an existing expression into a `reify` call. Use [[Expr]] to turn a [[Tree]] into an expression that can be spliced.
 
91
   * @group Universe
 
92
   */
 
93
  // implementation is hardwired to `scala.reflect.reify.Taggers`
 
94
  // using the mechanism implemented in `scala.tools.reflect.FastTrack`
 
95
  def reify[T](expr: T): Expr[T] = ??? // macro
 
96
}