summaryrefslogtreecommitdiff
path: root/src/compiler/scala/tools/nsc/interpreter/Imports.scala
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2011-04-08 16:42:38 +0000
committerPaul Phillips <paulp@improving.org>2011-04-08 16:42:38 +0000
commit8e093b517f2c987cb5b4efe8dfb6736d54708e35 (patch)
tree50a963109d8cd6851a05cd9d040fbfd4a676c737 /src/compiler/scala/tools/nsc/interpreter/Imports.scala
parent6eae720732d493a3a3370a067a3b3b05aef73820 (diff)
downloadscala-8e093b517f2c987cb5b4efe8dfb6736d54708e35.tar.gz
scala-8e093b517f2c987cb5b4efe8dfb6736d54708e35.tar.bz2
scala-8e093b517f2c987cb5b4efe8dfb6736d54708e35.zip
Added :imports command, no review.
Diffstat (limited to 'src/compiler/scala/tools/nsc/interpreter/Imports.scala')
-rw-r--r--src/compiler/scala/tools/nsc/interpreter/Imports.scala16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/compiler/scala/tools/nsc/interpreter/Imports.scala b/src/compiler/scala/tools/nsc/interpreter/Imports.scala
index 990f504692..b2706330e7 100644
--- a/src/compiler/scala/tools/nsc/interpreter/Imports.scala
+++ b/src/compiler/scala/tools/nsc/interpreter/Imports.scala
@@ -15,9 +15,21 @@ trait Imports {
import definitions.{ ScalaPackage, JavaLangPackage, PredefModule }
import memberHandlers._
+ /** Synthetic import handlers for the language defined imports. */
+ private def makeWildcardImportHandler(sym: Symbol): ImportHandler = {
+ val hd :: tl = sym.fullName.split('.').toList map newTermName
+ val tree = Import(
+ tl.foldLeft(Ident(hd): Tree)((x, y) => Select(x, y)),
+ List(ImportSelector(nme.WILDCARD, -1, null, -1))
+ )
+ tree setSymbol sym
+ new ImportHandler(tree)
+ }
+
/** Symbols whose contents are language-defined to be imported. */
def languageWildcardSyms: List[Symbol] = List(JavaLangPackage, ScalaPackage, PredefModule)
def languageWildcards: List[Type] = languageWildcardSyms map (_.tpe)
+ def languageWildcardHandlers = languageWildcardSyms map makeWildcardImportHandler
def importedTerms = onlyTerms(importHandlers flatMap (_.importedNames))
def importedTypes = onlyTypes(importHandlers flatMap (_.importedNames))
@@ -44,8 +56,12 @@ trait Imports {
def languageSymbols = languageWildcardSyms flatMap membersAtPickler
def sessionImportedSymbols = importHandlers flatMap (_.importedSymbols)
def importedSymbols = languageSymbols ++ sessionImportedSymbols
+ def importedTermSymbols = importedSymbols collect { case x: TermSymbol => x }
+ def importedTypeSymbols = importedSymbols collect { case x: TypeSymbol => x }
def implicitSymbols = importedSymbols filter (_.isImplicit)
+ def importedTermNamed(name: String) = importedTermSymbols find (_.name.toString == name)
+
/** Tuples of (source, imported symbols) in the order they were imported.
*/
def importedSymbolsBySource: List[(Symbol, List[Symbol])] = {