Skip to content
This repository was archived by the owner on Sep 16, 2022. It is now read-only.

refactor(Compiler): Try removing all computeNode() calls. #1469

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion _goldens/test/_files/change_detection.outline.golden
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import 'package:angular/src/core/linker/app_view.dart';
import 'change_detection.dart' as _user;

// Required for "type inference" (scoping).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Call this comment be removed as well?

import 'package:angular/angular.dart';

// For @Component class CheckOnceComponent.
external List<dynamic> get styles$CheckOnceComponent;
Expand Down
4 changes: 0 additions & 4 deletions _goldens/test/_files/component_loader_pattern.outline.golden
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,6 @@ import 'package:angular/src/core/linker/app_view.dart';
import 'component_loader_pattern.dart' as _user;

// Required for "type inference" (scoping).
import 'package:angular/angular.dart';
import 'package:angular/di.template.dart' as di_lib;
import 'package:angular/security.template.dart' deferred as security_lib;
import 'example_of_file_that_is_not_generated_yet.template.dart' as example_lib;

// For @Component class TestComponent.
external List<dynamic> get styles$TestComponent;
Expand Down
1 change: 0 additions & 1 deletion _goldens/test/_files/core_directives.outline.golden
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import 'package:angular/src/core/linker/app_view.dart';
import 'core_directives.dart' as _user;

// Required for "type inference" (scoping).
import 'package:angular/angular.dart';

// For @Component class TestFooComponent.
external List<dynamic> get styles$TestFooComponent;
Expand Down
2 changes: 0 additions & 2 deletions _goldens/test/_files/dart2js/dart2js_golden.outline.golden
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ import 'package:angular/src/core/linker/app_view.dart';
import 'dart2js_golden.dart' as _user;

// Required for "type inference" (scoping).
import 'package:angular/angular.dart';
import 'dart2js_golden.template.dart' as ng;

// For @Component class RootComponent.
external List<dynamic> get styles$RootComponent;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@ import 'package:angular/src/core/linker/app_view.dart';
import 'container_component.dart' as _user;

// Required for "type inference" (scoping).
import 'package:angular/angular.dart';
import 'package:_goldens/component.dart';
import 'deferred_component.dart';

// For @Component class TestContainerComponent.
external List<dynamic> get styles$TestContainerComponent;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import 'package:angular/src/core/linker/app_view.dart';
import 'deferred_component.dart' as _user;

// Required for "type inference" (scoping).
import 'package:angular/angular.dart';

// For @Component class DeferredChildComponent.
external List<dynamic> get styles$DeferredChildComponent;
Expand Down
2 changes: 0 additions & 2 deletions _goldens/test/_files/di/generated_injectors.outline.golden
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ import 'package:angular/src/core/linker/app_view.dart';
import 'generated_injectors.dart' as _user;

// Required for "type inference" (scoping).
import 'package:angular/angular.dart';
import 'generated_injectors.template.dart' as ng;

external Injector doGenerate$Injector([Injector parent]);

Expand Down
3 changes: 0 additions & 3 deletions _goldens/test/_files/directives/base_component.outline.golden
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@ import 'package:angular/src/core/linker/app_view.dart';
import 'base_component.dart' as _user;

// Required for "type inference" (scoping).
import 'package:angular/angular.dart';
import 'components.dart';
import 'directives.dart' as directive;

// For @Component class TestFooComponent.
external List<dynamic> get styles$TestFooComponent;
Expand Down
1 change: 0 additions & 1 deletion _goldens/test/_files/directives/components.outline.golden
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import 'package:angular/src/core/linker/app_view.dart';
import 'components.dart' as _user;

// Required for "type inference" (scoping).
import 'package:angular/angular.dart';

// For @Component class TestSubComponent.
external List<dynamic> get styles$TestSubComponent;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@ import 'package:angular/src/core/linker/app_view.dart';
import 'directive_wrapper.dart' as _user;

// Required for "type inference" (scoping).
import 'dart:async';
import 'dart:html';
import 'package:angular/angular.dart';

// For @Component class TestFooComponent.
external List<dynamic> get styles$TestFooComponent;
Expand Down
2 changes: 0 additions & 2 deletions _goldens/test/_files/directives/directives.outline.golden
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ import 'package:angular/src/core/linker/app_view.dart';
import 'directives.dart' as _user;

// Required for "type inference" (scoping).
import 'dart:collection' as collection_lib;
import 'package:angular/angular.dart';

// For @Directive class TestDirective.
class TestDirectiveNgCd extends DirectiveChangeDetector {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ import 'package:angular/src/core/linker/app_view.dart';
import 'functional_directives.dart' as _user;

// Required for "type inference" (scoping).
import 'dart:html';
import 'package:angular/angular.dart';

// For @Component class AppComponent.
external List<dynamic> get styles$AppComponent;
Expand Down
1 change: 0 additions & 1 deletion _goldens/test/_files/directives/generics.outline.golden
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import 'package:angular/src/core/linker/app_view.dart';
import 'generics.dart' as _user;

// Required for "type inference" (scoping).
import 'package:angular/angular.dart';

// For @Component class UntypedComp.
external List<dynamic> get styles$UntypedComp;
Expand Down
28 changes: 28 additions & 0 deletions _goldens/test/_files/directives/import_prefixes.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import 'package:angular/angular.dart' as angular;

// This is silly, but just for simplified testing.
import 'import_prefixes.dart' as prefixed;

@angular.Component(
selector: 'parent-comp',
directives: [
prefixed.ChildComponent,
],
template: '<child-comp [myType]="input"></child-comp>',
)
class ParentComponent {
final input = new prefixed.MyType();
}

@angular.Component(
selector: 'child-cmp',
template: r'''
{{myType}}
''',
)
class ChildComponent {
@angular.Input()
prefixed.MyType myType;
}

class MyType {}
31 changes: 31 additions & 0 deletions _goldens/test/_files/directives/import_prefixes.outline.golden
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// ignore_for_file: library_prefixes,unused_import,no_default_super_constructor_explicit,duplicate_import,unused_shown_name
// The .template.dart files also export the user code.
export 'import_prefixes.dart';

// Required for referencing runtime code.
import 'dart:html';
import 'package:angular/angular.dart';
import 'package:angular/src/core/change_detection/directive_change_detector.dart';
import 'package:angular/src/core/linker/app_view.dart';

// Required for specifically referencing user code.
import 'import_prefixes.dart' as _user;

// Required for "type inference" (scoping).

// For @Component class ParentComponent.
external List<dynamic> get styles$ParentComponent;
external ComponentFactory<_user.ParentComponent> get ParentComponentNgFactory;
external AppView<_user.ParentComponent> viewFactory_ParentComponent0(AppView<dynamic> parentView, int parentIndex);
class ViewParentComponent0 extends AppView<_user.ParentComponent> {
external ViewParentComponent0(AppView<dynamic> parentView, int parentIndex);
}
// For @Component class ChildComponent.
external List<dynamic> get styles$ChildComponent;
external ComponentFactory<_user.ChildComponent> get ChildComponentNgFactory;
external AppView<_user.ChildComponent> viewFactory_ChildComponent0(AppView<dynamic> parentView, int parentIndex);
class ViewChildComponent0 extends AppView<_user.ChildComponent> {
external ViewChildComponent0(AppView<dynamic> parentView, int parentIndex);
}

external void initReflector();
178 changes: 178 additions & 0 deletions _goldens/test/_files/directives/import_prefixes.template.golden
Original file line number Diff line number Diff line change
@@ -0,0 +1,178 @@
// **************************************************************************
// Generator: Instance of 'Compiler'
// **************************************************************************

// ignore_for_file: cancel_subscriptions,constant_identifier_names,duplicate_import,non_constant_identifier_names,library_prefixes,UNUSED_IMPORT,UNUSED_SHOWN_NAME
import 'import_prefixes.dart';
export 'import_prefixes.dart';
import 'package:angular/angular.dart' as angular;
import 'import_prefixes.dart' as prefixed;
import 'package:angular/src/di/reflector.dart' as _ngRef;
import 'package:angular/angular.template.dart' as _ref0;
import 'package:angular/src/core/linker/app_view.dart';
import 'import_prefixes.dart' as import1;
import 'dart:html' as import2;
import 'package:angular/src/core/render/api.dart';
import 'package:angular/src/core/linker/view_type.dart' as import4;
import 'package:angular/src/core/change_detection/change_detection.dart';
import 'package:angular/src/core/linker/app_view_utils.dart' as import6;
import 'package:angular/src/runtime.dart' as import7;
import 'package:angular/angular.dart';

final List<dynamic> styles$ParentComponent = const [];

class ViewParentComponent0 extends AppView<import1.ParentComponent> {
import2.Element _el_0;
static RenderComponentType _renderType;
ViewParentComponent0(AppView<dynamic> parentView, int parentIndex) : super(import4.ViewType.component, {}, parentView, parentIndex, ChangeDetectionStrategy.CheckAlways) {
rootEl = import2.document.createElement('parent-comp');
_renderType ??= import6.appViewUtils.createRenderType((import7.isDevMode ? 'asset:_goldens/test/_files/directives/import_prefixes.dart' : null), ViewEncapsulation.None, styles$ParentComponent);
setupComponentType(_renderType);
}
@override
ComponentRef<import1.ParentComponent> build() {
final _rootEl = rootEl;
final import2.HtmlElement parentRenderNode = initViewRoot(_rootEl);
var doc = import2.document;
_el_0 = createAndAppend(doc, 'child-comp', parentRenderNode);
init(const [], null);
return null;
}

@override
void detectChangesInternal() {
final import1.ParentComponent _ctx = ctx;
bool firstCheck = (this.cdState == 0);
if (firstCheck) {
if (!identical(_ctx.input, null)) {
setProp(_el_0, 'myType', _ctx.input);
}
}
}
}

AppView<import1.ParentComponent> viewFactory_ParentComponent0(AppView<dynamic> parentView, int parentIndex) {
return new ViewParentComponent0(parentView, parentIndex);
}

final List<dynamic> styles$ParentComponentHost = const [];

class _ViewParentComponentHost0 extends AppView<import1.ParentComponent> {
ViewParentComponent0 _compView_0;
import1.ParentComponent _ParentComponent_0_5;
_ViewParentComponentHost0(AppView<dynamic> parentView, int parentIndex) : super(import4.ViewType.host, {}, parentView, parentIndex, ChangeDetectionStrategy.CheckAlways);
@override
ComponentRef<import1.ParentComponent> build() {
_compView_0 = new ViewParentComponent0(this, 0);
rootEl = _compView_0.rootEl;
_ParentComponent_0_5 = new import1.ParentComponent();
_compView_0.create(_ParentComponent_0_5, projectableNodes);
init0(rootEl);
return new ComponentRef(0, this, rootEl, _ParentComponent_0_5);
}

@override
void detectChangesInternal() {
_compView_0.detectChanges();
}

@override
void destroyInternal() {
_compView_0?.destroy();
}
}

AppView<import1.ParentComponent> viewFactory_ParentComponentHost0(AppView<dynamic> parentView, int parentIndex) {
return new _ViewParentComponentHost0(parentView, parentIndex);
}

const ComponentFactory<import1.ParentComponent> _ParentComponentNgFactory = const ComponentFactory('parent-comp', viewFactory_ParentComponentHost0, _ParentComponentMetadata);
ComponentFactory<import1.ParentComponent> get ParentComponentNgFactory {
return _ParentComponentNgFactory;
}

final List<dynamic> styles$ChildComponent = const [];

class ViewChildComponent0 extends AppView<import1.ChildComponent> {
import2.Text _text_0;
var _expr_0;
static RenderComponentType _renderType;
ViewChildComponent0(AppView<dynamic> parentView, int parentIndex) : super(import4.ViewType.component, {}, parentView, parentIndex, ChangeDetectionStrategy.CheckAlways) {
rootEl = import2.document.createElement('child-cmp');
_renderType ??= import6.appViewUtils.createRenderType((import7.isDevMode ? 'asset:_goldens/test/_files/directives/import_prefixes.dart' : null), ViewEncapsulation.None, styles$ChildComponent);
setupComponentType(_renderType);
}
@override
ComponentRef<import1.ChildComponent> build() {
final _rootEl = rootEl;
final import2.HtmlElement parentRenderNode = initViewRoot(_rootEl);
_text_0 = new import2.Text('');
parentRenderNode.append(_text_0);
init(const [], null);
return null;
}

@override
void detectChangesInternal() {
final import1.ChildComponent _ctx = ctx;
final currVal_0 = import6.interpolate0(_ctx.myType);
if (import6.checkBinding(_expr_0, currVal_0)) {
_text_0.text = currVal_0;
_expr_0 = currVal_0;
}
}
}

AppView<import1.ChildComponent> viewFactory_ChildComponent0(AppView<dynamic> parentView, int parentIndex) {
return new ViewChildComponent0(parentView, parentIndex);
}

final List<dynamic> styles$ChildComponentHost = const [];

class _ViewChildComponentHost0 extends AppView<import1.ChildComponent> {
ViewChildComponent0 _compView_0;
import1.ChildComponent _ChildComponent_0_5;
_ViewChildComponentHost0(AppView<dynamic> parentView, int parentIndex) : super(import4.ViewType.host, {}, parentView, parentIndex, ChangeDetectionStrategy.CheckAlways);
@override
ComponentRef<import1.ChildComponent> build() {
_compView_0 = new ViewChildComponent0(this, 0);
rootEl = _compView_0.rootEl;
_ChildComponent_0_5 = new import1.ChildComponent();
_compView_0.create(_ChildComponent_0_5, projectableNodes);
init0(rootEl);
return new ComponentRef(0, this, rootEl, _ChildComponent_0_5);
}

@override
void detectChangesInternal() {
_compView_0.detectChanges();
}

@override
void destroyInternal() {
_compView_0?.destroy();
}
}

AppView<import1.ChildComponent> viewFactory_ChildComponentHost0(AppView<dynamic> parentView, int parentIndex) {
return new _ViewChildComponentHost0(parentView, parentIndex);
}

const ComponentFactory<import1.ChildComponent> _ChildComponentNgFactory = const ComponentFactory('child-cmp', viewFactory_ChildComponentHost0, _ChildComponentMetadata);
ComponentFactory<import1.ChildComponent> get ChildComponentNgFactory {
return _ChildComponentNgFactory;
}

const _ParentComponentMetadata = const [];
const _ChildComponentMetadata = const [];
var _visited = false;
void initReflector() {
if (_visited) {
return;
}
_visited = true;

_ngRef.registerComponent(ParentComponent, ParentComponentNgFactory);
_ngRef.registerComponent(ChildComponent, ChildComponentNgFactory);
_ref0.initReflector();
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import 'package:angular/src/core/linker/app_view.dart';
import 'intl_component.dart' as _user;

// Required for "type inference" (scoping).
import 'package:angular/angular.dart';

// For @Component class CompWithoutFinal.
external List<dynamic> get styles$CompWithoutFinal;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import 'package:angular/src/core/linker/app_view.dart';
import 'nested_ng_for.dart' as _user;

// Required for "type inference" (scoping).
import 'package:angular/angular.dart';

// For @Component class NestedNgForComponent.
external List<dynamic> get styles$NestedNgForComponent;
Expand Down
1 change: 0 additions & 1 deletion _goldens/test/_files/empty_properties.outline.golden
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import 'package:angular/src/core/linker/app_view.dart';
import 'empty_properties.dart' as _user;

// Required for "type inference" (scoping).
import 'package:angular/angular.dart';

// For @Component class EmptyPropertiesComponent.
external List<dynamic> get styles$EmptyPropertiesComponent;
Expand Down
1 change: 0 additions & 1 deletion _goldens/test/_files/event_tearoff.outline.golden
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import 'package:angular/src/core/linker/app_view.dart';
import 'event_tearoff.dart' as _user;

// Required for "type inference" (scoping).
import 'package:angular/angular.dart';

// For @Component class UsesEventTearoff.
external List<dynamic> get styles$UsesEventTearoff;
Expand Down
2 changes: 0 additions & 2 deletions _goldens/test/_files/events.outline.golden
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ import 'package:angular/src/core/linker/app_view.dart';
import 'events.dart' as _user;

// Required for "type inference" (scoping).
import 'dart:async';
import 'package:angular/angular.dart';

// For @Component class UsesNativeEvents.
external List<dynamic> get styles$UsesNativeEvents;
Expand Down
Loading