From 14a08beabff59f245ddd220d4097ce43996cf3e1 Mon Sep 17 00:00:00 2001 From: mihaylov Date: Fri, 10 Feb 2006 11:37:35 +0000 Subject: Interpet the scala.runtime.compat.BeanProperty ... Interpet the scala.runtime.compat.BeanProperty to generate Java Beans compliant names for variable accessors --- src/compiler/scala/tools/nsc/backend/jvm/GenJVM.scala | 17 ++++++++++++++++- src/compiler/scala/tools/nsc/symtab/Definitions.scala | 3 ++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/compiler/scala/tools/nsc/backend/jvm/GenJVM.scala b/src/compiler/scala/tools/nsc/backend/jvm/GenJVM.scala index 7b9c00016a..b4f4fd87f2 100644 --- a/src/compiler/scala/tools/nsc/backend/jvm/GenJVM.scala +++ b/src/compiler/scala/tools/nsc/backend/jvm/GenJVM.scala @@ -63,6 +63,7 @@ abstract class GenJVM extends SubComponent { val TransientAtt = definitions.getClass("scala.transient").tpe; val VolatileAttr = definitions.getClass("scala.volatile").tpe; val RemoteAttr = definitions.getClass("scala.remote").tpe; + val BeanPropertyAttr = definitions.BeanPropertyAttr; val CloneableClass = definitions.getClass("java.lang.Cloneable"); val RemoteInterface = definitions.getClass("java.rmi.Remote"); @@ -942,7 +943,21 @@ abstract class GenJVM extends SubComponent { (if (sym.isClass || (sym.isModule && !sym.isMethod)) sym.fullNameString('/') else - sym.simpleName.toString().trim()) + suffix; + { + if ( sym.hasFlag(Flags.ACCESSOR) && sym.attributes.exists(a => a match{ + case Pair(BeanPropertyAttr, _) => true + case _ => false + })) + { + if (sym.isSetter) + "set" + nme.setterToGetter(sym.simpleName).toString() + else "get" + sym.simpleName.toString() + } + else { + sym.simpleName.toString() + }.trim() + } + ) + suffix; } def javaNames(syms: List[Symbol]): Array[String] = { diff --git a/src/compiler/scala/tools/nsc/symtab/Definitions.scala b/src/compiler/scala/tools/nsc/symtab/Definitions.scala index 228a7cb08b..616070bc29 100644 --- a/src/compiler/scala/tools/nsc/symtab/Definitions.scala +++ b/src/compiler/scala/tools/nsc/symtab/Definitions.scala @@ -173,7 +173,7 @@ mixin class Definitions requires SymbolTable { // special attributes var SerializableAttr: Type = _; - + var BeanPropertyAttr: Type = _; def getModule(fullname: Name): Symbol = getModuleOrClass(fullname, true); @@ -420,6 +420,7 @@ mixin class Definitions requires SymbolTable { ObjectRefClass = getClass("scala.runtime.ObjectRef"); SerializableAttr = getClass("scala.serializable").tpe; + BeanPropertyAttr = getClass("scala.runtime.compat.BeanProperty").tpe; } } } -- cgit v1.2.3