Add preliminary support for methods to AstBuilder.
This is just enough support to get tests in TopLevelParserTest_Fasta. I'll come back and fill in the details later when working specifically on support for class members. R=scheglov@google.com Review-Url: https://codereview.chromium.org/2707163002 .
This commit is contained in:
@@ -469,60 +469,6 @@ class ScopeProxy implements Scope {
|
||||
@reflectiveTest
|
||||
class TopLevelParserTest_Fasta extends FastaParserTestCase
|
||||
with TopLevelParserTestMixin {
|
||||
@override
|
||||
@failingTest
|
||||
void
|
||||
test_function_literal_allowed_in_ArgumentList_in_ConstructorFieldInitializer() {
|
||||
// TODO(paulberry): Unhandled event: Method
|
||||
super
|
||||
.test_function_literal_allowed_in_ArgumentList_in_ConstructorFieldInitializer();
|
||||
}
|
||||
|
||||
@override
|
||||
@failingTest
|
||||
void
|
||||
test_function_literal_allowed_in_IndexExpression_in_ConstructorFieldInitializer() {
|
||||
// TODO(paulberry): Unhandled event: Method
|
||||
super
|
||||
.test_function_literal_allowed_in_IndexExpression_in_ConstructorFieldInitializer();
|
||||
}
|
||||
|
||||
@override
|
||||
@failingTest
|
||||
void
|
||||
test_function_literal_allowed_in_ListLiteral_in_ConstructorFieldInitializer() {
|
||||
// TODO(paulberry): Unhandled event: Method
|
||||
super
|
||||
.test_function_literal_allowed_in_ListLiteral_in_ConstructorFieldInitializer();
|
||||
}
|
||||
|
||||
@override
|
||||
@failingTest
|
||||
void
|
||||
test_function_literal_allowed_in_MapLiteral_in_ConstructorFieldInitializer() {
|
||||
// TODO(paulberry): Unhandled event: Method
|
||||
super
|
||||
.test_function_literal_allowed_in_MapLiteral_in_ConstructorFieldInitializer();
|
||||
}
|
||||
|
||||
@override
|
||||
@failingTest
|
||||
void
|
||||
test_function_literal_allowed_in_ParenthesizedExpression_in_ConstructorFieldInitializer() {
|
||||
// TODO(paulberry): Unhandled event: Method
|
||||
super
|
||||
.test_function_literal_allowed_in_ParenthesizedExpression_in_ConstructorFieldInitializer();
|
||||
}
|
||||
|
||||
@override
|
||||
@failingTest
|
||||
void
|
||||
test_function_literal_allowed_in_StringInterpolation_in_ConstructorFieldInitializer() {
|
||||
// TODO(paulberry): Unhandled event: Method
|
||||
super
|
||||
.test_function_literal_allowed_in_StringInterpolation_in_ConstructorFieldInitializer();
|
||||
}
|
||||
|
||||
@override
|
||||
@failingTest
|
||||
void test_parseClassDeclaration_abstract() {
|
||||
|
||||
@@ -1018,6 +1018,54 @@ class AstBuilder extends ScopeListener {
|
||||
push(ast.typeParameterList(toAnalyzerToken(beginToken), typeParameters,
|
||||
toAnalyzerToken(endToken)));
|
||||
}
|
||||
|
||||
@override
|
||||
void endMethod(Token getOrSet, Token beginToken, Token endToken) {
|
||||
debugEvent("Method");
|
||||
FunctionBody body = _endFunctionBody();
|
||||
ConstructorName redirectedConstructor = null; // TODO(paulberry)
|
||||
List<ConstructorInitializer> initializers = null; // TODO(paulberry)
|
||||
Token separator = null; // TODO(paulberry)
|
||||
FormalParameterList parameters = pop();
|
||||
TypeParameterList typeParameters = pop();
|
||||
var name = pop();
|
||||
analyzer.Token propertyKeyword = toAnalyzerToken(getOrSet);
|
||||
TypeAnnotation returnType = pop();
|
||||
// TODO(paulberry): handle modifiers.
|
||||
var modifiers = pop();
|
||||
assert(modifiers == null);
|
||||
Token externalKeyword = null; // TODO(paulberry)
|
||||
Token constKeyword = null; // TODO(paulberry)
|
||||
Token factoryKeyword = null; // TODO(paulberry)
|
||||
List<Annotation> metadata = pop();
|
||||
// TODO(paulberry): capture doc comments.
|
||||
Comment comment = null;
|
||||
SimpleIdentifier returnType2;
|
||||
Token period;
|
||||
SimpleIdentifier name2;
|
||||
if (name is SimpleIdentifier) {
|
||||
SimpleIdentifier returnType2 = name;
|
||||
}
|
||||
push(ast.constructorDeclaration(
|
||||
comment,
|
||||
metadata,
|
||||
toAnalyzerToken(externalKeyword),
|
||||
toAnalyzerToken(constKeyword),
|
||||
toAnalyzerToken(factoryKeyword),
|
||||
returnType2,
|
||||
toAnalyzerToken(period),
|
||||
name2,
|
||||
parameters,
|
||||
toAnalyzerToken(separator),
|
||||
initializers,
|
||||
redirectedConstructor,
|
||||
body));
|
||||
}
|
||||
|
||||
@override
|
||||
void endMember() {
|
||||
debugEvent("Member");
|
||||
}
|
||||
}
|
||||
|
||||
/// Data structure placed on the stack to represent a class body.
|
||||
|
||||
@@ -452,6 +452,16 @@ class Listener {
|
||||
|
||||
void beginMethod(Token token, Token name) {}
|
||||
|
||||
/// Handle the end of a method declaration. Substructures:
|
||||
/// - metadata
|
||||
/// - modifiers
|
||||
/// - return type
|
||||
/// - method name (identifier, possibly qualified)
|
||||
/// - type variables
|
||||
/// - formal parameters
|
||||
/// - initializers
|
||||
/// - async marker
|
||||
/// - body
|
||||
void endMethod(Token getOrSet, Token beginToken, Token endToken) {
|
||||
logEvent("Method");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user