diff options
author | Paul Phillips <paulp@improving.org> | 2010-12-04 18:33:23 +0000 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2010-12-04 18:33:23 +0000 |
commit | b1e969a11b2b24f5883198dc0b90d9ab5513498b (patch) | |
tree | 434257c2afc84c4d86e55cd2bf78d9e29ca66dc9 /src/compiler/scala/tools/nsc/ast/TreeGen.scala | |
parent | 3d97123034a9d82e6e6961d589ccd3a1afde4390 (diff) | |
download | scala-b1e969a11b2b24f5883198dc0b90d9ab5513498b.tar.gz scala-b1e969a11b2b24f5883198dc0b90d9ab5513498b.tar.bz2 scala-b1e969a11b2b24f5883198dc0b90d9ab5513498b.zip |
A foot in the door with Parsers/JavaParsers and...
A foot in the door with Parsers/JavaParsers and Scanners/JavaScanners.
Recently clued in as to how this situation came to be, I now know
there's no reason not to start containing the damage. Also more work
on names: made a general method for transforming Trees into type-named
Trees and put it to work. No review.
Diffstat (limited to 'src/compiler/scala/tools/nsc/ast/TreeGen.scala')
-rw-r--r-- | src/compiler/scala/tools/nsc/ast/TreeGen.scala | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/src/compiler/scala/tools/nsc/ast/TreeGen.scala b/src/compiler/scala/tools/nsc/ast/TreeGen.scala index d93496a7c4..e606b1c6af 100644 --- a/src/compiler/scala/tools/nsc/ast/TreeGen.scala +++ b/src/compiler/scala/tools/nsc/ast/TreeGen.scala @@ -361,15 +361,19 @@ abstract class TreeGen { else mkCast(tree, pt) + /** Translate names in Select/Ident nodes to type names. + */ + def convertToTypeName(tree: Tree): Option[RefTree] = tree match { + case Select(qual, name) => Some(Select(qual, name.toTypeName)) + case Ident(name) => Some(Ident(name.toTypeName)) + case _ => None + } + /** Try to convert Select(qual, name) to a SelectFromTypeTree. */ - def convertToSelectFromType(qual: Tree, origName: Name): Tree = { - def selFromType(qual1: Tree) = SelectFromTypeTree(qual1 setPos qual.pos, origName) - qual match { - case Select(qual1, name) => selFromType(Select(qual1, name.toTypeName)) - case Ident(name) => selFromType(Ident(name.toTypeName)) - case _ => EmptyTree - } + def convertToSelectFromType(qual: Tree, origName: Name) = convertToTypeName(qual) match { + case Some(qual1) => SelectFromTypeTree(qual1 setPos qual.pos, origName) + case _ => EmptyTree } /** Used in situations where you need to access value of an expression several times |