diff --git a/build.yaml b/build.yaml index da687494d..6772947dc 100644 --- a/build.yaml +++ b/build.yaml @@ -23,6 +23,7 @@ targets: exclude: # This tests un-built behavior, and therefore should not be built - "test/over_react/component_declaration/builder_helpers_test.dart" + over_react|overReactBuilder: enabled: false @@ -37,13 +38,9 @@ targets: - "web/**" exclude: - "lib/src/builder/**" + build_web_compilers|entrypoint: generate_for: - include: - - "example/**" - - "lib/*.dart" - - "test/*.dart" - - "web/*.dart" - exclude: - - "lib/src/builder/**" - + - "example/**.dart" + - "test/*.browser_test.dart" + - "web/*.dart" diff --git a/example/builder/abstract_inheritance.over_react.g.dart b/example/builder/abstract_inheritance.over_react.g.dart index aa56749ed..81574bdb5 100644 --- a/example/builder/abstract_inheritance.over_react.g.dart +++ b/example/builder/abstract_inheritance.over_react.g.dart @@ -3,7 +3,7 @@ part of 'abstract_inheritance.dart'; // ************************************************************************** -// OverReactGenerator +// OverReactBuilder (package:over_react/src/builder.dart) // ************************************************************************** // React component factory implementation. diff --git a/example/builder/basic.over_react.g.dart b/example/builder/basic.over_react.g.dart index 71a660bd6..c1bc83e3c 100644 --- a/example/builder/basic.over_react.g.dart +++ b/example/builder/basic.over_react.g.dart @@ -3,7 +3,7 @@ part of 'basic.dart'; // ************************************************************************** -// OverReactGenerator +// OverReactBuilder (package:over_react/src/builder.dart) // ************************************************************************** // React component factory implementation. diff --git a/example/builder/basic_library.over_react.g.dart b/example/builder/basic_library.over_react.g.dart index 0926c876a..be560b90e 100644 --- a/example/builder/basic_library.over_react.g.dart +++ b/example/builder/basic_library.over_react.g.dart @@ -1,9 +1,9 @@ // GENERATED CODE - DO NOT MODIFY BY HAND -part of basic.library; +part of 'basic_library.dart'; // ************************************************************************** -// OverReactGenerator +// OverReactBuilder (package:over_react/src/builder.dart) // ************************************************************************** // React component factory implementation. diff --git a/example/builder/basic_with_state.over_react.g.dart b/example/builder/basic_with_state.over_react.g.dart index 2c6d6a76c..6542eb5d9 100644 --- a/example/builder/basic_with_state.over_react.g.dart +++ b/example/builder/basic_with_state.over_react.g.dart @@ -3,7 +3,7 @@ part of 'basic_with_state.dart'; // ************************************************************************** -// OverReactGenerator +// OverReactBuilder (package:over_react/src/builder.dart) // ************************************************************************** // React component factory implementation. diff --git a/example/builder/basic_with_type_params.over_react.g.dart b/example/builder/basic_with_type_params.over_react.g.dart index 48a2924e6..4ea07d768 100644 --- a/example/builder/basic_with_type_params.over_react.g.dart +++ b/example/builder/basic_with_type_params.over_react.g.dart @@ -3,7 +3,7 @@ part of 'basic_with_type_params.dart'; // ************************************************************************** -// OverReactGenerator +// OverReactBuilder (package:over_react/src/builder.dart) // ************************************************************************** // React component factory implementation. diff --git a/example/builder/generic_inheritance_sub.over_react.g.dart b/example/builder/generic_inheritance_sub.over_react.g.dart index db0a1afca..0bf02ae05 100644 --- a/example/builder/generic_inheritance_sub.over_react.g.dart +++ b/example/builder/generic_inheritance_sub.over_react.g.dart @@ -3,7 +3,7 @@ part of 'generic_inheritance_sub.dart'; // ************************************************************************** -// OverReactGenerator +// OverReactBuilder (package:over_react/src/builder.dart) // ************************************************************************** // React component factory implementation. diff --git a/example/builder/generic_inheritance_super.over_react.g.dart b/example/builder/generic_inheritance_super.over_react.g.dart index 04d4ab425..dcba3494e 100644 --- a/example/builder/generic_inheritance_super.over_react.g.dart +++ b/example/builder/generic_inheritance_super.over_react.g.dart @@ -3,7 +3,7 @@ part of 'generic_inheritance_super.dart'; // ************************************************************************** -// OverReactGenerator +// OverReactBuilder (package:over_react/src/builder.dart) // ************************************************************************** // React component factory implementation. diff --git a/example/builder/private_component.over_react.g.dart b/example/builder/private_component.over_react.g.dart index 5b3dc3914..f583d99dd 100644 --- a/example/builder/private_component.over_react.g.dart +++ b/example/builder/private_component.over_react.g.dart @@ -3,7 +3,7 @@ part of 'private_component.dart'; // ************************************************************************** -// OverReactGenerator +// OverReactBuilder (package:over_react/src/builder.dart) // ************************************************************************** // React component factory implementation. diff --git a/example/builder/private_factory_public_component.over_react.g.dart b/example/builder/private_factory_public_component.over_react.g.dart index 12054bea2..11137a85d 100644 --- a/example/builder/private_factory_public_component.over_react.g.dart +++ b/example/builder/private_factory_public_component.over_react.g.dart @@ -3,7 +3,7 @@ part of 'private_factory_public_component.dart'; // ************************************************************************** -// OverReactGenerator +// OverReactBuilder (package:over_react/src/builder.dart) // ************************************************************************** // React component factory implementation. diff --git a/example/builder/props_mixin.over_react.g.dart b/example/builder/props_mixin.over_react.g.dart index e0b2790e0..15dbf9936 100644 --- a/example/builder/props_mixin.over_react.g.dart +++ b/example/builder/props_mixin.over_react.g.dart @@ -3,7 +3,7 @@ part of 'props_mixin.dart'; // ************************************************************************** -// OverReactGenerator +// OverReactBuilder (package:over_react/src/builder.dart) // ************************************************************************** abstract class ExamplePropsMixinClass implements _$ExamplePropsMixinClass { diff --git a/example/builder/state_mixin.over_react.g.dart b/example/builder/state_mixin.over_react.g.dart index 84c9257d7..664c0ee49 100644 --- a/example/builder/state_mixin.over_react.g.dart +++ b/example/builder/state_mixin.over_react.g.dart @@ -3,7 +3,7 @@ part of 'state_mixin.dart'; // ************************************************************************** -// OverReactGenerator +// OverReactBuilder (package:over_react/src/builder.dart) // ************************************************************************** abstract class ExampleStateMixinClass implements _$ExampleStateMixinClass { diff --git a/lib/src/builder/builder.dart b/lib/src/builder/builder.dart index 41ffcd954..91d6a8a7f 100644 --- a/lib/src/builder/builder.dart +++ b/lib/src/builder/builder.dart @@ -1,8 +1,142 @@ +import 'dart:async'; + +import 'package:analyzer/analyzer.dart'; import 'package:build/build.dart'; -import 'package:source_gen/source_gen.dart'; +import 'package:dart_style/dart_style.dart'; +import 'package:over_react/src/builder/generation/declaration_parsing.dart'; +import 'package:over_react/src/builder/generation/impl_generation.dart'; +import 'package:path/path.dart' as p; +import 'package:source_span/source_span.dart'; import './util.dart'; -import './generator.dart'; -Builder overReactBuilder(BuilderOptions options) => - new PartBuilder([new OverReactGenerator()], outputExtension); +Builder overReactBuilder(BuilderOptions options) => new OverReactBuilder(); + +class OverReactBuilder extends Builder { + @override + Map> get buildExtensions => { + '.dart': [outputExtension], + }; + + @override + FutureOr build(BuildStep buildStep) async { + final source = await buildStep.readAsString(buildStep.inputId); + final libraryUnit = _tryParseCompilationUnit(source, buildStep.inputId); + if (libraryUnit == null) { + return; + } + if (isPart(libraryUnit)) { + return; + } + + final outputs = []; + void generateForFile(String source, AssetId id, CompilationUnit unit) { + if (!ParsedDeclarations.mightContainDeclarations(source)) { + return; + } + final sourceFile = new SourceFile.fromString( + source, url: idToPackageUri(id)); + final declarations = new ParsedDeclarations(unit, sourceFile, log); + if (declarations.hasErrors) { + log.severe('There was an error parsing the file declarations for file: $id'); + return; + } + final generator = new ImplGenerator(log, sourceFile) + ..generate(declarations); + final generatedOutput = generator.outputContentsBuffer.toString().trim(); + if (generatedOutput.isNotEmpty) { + outputs.add(generatedOutput); + } + } + + // Collect all of the part files for this library. + final parts = libraryUnit.directives + .whereType() + // Ignore all generated `.g.dart` parts. + .where((part) => !part.uri.stringValue.endsWith('.g.dart')); + + // Generate over_react code for the input library. + generateForFile(source, buildStep.inputId, libraryUnit); + + // Generate over_react code for each part file of the input library. + for (final part in parts) { + final partId = new AssetId.resolve( + part.uri.stringValue, + from: buildStep.inputId); + if (!await buildStep.canRead(partId)) { + continue; + } + final partSource = await buildStep.readAsString(partId); + final partUnit = _tryParseCompilationUnit(partSource, partId); + if (partUnit == null) { + continue; + } + generateForFile(partSource, partId, partUnit); + } + + if (outputs.isNotEmpty) { + final outputId = buildStep.inputId.changeExtension(outputExtension); + + // Verify that the library file has an `.over_react.g.dart` part. + final expectedPart = p.basename(outputId.path); + final partUris = libraryUnit.directives + .whereType() + .map((p) => p.uri.stringValue); + if (!partUris.contains(expectedPart)) { + log.warning('Missing "part \'$expectedPart\';".'); + } + + await _writePart(buildStep, outputId, outputs); + } + } + + static final _headerLine = '// '.padRight(77, '*'); + + static final _formatter = new DartFormatter(); + + static final RegExp _overReactPartDirective = new RegExp( + r'''['"].*\.over_react\.g\.dart['"]''', + ); + + static bool _mightContainDeclarations(String source) { + return ParsedDeclarations.mightContainDeclarations(source) || + _overReactPartDirective.hasMatch(source); + } + + static CompilationUnit _tryParseCompilationUnit(String source, AssetId id) { + try { + return parseCompilationUnit( + source, + name: id.path, + suppressErrors: false, + parseFunctionBodies: true); + } catch (error, stackTrace) { + log.severe('There was an error parsing the compilation unit for file: $id'); + log.fine(error); + log.fine(stackTrace); + return null; + } + } + + static FutureOr _writePart(BuildStep buildStep, AssetId outputId, Iterable outputs) async { + final partOf = "'${p.basename(buildStep.inputId.uri.toString())}'"; + + final buffer = new StringBuffer() + ..writeln('// GENERATED CODE - DO NOT MODIFY BY HAND') + ..writeln() + ..writeln('part of $partOf;') + ..writeln() + ..writeln(_headerLine) + ..writeln('// OverReactBuilder (package:over_react/src/builder.dart)') + ..writeln(_headerLine); + + for (final item in outputs) { + buffer + ..writeln() + ..writeln(item); + } + + final output = _formatter.format(buffer.toString()); + await buildStep.writeAsString(outputId, output); + } +} \ No newline at end of file diff --git a/lib/src/builder/generator.dart b/lib/src/builder/generator.dart deleted file mode 100644 index 9a446af9d..000000000 --- a/lib/src/builder/generator.dart +++ /dev/null @@ -1,73 +0,0 @@ -import 'dart:async'; - -import 'package:analyzer/analyzer.dart'; -import 'package:build/build.dart'; - -import 'package:over_react/src/builder/generation/declaration_parsing.dart'; -import 'package:over_react/src/builder/generation/impl_generation.dart'; -import 'package:source_gen/source_gen.dart'; -import 'package:source_span/source_span.dart'; - -import './util.dart'; - -class OverReactGenerator extends Generator { - String _generateForFile(AssetId inputId, String primaryInputContents, CompilationUnit resolvedUnit) { - final sourceFile = new SourceFile.fromString( - primaryInputContents, url: idToPackageUri(inputId)); - - ImplGenerator generator; - if (ParsedDeclarations.mightContainDeclarations(primaryInputContents)) { - final declarations = new ParsedDeclarations(resolvedUnit, sourceFile, log); - - if (declarations.hasErrors) { - log.severe('There was an error parsing the file declarations for file: $inputId'); - return ''; - } - generator = new ImplGenerator(log, sourceFile)..generate(declarations); - } else { - log.fine('There were no declarations found for file: $inputId'); - } - return generator?.outputContentsBuffer?.toString() ?? ''; - } - - @override - Future generate(LibraryReader library, BuildStep buildStep) async { - // Don't build on non-library files - if (!await buildStep.resolver.isLibrary(buildStep.inputId)) { - log.fine('No output generated for non-library file: ${buildStep.inputId}'); - return ''; - } - - final inputId = await buildStep.inputId; - final entryLib = await buildStep.inputLibrary; - - // Get list of compilation units for each part in this library, as well - // as the base library file itself - final compUnits = List.from(entryLib.parts)..add(entryLib.definingCompilationUnit); - - final contentBuffer = new StringBuffer(); - for (final unit in compUnits) { - log.fine('Generating implementations for file: ${unit.name}'); - // unit.uri is needed for part files, but is null for the parent file. - // In the case of a parent file, unit.name will suffice. - // TODO: Make this play nice with analyzer ^0.33.0 (unit.uri and name are both null in some cases): - final assetId = AssetId.resolve(unit.uri ?? unit.name, from: inputId); - - // Only generate on part files which were not generated by this builder and - // which can be read. - if (!assetId.toString().contains(outputExtension) && await buildStep.canRead(assetId)) { - final resolvedUnit = unit.computeNode(); - final inputContents = await buildStep.readAsString(assetId); - contentBuffer.write(_generateForFile(assetId, inputContents, resolvedUnit)); - } - } - - if (contentBuffer.isNotEmpty) { - return contentBuffer.toString(); - } else { - log.fine('No output generated for file: $inputId'); - } - return ''; - } -} - diff --git a/lib/src/builder/util.dart b/lib/src/builder/util.dart index da6c97848..42eee8a25 100644 --- a/lib/src/builder/util.dart +++ b/lib/src/builder/util.dart @@ -1,6 +1,6 @@ import 'dart:mirrors'; -import 'package:analyzer/analyzer.dart'; +import 'package:analyzer/dart/ast/ast.dart'; import 'package:path/path.dart' as p; import 'package:build/build.dart' show AssetId; import 'package:source_span/source_span.dart'; @@ -28,6 +28,10 @@ Uri idToPackageUri(AssetId id) { path: p.url.join(id.package, id.path.replaceFirst('lib/', ''))); } +/// Returns true if the given compilation unit is a part file. +bool isPart(CompilationUnit unit) => + unit.directives.any((directive) => directive is PartOfDirective); + /// Returns a string representing a [TypeParameterList], but type bounds removed. /// /// Example: diff --git a/lib/src/component/abstract_transition.over_react.g.dart b/lib/src/component/abstract_transition.over_react.g.dart index 90b7d197a..51b755900 100644 --- a/lib/src/component/abstract_transition.over_react.g.dart +++ b/lib/src/component/abstract_transition.over_react.g.dart @@ -1,9 +1,9 @@ // GENERATED CODE - DO NOT MODIFY BY HAND -part of over_react.abstract_transition; +part of 'abstract_transition.dart'; // ************************************************************************** -// OverReactGenerator +// OverReactBuilder (package:over_react/src/builder.dart) // ************************************************************************** abstract class _$AbstractTransitionPropsAccessorsMixin diff --git a/lib/src/component/abstract_transition_props.over_react.g.dart b/lib/src/component/abstract_transition_props.over_react.g.dart index bb9ff86ec..d3284de05 100644 --- a/lib/src/component/abstract_transition_props.over_react.g.dart +++ b/lib/src/component/abstract_transition_props.over_react.g.dart @@ -1,9 +1,9 @@ // GENERATED CODE - DO NOT MODIFY BY HAND -part of over_react.abstract_transition_props; +part of 'abstract_transition_props.dart'; // ************************************************************************** -// OverReactGenerator +// OverReactBuilder (package:over_react/src/builder.dart) // ************************************************************************** abstract class TransitionPropsMixin implements _$TransitionPropsMixin { diff --git a/lib/src/component/aria_mixin.over_react.g.dart b/lib/src/component/aria_mixin.over_react.g.dart index 7532ac38e..a45c17108 100644 --- a/lib/src/component/aria_mixin.over_react.g.dart +++ b/lib/src/component/aria_mixin.over_react.g.dart @@ -1,9 +1,9 @@ // GENERATED CODE - DO NOT MODIFY BY HAND -part of over_react.aria_mixin; +part of 'aria_mixin.dart'; // ************************************************************************** -// OverReactGenerator +// OverReactBuilder (package:over_react/src/builder.dart) // ************************************************************************** abstract class AriaPropsMixin implements _$AriaPropsMixin { diff --git a/lib/src/component/error_boundary.over_react.g.dart b/lib/src/component/error_boundary.over_react.g.dart index d7b829361..e5ab053d9 100644 --- a/lib/src/component/error_boundary.over_react.g.dart +++ b/lib/src/component/error_boundary.over_react.g.dart @@ -3,7 +3,7 @@ part of 'error_boundary.dart'; // ************************************************************************** -// OverReactGenerator +// OverReactBuilder (package:over_react/src/builder.dart) // ************************************************************************** // React component factory implementation. diff --git a/lib/src/component/prop_mixins.over_react.g.dart b/lib/src/component/prop_mixins.over_react.g.dart index e11bfdfeb..d0a1ef34a 100644 --- a/lib/src/component/prop_mixins.over_react.g.dart +++ b/lib/src/component/prop_mixins.over_react.g.dart @@ -1,9 +1,9 @@ // GENERATED CODE - DO NOT MODIFY BY HAND -part of over_react.prop_mixins; +part of 'prop_mixins.dart'; // ************************************************************************** -// OverReactGenerator +// OverReactBuilder (package:over_react/src/builder.dart) // ************************************************************************** abstract class ReactPropsMixin implements _$ReactPropsMixin { diff --git a/lib/src/component/resize_sensor.over_react.g.dart b/lib/src/component/resize_sensor.over_react.g.dart index fcd24193c..e9ca76863 100644 --- a/lib/src/component/resize_sensor.over_react.g.dart +++ b/lib/src/component/resize_sensor.over_react.g.dart @@ -1,9 +1,9 @@ // GENERATED CODE - DO NOT MODIFY BY HAND -part of over_react.resize_sensor; +part of 'resize_sensor.dart'; // ************************************************************************** -// OverReactGenerator +// OverReactBuilder (package:over_react/src/builder.dart) // ************************************************************************** // React component factory implementation. diff --git a/lib/src/util/class_names.over_react.g.dart b/lib/src/util/class_names.over_react.g.dart index b82f2d54b..abe4a76fd 100644 --- a/lib/src/util/class_names.over_react.g.dart +++ b/lib/src/util/class_names.over_react.g.dart @@ -1,9 +1,9 @@ // GENERATED CODE - DO NOT MODIFY BY HAND -part of over_react.class_names; +part of 'class_names.dart'; // ************************************************************************** -// OverReactGenerator +// OverReactBuilder (package:over_react/src/builder.dart) // ************************************************************************** abstract class CssClassPropsMixin implements _$CssClassPropsMixin { diff --git a/pubspec.yaml b/pubspec.yaml index 596867969..005aa4f6f 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -14,12 +14,12 @@ dependencies: build: ^1.0.0 built_redux: ^7.4.2 built_value: ^5.4.4 + dart_style: '>=0.1.7 <2.0.0' js: ^0.6.1+1 logging: ">=0.11.3+2 <1.0.0" meta: ^1.1.6 path: ^1.5.1 react: ^4.6.0 - source_gen: ^0.9.0 source_span: ^1.4.1 transformer_utils: ^0.2.0 w_common: ^1.13.0 diff --git a/test/over_react/component/abstract_transition_test.over_react.g.dart b/test/over_react/component/abstract_transition_test.over_react.g.dart index 31592bdb6..8008b6834 100644 --- a/test/over_react/component/abstract_transition_test.over_react.g.dart +++ b/test/over_react/component/abstract_transition_test.over_react.g.dart @@ -1,9 +1,9 @@ // GENERATED CODE - DO NOT MODIFY BY HAND -part of abstract_transition_test; +part of 'abstract_transition_test.dart'; // ************************************************************************** -// OverReactGenerator +// OverReactBuilder (package:over_react/src/builder.dart) // ************************************************************************** // React component factory implementation. diff --git a/test/over_react/component_declaration/builder_integration_tests/abstract_accessor_integration_test.over_react.g.dart b/test/over_react/component_declaration/builder_integration_tests/abstract_accessor_integration_test.over_react.g.dart index edfd22f40..3733802ae 100644 --- a/test/over_react/component_declaration/builder_integration_tests/abstract_accessor_integration_test.over_react.g.dart +++ b/test/over_react/component_declaration/builder_integration_tests/abstract_accessor_integration_test.over_react.g.dart @@ -3,7 +3,7 @@ part of 'abstract_accessor_integration_test.dart'; // ************************************************************************** -// OverReactGenerator +// OverReactBuilder (package:over_react/src/builder.dart) // ************************************************************************** abstract class _$TestAbstractPropsAccessorsMixin diff --git a/test/over_react/component_declaration/builder_integration_tests/accessor_mixin_integration_test.over_react.g.dart b/test/over_react/component_declaration/builder_integration_tests/accessor_mixin_integration_test.over_react.g.dart index 165457b4b..2d67833bb 100644 --- a/test/over_react/component_declaration/builder_integration_tests/accessor_mixin_integration_test.over_react.g.dart +++ b/test/over_react/component_declaration/builder_integration_tests/accessor_mixin_integration_test.over_react.g.dart @@ -3,7 +3,7 @@ part of 'accessor_mixin_integration_test.dart'; // ************************************************************************** -// OverReactGenerator +// OverReactBuilder (package:over_react/src/builder.dart) // ************************************************************************** abstract class TestPropsMixin implements _$TestPropsMixin { diff --git a/test/over_react/component_declaration/builder_integration_tests/backwards_compatible/abstract_accessor_integration_test.over_react.g.dart b/test/over_react/component_declaration/builder_integration_tests/backwards_compatible/abstract_accessor_integration_test.over_react.g.dart index 963e7fb1f..7f6570c2f 100644 --- a/test/over_react/component_declaration/builder_integration_tests/backwards_compatible/abstract_accessor_integration_test.over_react.g.dart +++ b/test/over_react/component_declaration/builder_integration_tests/backwards_compatible/abstract_accessor_integration_test.over_react.g.dart @@ -3,7 +3,7 @@ part of 'abstract_accessor_integration_test.dart'; // ************************************************************************** -// OverReactGenerator +// OverReactBuilder (package:over_react/src/builder.dart) // ************************************************************************** abstract class _$TestAbstractPropsAccessorsMixin diff --git a/test/over_react/component_declaration/builder_integration_tests/backwards_compatible/accessor_mixin_integration_test.over_react.g.dart b/test/over_react/component_declaration/builder_integration_tests/backwards_compatible/accessor_mixin_integration_test.over_react.g.dart index 4f99baadb..941c997e9 100644 --- a/test/over_react/component_declaration/builder_integration_tests/backwards_compatible/accessor_mixin_integration_test.over_react.g.dart +++ b/test/over_react/component_declaration/builder_integration_tests/backwards_compatible/accessor_mixin_integration_test.over_react.g.dart @@ -3,7 +3,7 @@ part of 'accessor_mixin_integration_test.dart'; // ************************************************************************** -// OverReactGenerator +// OverReactBuilder (package:over_react/src/builder.dart) // ************************************************************************** abstract class $TestPropsMixin implements TestPropsMixin { diff --git a/test/over_react/component_declaration/builder_integration_tests/backwards_compatible/component_integration_test.over_react.g.dart b/test/over_react/component_declaration/builder_integration_tests/backwards_compatible/component_integration_test.over_react.g.dart index d088dcedb..342fe60c6 100644 --- a/test/over_react/component_declaration/builder_integration_tests/backwards_compatible/component_integration_test.over_react.g.dart +++ b/test/over_react/component_declaration/builder_integration_tests/backwards_compatible/component_integration_test.over_react.g.dart @@ -3,7 +3,7 @@ part of 'component_integration_test.dart'; // ************************************************************************** -// OverReactGenerator +// OverReactBuilder (package:over_react/src/builder.dart) // ************************************************************************** // React component factory implementation. diff --git a/test/over_react/component_declaration/builder_integration_tests/backwards_compatible/constant_required_accessor_integration_test.over_react.g.dart b/test/over_react/component_declaration/builder_integration_tests/backwards_compatible/constant_required_accessor_integration_test.over_react.g.dart index 29c026399..7fda8fb8f 100644 --- a/test/over_react/component_declaration/builder_integration_tests/backwards_compatible/constant_required_accessor_integration_test.over_react.g.dart +++ b/test/over_react/component_declaration/builder_integration_tests/backwards_compatible/constant_required_accessor_integration_test.over_react.g.dart @@ -3,7 +3,7 @@ part of 'constant_required_accessor_integration_test.dart'; // ************************************************************************** -// OverReactGenerator +// OverReactBuilder (package:over_react/src/builder.dart) // ************************************************************************** // React component factory implementation. diff --git a/test/over_react/component_declaration/builder_integration_tests/backwards_compatible/do_not_generate_accessor_integration_test.over_react.g.dart b/test/over_react/component_declaration/builder_integration_tests/backwards_compatible/do_not_generate_accessor_integration_test.over_react.g.dart index 95db004f3..3651f1724 100644 --- a/test/over_react/component_declaration/builder_integration_tests/backwards_compatible/do_not_generate_accessor_integration_test.over_react.g.dart +++ b/test/over_react/component_declaration/builder_integration_tests/backwards_compatible/do_not_generate_accessor_integration_test.over_react.g.dart @@ -3,7 +3,7 @@ part of 'do_not_generate_accessor_integration_test.dart'; // ************************************************************************** -// OverReactGenerator +// OverReactBuilder (package:over_react/src/builder.dart) // ************************************************************************** // React component factory implementation. diff --git a/test/over_react/component_declaration/builder_integration_tests/backwards_compatible/namespaced_accessor_integration_test.over_react.g.dart b/test/over_react/component_declaration/builder_integration_tests/backwards_compatible/namespaced_accessor_integration_test.over_react.g.dart index 8134f4d52..99f4d66b6 100644 --- a/test/over_react/component_declaration/builder_integration_tests/backwards_compatible/namespaced_accessor_integration_test.over_react.g.dart +++ b/test/over_react/component_declaration/builder_integration_tests/backwards_compatible/namespaced_accessor_integration_test.over_react.g.dart @@ -3,7 +3,7 @@ part of 'namespaced_accessor_integration_test.dart'; // ************************************************************************** -// OverReactGenerator +// OverReactBuilder (package:over_react/src/builder.dart) // ************************************************************************** // React component factory implementation. diff --git a/test/over_react/component_declaration/builder_integration_tests/backwards_compatible/private_props_ddc_bug.over_react.g.dart b/test/over_react/component_declaration/builder_integration_tests/backwards_compatible/private_props_ddc_bug.over_react.g.dart index 6c9aa8654..b979d2864 100644 --- a/test/over_react/component_declaration/builder_integration_tests/backwards_compatible/private_props_ddc_bug.over_react.g.dart +++ b/test/over_react/component_declaration/builder_integration_tests/backwards_compatible/private_props_ddc_bug.over_react.g.dart @@ -3,7 +3,7 @@ part of 'private_props_ddc_bug.dart'; // ************************************************************************** -// OverReactGenerator +// OverReactBuilder (package:over_react/src/builder.dart) // ************************************************************************** // React component factory implementation. diff --git a/test/over_react/component_declaration/builder_integration_tests/backwards_compatible/required_accessor_integration_test.over_react.g.dart b/test/over_react/component_declaration/builder_integration_tests/backwards_compatible/required_accessor_integration_test.over_react.g.dart index 5223f9342..78ec0c646 100644 --- a/test/over_react/component_declaration/builder_integration_tests/backwards_compatible/required_accessor_integration_test.over_react.g.dart +++ b/test/over_react/component_declaration/builder_integration_tests/backwards_compatible/required_accessor_integration_test.over_react.g.dart @@ -3,7 +3,7 @@ part of 'required_accessor_integration_test.dart'; // ************************************************************************** -// OverReactGenerator +// OverReactBuilder (package:over_react/src/builder.dart) // ************************************************************************** // React component factory implementation. diff --git a/test/over_react/component_declaration/builder_integration_tests/backwards_compatible/required_prop_integration_tests.over_react.g.dart b/test/over_react/component_declaration/builder_integration_tests/backwards_compatible/required_prop_integration_tests.over_react.g.dart index c26f66091..3f14b4d1b 100644 --- a/test/over_react/component_declaration/builder_integration_tests/backwards_compatible/required_prop_integration_tests.over_react.g.dart +++ b/test/over_react/component_declaration/builder_integration_tests/backwards_compatible/required_prop_integration_tests.over_react.g.dart @@ -3,7 +3,7 @@ part of 'required_prop_integration_tests.dart'; // ************************************************************************** -// OverReactGenerator +// OverReactBuilder (package:over_react/src/builder.dart) // ************************************************************************** // React component factory implementation. diff --git a/test/over_react/component_declaration/builder_integration_tests/backwards_compatible/stateful_component_integration_test.over_react.g.dart b/test/over_react/component_declaration/builder_integration_tests/backwards_compatible/stateful_component_integration_test.over_react.g.dart index f0e13dac4..a59a60c57 100644 --- a/test/over_react/component_declaration/builder_integration_tests/backwards_compatible/stateful_component_integration_test.over_react.g.dart +++ b/test/over_react/component_declaration/builder_integration_tests/backwards_compatible/stateful_component_integration_test.over_react.g.dart @@ -3,7 +3,7 @@ part of 'stateful_component_integration_test.dart'; // ************************************************************************** -// OverReactGenerator +// OverReactBuilder (package:over_react/src/builder.dart) // ************************************************************************** // React component factory implementation. diff --git a/test/over_react/component_declaration/builder_integration_tests/backwards_compatible/unassigned_prop_integration_test.over_react.g.dart b/test/over_react/component_declaration/builder_integration_tests/backwards_compatible/unassigned_prop_integration_test.over_react.g.dart index d7354bba2..eebd6b92c 100644 --- a/test/over_react/component_declaration/builder_integration_tests/backwards_compatible/unassigned_prop_integration_test.over_react.g.dart +++ b/test/over_react/component_declaration/builder_integration_tests/backwards_compatible/unassigned_prop_integration_test.over_react.g.dart @@ -3,7 +3,7 @@ part of 'unassigned_prop_integration_test.dart'; // ************************************************************************** -// OverReactGenerator +// OverReactBuilder (package:over_react/src/builder.dart) // ************************************************************************** // React component factory implementation. diff --git a/test/over_react/component_declaration/builder_integration_tests/component_integration_test.over_react.g.dart b/test/over_react/component_declaration/builder_integration_tests/component_integration_test.over_react.g.dart index 08fb80041..d7dab1da5 100644 --- a/test/over_react/component_declaration/builder_integration_tests/component_integration_test.over_react.g.dart +++ b/test/over_react/component_declaration/builder_integration_tests/component_integration_test.over_react.g.dart @@ -3,7 +3,7 @@ part of 'component_integration_test.dart'; // ************************************************************************** -// OverReactGenerator +// OverReactBuilder (package:over_react/src/builder.dart) // ************************************************************************** // React component factory implementation. diff --git a/test/over_react/component_declaration/builder_integration_tests/constant_required_accessor_integration_test.over_react.g.dart b/test/over_react/component_declaration/builder_integration_tests/constant_required_accessor_integration_test.over_react.g.dart index ca2e7467a..62d3e2364 100644 --- a/test/over_react/component_declaration/builder_integration_tests/constant_required_accessor_integration_test.over_react.g.dart +++ b/test/over_react/component_declaration/builder_integration_tests/constant_required_accessor_integration_test.over_react.g.dart @@ -3,7 +3,7 @@ part of 'constant_required_accessor_integration_test.dart'; // ************************************************************************** -// OverReactGenerator +// OverReactBuilder (package:over_react/src/builder.dart) // ************************************************************************** // React component factory implementation. diff --git a/test/over_react/component_declaration/builder_integration_tests/do_not_generate_accessor_integration_test.over_react.g.dart b/test/over_react/component_declaration/builder_integration_tests/do_not_generate_accessor_integration_test.over_react.g.dart index 482f38482..846ac8599 100644 --- a/test/over_react/component_declaration/builder_integration_tests/do_not_generate_accessor_integration_test.over_react.g.dart +++ b/test/over_react/component_declaration/builder_integration_tests/do_not_generate_accessor_integration_test.over_react.g.dart @@ -3,7 +3,7 @@ part of 'do_not_generate_accessor_integration_test.dart'; // ************************************************************************** -// OverReactGenerator +// OverReactBuilder (package:over_react/src/builder.dart) // ************************************************************************** // React component factory implementation. diff --git a/test/over_react/component_declaration/builder_integration_tests/namespaced_accessor_integration_test.over_react.g.dart b/test/over_react/component_declaration/builder_integration_tests/namespaced_accessor_integration_test.over_react.g.dart index 8b2294cc9..71b3f859c 100644 --- a/test/over_react/component_declaration/builder_integration_tests/namespaced_accessor_integration_test.over_react.g.dart +++ b/test/over_react/component_declaration/builder_integration_tests/namespaced_accessor_integration_test.over_react.g.dart @@ -3,7 +3,7 @@ part of 'namespaced_accessor_integration_test.dart'; // ************************************************************************** -// OverReactGenerator +// OverReactBuilder (package:over_react/src/builder.dart) // ************************************************************************** // React component factory implementation. diff --git a/test/over_react/component_declaration/builder_integration_tests/private_props_ddc_bug.over_react.g.dart b/test/over_react/component_declaration/builder_integration_tests/private_props_ddc_bug.over_react.g.dart index 5bfb0fdcb..7e10a1abf 100644 --- a/test/over_react/component_declaration/builder_integration_tests/private_props_ddc_bug.over_react.g.dart +++ b/test/over_react/component_declaration/builder_integration_tests/private_props_ddc_bug.over_react.g.dart @@ -3,7 +3,7 @@ part of 'private_props_ddc_bug.dart'; // ************************************************************************** -// OverReactGenerator +// OverReactBuilder (package:over_react/src/builder.dart) // ************************************************************************** // React component factory implementation. diff --git a/test/over_react/component_declaration/builder_integration_tests/required_accessor_integration_test.over_react.g.dart b/test/over_react/component_declaration/builder_integration_tests/required_accessor_integration_test.over_react.g.dart index ebd9c7e82..739511ba9 100644 --- a/test/over_react/component_declaration/builder_integration_tests/required_accessor_integration_test.over_react.g.dart +++ b/test/over_react/component_declaration/builder_integration_tests/required_accessor_integration_test.over_react.g.dart @@ -3,7 +3,7 @@ part of 'required_accessor_integration_test.dart'; // ************************************************************************** -// OverReactGenerator +// OverReactBuilder (package:over_react/src/builder.dart) // ************************************************************************** // React component factory implementation. diff --git a/test/over_react/component_declaration/builder_integration_tests/required_prop_integration_tests.over_react.g.dart b/test/over_react/component_declaration/builder_integration_tests/required_prop_integration_tests.over_react.g.dart index 9022a557d..15d70f9c0 100644 --- a/test/over_react/component_declaration/builder_integration_tests/required_prop_integration_tests.over_react.g.dart +++ b/test/over_react/component_declaration/builder_integration_tests/required_prop_integration_tests.over_react.g.dart @@ -3,7 +3,7 @@ part of 'required_prop_integration_tests.dart'; // ************************************************************************** -// OverReactGenerator +// OverReactBuilder (package:over_react/src/builder.dart) // ************************************************************************** // React component factory implementation. diff --git a/test/over_react/component_declaration/builder_integration_tests/stateful_component_integration_test.over_react.g.dart b/test/over_react/component_declaration/builder_integration_tests/stateful_component_integration_test.over_react.g.dart index 698faa785..dad3c8720 100644 --- a/test/over_react/component_declaration/builder_integration_tests/stateful_component_integration_test.over_react.g.dart +++ b/test/over_react/component_declaration/builder_integration_tests/stateful_component_integration_test.over_react.g.dart @@ -3,7 +3,7 @@ part of 'stateful_component_integration_test.dart'; // ************************************************************************** -// OverReactGenerator +// OverReactBuilder (package:over_react/src/builder.dart) // ************************************************************************** // React component factory implementation. diff --git a/test/over_react/component_declaration/builder_integration_tests/unassigned_prop_integration_test.over_react.g.dart b/test/over_react/component_declaration/builder_integration_tests/unassigned_prop_integration_test.over_react.g.dart index 1e188c8b7..684d0832b 100644 --- a/test/over_react/component_declaration/builder_integration_tests/unassigned_prop_integration_test.over_react.g.dart +++ b/test/over_react/component_declaration/builder_integration_tests/unassigned_prop_integration_test.over_react.g.dart @@ -3,7 +3,7 @@ part of 'unassigned_prop_integration_test.dart'; // ************************************************************************** -// OverReactGenerator +// OverReactBuilder (package:over_react/src/builder.dart) // ************************************************************************** // React component factory implementation. diff --git a/test/over_react/component_declaration/component_type_checking_test/test_a.over_react.g.dart b/test/over_react/component_declaration/component_type_checking_test/test_a.over_react.g.dart index dc65b6122..5f75495b2 100644 --- a/test/over_react/component_declaration/component_type_checking_test/test_a.over_react.g.dart +++ b/test/over_react/component_declaration/component_type_checking_test/test_a.over_react.g.dart @@ -1,9 +1,9 @@ // GENERATED CODE - DO NOT MODIFY BY HAND -part of test_component.test_a; +part of 'test_a.dart'; // ************************************************************************** -// OverReactGenerator +// OverReactBuilder (package:over_react/src/builder.dart) // ************************************************************************** // React component factory implementation. diff --git a/test/over_react/component_declaration/component_type_checking_test/test_b.over_react.g.dart b/test/over_react/component_declaration/component_type_checking_test/test_b.over_react.g.dart index a3eb3a0e1..8a8acbaf3 100644 --- a/test/over_react/component_declaration/component_type_checking_test/test_b.over_react.g.dart +++ b/test/over_react/component_declaration/component_type_checking_test/test_b.over_react.g.dart @@ -1,9 +1,9 @@ // GENERATED CODE - DO NOT MODIFY BY HAND -part of test_component.test_b; +part of 'test_b.dart'; // ************************************************************************** -// OverReactGenerator +// OverReactBuilder (package:over_react/src/builder.dart) // ************************************************************************** // React component factory implementation. diff --git a/test/over_react/component_declaration/component_type_checking_test/type_inheritance/abstract_inheritance/abstract.over_react.g.dart b/test/over_react/component_declaration/component_type_checking_test/type_inheritance/abstract_inheritance/abstract.over_react.g.dart index afc9dcc89..c5642088d 100644 --- a/test/over_react/component_declaration/component_type_checking_test/type_inheritance/abstract_inheritance/abstract.over_react.g.dart +++ b/test/over_react/component_declaration/component_type_checking_test/type_inheritance/abstract_inheritance/abstract.over_react.g.dart @@ -1,9 +1,9 @@ // GENERATED CODE - DO NOT MODIFY BY HAND -part of test_component.type_inheritance.abstract; +part of 'abstract.dart'; // ************************************************************************** -// OverReactGenerator +// OverReactBuilder (package:over_react/src/builder.dart) // ************************************************************************** abstract class _$TestAbstractPropsAccessorsMixin diff --git a/test/over_react/component_declaration/component_type_checking_test/type_inheritance/abstract_inheritance/extendedtype.over_react.g.dart b/test/over_react/component_declaration/component_type_checking_test/type_inheritance/abstract_inheritance/extendedtype.over_react.g.dart index 12d545663..1997d1fba 100644 --- a/test/over_react/component_declaration/component_type_checking_test/type_inheritance/abstract_inheritance/extendedtype.over_react.g.dart +++ b/test/over_react/component_declaration/component_type_checking_test/type_inheritance/abstract_inheritance/extendedtype.over_react.g.dart @@ -1,9 +1,9 @@ // GENERATED CODE - DO NOT MODIFY BY HAND -part of test_component.type_inheritance.extendedtype; +part of 'extendedtype.dart'; // ************************************************************************** -// OverReactGenerator +// OverReactBuilder (package:over_react/src/builder.dart) // ************************************************************************** // React component factory implementation. diff --git a/test/over_react/component_declaration/component_type_checking_test/type_inheritance/parent.over_react.g.dart b/test/over_react/component_declaration/component_type_checking_test/type_inheritance/parent.over_react.g.dart index 3e5e6f40a..81075b8cf 100644 --- a/test/over_react/component_declaration/component_type_checking_test/type_inheritance/parent.over_react.g.dart +++ b/test/over_react/component_declaration/component_type_checking_test/type_inheritance/parent.over_react.g.dart @@ -1,9 +1,9 @@ // GENERATED CODE - DO NOT MODIFY BY HAND -part of test_component.type_inheritance.parent; +part of 'parent.dart'; // ************************************************************************** -// OverReactGenerator +// OverReactBuilder (package:over_react/src/builder.dart) // ************************************************************************** // React component factory implementation. diff --git a/test/over_react/component_declaration/component_type_checking_test/type_inheritance/subsubtype.over_react.g.dart b/test/over_react/component_declaration/component_type_checking_test/type_inheritance/subsubtype.over_react.g.dart index fc7b69f4d..d19c9a60b 100644 --- a/test/over_react/component_declaration/component_type_checking_test/type_inheritance/subsubtype.over_react.g.dart +++ b/test/over_react/component_declaration/component_type_checking_test/type_inheritance/subsubtype.over_react.g.dart @@ -1,9 +1,9 @@ // GENERATED CODE - DO NOT MODIFY BY HAND -part of test_component.type_inheritance.subsubtype; +part of 'subsubtype.dart'; // ************************************************************************** -// OverReactGenerator +// OverReactBuilder (package:over_react/src/builder.dart) // ************************************************************************** // React component factory implementation. diff --git a/test/over_react/component_declaration/component_type_checking_test/type_inheritance/subtype.over_react.g.dart b/test/over_react/component_declaration/component_type_checking_test/type_inheritance/subtype.over_react.g.dart index e16ca29b5..2dfca4ff2 100644 --- a/test/over_react/component_declaration/component_type_checking_test/type_inheritance/subtype.over_react.g.dart +++ b/test/over_react/component_declaration/component_type_checking_test/type_inheritance/subtype.over_react.g.dart @@ -1,9 +1,9 @@ // GENERATED CODE - DO NOT MODIFY BY HAND -part of test_component.type_inheritance.subtype; +part of 'subtype.dart'; // ************************************************************************** -// OverReactGenerator +// OverReactBuilder (package:over_react/src/builder.dart) // ************************************************************************** // React component factory implementation. diff --git a/test/over_react/component_declaration/flux_component_test.over_react.g.dart b/test/over_react/component_declaration/flux_component_test.over_react.g.dart index 8e956eb32..8920b8d8c 100644 --- a/test/over_react/component_declaration/flux_component_test.over_react.g.dart +++ b/test/over_react/component_declaration/flux_component_test.over_react.g.dart @@ -1,9 +1,9 @@ // GENERATED CODE - DO NOT MODIFY BY HAND -part of over_react.component_declaration.flux_component_test; +part of 'flux_component_test.dart'; // ************************************************************************** -// OverReactGenerator +// OverReactBuilder (package:over_react/src/builder.dart) // ************************************************************************** // React component factory implementation. diff --git a/test/over_react/component_declaration/redux_component_test.over_react.g.dart b/test/over_react/component_declaration/redux_component_test.over_react.g.dart index 4d12a3192..d8be6aae1 100644 --- a/test/over_react/component_declaration/redux_component_test.over_react.g.dart +++ b/test/over_react/component_declaration/redux_component_test.over_react.g.dart @@ -1,9 +1,9 @@ // GENERATED CODE - DO NOT MODIFY BY HAND -part of over_react.component_declaration.redux_component_test; +part of 'redux_component_test.dart'; // ************************************************************************** -// OverReactGenerator +// OverReactBuilder (package:over_react/src/builder.dart) // ************************************************************************** // React component factory implementation. diff --git a/test/over_react/dom/fixtures/dummy_composite_component.over_react.g.dart b/test/over_react/dom/fixtures/dummy_composite_component.over_react.g.dart index aa3918146..f8d22a453 100644 --- a/test/over_react/dom/fixtures/dummy_composite_component.over_react.g.dart +++ b/test/over_react/dom/fixtures/dummy_composite_component.over_react.g.dart @@ -3,7 +3,7 @@ part of 'dummy_composite_component.dart'; // ************************************************************************** -// OverReactGenerator +// OverReactBuilder (package:over_react/src/builder.dart) // ************************************************************************** // React component factory implementation. diff --git a/test/over_react/util/dom_util_test.over_react.g.dart b/test/over_react/util/dom_util_test.over_react.g.dart index cede73bab..f76393cc9 100644 --- a/test/over_react/util/dom_util_test.over_react.g.dart +++ b/test/over_react/util/dom_util_test.over_react.g.dart @@ -1,9 +1,9 @@ // GENERATED CODE - DO NOT MODIFY BY HAND -part of dom_util_test; +part of 'dom_util_test.dart'; // ************************************************************************** -// OverReactGenerator +// OverReactBuilder (package:over_react/src/builder.dart) // ************************************************************************** // React component factory implementation. diff --git a/test/over_react/util/prop_key_util_test_dart2.over_react.g.dart b/test/over_react/util/prop_key_util_test_dart2.over_react.g.dart index 84e2c29e3..e277c3ff8 100644 --- a/test/over_react/util/prop_key_util_test_dart2.over_react.g.dart +++ b/test/over_react/util/prop_key_util_test_dart2.over_react.g.dart @@ -3,7 +3,7 @@ part of 'prop_key_util_test_dart2.dart'; // ************************************************************************** -// OverReactGenerator +// OverReactBuilder (package:over_react/src/builder.dart) // ************************************************************************** // React component factory implementation. diff --git a/test/test_util/one_level_wrapper.over_react.g.dart b/test/test_util/one_level_wrapper.over_react.g.dart index 96385c530..a86800128 100644 --- a/test/test_util/one_level_wrapper.over_react.g.dart +++ b/test/test_util/one_level_wrapper.over_react.g.dart @@ -1,9 +1,9 @@ // GENERATED CODE - DO NOT MODIFY BY HAND -part of test_util.one_level_wrapper; +part of 'one_level_wrapper.dart'; // ************************************************************************** -// OverReactGenerator +// OverReactBuilder (package:over_react/src/builder.dart) // ************************************************************************** // React component factory implementation. diff --git a/test/test_util/two_level_wrapper.over_react.g.dart b/test/test_util/two_level_wrapper.over_react.g.dart index 5bc510795..884c3b8d2 100644 --- a/test/test_util/two_level_wrapper.over_react.g.dart +++ b/test/test_util/two_level_wrapper.over_react.g.dart @@ -1,9 +1,9 @@ // GENERATED CODE - DO NOT MODIFY BY HAND -part of test_util.two_level_wrapper; +part of 'two_level_wrapper.dart'; // ************************************************************************** -// OverReactGenerator +// OverReactBuilder (package:over_react/src/builder.dart) // ************************************************************************** // React component factory implementation. diff --git a/test/vm_tests/builder/over_react_builder_test.dart b/test/vm_tests/builder/over_react_builder_test.dart index 692075376..f8151c656 100644 --- a/test/vm_tests/builder/over_react_builder_test.dart +++ b/test/vm_tests/builder/over_react_builder_test.dart @@ -1,4 +1,5 @@ @TestOn('vm') +import 'dart:async'; import 'dart:io'; import 'package:build/build.dart'; @@ -14,12 +15,14 @@ typedef void LogRecordFunction(LogRecord record); main() { group('overReactBuilder', () { final builder = overReactBuilder(null); + final logger = Logger('overReactBuilderTestLogger'); AssetReader reader; InMemoryAssetWriter writer; AssetWriterSpy writerSpy; - List logMsgs = []; - List logLevels = []; + StreamSubscription logSub; + List logs = []; + setUp(() async { reader = await PackageAssetReader.currentIsolate( rootPackage: 'over_react', @@ -27,23 +30,22 @@ main() { writer = new InMemoryAssetWriter(); writerSpy = AssetWriterSpy(writer); + + logSub = logger.onRecord.listen(logs.add); }); - tearDown(() { - logMsgs.clear(); + tearDown(() async { + await logSub?.cancel(); + logs.clear(); reader = null; writer = null; writerSpy = null; }); void verifyNoErrorLogs() { - expect(logLevels, isNot(contains(Level.SEVERE))); - expect(logLevels, isNot(contains(Level.WARNING))); - } - - void recordLogs(LogRecord record) { - logMsgs.add(record.message); - logLevels.add(record.level); + expect(logs.where((log) => log.level >= Level.WARNING), isEmpty, + reason: 'Expected no logs at WARNING or SEVERE level, but got:\n' + '\t${logs.join('\n\t')}'); } void checkBuildForFile(String assetPath, String expectedOutputAssetPath, @@ -55,11 +57,8 @@ main() { expectedOutputAssetPath : expectedContent }; - final logger = Logger('overReactBuilderTestLogger'); - final sub = logger.onRecord.listen(recordLogs); await runBuilder(builder, [inputAsset], reader, writerSpy, AnalyzerResolvers(), logger: logger); final actual = writerSpy.assetsWritten; - sub.cancel(); checkOutputs(expected, actual, writer); verifyNoErrorLogs(); @@ -67,7 +66,7 @@ main() { test('does not produce a build output for a file with no over_react annotations', () async { var basicAsset = makeAssetId('over_react|test_fixtures/source_files/no_annotations.dart'); - await runBuilder(builder, [basicAsset], reader, writerSpy, AnalyzerResolvers()); + await runBuilder(builder, [basicAsset], reader, writerSpy, AnalyzerResolvers(), logger: logger); expect(writerSpy.assetsWritten, isEmpty); verifyNoErrorLogs(); @@ -75,12 +74,22 @@ main() { test('does not produce a build output for just a part file', () async { var basicAsset = makeAssetId('over_react|test_fixtures/source_files/part_of_basic_library.dart'); - await runBuilder(builder, [basicAsset], reader, writerSpy, AnalyzerResolvers()); + await runBuilder(builder, [basicAsset], reader, writerSpy, AnalyzerResolvers(), logger: logger); expect(writerSpy.assetsWritten, isEmpty); verifyNoErrorLogs(); }); + test('warns if the .over_react.g.dart part is missing', () async { + var libraryAsset = makeAssetId('over_react|test_fixtures/source_files/missing_over_react_g_part/library.dart'); + await runBuilder(builder, [libraryAsset], reader, writerSpy, AnalyzerResolvers(), logger: logger); + final expectedWarning = logs.firstWhere((log) { + return log.level == Level.WARNING && log.message == 'Missing "part \'library.over_react.g.dart\';".'; + }, orElse: () => null); + expect(expectedWarning, isNotNull, + reason: 'Expected a WARNING log for the missing over_react part.'); + }); + group('for backwards compatible boilerplate:', () { test('builds from basic component file', () async { await checkBuildForFile( diff --git a/test_fixtures/gold_output_files/backwards_compatible/basic.over_react.g.dart.goldFile b/test_fixtures/gold_output_files/backwards_compatible/basic.over_react.g.dart.goldFile index 94b585dd6..b62a9aaa8 100644 --- a/test_fixtures/gold_output_files/backwards_compatible/basic.over_react.g.dart.goldFile +++ b/test_fixtures/gold_output_files/backwards_compatible/basic.over_react.g.dart.goldFile @@ -3,7 +3,7 @@ part of 'basic.dart'; // ************************************************************************** -// OverReactGenerator +// OverReactBuilder (package:over_react/src/builder.dart) // ************************************************************************** // React component factory implementation. diff --git a/test_fixtures/gold_output_files/backwards_compatible/basic_library.over_react.g.dart.goldFile b/test_fixtures/gold_output_files/backwards_compatible/basic_library.over_react.g.dart.goldFile index e2568732f..68a69f872 100644 --- a/test_fixtures/gold_output_files/backwards_compatible/basic_library.over_react.g.dart.goldFile +++ b/test_fixtures/gold_output_files/backwards_compatible/basic_library.over_react.g.dart.goldFile @@ -1,9 +1,9 @@ // GENERATED CODE - DO NOT MODIFY BY HAND -part of basic.library; +part of 'basic_library.dart'; // ************************************************************************** -// OverReactGenerator +// OverReactBuilder (package:over_react/src/builder.dart) // ************************************************************************** // React component factory implementation. diff --git a/test_fixtures/gold_output_files/basic.over_react.g.dart.goldFile b/test_fixtures/gold_output_files/basic.over_react.g.dart.goldFile index 711aefe03..134da9837 100644 --- a/test_fixtures/gold_output_files/basic.over_react.g.dart.goldFile +++ b/test_fixtures/gold_output_files/basic.over_react.g.dart.goldFile @@ -3,7 +3,7 @@ part of 'basic.dart'; // ************************************************************************** -// OverReactGenerator +// OverReactBuilder (package:over_react/src/builder.dart) // ************************************************************************** // React component factory implementation. diff --git a/test_fixtures/gold_output_files/basic_library.over_react.g.dart.goldFile b/test_fixtures/gold_output_files/basic_library.over_react.g.dart.goldFile index cce3afde3..4c0919678 100644 --- a/test_fixtures/gold_output_files/basic_library.over_react.g.dart.goldFile +++ b/test_fixtures/gold_output_files/basic_library.over_react.g.dart.goldFile @@ -1,9 +1,9 @@ // GENERATED CODE - DO NOT MODIFY BY HAND -part of basic.library; +part of 'basic_library.dart'; // ************************************************************************** -// OverReactGenerator +// OverReactBuilder (package:over_react/src/builder.dart) // ************************************************************************** // React component factory implementation. diff --git a/test_fixtures/source_files/missing_over_react_g_part/library.dart b/test_fixtures/source_files/missing_over_react_g_part/library.dart new file mode 100644 index 000000000..44571c4b1 --- /dev/null +++ b/test_fixtures/source_files/missing_over_react_g_part/library.dart @@ -0,0 +1,3 @@ +import 'package:over_react/over_react.dart'; + +part 'part.dart'; \ No newline at end of file diff --git a/test_fixtures/source_files/missing_over_react_g_part/part.dart b/test_fixtures/source_files/missing_over_react_g_part/part.dart new file mode 100644 index 000000000..3f45f1fdc --- /dev/null +++ b/test_fixtures/source_files/missing_over_react_g_part/part.dart @@ -0,0 +1,17 @@ +part of 'library.dart'; + +@Factory() +UiFactory BasicPartOfLib = _$BasicPartOfLib; + +@Props() +class _$BasicPartOfLibProps extends UiProps { + String basicProp; +} + +@Component() +class BasicPartOfLibComponent extends UiComponent { + @override + render() { + return Dom.div()('foo'); + } +} diff --git a/test_fixtures/source_files/part_of_basic_library.g.dart b/test_fixtures/source_files/part_of_basic_library.g.dart new file mode 100644 index 000000000..75c2a82ea --- /dev/null +++ b/test_fixtures/source_files/part_of_basic_library.g.dart @@ -0,0 +1,6 @@ +// This file should be ignored because of the .g.dart extension. + +part of basic.library; + +@Factory() +UiFactory Ignored; \ No newline at end of file diff --git a/web/src/demo_components/button.over_react.g.dart b/web/src/demo_components/button.over_react.g.dart index 19f4d6dc6..5fc61e06a 100644 --- a/web/src/demo_components/button.over_react.g.dart +++ b/web/src/demo_components/button.over_react.g.dart @@ -3,7 +3,7 @@ part of 'button.dart'; // ************************************************************************** -// OverReactGenerator +// OverReactBuilder (package:over_react/src/builder.dart) // ************************************************************************** // React component factory implementation. diff --git a/web/src/demo_components/button_group.over_react.g.dart b/web/src/demo_components/button_group.over_react.g.dart index ad2e27a4e..6d271581a 100644 --- a/web/src/demo_components/button_group.over_react.g.dart +++ b/web/src/demo_components/button_group.over_react.g.dart @@ -3,7 +3,7 @@ part of 'button_group.dart'; // ************************************************************************** -// OverReactGenerator +// OverReactBuilder (package:over_react/src/builder.dart) // ************************************************************************** // React component factory implementation. diff --git a/web/src/demo_components/list_group.over_react.g.dart b/web/src/demo_components/list_group.over_react.g.dart index 64ca9ca41..7f34fe424 100644 --- a/web/src/demo_components/list_group.over_react.g.dart +++ b/web/src/demo_components/list_group.over_react.g.dart @@ -3,7 +3,7 @@ part of 'list_group.dart'; // ************************************************************************** -// OverReactGenerator +// OverReactBuilder (package:over_react/src/builder.dart) // ************************************************************************** // React component factory implementation. diff --git a/web/src/demo_components/list_group_item.over_react.g.dart b/web/src/demo_components/list_group_item.over_react.g.dart index 157482c0f..2772f88cb 100644 --- a/web/src/demo_components/list_group_item.over_react.g.dart +++ b/web/src/demo_components/list_group_item.over_react.g.dart @@ -3,7 +3,7 @@ part of 'list_group_item.dart'; // ************************************************************************** -// OverReactGenerator +// OverReactBuilder (package:over_react/src/builder.dart) // ************************************************************************** // React component factory implementation. diff --git a/web/src/demo_components/progress.over_react.g.dart b/web/src/demo_components/progress.over_react.g.dart index d4778e9f7..70bf22d5c 100644 --- a/web/src/demo_components/progress.over_react.g.dart +++ b/web/src/demo_components/progress.over_react.g.dart @@ -3,7 +3,7 @@ part of 'progress.dart'; // ************************************************************************** -// OverReactGenerator +// OverReactBuilder (package:over_react/src/builder.dart) // ************************************************************************** // React component factory implementation. diff --git a/web/src/demo_components/tag.over_react.g.dart b/web/src/demo_components/tag.over_react.g.dart index a0fdc3f63..2108dda56 100644 --- a/web/src/demo_components/tag.over_react.g.dart +++ b/web/src/demo_components/tag.over_react.g.dart @@ -3,7 +3,7 @@ part of 'tag.dart'; // ************************************************************************** -// OverReactGenerator +// OverReactBuilder (package:over_react/src/builder.dart) // ************************************************************************** // React component factory implementation. diff --git a/web/src/demo_components/toggle_button.over_react.g.dart b/web/src/demo_components/toggle_button.over_react.g.dart index 5bfde667c..efaa51292 100644 --- a/web/src/demo_components/toggle_button.over_react.g.dart +++ b/web/src/demo_components/toggle_button.over_react.g.dart @@ -3,7 +3,7 @@ part of 'toggle_button.dart'; // ************************************************************************** -// OverReactGenerator +// OverReactBuilder (package:over_react/src/builder.dart) // ************************************************************************** // React component factory implementation. diff --git a/web/src/demo_components/toggle_button_group.over_react.g.dart b/web/src/demo_components/toggle_button_group.over_react.g.dart index 8f3a3cbd3..36fb2ac0d 100644 --- a/web/src/demo_components/toggle_button_group.over_react.g.dart +++ b/web/src/demo_components/toggle_button_group.over_react.g.dart @@ -3,7 +3,7 @@ part of 'toggle_button_group.dart'; // ************************************************************************** -// OverReactGenerator +// OverReactBuilder (package:over_react/src/builder.dart) // ************************************************************************** // React component factory implementation. diff --git a/web/src/shared/constants.over_react.g.dart b/web/src/shared/constants.over_react.g.dart index b53c1421a..1fef35eb5 100644 --- a/web/src/shared/constants.over_react.g.dart +++ b/web/src/shared/constants.over_react.g.dart @@ -3,7 +3,7 @@ part of 'constants.dart'; // ************************************************************************** -// OverReactGenerator +// OverReactBuilder (package:over_react/src/builder.dart) // ************************************************************************** abstract class AbstractInputPropsMixin implements _$AbstractInputPropsMixin {