mirror of
https://github.com/dart-lang/sdk
synced 2024-10-14 15:09:04 +00:00
Add Forest method to access the name of a variable declaration
Change-Id: I2c24961573887ea56b0a09152c8926b3445e6c01 Reviewed-on: https://dart-review.googlesource.com/57006 Reviewed-by: Dan Rubel <danrubel@google.com> Reviewed-by: Peter von der Ahé <ahe@google.com> Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
This commit is contained in:
parent
3b86f823d0
commit
13987b073d
|
@ -247,6 +247,11 @@ class AstBuildingForest
|
||||||
int getTypeCount(TypeArgumentList typeArguments) =>
|
int getTypeCount(TypeArgumentList typeArguments) =>
|
||||||
typeArguments.arguments.length;
|
typeArguments.arguments.length;
|
||||||
|
|
||||||
|
@override
|
||||||
|
String getVariableDeclarationName(VariableDeclaration declaration) {
|
||||||
|
return declaration.name.name;
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Statement ifStatement(
|
Statement ifStatement(
|
||||||
Token ifKeyword,
|
Token ifKeyword,
|
||||||
|
|
|
@ -358,8 +358,8 @@ abstract class BodyBuilder<Expression, Statement, Arguments>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void declareVariable(VariableDeclaration variable, Scope scope) {
|
void declareVariable(Object variable, Scope scope) {
|
||||||
String name = variable.name;
|
String name = forest.getVariableDeclarationName(variable);
|
||||||
Builder existing = scope.local[name];
|
Builder existing = scope.local[name];
|
||||||
if (existing != null) {
|
if (existing != null) {
|
||||||
// This reports an error for duplicated declarations in the same scope:
|
// This reports an error for duplicated declarations in the same scope:
|
||||||
|
@ -373,7 +373,7 @@ abstract class BodyBuilder<Expression, Statement, Arguments>
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
LocatedMessage context = scope.declare(
|
LocatedMessage context = scope.declare(
|
||||||
variable.name,
|
forest.getVariableDeclarationName(variable),
|
||||||
new KernelVariableBuilder(
|
new KernelVariableBuilder(
|
||||||
variable, member ?? classBuilder ?? library, uri),
|
variable, member ?? classBuilder ?? library, uri),
|
||||||
uri);
|
uri);
|
||||||
|
|
|
@ -545,6 +545,11 @@ class Fangorn extends Forest<Expression, Statement, Token, Arguments> {
|
||||||
@override
|
@override
|
||||||
int getLabelOffset(Label label) => label.charOffset;
|
int getLabelOffset(Label label) => label.charOffset;
|
||||||
|
|
||||||
|
@override
|
||||||
|
String getVariableDeclarationName(VariableDeclaration declaration) {
|
||||||
|
return declaration.name;
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
bool isBlock(Object node) => node is Block;
|
bool isBlock(Object node) => node is Block;
|
||||||
|
|
||||||
|
|
|
@ -322,6 +322,9 @@ abstract class Forest<Expression, Statement, Location, Arguments> {
|
||||||
/// Return the offset of the given [label].
|
/// Return the offset of the given [label].
|
||||||
int getLabelOffset(covariant label);
|
int getLabelOffset(covariant label);
|
||||||
|
|
||||||
|
/// Return the name of the given variable [declaration].
|
||||||
|
String getVariableDeclarationName(covariant declaration);
|
||||||
|
|
||||||
bool isBlock(Object node);
|
bool isBlock(Object node);
|
||||||
|
|
||||||
/// Return `true` if the given [statement] is the representation of an empty
|
/// Return `true` if the given [statement] is the representation of an empty
|
||||||
|
|
Loading…
Reference in a new issue