Skip to content
This repository was archived by the owner on Sep 16, 2022. It is now read-only.
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
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ language: dart

dart:
# Temporarily disabled. We only have the stable release of Dartium installed.
# - dev
- dev
- stable

env:
Expand Down
1 change: 1 addition & 0 deletions _tests/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ dev_dependencies:

# DO NOT REMOVE. We don't publish this package, it is just for testing.
dependency_overrides:
analyzer: 0.31.0-alpha.0
angular:
path: ../angular
angular_compiler:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import 'dart:js_util' as js_util;

import 'package:func/func.dart' show VoidFunc0, VoidFunc1;
import 'package:angular/core.dart' show Directive, ElementRef, Provider;

import 'control_value_accessor.dart';
Expand Down Expand Up @@ -29,12 +28,12 @@ const DEFAULT_VALUE_ACCESSOR = const Provider(NG_VALUE_ACCESSOR,
])
class DefaultValueAccessor implements ControlValueAccessor {
ElementRef _elementRef;
VoidFunc1 onChange = (dynamic _) {};
void Function(dynamic) onChange = (dynamic _) {};
void touchHandler() {
onTouched();
}

VoidFunc0 onTouched = () {};
void Function() onTouched = () {};
DefaultValueAccessor(this._elementRef);
@override
void writeValue(dynamic value) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ import 'control_value_accessor.dart'
const NUMBER_VALUE_ACCESSOR = const Provider(NG_VALUE_ACCESSOR,
useExisting: NumberValueAccessor, multi: true);

typedef dynamic _SimpleChangeFn(value);

/// The accessor for writing a number value and listening to changes that is used by the
/// [NgModel], [NgFormControl], and [NgControlName] directives.
///
Expand All @@ -30,7 +28,7 @@ typedef dynamic _SimpleChangeFn(value);
])
class NumberValueAccessor implements ControlValueAccessor {
final ElementRef _elementRef;
_SimpleChangeFn onChange = (_) {};
dynamic Function(dynamic) onChange = (_) {};
void touchHandler() {
onTouched();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import 'dart:js_util' as js_util;

import 'package:func/func.dart' show Func0, VoidFunc0;
import 'package:angular/core.dart'
show Directive, ElementRef, Provider, Input, OnInit, OnDestroy, Injector;
import 'package:angular/di.dart' show Injectable;
Expand Down Expand Up @@ -89,8 +88,8 @@ class RadioControlValueAccessor
onTouched();
}

VoidFunc0 onChange = () {};
Func0 onTouched = () {};
void Function() onChange = () {};
Function() onTouched = () {};
RadioControlValueAccessor(this._elementRef, this._registry, this._injector);

@override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import 'dart:html';

import 'package:func/func.dart' show Func0, VoidFunc1;
import 'package:angular/core.dart'
show Directive, Provider, ElementRef, Input, OnDestroy;
import 'package:angular/di.dart' show Host, Optional;
Expand Down Expand Up @@ -45,13 +44,13 @@ class SelectControlValueAccessor implements ControlValueAccessor {
dynamic value;
final Map<String, dynamic> _optionMap = new Map<String, dynamic>();
num _idCounter = 0;
VoidFunc1 onChange = (dynamic _) {};
void Function(dynamic) onChange = (dynamic _) {};

void touchHandler() {
onTouched();
}

Func0 onTouched = () {};
Function() onTouched = () {};
SelectControlValueAccessor(this._elementRef);

@override
Expand Down
4 changes: 1 addition & 3 deletions angular/lib/src/common/pipes/replace_pipe.dart
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class ReplacePipe implements PipeTransform {
throw new InvalidPipeArgumentException(ReplacePipe, replacement);
}
// template fails with literal RegExp e.g /pattern/igm
if (replacement is _Matcher) {
if (replacement is String Function(Match)) {
var rgxPattern =
pattern is String ? new RegExp(pattern) : (pattern as RegExp);
return input.replaceAllMapped(rgxPattern, replacement);
Expand All @@ -68,5 +68,3 @@ class ReplacePipe implements PipeTransform {
return replacement is String || replacement is Function;
}
}

typedef String _Matcher(Match _);
2 changes: 1 addition & 1 deletion angular/lib/src/common/pipes/uppercase_pipe.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import 'package:angular/di.dart' show PipeTransform, Injectable, Pipe;
import 'package:angular/di.dart' show PipeTransform, Pipe;

import 'invalid_pipe_argument_exception.dart' show InvalidPipeArgumentException;

Expand Down
2 changes: 0 additions & 2 deletions angular/lib/src/compiler/selector.dart
Original file line number Diff line number Diff line change
Expand Up @@ -340,8 +340,6 @@ class SelectorMatcher {
}
}

typedef void MatchCallbackHandler(CssSelector, dynamic);

class SelectorListContext {
List<CssSelector> selectors;
bool alreadyMatched = false;
Expand Down
2 changes: 1 addition & 1 deletion angular/lib/src/compiler/view_compiler/view_binder.dart
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import 'package:source_span/source_span.dart';
import '../../core/linker/view_type.dart';
import '../expression_parser/parser.dart';
import '../output/output_ast.dart' as o;
import '../schema/element_schema_registry.dart';
import '../expression_parser/parser.dart';
import "../template_ast.dart"
show
TemplateAst,
Expand Down
5 changes: 2 additions & 3 deletions angular/lib/src/core/linker/app_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import 'dart:async';
import 'dart:html';
import 'dart:js_util' as js_util;

import 'package:func/func.dart';
import 'package:meta/meta.dart';
import 'package:angular/src/core/change_detection/change_detection.dart'
show ChangeDetectorRef, ChangeDetectionStrategy, ChangeDetectorState;
Expand Down Expand Up @@ -557,7 +556,7 @@ abstract class AppView<T> {
domRootRendererIsDirty = true;
}

VoidFunc1<E> eventHandler0<E>(VoidFunc0 handler) {
void Function(E) eventHandler0<E>(void Function() handler) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Are we decided on what syntax to use when declaring function parameters? Both are valid:

void Function(E) eventHandler0<E>(void Function() handler) {}

void Function(E) eventHandler0<E>(void handler()) {}

I'm in favor of the latter as it's more concise, but I can understand the desire to be consistent with the former.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think we decided always the former, the latter may be removed in a future version of Dart.

Copy link
Member Author

Choose a reason for hiding this comment

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

And encouraging the new syntax is goodness.

// No error, but this handle has no argument type
foo(void handler(int)) {};

// Does what you expect
foo(void Function(int)) {};

Copy link
Contributor

Choose a reason for hiding this comment

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

In that case there are some old style function parameters in these files you could update as well.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah...but that's hard to regexp

I'd almost want a lint for that

return (E event) {
markPathToRootAsCheckOnce();
if (NgZone.isInAngularZone()) {
Expand All @@ -576,7 +575,7 @@ abstract class AppView<T> {
// parameter of the event listener is a subclass of Event. The Event passed in
// from EventTarget.addEventListener() can then be safely coerced back to its
// known type.
VoidFunc1<E> eventHandler1<E, F extends E>(VoidFunc1<F> handler) {
void Function(E) eventHandler1<E, F extends E>(void Function(F) handler) {
return (E event) {
markPathToRootAsCheckOnce();
if (NgZone.isInAngularZone()) {
Expand Down
7 changes: 2 additions & 5 deletions angular/lib/src/core/zone/ng_zone.dart
Original file line number Diff line number Diff line change
Expand Up @@ -370,20 +370,17 @@ class NgZone {
Stream get onUnstable => _onUnstableController.stream;
}

typedef void ZeroArgFunction();
typedef void ErrorHandlingFn(error, stackTrace);

/// A `Timer` wrapper that lets you specify additional functions to call when it
/// is cancelled.
class WrappedTimer implements Timer {
Timer _timer;
ZeroArgFunction _onCancelCb;
void Function() _onCancelCb;

WrappedTimer(Timer timer) {
_timer = timer;
}

void addOnCancelCb(ZeroArgFunction onCancelCb) {
void addOnCancelCb(void Function() onCancelCb) {
if (this._onCancelCb != null) {
throw "On cancel cb already registered";
}
Expand Down
5 changes: 2 additions & 3 deletions angular/lib/src/debug/debug_app_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import 'dart:convert';
import 'dart:html';
import 'dart:js_util' as js_util;

import 'package:func/func.dart';
import 'package:js/js.dart' as js;
import 'package:meta/meta.dart';
import 'package:angular/src/core/change_detection/change_detection.dart'
Expand Down Expand Up @@ -144,7 +143,7 @@ class DebugAppView<T> extends AppView<T> {
}

@override
VoidFunc1<E> eventHandler0<E>(VoidFunc0 handler) {
void Function(E) eventHandler0<E>(void Function() handler) {
return (E event) {
_resetDebug();
try {
Expand All @@ -157,7 +156,7 @@ class DebugAppView<T> extends AppView<T> {
}

@override
VoidFunc1<E> eventHandler1<E, F extends E>(VoidFunc1<F> handler) {
void Function(E) eventHandler1<E, F extends E>(void Function(F) handler) {
return (E event) {
_resetDebug();
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,5 @@ abstract class PlatformLocation {
void back();
}

typedef String BaseHRefFromDOMProvider();

/// Returns base href from browser location.
BaseHRefFromDOMProvider baseHRefFromDOM;
String Function() baseHRefFromDOM;
Original file line number Diff line number Diff line change
Expand Up @@ -141,13 +141,12 @@ DartObject getField(DartObject object, String field) {
return getField(object.getField('(super)'), field);
}

typedef T RecurseFn<T>(DartObject obj);

/// Visits all of the [DartObject]s, accumulating the results of [RecurseFn].
///
/// If the DartObject is a list, then it will recursively visitAll
/// on that list. Otherwise, then it will call [RecurseFn] on the object.
List<T> visitAll<T>(Iterable<DartObject> objs, RecurseFn<T> recurseFn) {
/// on that list. Otherwise, then it will call [recurseFn] on the object.
List<T> visitAll<T>(
Iterable<DartObject> objs, T Function(DartObject) recurseFn) {
var metadata = <T>[];
for (DartObject obj in objs) {
var maybeList = obj.toListValue();
Expand Down
4 changes: 1 addition & 3 deletions angular/lib/src/transform/common/zone.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,12 @@ import 'package:angular/src/compiler/offline_compiler.dart';

import 'logging.dart' show forwardLogRecord;

typedef Future _SimpleCallback();

// Keys used to store zone local values on the current zone.
final _loggerKey = #loggingZonedLoggerKey;
final _templateCompilerKey = #templateCompilerKey;

/// Executes `fn` inside a new `Zone` with the provided zone-local values.
Future<dynamic> exec(_SimpleCallback fn,
Future<dynamic> exec(Future Function() fn,
{TransformLogger log, OfflineCompiler templateCompiler}) async {
return runZoned(() async {
var loggerSubscription = Logger.root.onRecord.listen(forwardLogRecord);
Expand Down
2 changes: 1 addition & 1 deletion angular/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ dependencies:
collection: '^1.12.0'
csslib: ^0.14.0
dart_style: '>=0.1.8 <2.0.0'
func: '>=0.1.0 <2.0.0'
glob: ^1.0.0
html: '>=0.12.0 <0.14.0'
intl: '>=0.13.0 <0.16.0'
Expand All @@ -32,6 +31,7 @@ dependencies:

# === vvv REMOVE WHEN PUBLISHING vvv ===
dependency_overrides:
analyzer: 0.31.0-alpha.0
angular_compiler:
path: ../angular_compiler
# === ^^^ REMOVE WHEN PUBLISHING ^^^ ===
Expand Down
1 change: 1 addition & 0 deletions angular_test/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ dependencies:

# === vvv REMOVE WHEN PUBLISHING vvv ===
dependency_overrides:
analyzer: 0.31.0-alpha.0
angular:
path: ../angular
angular_compiler:
Expand Down