@@ -155,11 +155,15 @@ class StringPart extends StringPart_, AstNode {
155155
156156 override Location getLocation ( ) { result = StringPart_ .super .getLocation ( ) }
157157
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 ) {
160164 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
163167 )
164168 }
165169
@@ -168,8 +172,8 @@ class StringPart extends StringPart_, AstNode {
168172 * See `context` for obtaining the prefix and the quote.
169173 */
170174 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
173177 )
174178 }
175179}
0 commit comments