35
35
*
36
36
*/
37
37
public class StringInterpolationSequence {
38
- private boolean containsInterpolation = false ;
39
- private SassList items ;
38
+ private boolean containsInterpolation ;
39
+ private List < SassListItem > items ;
40
40
private String toString ;
41
41
42
42
/**
43
- * Creates a new StringInterpolationSequence containing only the given item.
44
- *
43
+ * Creates a new StringInterpolationSequence containing only the given item without interpolation .
44
+ * @param value single string value
45
45
*/
46
- public StringInterpolationSequence (String value ) {
47
- this ( Collections .<SassListItem > singletonList (new StringItem (value )) );
46
+ public StringInterpolationSequence ( String value ) {
47
+ items = Collections .<SassListItem > singletonList ( new StringItem ( value ) );
48
48
}
49
49
50
50
/**
@@ -61,11 +61,7 @@ public StringInterpolationSequence(List<SassListItem> sequence) {
61
61
break ;
62
62
}
63
63
}
64
- items = new SassList (SassList .Separator .SPACE , sequence );
65
- }
66
-
67
- private StringInterpolationSequence (SassList list ) {
68
- this (list .getItems ());
64
+ items = sequence ;
69
65
}
70
66
71
67
/**
@@ -77,12 +73,12 @@ private StringInterpolationSequence(SassList list) {
77
73
* current compilation context
78
74
* @return A new StringInterpolationSequence.
79
75
*/
80
- public StringInterpolationSequence replaceVariables (ScssContext context ) {
76
+ public StringInterpolationSequence replaceVariables ( ScssContext context ) {
81
77
if ( !containsInterpolation ) {
82
78
return this ;
83
79
}
84
- SassList resultList = items . replaceVariables ( context );
85
- return new StringInterpolationSequence ( resultList );
80
+
81
+ return new StringInterpolationSequence ( SassList . replaceVariables ( context , items ) );
86
82
}
87
83
88
84
/**
@@ -96,17 +92,21 @@ public StringInterpolationSequence replaceVariables(ScssContext context) {
96
92
*/
97
93
public StringInterpolationSequence append (StringInterpolationSequence other ) {
98
94
ArrayList <SassListItem > result = new ArrayList <SassListItem >(
99
- items . getItems () );
100
- result .addAll (other .items . getItems () );
95
+ items );
96
+ result .addAll (other .items );
101
97
return new StringInterpolationSequence (result );
102
98
}
103
99
104
100
@ Override
105
101
public String toString () {
106
- if (toString == null ) {
102
+ if ( toString == null ) {
103
+ List <SassListItem > items = this .items ;
104
+ if ( items .size () == 1 ) {
105
+ return items .get ( 0 ).printState ();
106
+ }
107
107
StringBuilder result = new StringBuilder ();
108
- for ( SassListItem item : items ) {
109
- result .append (item .printState ());
108
+ for ( SassListItem item : items ) {
109
+ result .append ( item .printState () );
110
110
}
111
111
toString = result .toString ();
112
112
}
@@ -129,12 +129,12 @@ public boolean containsInterpolation() {
129
129
}
130
130
131
131
public List <SassListItem > getItems () {
132
- return items . getItems () ;
132
+ return items ;
133
133
}
134
134
135
135
public StringInterpolationSequence updateUrl (String prefix ) {
136
136
if ( containsInterpolation ) {
137
- return new StringInterpolationSequence (items .updateUrl (prefix ) );
137
+ return new StringInterpolationSequence ( SassList .updateUrl ( items , prefix ) );
138
138
}
139
139
return this ;
140
140
}
0 commit comments