Skip to content

Commit

Permalink
Better escaping for lens, disallow the name Map in property testing.
Browse files Browse the repository at this point in the history
  • Loading branch information
thesamet committed Jan 15, 2015
1 parent 04cbd2a commit 83398e7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -375,11 +375,11 @@ class ProtobufGenerator(params: GeneratorParams) {
printer.add(s"var __${oneof.scalaName} = this.${oneof.scalaName.asSymbol}")
)
.addM(
s"""var done__ = false
|while (!done__) {
| val tag__ = __input.readTag()
| tag__ match {
| case 0 => done__ = true""")
s"""var _done__ = false
|while (!_done__) {
| val _tag__ = __input.readTag()
| _tag__ match {
| case 0 => _done__ = true""")
.print(message.getFields) {
(field, printer) =>
if (!field.isPacked) {
Expand Down Expand Up @@ -550,11 +550,12 @@ class ProtobufGenerator(params: GeneratorParams) {

def generateMessageLens(message: Descriptor)(printer: FunctionalPrinter): FunctionalPrinter = {
val myFullScalaName = message.scalaTypeName
val className = message.getName.asSymbol
val className = message.getName
val classNameSymbol = className.asSymbol
def lensType(s: String) = s"com.trueaccord.lenses.Lens[UpperPB, $s]"

printer.add(
s"implicit class ${className}Lens[UpperPB](_l: com.trueaccord.lenses.Lens[UpperPB, $className]) extends com.trueaccord.lenses.ObjectLens[UpperPB, $className](_l) {")
s"implicit class ${className}Lens[UpperPB](_l: com.trueaccord.lenses.Lens[UpperPB, $classNameSymbol]) extends com.trueaccord.lenses.ObjectLens[UpperPB, $classNameSymbol](_l) {")
.indent
.print(message.getFields) {
case (field, printer) =>
Expand Down
2 changes: 1 addition & 1 deletion proptest/src/test/scala/SchemaGenerators.scala
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ object SchemaGenerators {
"java", "com", "google",

// Scala
"ne", "eq", "val", "var", "def", "any", "nil", "seq",
"ne", "eq", "val", "var", "def", "any", "map", "nil", "seq",

// Words that are not allowed by the Java protocol buffer compiler:
"tag",
Expand Down

0 comments on commit 83398e7

Please sign in to comment.