@@ -155,11 +155,15 @@ class StringPart extends StringPart_, AstNode {
155
155
156
156
override Location getLocation ( ) { result = StringPart_ .super .getLocation ( ) }
157
157
158
- /** Holds if the content of string `StringPart` is surrounded by `prefix` and `quote`. */
159
- predicate context ( string prefix , string quote ) {
158
+ /**
159
+ * Holds if the content of string `StringPart` is surrounded by
160
+ * a prefix (including a quote) of length `prefixLength` and
161
+ * a quote of length `quoteLength`.
162
+ */
163
+ predicate contextSize ( int prefixLength , int quoteLength ) {
160
164
exists ( int occurrenceOffset |
161
- quote = this .getText ( ) .regexpFind ( "\"{3}|\"{1}|'{3}|'{1}" , 0 , occurrenceOffset ) and
162
- prefix = this . getText ( ) . prefix ( occurrenceOffset + quote . length ( ) )
165
+ quoteLength = this .getText ( ) .regexpFind ( "\"{3}|\"{1}|'{3}|'{1}" , 0 , occurrenceOffset ) . length ( ) and
166
+ prefixLength = occurrenceOffset + quoteLength
163
167
)
164
168
}
165
169
@@ -168,8 +172,8 @@ class StringPart extends StringPart_, AstNode {
168
172
* See `context` for obtaining the prefix and the quote.
169
173
*/
170
174
int getContentLength ( ) {
171
- exists ( string prefix , string quote | this .context ( prefix , quote ) |
172
- result = this .getText ( ) .length ( ) - prefix . length ( ) - quote . length ( )
175
+ exists ( int prefixLength , int quoteLength | this .contextSize ( prefixLength , quoteLength ) |
176
+ result = this .getText ( ) .length ( ) - prefixLength - quoteLength
173
177
)
174
178
}
175
179
}
0 commit comments