@@ -42,12 +42,14 @@ class SymbolicXMLBuilder(parser: Parser, preserveWS: Boolean)(using Context) {
42
42
val _Group : TypeName = " Group"
43
43
val _MetaData : TypeName = " MetaData"
44
44
val _NamespaceBinding : TypeName = " NamespaceBinding"
45
+ val _Node : TypeName = " Node"
45
46
val _NodeBuffer : TypeName = " NodeBuffer"
46
47
val _PrefixedAttribute : TypeName = " PrefixedAttribute"
47
48
val _ProcInstr : TypeName = " ProcInstr"
48
49
val _Text : TypeName = " Text"
49
50
val _Unparsed : TypeName = " Unparsed"
50
51
val _UnprefixedAttribute : TypeName = " UnprefixedAttribute"
52
+ val _Seq : TypeName = " Seq"
51
53
}
52
54
53
55
private object xmlterms extends ScalaTermNames {
@@ -59,12 +61,13 @@ class SymbolicXMLBuilder(parser: Parser, preserveWS: Boolean)(using Context) {
59
61
val _plus : TermName = " &+"
60
62
val _tmpscope : TermName = " $tmpscope"
61
63
val _xml : TermName = " xml"
64
+ val _toVector : TermName = " toVector"
62
65
}
63
66
64
- import xmltypes .{_Comment , _Elem , _EntityRef , _Group , _MetaData , _NamespaceBinding , _NodeBuffer ,
65
- _PrefixedAttribute , _ProcInstr , _Text , _Unparsed , _UnprefixedAttribute }
67
+ import xmltypes .{_Comment , _Elem , _EntityRef , _Group , _MetaData , _NamespaceBinding , _NodeBuffer , _Node ,
68
+ _PrefixedAttribute , _ProcInstr , _Text , _Unparsed , _UnprefixedAttribute , _Seq }
66
69
67
- import xmlterms .{_Null , __Elem , __Text , _buf , _md , _plus , _scope , _tmpscope , _xml }
70
+ import xmlterms .{_Null , __Elem , __Text , _buf , _md , _plus , _scope , _tmpscope , _xml , _toVector }
68
71
69
72
// convenience methods
70
73
private def LL [A ](x : A * ): List [List [A ]] = List (x.toList)
@@ -89,6 +92,7 @@ class SymbolicXMLBuilder(parser: Parser, preserveWS: Boolean)(using Context) {
89
92
private def _scala_xml_UnprefixedAttribute = _scala_xml(_UnprefixedAttribute)
90
93
private def _scala_xml__Elem = _scala_xml(__Elem)
91
94
private def _scala_xml__Text = _scala_xml(__Text)
95
+ private def _scala_Seq_Node = AppliedTypeTree (_scala(_Seq), List (_scala_xml(_Node)))
92
96
93
97
/** Wildly wrong documentation deleted in favor of "self-documenting code." */
94
98
protected def mkXML (
@@ -103,7 +107,7 @@ class SymbolicXMLBuilder(parser: Parser, preserveWS: Boolean)(using Context) {
103
107
{
104
108
def starArgs =
105
109
if (children.isEmpty) Nil
106
- else List (Typed (makeXMLseq(span, children), wildStar))
110
+ else List (Typed (makeXMLseq(span, children, toVector = true ), wildStar))
107
111
108
112
def pat = Apply (_scala_xml__Elem, List (pre, label, wild, wild) ::: convertToTextPat(children))
109
113
def nonpat = New (_scala_xml_Elem, List (List (pre, label, attrs, scope, if (empty) Literal (Constant (true )) else Literal (Constant (false ))) ::: starArgs))
@@ -152,7 +156,7 @@ class SymbolicXMLBuilder(parser: Parser, preserveWS: Boolean)(using Context) {
152
156
ts match {
153
157
case Nil => TypedSplice (tpd.ref(defn.NilModule ).withSpan(span))
154
158
case t :: Nil => t
155
- case _ => makeXMLseq(span, ts)
159
+ case _ => makeXMLseq(span, ts, toVector = true )
156
160
}
157
161
}
158
162
@@ -162,11 +166,12 @@ class SymbolicXMLBuilder(parser: Parser, preserveWS: Boolean)(using Context) {
162
166
}
163
167
164
168
/** could optimize if args.length == 0, args.length == 1 AND args(0) is <: Node. */
165
- def makeXMLseq (span : Span , args : collection.Seq [Tree ]): Block = {
169
+ def makeXMLseq (span : Span , args : collection.Seq [Tree ], toVector : Boolean ): Block = {
166
170
val buffer = ValDef (_buf, TypeTree (), New (_scala_xml_NodeBuffer, ListOfNil ))
167
171
val applies = args filterNot isEmptyText map (t => Apply (Select (Ident (_buf), _plus), List (t)))
168
172
169
- atSpan(span)(new XMLBlock (buffer :: applies.toList, Ident (_buf)) )
173
+ val res = if (toVector) Select (Ident (_buf), _toVector) else Ident (_buf)
174
+ atSpan(span)(new XMLBlock (buffer :: applies.toList, res))
170
175
}
171
176
172
177
/** Returns (Some(prefix) | None, rest) based on position of ':' */
@@ -177,7 +182,7 @@ class SymbolicXMLBuilder(parser: Parser, preserveWS: Boolean)(using Context) {
177
182
178
183
/** Various node constructions. */
179
184
def group (span : Span , args : collection.Seq [Tree ]): Tree =
180
- atSpan(span)( New (_scala_xml_Group, LL (makeXMLseq(span, args))) )
185
+ atSpan(span)( New (_scala_xml_Group, LL (makeXMLseq(span, args, toVector = true ))) )
181
186
182
187
def unparsed (span : Span , str : String ): Tree =
183
188
atSpan(span)( New (_scala_xml_Unparsed, LL (const(str))) )
0 commit comments