mirror of
https://github.com/dart-lang/sdk
synced 2024-10-14 16:37:43 +00:00
[_fe_analyzer_shared] handle $this
in String interpolation
Fixes #50263 Change-Id: I4fdfab69a2d462768848f01aceb450f266e09072 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/265083 Reviewed-by: Konstantin Shcheglov <scheglov@google.com> Reviewed-by: Jens Johansen <jensj@google.com> Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
This commit is contained in:
parent
79b11174a2
commit
5e75bb14a5
|
@ -1632,7 +1632,7 @@ abstract class AbstractScanner implements Scanner {
|
|||
if (($A <= next && next <= $Z) ||
|
||||
($0 <= next && next <= $9) ||
|
||||
identical(next, $_) ||
|
||||
identical(next, $$)) {
|
||||
(allowDollar && identical(next, $$))) {
|
||||
return tokenizeIdentifier(next, start, allowDollar);
|
||||
} else {
|
||||
appendKeywordToken(keyword);
|
||||
|
|
|
@ -1783,6 +1783,37 @@ final v = """a${bb}ccc""";
|
|||
expect(node.isSingleQuoted, isFalse);
|
||||
}
|
||||
}
|
||||
|
||||
void test_this_followedByDollar() {
|
||||
final parseResult = parseStringWithErrors(r'''
|
||||
class C {
|
||||
void m(int foo) {
|
||||
'$this$foo';
|
||||
}
|
||||
}
|
||||
''');
|
||||
parseResult.assertNoErrors();
|
||||
var node = parseResult.findNode.stringInterpolation('this');
|
||||
assertParsedNodeText(node, r'''
|
||||
StringInterpolation
|
||||
elements
|
||||
InterpolationString
|
||||
contents: '
|
||||
InterpolationExpression
|
||||
leftBracket: $
|
||||
expression: ThisExpression
|
||||
thisKeyword: this
|
||||
InterpolationString
|
||||
contents: <empty> <synthetic>
|
||||
InterpolationExpression
|
||||
leftBracket: $
|
||||
expression: SimpleIdentifier
|
||||
token: foo
|
||||
InterpolationString
|
||||
contents: '
|
||||
stringValue: null
|
||||
''');
|
||||
}
|
||||
}
|
||||
|
||||
@reflectiveTest
|
||||
|
|
Loading…
Reference in a new issue