Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(239)

Unified Diff: frog/leg/scanner/class_element_parser.dart

Issue 9027002: Support factory methods. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: '' Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: frog/leg/scanner/class_element_parser.dart
===================================================================
--- frog/leg/scanner/class_element_parser.dart (revision 2741)
+++ frog/leg/scanner/class_element_parser.dart (working copy)
@@ -48,7 +48,7 @@
pushNode(null);
Identifier name = method.name; // TODO(ahe): Named constructors.
ElementKind kind = isConstructor(name) ?
- ElementKind.CONSTRUCTOR :
+ ElementKind.GENERATIVE_CONSTRUCTOR :
ElementKind.FUNCTION;
Element memberElement =
new PartialFunctionElement(name.source, beginToken, endToken,
@@ -56,6 +56,20 @@
enclosingElement.addMember(memberElement);
}
+ void endFactoryMethod(Token factoryKeyword, Token periodBeforeName,
+ Token endToken) {
+ super.endFactoryMethod(factoryKeyword, periodBeforeName, endToken);
+ FunctionExpression method = popNode();
+ pushNode(null);
+ // TODO(ahe): Named constructors.
+ Identifier name = method.returnType.typeName;
+ ElementKind kind = ElementKind.FUNCTION;
+ Element memberElement =
+ new PartialFunctionElement(name.source, factoryKeyword, endToken, kind,
+ method.modifiers, enclosingElement);
+ enclosingElement.addMember(memberElement);
+ }
+
void endFields(int count, Token beginToken, Token endToken) {
super.endFields(count, beginToken, endToken);
VariableDefinitions variableDefinitions = popNode();

Powered by Google App Engine
This is Rietveld 408576698