style(dart): Format with dartfmt v0.2.0

Format all pure Dart code with package:dart_style v0.2.0

Command:
```
find -type f -name "*.dart" | xargs dartformat -w
```
This commit is contained in:
Tim Blasi
2015-08-05 11:04:29 -07:00
parent 450d3630cc
commit f11f4e0b45
145 changed files with 1627 additions and 1013 deletions
@@ -86,7 +86,8 @@ class AnnotationMatcher extends ClassMatcherBase {
ClassDescriptor descriptor = firstMatch(annotation.name, assetId);
if (descriptor == null) return false;
return implements(descriptor, interfaces,
missingSuperClassWarning: 'Missing `custom_annotation` entry for `${descriptor.superClass}`.');
missingSuperClassWarning:
'Missing `custom_annotation` entry for `${descriptor.superClass}`.');
}
/// Checks if an [Annotation] node implements [Injectable].
@@ -48,8 +48,8 @@ abstract class ClassMatcherBase {
if (descriptor == null) return false;
if (interfaces.contains(descriptor)) return true;
if (descriptor.superClass == null) return false;
var superClass = _classDescriptors.firstWhere(
(a) => a.name == descriptor.superClass, orElse: () => null);
var superClass = _classDescriptors
.firstWhere((a) => a.name == descriptor.superClass, orElse: () => null);
if (superClass == null) {
if (missingSuperClassWarning != null &&
missingSuperClassWarning.isNotEmpty) {
@@ -74,7 +74,8 @@ ImportDirective _getMatchingImport(
name = className.name;
}
if (name != descriptor.name) return null;
return (className.root as CompilationUnit).directives
return (className.root as CompilationUnit)
.directives
.where((d) => d is ImportDirective)
.firstWhere((ImportDirective i) {
var importMatch = false;
@@ -106,8 +107,10 @@ bool isMatch(
class ClassDescriptor {
/// The name of the class.
final String name;
/// A `package:` style import path to the file where the class is defined.
final String import;
/// The class that this class extends or implements. This is the only optional
/// field.
final String superClass;
@@ -108,7 +108,8 @@ class _DirectiveMetadataVisitor extends Object
var directiveType = _getDirectiveType('${node.name}', node.element);
if (directiveType >= 0) {
if (_hasMeta) {
throw new FormatException('Only one Directive is allowed per class. '
throw new FormatException(
'Only one Directive is allowed per class. '
'Found "$node" but already processed "$meta".',
'$node' /* source */);
}
@@ -125,7 +126,8 @@ class _DirectiveMetadataVisitor extends Object
'${node.constructorName.type.name}', node.staticElement);
if (directiveType >= 0) {
if (_hasMeta) {
throw new FormatException('Only one Directive is allowed per class. '
throw new FormatException(
'Only one Directive is allowed per class. '
'Found "$node" but already processed "$meta".',
'$node' /* source */);
}
@@ -177,8 +179,10 @@ class _DirectiveMetadataVisitor extends Object
String _expressionToString(Expression node, String nodeDescription) {
var value = node.accept(_evaluator);
if (value is! String) {
throw new FormatException('Angular 2 could not understand the value '
'in $nodeDescription.', '$node' /* source */);
throw new FormatException(
'Angular 2 could not understand the value '
'in $nodeDescription.',
'$node' /* source */);
}
return value;
}
@@ -203,7 +207,8 @@ class _DirectiveMetadataVisitor extends Object
if (evaluated is! bool) {
throw new FormatException(
'Angular 2 expects a bool but could not understand the value for '
'Directive#compileChildren.', '$compileChildrenValue' /* source */);
'Directive#compileChildren.',
'$compileChildrenValue' /* source */);
}
_compileChildren = evaluated;
}
@@ -216,7 +221,8 @@ class _DirectiveMetadataVisitor extends Object
if (evaluated is! Map) {
throw new FormatException(
'Angular 2 expects a Map but could not understand the value for '
'$propertyName.', '$expression' /* source */);
'$propertyName.',
'$expression' /* source */);
}
evaluated.forEach((key, value) {
if (value != null) {
@@ -233,7 +239,8 @@ class _DirectiveMetadataVisitor extends Object
if (evaluated is! List) {
throw new FormatException(
'Angular 2 expects a List but could not understand the value for '
'$propertyName.', '$expression' /* source */);
'$propertyName.',
'$expression' /* source */);
}
list.addAll(evaluated);
}
@@ -40,6 +40,7 @@ class PrintLogger implements BuildLogger {
void error(msg, {AssetId asset, SourceSpan span}) {
throw new PrintLoggerError(msg, asset, span);
}
Future writeOutput() => null;
Future addLogFilesFromAsset(AssetId id, [int nextNumber = 1]) => null;
}
@@ -51,25 +51,41 @@ class TransformerOptions {
/// The "correct" number of phases varies with the structure of the app.
final int optimizationPhases;
TransformerOptions._internal(this.entryPoints, this.reflectionEntryPoints,
this.modeName, this.mirrorMode, this.initReflector,
this.annotationMatcher, this.optimizationPhases,
this.generateChangeDetectors, this.inlineViews);
TransformerOptions._internal(
this.entryPoints,
this.reflectionEntryPoints,
this.modeName,
this.mirrorMode,
this.initReflector,
this.annotationMatcher,
this.optimizationPhases,
this.generateChangeDetectors,
this.inlineViews);
factory TransformerOptions(List<String> entryPoints,
{List<String> reflectionEntryPoints, String modeName: 'release',
MirrorMode mirrorMode: MirrorMode.none, bool initReflector: true,
{List<String> reflectionEntryPoints,
String modeName: 'release',
MirrorMode mirrorMode: MirrorMode.none,
bool initReflector: true,
List<ClassDescriptor> customAnnotationDescriptors: const [],
int optimizationPhases: DEFAULT_OPTIMIZATION_PHASES,
bool inlineViews: true, bool generateChangeDetectors: true}) {
bool inlineViews: true,
bool generateChangeDetectors: true}) {
if (reflectionEntryPoints == null || reflectionEntryPoints.isEmpty) {
reflectionEntryPoints = entryPoints;
}
var annotationMatcher = new AnnotationMatcher()
..addAll(customAnnotationDescriptors);
optimizationPhases = optimizationPhases.isNegative ? 0 : optimizationPhases;
return new TransformerOptions._internal(entryPoints, reflectionEntryPoints,
modeName, mirrorMode, initReflector, annotationMatcher,
optimizationPhases, generateChangeDetectors, inlineViews);
return new TransformerOptions._internal(
entryPoints,
reflectionEntryPoints,
modeName,
mirrorMode,
initReflector,
annotationMatcher,
optimizationPhases,
generateChangeDetectors,
inlineViews);
}
}
@@ -10,12 +10,16 @@ import 'package:angular2/src/transform/common/names.dart';
class RegisteredType {
/// The type registered by this call.
final Identifier typeName;
/// The actual call to `Reflector#registerType`.
final MethodInvocation registerMethod;
/// The factory method registered.
final Expression factoryFn;
/// The parameters registered.
final Expression parameters;
/// The annotations registered.
final Expression annotations;