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

Unified Diff: tools/dom/scripts/htmldartgenerator.py

Issue 896723009: Annotate dart:html constructor expressions with precise non-nullable types. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 11 months 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: tools/dom/scripts/htmldartgenerator.py
diff --git a/tools/dom/scripts/htmldartgenerator.py b/tools/dom/scripts/htmldartgenerator.py
index 6699fd3ca366136b15f2c001b540bc9fa9c890dc..da82b1ad2281ba039ac2c278b96257ad617fc1cd 100644
--- a/tools/dom/scripts/htmldartgenerator.py
+++ b/tools/dom/scripts/htmldartgenerator.py
@@ -547,31 +547,29 @@ class HtmlDartGenerator(object):
has_optional = any(param_info.is_optional
for param_info in constructor_info.param_infos)
+ factory_expression = self.FactoryConstructorExpression(constructor_info,
+ factory_name, factory_constructor_name, factory_parameters)
+
if not has_optional:
self._members_emitter.Emit(
'\n $(METADATA)'
- 'factory $CTOR($PARAMS) => '
- '$FACTORY.$CTOR_FACTORY_NAME($FACTORY_PARAMS);\n',
+ 'factory $CTOR($PARAMS) => $FACTORY_EXPRESSION;\n',
CTOR=constructor_info._ConstructorFullName(self._DartType),
PARAMS=constructor_info.ParametersAsDeclaration(self._DartType),
- FACTORY=factory_name,
- METADATA=metadata,
- CTOR_FACTORY_NAME=factory_constructor_name,
- FACTORY_PARAMS=factory_parameters)
+ FACTORY_EXPRESSION=factory_expression,
+ METADATA=metadata)
else:
inits = self._members_emitter.Emit(
'\n $(METADATA)'
'factory $CONSTRUCTOR($PARAMS) {\n'
- ' var e = $FACTORY.$CTOR_FACTORY_NAME($FACTORY_PARAMS);\n'
+ ' var e = $FACTORY_EXPRESSION;\n'
'$!INITS'
' return e;\n'
' }\n',
CONSTRUCTOR=constructor_info._ConstructorFullName(self._DartType),
METADATA=metadata,
- FACTORY=factory_name,
- CTOR_FACTORY_NAME=factory_constructor_name,
- PARAMS=constructor_info.ParametersAsDeclaration(self._DartType),
- FACTORY_PARAMS=factory_parameters)
+ FACTORY_EXPRESSION=factory_expression,
+ PARAMS=constructor_info.ParametersAsDeclaration(self._DartType))
for index, param_info in enumerate(constructor_info.param_infos):
if param_info.is_optional:
@@ -628,6 +626,14 @@ class HtmlDartGenerator(object):
IsOptional,
overload_emitter)
+ def FactoryConstructorExpression(self, constructor_info,
+ factory_name, factory_constructor_name, factory_parameters):
+ return emitter.Format(
+ '$FACTORY.$CTOR_FACTORY_NAME($FACTORY_PARAMS)',
+ FACTORY=factory_name,
+ CTOR_FACTORY_NAME=factory_constructor_name,
+ FACTORY_PARAMS=factory_parameters);
+
def _AddFutureifiedOperation(self, info, html_name):
"""Given a API function that uses callbacks, convert it to using Futures.

Powered by Google App Engine
This is Rietveld 408576698