Skip to content

Commit 760d7f2

Browse files
scheglovCommit Queue
authored andcommitted
Fine. Support for class type alias in library manifests.
Change-Id: I2a9fd308590613bb2f700b3ed843acdd07273ca7 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/422361 Commit-Queue: Konstantin Shcheglov <[email protected]> Reviewed-by: Paul Berry <[email protected]>
1 parent a16d1f3 commit 760d7f2

File tree

2 files changed

+508
-16
lines changed

2 files changed

+508
-16
lines changed

pkg/analyzer/lib/src/dart/element/element.dart

Lines changed: 34 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -477,26 +477,44 @@ class ClassElementImpl extends ClassOrMixinElementImpl
477477
ConstructorMember.from(superclassConstructor, superType);
478478

479479
var isNamed = superclassConstructor.name.isNotEmpty;
480-
implicitConstructor.constantInitializers = [
481-
SuperConstructorInvocationImpl(
482-
superKeyword: Tokens.super_(),
483-
period: isNamed ? Tokens.period() : null,
484-
constructorName: isNamed
485-
? (SimpleIdentifierImpl(
486-
StringToken(TokenType.STRING, superclassConstructor.name, -1),
487-
)..element = superclassConstructor.asElement2)
488-
: null,
489-
argumentList: ArgumentListImpl(
490-
leftParenthesis: Tokens.openParenthesis(),
491-
arguments: argumentsForSuperInvocation,
492-
rightParenthesis: Tokens.closeParenthesis(),
493-
),
494-
)..element = superclassConstructor.asElement2,
495-
];
480+
var superInvocation = SuperConstructorInvocationImpl(
481+
superKeyword: Tokens.super_(),
482+
period: isNamed ? Tokens.period() : null,
483+
constructorName: isNamed
484+
? (SimpleIdentifierImpl(
485+
StringToken(TokenType.STRING, superclassConstructor.name, -1),
486+
)..element = superclassConstructor.asElement2)
487+
: null,
488+
argumentList: ArgumentListImpl(
489+
leftParenthesis: Tokens.openParenthesis(),
490+
arguments: argumentsForSuperInvocation,
491+
rightParenthesis: Tokens.closeParenthesis(),
492+
),
493+
);
494+
_linkTokens(superInvocation);
495+
superInvocation.element = superclassConstructor.asElement2;
496+
implicitConstructor.constantInitializers = [superInvocation];
496497

497498
return implicitConstructor;
498499
}).toList(growable: false);
499500
}
501+
502+
static void _linkTokens(AstNode parent) {
503+
Token? lastToken;
504+
for (var entity in parent.childEntities) {
505+
switch (entity) {
506+
case Token token:
507+
lastToken?.next = token;
508+
token.previous = lastToken;
509+
lastToken = token;
510+
case AstNode node:
511+
_linkTokens(node);
512+
lastToken?.next = node.beginToken;
513+
node.beginToken.previous = lastToken;
514+
lastToken = node.endToken;
515+
}
516+
}
517+
}
500518
}
501519

502520
class ClassElementImpl2 extends InterfaceElementImpl2 implements ClassElement2 {

0 commit comments

Comments
 (0)