Skip to content

Commit

Permalink
[_fe_analyzer_shared] Rename StringJuxtaposition to AdjacentStringLit…
Browse files Browse the repository at this point in the history
…erals

Change-Id: I2ed9172f51f9a9011ca9dff59c62c42ffb56f05e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/391605
Reviewed-by: Konstantin Shcheglov <[email protected]>
Commit-Queue: Johnni Winther <[email protected]>
Reviewed-by: Jens Johansen <[email protected]>
  • Loading branch information
johnniwinther authored and Commit Queue committed Oct 24, 2024
1 parent 4b2b07b commit 4d552d1
Show file tree
Hide file tree
Showing 17 changed files with 47 additions and 46 deletions.
8 changes: 4 additions & 4 deletions pkg/_fe_analyzer_shared/lib/src/metadata/expressions.dart
Original file line number Diff line number Diff line change
Expand Up @@ -162,20 +162,20 @@ class StringLiteral extends Expression {
}
}

class StringJuxtaposition extends Expression {
class AdjacentStringLiterals extends Expression {
final List<Expression> expressions;

StringJuxtaposition(this.expressions);
AdjacentStringLiterals(this.expressions);

@override
String toString() => 'StringJuxtaposition($expressions)';
String toString() => 'AdjacentStringLiterals($expressions)';

@override
Expression? resolve() {
List<Expression>? newExpressions = expressions.resolve((e) => e.resolve());
return newExpressions == null
? null
: new StringJuxtaposition(newExpressions);
: new AdjacentStringLiterals(newExpressions);
}
}

Expand Down
4 changes: 2 additions & 2 deletions pkg/_fe_analyzer_shared/lib/src/metadata/parser.dart
Original file line number Diff line number Diff line change
Expand Up @@ -666,15 +666,15 @@ class AnnotationsListener extends StackListener {
}

@override
void handleStringJuxtaposition(Token startToken, int literalCount) {
void handleAdjacentStringLiterals(Token startToken, int literalCount) {
assert(
checkState(startToken, repeatedKind(_ValueKinds._Proto, literalCount)));
List<Expression> expressions =
new List.filled(literalCount, _dummyExpression);
while (--literalCount >= 0) {
expressions[literalCount] = _popExpression();
}
push(new ExpressionProto(new StringJuxtaposition(expressions)));
push(new ExpressionProto(new AdjacentStringLiterals(expressions)));
}

@override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1991,8 +1991,8 @@ class ForwardingListener implements Listener {
}

@override
void handleStringJuxtaposition(Token startToken, int literalCount) {
listener?.handleStringJuxtaposition(startToken, literalCount);
void handleAdjacentStringLiterals(Token startToken, int literalCount) {
listener?.handleAdjacentStringLiterals(startToken, literalCount);
}

@override
Expand Down
4 changes: 2 additions & 2 deletions pkg/_fe_analyzer_shared/lib/src/parser/listener.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1141,8 +1141,8 @@ class Listener implements UnescapeErrorListener {
logEvent("LiteralString");
}

void handleStringJuxtaposition(Token startToken, int literalCount) {
logEvent("StringJuxtaposition");
void handleAdjacentStringLiterals(Token startToken, int literalCount) {
logEvent("AdjacentStringLiterals");
}

/// Called for class-like members (class, mixin, extension), but each member
Expand Down
2 changes: 1 addition & 1 deletion pkg/_fe_analyzer_shared/lib/src/parser/parser_impl.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7564,7 +7564,7 @@ class Parser {
count++;
}
if (count > 1) {
listener.handleStringJuxtaposition(startToken, count);
listener.handleAdjacentStringLiterals(startToken, count);
}
mayParseFunctionExpressions = old;
return token;
Expand Down
4 changes: 2 additions & 2 deletions pkg/_fe_analyzer_shared/lib/src/testing/metadata_helper.dart
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,8 @@ class Writer {
_write('StringLiteral(');
_stringPartsToText(expression.parts);
_write(')');
case StringJuxtaposition():
_write('StringJuxtaposition(');
case AdjacentStringLiterals():
_write('AdjacentStringLiterals(');
_incIndent(addNewLine: false);
_expressionsToText(expression.expressions, delimiter: '');
_decIndent();
Expand Down
8 changes: 4 additions & 4 deletions pkg/_fe_analyzer_shared/test/metadata/data/literal/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,10 @@ void literal9() {}
/*member: literal10:
unresolved=UnresolvedExpression(UnresolvedInvoke(
UnresolvedIdentifier(Helper)
(StringJuxtaposition(
(AdjacentStringLiterals(
StringLiteral('a')
StringLiteral('b')))))
resolved=StringJuxtaposition(
resolved=AdjacentStringLiterals(
StringLiteral('a')
StringLiteral('b'))*/
void literal10() {}
Expand All @@ -96,11 +96,11 @@ void literal10() {}
/*member: literal11:
unresolved=UnresolvedExpression(UnresolvedInvoke(
UnresolvedIdentifier(Helper)
(StringJuxtaposition(
(AdjacentStringLiterals(
StringLiteral('a')
StringLiteral('b')
StringLiteral('c')))))
resolved=StringJuxtaposition(
resolved=AdjacentStringLiterals(
StringLiteral('a')
StringLiteral('b')
StringLiteral('c'))*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -388,11 +388,11 @@ void literals2() {}
/*member: literals3:
unresolved=UnresolvedExpression(UnresolvedInvoke(
UnresolvedIdentifier(Helper)
(StringJuxtaposition(
(AdjacentStringLiterals(
StringLiteral('a')
StringLiteral('b${UnresolvedExpression(UnresolvedIdentifier(constInt))}')
StringLiteral('c')))))
resolved=StringJuxtaposition(
resolved=AdjacentStringLiterals(
StringLiteral('a')
StringLiteral('b${UnresolvedExpression(UnresolvedIdentifier(constInt))}')
StringLiteral('c'))*/
Expand Down
16 changes: 8 additions & 8 deletions pkg/analyzer/lib/src/fasta/ast_builder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3709,6 +3709,14 @@ class AstBuilder extends StackListener {
);
}

@override
void handleAdjacentStringLiterals(Token startToken, int literalCount) {
debugEvent("AdjacentStringLiterals");

var strings = popTypedList2<StringLiteralImpl>(literalCount);
push(AdjacentStringsImpl(strings: strings));
}

@override
void handleAsOperator(Token asOperator) {
assert(optional('as', asOperator));
Expand Down Expand Up @@ -5535,14 +5543,6 @@ class AstBuilder extends StackListener {
);
}

@override
void handleStringJuxtaposition(Token startToken, int literalCount) {
debugEvent("StringJuxtaposition");

var strings = popTypedList2<StringLiteralImpl>(literalCount);
push(AdjacentStringsImpl(strings: strings));
}

@override
void handleStringPart(Token literalString) {
assert(identical(literalString.kind, STRING_TOKEN));
Expand Down
4 changes: 2 additions & 2 deletions pkg/front_end/lib/src/kernel/body_builder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3499,8 +3499,8 @@ class BodyBuilder extends StackListenerImpl
}

@override
void handleStringJuxtaposition(Token startToken, int literalCount) {
debugEvent("StringJuxtaposition");
void handleAdjacentStringLiterals(Token startToken, int literalCount) {
debugEvent("AdjacentStringLiterals");
List<Expression> parts = popListForValue(literalCount);
List<Expression>? expressions;
// Flatten string juxtapositions of string interpolation.
Expand Down
2 changes: 1 addition & 1 deletion pkg/front_end/lib/src/kernel/macro/annotation_parser.dart
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,7 @@ class _MacroListener implements Listener {
}

@override
void handleStringJuxtaposition(Token startToken, int literalCount) {
void handleAdjacentStringLiterals(Token startToken, int literalCount) {
if (unrecognized) {
pushUnsupported();
} else {
Expand Down
4 changes: 2 additions & 2 deletions pkg/front_end/lib/src/source/diet_listener.dart
Original file line number Diff line number Diff line change
Expand Up @@ -515,8 +515,8 @@ class DietListener extends StackListenerImpl {

@override
// Coverage-ignore(suite): Not run.
void handleStringJuxtaposition(Token startToken, int literalCount) {
debugEvent("StringJuxtaposition");
void handleAdjacentStringLiterals(Token startToken, int literalCount) {
debugEvent("AdjacentStringLiterals");
}

@override
Expand Down
4 changes: 2 additions & 2 deletions pkg/front_end/lib/src/source/outline_builder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -900,8 +900,8 @@ class OutlineBuilder extends StackListenerImpl {

@override
// Coverage-ignore(suite): Not run.
void handleStringJuxtaposition(Token startToken, int literalCount) {
debugEvent("StringJuxtaposition");
void handleAdjacentStringLiterals(Token startToken, int literalCount) {
debugEvent("AdjacentStringLiterals");
List<String> list =
new List<String>.filled(literalCount, /* dummyValue = */ '');
int charOffset = -1;
Expand Down
17 changes: 9 additions & 8 deletions pkg/front_end/lib/src/util/parser_ast_helper.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1490,8 +1490,8 @@ abstract class AbstractParserAstListener implements Listener {
}

@override
void handleStringJuxtaposition(Token startToken, int literalCount) {
StringJuxtapositionHandle data = new StringJuxtapositionHandle(
void handleAdjacentStringLiterals(Token startToken, int literalCount) {
AdjacentStringLiteralsHandle data = new AdjacentStringLiteralsHandle(
ParserAstType.HANDLE,
startToken: startToken,
literalCount: literalCount);
Expand Down Expand Up @@ -6356,13 +6356,13 @@ class LiteralStringEnd extends ParserAstNode {
R accept<R>(ParserAstVisitor<R> v) => v.visitLiteralStringEnd(this);
}

class StringJuxtapositionHandle extends ParserAstNode {
class AdjacentStringLiteralsHandle extends ParserAstNode {
final Token startToken;
final int literalCount;

StringJuxtapositionHandle(ParserAstType type,
AdjacentStringLiteralsHandle(ParserAstType type,
{required this.startToken, required this.literalCount})
: super("StringJuxtaposition", type);
: super("AdjacentStringLiterals", type);

@override
Map<String, Object?> get deprecatedArguments => {
Expand All @@ -6371,7 +6371,8 @@ class StringJuxtapositionHandle extends ParserAstNode {
};

@override
R accept<R>(ParserAstVisitor<R> v) => v.visitStringJuxtapositionHandle(this);
R accept<R>(ParserAstVisitor<R> v) =>
v.visitAdjacentStringLiteralsHandle(this);
}

class MemberBegin extends ParserAstNode {
Expand Down Expand Up @@ -10254,7 +10255,7 @@ abstract class ParserAstVisitor<R> {
R visitLiteralStringBegin(LiteralStringBegin node);
R visitInterpolationExpressionHandle(InterpolationExpressionHandle node);
R visitLiteralStringEnd(LiteralStringEnd node);
R visitStringJuxtapositionHandle(StringJuxtapositionHandle node);
R visitAdjacentStringLiteralsHandle(AdjacentStringLiteralsHandle node);
R visitMemberBegin(MemberBegin node);
R visitInvalidMemberHandle(InvalidMemberHandle node);
R visitMemberEnd(MemberEnd node);
Expand Down Expand Up @@ -11101,7 +11102,7 @@ class RecursiveParserAstVisitor implements ParserAstVisitor<void> {
void visitLiteralStringEnd(LiteralStringEnd node) => node.visitChildren(this);

@override
void visitStringJuxtapositionHandle(StringJuxtapositionHandle node) =>
void visitAdjacentStringLiteralsHandle(AdjacentStringLiteralsHandle node) =>
node.visitChildren(this);

@override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,7 @@ beginCompilationUnit(import)
endLiteralString(0, 'bar')
beginLiteralString('bar')
endLiteralString(0, :)
handleStringJuxtaposition(case, 2)
handleAdjacentStringLiterals(case, 2)
endConstantPattern(null)
endPattern('bar')
handleSwitchCaseNoWhenClause('bar')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,7 @@ parseUnit(import)
parseSingleLiteralString('foo')
listener: beginLiteralString('bar')
listener: endLiteralString(0, :)
listener: handleStringJuxtaposition(case, 2)
listener: handleAdjacentStringLiterals(case, 2)
listener: endConstantPattern(null)
listener: endPattern('bar')
listener: handleSwitchCaseNoWhenClause('bar')
Expand Down
4 changes: 2 additions & 2 deletions pkg/front_end/test/parser_test_listener.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1629,9 +1629,9 @@ class ParserTestListener implements Listener {
}

@override
void handleStringJuxtaposition(Token startToken, int literalCount) {
void handleAdjacentStringLiterals(Token startToken, int literalCount) {
seen(startToken);
doPrint('handleStringJuxtaposition(' '$startToken, ' '$literalCount)');
doPrint('handleAdjacentStringLiterals(' '$startToken, ' '$literalCount)');
}

@override
Expand Down

0 comments on commit 4d552d1

Please sign in to comment.