From 7f3223bd2cb058779923a3832f16599fa6bfe0a0 Mon Sep 17 00:00:00 2001 From: vsavkin Date: Tue, 24 Nov 2015 14:08:43 -0800 Subject: [PATCH] fix(transformers): use BarbackMode instead of assertionEnabled to enable debug info generation Closes #5245 Closes #5466 --- .../transform/lib/src/transform/common/options.dart | 11 +++++++++-- .../lib/src/transform/common/options_reader.dart | 1 + .../src/transform/template_compiler/generator.dart | 5 +++-- .../src/transform/template_compiler/transformer.dart | 1 + 4 files changed, 14 insertions(+), 4 deletions(-) diff --git a/modules_dart/transform/lib/src/transform/common/options.dart b/modules_dart/transform/lib/src/transform/common/options.dart index f5d1e5038d..9be884274d 100644 --- a/modules_dart/transform/lib/src/transform/common/options.dart +++ b/modules_dart/transform/lib/src/transform/common/options.dart @@ -41,6 +41,10 @@ class TransformerOptions { /// as attributes on DOM elements, which may aid in application debugging. final bool reflectPropertiesAsAttributes; + /// Whether to generate debug information in change detectors. + /// This improves error messages when exception are triggered in templates. + final bool genChangeDetectionDebugInfo; + /// A set of directives that will be automatically passed-in to the template compiler /// Format of an item in the list: angular2/lib/src/common/directives.dart#CORE_DIRECTIVES final List platformDirectives; @@ -71,7 +75,8 @@ class TransformerOptions { this.mirrorMode, this.initReflector, this.annotationMatcher, - {this.reflectPropertiesAsAttributes, + {this.genChangeDetectionDebugInfo, + this.reflectPropertiesAsAttributes, this.platformDirectives, this.inlineViews, this.lazyTransformers, @@ -83,7 +88,8 @@ class TransformerOptions { bool initReflector: true, List customAnnotationDescriptors: const [], bool inlineViews: false, - bool reflectPropertiesAsAttributes: true, + bool genChangeDetectionDebugInfo: false, + bool reflectPropertiesAsAttributes: false, List platformDirectives, bool lazyTransformers: false, bool formatCode: false}) { @@ -94,6 +100,7 @@ class TransformerOptions { : null; return new TransformerOptions._internal(entryPoints, entryPointGlobs, modeName, mirrorMode, initReflector, annotationMatcher, + genChangeDetectionDebugInfo: genChangeDetectionDebugInfo, reflectPropertiesAsAttributes: reflectPropertiesAsAttributes, platformDirectives: platformDirectives, inlineViews: inlineViews, diff --git a/modules_dart/transform/lib/src/transform/common/options_reader.dart b/modules_dart/transform/lib/src/transform/common/options_reader.dart index 18d8566a4a..bd325c82e8 100644 --- a/modules_dart/transform/lib/src/transform/common/options_reader.dart +++ b/modules_dart/transform/lib/src/transform/common/options_reader.dart @@ -38,6 +38,7 @@ TransformerOptions parseBarbackSettings(BarbackSettings settings) { modeName: settings.mode.name, mirrorMode: mirrorMode, initReflector: initReflector, + genChangeDetectionDebugInfo: settings.mode == BarbackMode.DEBUG, customAnnotationDescriptors: _readCustomAnnotations(config), reflectPropertiesAsAttributes: reflectPropertiesAsAttributes, platformDirectives: platformDirectives, diff --git a/modules_dart/transform/lib/src/transform/template_compiler/generator.dart b/modules_dart/transform/lib/src/transform/template_compiler/generator.dart index 68e89badc3..960fbfc985 100644 --- a/modules_dart/transform/lib/src/transform/template_compiler/generator.dart +++ b/modules_dart/transform/lib/src/transform/template_compiler/generator.dart @@ -28,7 +28,8 @@ import 'compile_data_creator.dart'; /// /// This method assumes a {@link DomAdapter} has been registered. Future processTemplates(AssetReader reader, AssetId assetId, - {bool reflectPropertiesAsAttributes: false, + {bool genChangeDetectionDebugInfo: false, + bool reflectPropertiesAsAttributes: false, List platformDirectives}) async { var viewDefResults = await createCompileData(reader, assetId, platformDirectives); @@ -48,7 +49,7 @@ Future processTemplates(AssetReader reader, AssetId assetId, if (templateCompiler == null) { templateCompiler = createTemplateCompiler(reader, changeDetectionConfig: new ChangeDetectorGenConfig( - assertionsEnabled(), reflectPropertiesAsAttributes, false)); + genChangeDetectionDebugInfo, reflectPropertiesAsAttributes, false)); } final compileData = diff --git a/modules_dart/transform/lib/src/transform/template_compiler/transformer.dart b/modules_dart/transform/lib/src/transform/template_compiler/transformer.dart index b5069918c0..79281476aa 100644 --- a/modules_dart/transform/lib/src/transform/template_compiler/transformer.dart +++ b/modules_dart/transform/lib/src/transform/template_compiler/transformer.dart @@ -44,6 +44,7 @@ class TemplateCompiler extends Transformer implements LazyTransformer { var primaryId = transform.primaryInput.id; var reader = new AssetReader.fromTransform(transform); var outputs = await processTemplates(reader, primaryId, + genChangeDetectionDebugInfo: options.genChangeDetectionDebugInfo, reflectPropertiesAsAttributes: options.reflectPropertiesAsAttributes, platformDirectives: options.platformDirectives); var ngDepsCode = _emptyNgDepsContents;