Skip to content

Commit

Permalink
Merge pull request #531 from margussipria/non-infix-syntax-for-string…
Browse files Browse the repository at this point in the history
…-format

Removing multiarg infix syntax warnings introduced with Scala 2.13.3
  • Loading branch information
eed3si9n authored Jun 27, 2020
2 parents c717a51 + a73d356 commit f6b7819
Show file tree
Hide file tree
Showing 12 changed files with 52 additions and 49 deletions.
6 changes: 3 additions & 3 deletions cli/src/main/resources/scalaxb.scala.template
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ object `package` {
def fromXML[A](seq: NodeSeq, stack: List[ElemName] = Nil)
(implicit format: XMLFormat[A]): A = format.reads(seq, stack) match {
case Right(a) => a
case Left(a) => throw new ParserFailure("Error while parsing %s: %s" format(seq.toString, a))
case Left(a) => throw new ParserFailure("Error while parsing %s: %s".format(seq.toString, a))
}

@implicitNotFound(msg = "Cannot find XMLFormat type class for ${A}")
Expand Down Expand Up @@ -880,7 +880,7 @@ object Helper {

def toString(value: QName, scope: NamespaceBinding): String =
Option[String](scope.getPrefix(value.getNamespaceURI)) map {
"%s:%s" format (_, value.getLocalPart)} getOrElse {value.getLocalPart}
"%s:%s".format(_, value.getLocalPart)} getOrElse {value.getLocalPart}

def toCalendar(value: String): XMLGregorianCalendar = {
DataTypeFactory.get().newXMLGregorianCalendar(value)
Expand Down Expand Up @@ -959,7 +959,7 @@ object Helper {
else nullOrEmpty(scope.getPrefix(namespace.orNull))

def prefixedName(namespace: Option[String], name: String, scope: scala.xml.NamespaceBinding) =
getPrefix(namespace, scope) map { """%s:%s""" format(_, name)
getPrefix(namespace, scope) map { """%s:%s""".format(_, name)
} getOrElse {name}

def stringToXML(obj: String, namespace: Option[String], elementLabel: Option[String],
Expand Down
2 changes: 1 addition & 1 deletion cli/src/main/resources/soap12.scala.template
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ trait SoapClients { this: HttpClients =>
case x => sys.error("unexpected non-elem: " + x.toString)
}}
val contentType = "application/soap+xml; charset=utf-8" +
(action map {"""; action="%s"""" format(_)} getOrElse {""})
(action map {"""; action="%s"""".format(_)} getOrElse {""})
val headers = Map[String, String]("Content-Type" -> contentType)
val s = httpClient.request(r map {_.toString} getOrElse {""}, address, headers)

Expand Down
2 changes: 1 addition & 1 deletion cli/src/main/resources/soap12_async.scala.template
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ trait SoapClientsAsync {
case x => sys.error("unexpected non-elem: " + x.toString)
}}
val contentType = "application/soap+xml; charset=utf-8" +
(action map {"""; action="%s"""" format(_)} getOrElse {""})
(action map {"""; action="%s"""".format(_)} getOrElse {""})
val headers = Map[String, String]("Content-Type" -> contentType)
val ftr: Future[String] = httpClient.request(r map {_.toString} getOrElse {""}, address, headers)
ftr map { s: String =>
Expand Down
33 changes: 17 additions & 16 deletions cli/src/main/scala/scalaxb/compiler/wsdl11/GenSource.scala
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ trait {interfaceTypeName} {{
}
outputOpt flatMap { output: XParamType =>
isMultiPart(output, binding.output) map { _ =>
"case class %s(%s)" format(
"case class %s(%s)".format(
makeOperationOutputWrapperName(op),
makeOperationOutputArgs map {_.toScalaCode} mkString(", ")
)
Expand Down Expand Up @@ -522,8 +522,8 @@ trait {interfaceTypeName} {{
} match {
case Nil => "Nil"
case x :: Nil => x
case xs if config.useLists => "List.concat(%s)" format (xs.mkString("," + NL + " "))
case xs => "Seq.concat(%s)" format (xs.mkString("," + NL + " "))
case xs if config.useLists => "List.concat(%s)".format(xs.mkString("," + NL + " "))
case xs => "Seq.concat(%s)".format(xs.mkString("," + NL + " "))
}

// http://www.w3.org/TR/wsdl#_soap:body
Expand Down Expand Up @@ -609,14 +609,14 @@ trait {interfaceTypeName} {{
val elem = xsdgenerator.elements(splitTypeName(elementQName))
"""({
scala.xml.Elem(null, "Body", scala.xml.Null, defaultScope, true, body.toSeq: _*)
} \ "%s").head""" format (elem.name)
} \ "%s").head""".format(elem.name)
case (DocumentStyle, None) =>
"""body.head"""
case (RpcStyle, Some(elementQName)) =>
val elem = xsdgenerator.elements(splitTypeName(elementQName))
"""(body.head \ "%s").head""" format (elem.name)
"""(body.head \ "%s").head""".format(elem.name)
case (RpcStyle, None) =>
"""(body.head \ "%s").head""" format (p.name.get)
"""(body.head \ "%s").head""".format(p.name.get)
}
buildPartArg(p, v) + (soapBindingStyle match {
case DocumentStyle =>
Expand All @@ -628,13 +628,13 @@ trait {interfaceTypeName} {{
})
}) ++ (headerParts map { p =>
val v =
if (p.element.isDefined) """(<x>{header}</x> \ "%s").head""" format (p.element.get.getLocalPart)
else """(<x>{header}</x> \ "%s").head""" format (p.name.get)
if (p.element.isDefined) """(<x>{header}</x> \ "%s").head""".format(p.element.get.getLocalPart)
else """(<x>{header}</x> \ "%s").head""".format(p.name.get)
buildPartArg(p, v)
})

if (!multipart) fromXmls.head
else "%s(%s)" format (xsdgenerator.buildFullyQualifiedNameFromPackage(pkg, makeOperationOutputWrapperName(op)),
else "%s(%s)".format(xsdgenerator.buildFullyQualifiedNameFromPackage(pkg, makeOperationOutputWrapperName(op)),
fromXmls.mkString("," + NL + " "))
}
}
Expand Down Expand Up @@ -666,7 +666,7 @@ trait {interfaceTypeName} {{
}
def baseTypeName: String = xsdgenerator.buildTypeName(typeSymbol)
def toParamName = escapeKeyWord(paramName)
def toScalaCode: String = "%s: %s" format(toParamName, typeName)
def toScalaCode: String = "%s: %s".format(toParamName, typeName)
def toVarg: String =
if (seqParam) toParamName + ": _*"
else toParamName
Expand Down Expand Up @@ -768,12 +768,13 @@ trait {interfaceTypeName} {{
}

def faultsToTypeName(faults: Seq[XFaultType], soap12: Boolean): String =
"%s[%s]" format (if (soap12) "scalaxb.Fault"
else "scalaxb.Soap11Fault",
faultsToFaultParamTypeName(faults) match {
case (x, true) => s"""Option[$x]"""
case (x, _) => x
})
"%s[%s]".format(
if (soap12) "scalaxb.Fault" else "scalaxb.Soap11Fault",
faultsToFaultParamTypeName(faults) match {
case (x, true) => s"""Option[$x]"""
case (x, _) => x
}
)

// param type and nillable
def faultParamTypeName(fault: XFaultType): (String, Boolean) = {
Expand Down
26 changes: 13 additions & 13 deletions cli/src/main/scala/scalaxb/compiler/xsd/ContextProcessor.scala
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ trait ContextProcessor extends ScalaNames with PackageName {
val anonymousTypes = mutable.ListBuffer.empty[(SchemaDecl, ComplexTypeDecl)]

for (schema <- schemas) {
logger.debug("processContext - " + schema.targetNamespace)
logger.debug("processContext - %s".format(schema.targetNamespace))
context.typeNames(schema) = makeProtectedTypeName(schema, context)
resolveType(schema, context)
}
Expand All @@ -92,7 +92,7 @@ trait ContextProcessor extends ScalaNames with PackageName {
if (context.typeNames.contains(decl)) registerDuplicatedType(schema, decl, decl.name)
else {
context.typeNames(decl) = makeProtectedTypeName(schema.targetNamespace, initialName, postfix, context)
logger.debug("processContent: enum %s is named %s" format(decl.name, context.typeNames(decl)))
logger.debug("processContent: enum %s is named %s".format(decl.name, context.typeNames(decl)))
makeEnumValues(decl, schema.scope, context)
} // if-else
}
Expand All @@ -107,21 +107,21 @@ trait ContextProcessor extends ScalaNames with PackageName {
} ref.decl match {
case decl: ComplexTypeDecl =>
anonymousTypes += ((schema, decl))
logger.debug("processContent: %s's %s" format(elem.name, decl.name))
logger.debug("processContent: %s's %s".format(elem.name, decl.name))
if (context.typeNames.contains(decl)) registerDuplicatedType(schema, decl, elem.name)

context.typeNames.getOrElseUpdate(decl, {
val prefix: Option[String] =
if (decl.family != List(elem.name, elem.name) && config.prependFamilyName) Some(decl.family.head)
else None
val name = makeProtectedTypeName(schema.targetNamespace, prefix, elem, context)
logger.debug("processContent: %s's %s is named %s" format(elem.name, decl.name, name))
logger.debug("processContent: %s's %s is named %s".format(elem.name, decl.name, name))
name
})

// simple types are handled later.
// case decl: SimpleTypeDecl if containsEnumeration(decl) =>
// logger.debug("processContent: %s's %s" format(elem.name, decl.name))
// logger.debug("processContent: %s's %s".format(elem.name, decl.name))
// nameEnumSimpleType(schema, decl, elem.name, "")
case _ =>
}
Expand All @@ -132,16 +132,16 @@ trait ContextProcessor extends ScalaNames with PackageName {
typ <- schema.topTypes
} typ match {
case (_, decl: ComplexTypeDecl) =>
logger.debug("processContext: top-level type %s" format (decl.name))
logger.debug("processContext: top-level type %s".format(decl.name))
namedTypes += ((schema, decl))
if (context.typeNames.contains(decl)) registerDuplicatedType(schema, decl, decl.name)
else {
val name = makeProtectedTypeName(schema.targetNamespace, decl, context)
logger.debug("processContext: top-level type %s is named %s" format (decl.name, name))
logger.debug("processContext: top-level type %s is named %s".format(decl.name, name))
context.typeNames.getOrElseUpdate(decl, name)
}
case (_, decl@SimpleTypeDecl(_, _, _, _, _)) if containsEnumeration(decl) =>
logger.debug("processContext: top-level type %s" format (decl.name))
logger.debug("processContext: top-level type %s".format(decl.name))
nameEnumSimpleType(schema, decl, decl.name)
case _ =>
}
Expand Down Expand Up @@ -172,22 +172,22 @@ trait ContextProcessor extends ScalaNames with PackageName {
if !base.abstractValue &&
!context.schemas.exists(schema => context.duplicatedTypes.contains((schema, base))) ) {
context.typeNames(base) = makeTraitName(base)
logger.debug("processContext: naming trait %s" format context.typeNames(base))
logger.debug("processContext: naming trait %s".format(context.typeNames(base)))
}

for (schema <- schemas;
group <- schema.topGroups.valuesIterator.toList) {
val pair = (schema, group)
context.groups += pair
logger.debug("processContext: added group " + group.name)
logger.debug("processContext: added group %s".format(group.name))
}

for (schema <- schemas;
elem <- schema.topElems.valuesIterator.toList) {
elem.substitutionGroup foreach { sub =>
if (!context.substituteGroups.contains(sub)) {
context.substituteGroups += sub
logger.debug("processContext: added sub group " + sub)
logger.debug("processContext: added sub group %s".format(sub))
}
}
}
Expand All @@ -197,7 +197,7 @@ trait ContextProcessor extends ScalaNames with PackageName {
typ <- schema.typeList if !(schema.topTypes.valuesIterator contains typ)
} typ match {
case decl: SimpleTypeDecl if containsEnumeration(decl) =>
logger.debug("processContext: inner simple type %s" format (decl.name))
logger.debug("processContext: inner simple type %s".format(decl.name))
nameEnumSimpleType(schema, decl, decl.family.last)
case _ =>
}
Expand Down Expand Up @@ -509,7 +509,7 @@ trait ContextProcessor extends ScalaNames with PackageName {
def makeProtectedTypeName(namespace: Option[String], prefix: Option[String],
elem: ElemDecl, context: XsdContext): String =
makeProtectedTypeName(elem.namespace orElse namespace,
prefix map { "%s%s" format (_, elem.name.capitalize) } getOrElse {elem.name}, "", context)
prefix map { "%s%s".format(_, elem.name.capitalize) } getOrElse {elem.name}, "", context)

def makeProtectedTypeName(namespace: Option[String], decl: ComplexTypeDecl, context: XsdContext): String =
makeProtectedTypeName(decl.namespace orElse namespace, decl.name, "Type", context)
Expand Down
2 changes: 1 addition & 1 deletion cli/src/main/scala/scalaxb/compiler/xsd/Decl.scala
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ object ElemDecl {
} getOrElse {
for (child <- node.child) child match {
case <complexType>{ _* }</complexType> =>
val decl = ComplexTypeDecl.fromXML(child, "@%s" format (family :+ name).mkString("/"), family :+ name, config)
val decl = ComplexTypeDecl.fromXML(child, "@%s".format((family :+ name).mkString("/")), family :+ name, config)
config.typeList += decl
val symbol = ReferenceTypeSymbol(config.targetNamespace, decl.name)
symbol.decl = decl
Expand Down
14 changes: 8 additions & 6 deletions cli/src/main/scala/scalaxb/compiler/xsd/Parsers.scala
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,15 @@ trait Parsers extends Args with Params {
if (laxAny) "_ => true"
else namespaceConstraint match {
case ("##any" :: Nil) | Nil | ("" :: Nil) => "_ => true"
case "##other" :: Nil => "_.namespace != %s" format (quoteNamespace(schema.targetNamespace))
case "##other" :: Nil => "_.namespace != %s".format(quoteNamespace(schema.targetNamespace))
case _ =>
"""x => %s contains x.namespace""" format (namespaceConstraint.map {
case "##targetNamespace" => quoteNamespace(schema.targetNamespace)
case "##local" => "None"
case x => quoteNamespace(Some(x))
}).mkString("List(", ", ", ")")
"""x => %s contains x.namespace""".format(
namespaceConstraint.map {
case "##targetNamespace" => quoteNamespace(schema.targetNamespace)
case "##local" => "None"
case x => quoteNamespace(Some(x))
}.mkString("List(", ", ", ")")
)
})

buildParserString(if (mixed) "((" + parser + " ^^ (" + converter + ")) " + follow + newline +
Expand Down
2 changes: 1 addition & 1 deletion cli/src/main/scala/scalaxb/compiler/xsd/XMLOutput.scala
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ trait XMLOutput extends Args {
def buildToString(selector: String, typeSymbol: XsTypeSymbol): String = typeSymbol match {
case symbol: BuiltInSimpleTypeSymbol =>
buildTypeName(symbol) match {
case "javax.xml.namespace.QName" => "scalaxb.Helper.toString(%s, __scope)" format selector
case "javax.xml.namespace.QName" => "scalaxb.Helper.toString(%s, __scope)".format(selector)
case "BigDecimal" => selector + ".bigDecimal.toPlainString"
case _ => selector + ".toString"
}
Expand Down
2 changes: 1 addition & 1 deletion cli/src/main/scala/scalaxb/compiler/xsd/XsTypeSymbol.scala
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ object ReferenceTypeSymbol {
class ReferenceTypeSymbol(val qname: QName) extends XsTypeSymbol {
val namespace = masked.scalaxb.Helper.nullOrEmpty(qname.getNamespaceURI)
val localPart = qname.getLocalPart
val name: String = (namespace map {"{%s}" format _} getOrElse("")) + localPart
val name: String = (namespace map {"{%s}".format(_)} getOrElse("")) + localPart

var decl: TypeDecl = null
override def toString(): String = {
Expand Down
6 changes: 3 additions & 3 deletions cli/src_managed/scalaxb/scalaxb.scala
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ object `package` {
def fromXML[A](seq: NodeSeq, stack: List[ElemName] = Nil)
(implicit format: XMLFormat[A]): A = format.reads(seq, stack) match {
case Right(a) => a
case Left(a) => throw new ParserFailure("Error while parsing %s: %s" format(seq.toString, a))
case Left(a) => throw new ParserFailure("Error while parsing %s: %s".format(seq.toString, a))
}

@implicitNotFound(msg = "Cannot find XMLFormat type class for ${A}")
Expand Down Expand Up @@ -810,7 +810,7 @@ object Helper {

def toString(value: QName, scope: NamespaceBinding): String =
Option[String](scope.getPrefix(value.getNamespaceURI)) map {
"%s:%s" format (_, value.getLocalPart)} getOrElse {value.getLocalPart}
"%s:%s".format(_, value.getLocalPart)} getOrElse {value.getLocalPart}

def toCalendar(value: String): XMLGregorianCalendar = {
DataTypeFactory.get().newXMLGregorianCalendar(value)
Expand Down Expand Up @@ -889,7 +889,7 @@ object Helper {
else nullOrEmpty(scope.getPrefix(namespace.orNull))

def prefixedName(namespace: Option[String], name: String, scope: scala.xml.NamespaceBinding) =
getPrefix(namespace, scope) map { """%s:%s""" format(_, name)
getPrefix(namespace, scope) map { """%s:%s""".format(_, name)
} getOrElse {name}

def stringToXML(obj: String, namespace: Option[String], elementLabel: Option[String],
Expand Down
2 changes: 1 addition & 1 deletion integration/src/test/scala-2.13-/CompilerMatcher.scala
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ trait CompilerMatcher {
sys.error(s"""Error compiling: ${ files.mkString(",") }""")
}
code foreach { c => main.interpret(c) match {
case IR.Error => sys.error("Error interpreting %s" format (c))
case IR.Error => sys.error("Error interpreting %s".format(c))
case _ =>
}}
val holder0 = allCatch opt {
Expand Down
4 changes: 2 additions & 2 deletions project/dependencies.scala
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import sbt._

object Dependencies {
val scala213 = "2.13.1"
val scala212 = "2.12.10"
val scala213 = "2.13.3"
val scala212 = "2.12.11"
val scala211 = "2.11.12"
val scala210 = "2.10.7"

Expand Down

0 comments on commit f6b7819

Please sign in to comment.