Skip to content
This repository has been archived by the owner on Nov 1, 2024. It is now read-only.

Commit

Permalink
Remove deprecated code and classes. (#182)
Browse files Browse the repository at this point in the history
  • Loading branch information
matanlurey authored Dec 22, 2017
1 parent d977a99 commit 5b17b90
Show file tree
Hide file tree
Showing 19 changed files with 49 additions and 361 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
## 3.0.0-alpha

* Using `equalsDart` no longer formats automatically with `dartfmt`.

* Removed deprecated `Annotation` and `File` classes.

* `Method.lambda` is inferred based on `Method.body` where possible and now
defaults to `null`.

## 2.4.0

* Add `equalTo`, `notEqualTo`, `greaterThan`, `lessThan`, `greateOrEqualTo`, and
Expand Down
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ void main() {
..extend = refer('Organism')
..methods.add(new Method.returnsVoid((b) => b
..name = 'eat'
..lambda = true
..body = const Code('print(\'Yum\')'))));
final emitter = new DartEmitter();
print(new DartFormatter().format('${animal.accept(emitter)}'));
Expand Down
1 change: 0 additions & 1 deletion example/example.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ String animalClass() {
..extend = refer('Organism')
..methods.add(new Method.returnsVoid((b) => b
..name = 'eat'
..lambda = null
..body = refer('print').call([literalString('Yum!')]).code)));
return _dartfmt.format('${animal.accept(new DartEmitter())}');
}
Expand Down
6 changes: 1 addition & 5 deletions lib/code_builder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ export 'src/base.dart' show lazySpec, Spec;
export 'src/emitter.dart' show DartEmitter;
export 'src/matchers.dart' show equalsDart, EqualsDart;
export 'src/matchers.dart' show equalsDart;
// ignore: deprecated_member_use
export 'src/specs/annotation.dart' show Annotation, AnnotationBuilder;
export 'src/specs/class.dart' show Class, ClassBuilder;
export 'src/specs/code.dart'
show lazyCode, Block, BlockBuilder, Code, StaticCode, ScopedCode;
Expand Down Expand Up @@ -38,9 +36,7 @@ export 'src/specs/expression.dart'
literalTrue,
literalFalse;
export 'src/specs/field.dart' show Field, FieldBuilder, FieldModifier;
// TODO: Remove File, FileBuilder in 3.0.0.
// ignore: deprecated_member_use
export 'src/specs/library.dart' show File, FileBuilder, Library, LibraryBuilder;
export 'src/specs/library.dart' show Library, LibraryBuilder;
export 'src/specs/method.dart'
show
Method,
Expand Down
14 changes: 2 additions & 12 deletions lib/src/emitter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import 'package:meta/meta.dart';

import 'allocator.dart';
import 'base.dart';
import 'specs/annotation.dart';
import 'specs/class.dart';
import 'specs/code.dart';
import 'specs/constructor.dart';
Expand Down Expand Up @@ -79,11 +78,7 @@ class DartEmitter extends Object
@override
visitAnnotation(Expression spec, [StringSink output]) {
(output ??= new StringBuffer()).write('@');
if (spec is Annotation) {
spec.code.accept(this, output);
} else {
spec.accept(this, output);
}
spec.accept(this, output);
output.write(' ');
return output;
}
Expand Down Expand Up @@ -281,12 +276,7 @@ class DartEmitter extends Object
}

@override
visitLibrary(Library spec, [StringSink output]) => visitFile(spec, output);

@override
// TODO: Remove File in 3.0.0.
// ignore: deprecated_member_use
visitFile(File spec, [StringSink output]) {
visitLibrary(Library spec, [StringSink output]) {
output ??= new StringBuffer();
// Process the body first in order to prime the allocators.
final body = new StringBuffer();
Expand Down
19 changes: 4 additions & 15 deletions lib/src/matchers.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

import 'package:dart_style/dart_style.dart';
import 'package:matcher/matcher.dart';

import 'base.dart';
Expand All @@ -23,23 +22,13 @@ Matcher equalsDart(
///
/// See [EqualsDart.format] to specify the default source code formatter.
class EqualsDart extends Matcher {
// TODO: Remove in 3.0.0.
static final _formatter = new DartFormatter();

/// May override to provide a function to format Dart on [equalsDart].
///
/// As of `2.x.x`, this defaults to using `dartfmt`, but in an upcoming
/// release (`3.x.x`) it will default to [collapseWhitespace]. This is in
/// order to avoid a dependency on specific versions of `dartfmt` and the
/// `analyzer` package.
///
/// To future proof, see an example in code_builder's `test/common.dart`.
/// By default, uses [collapseWhitespace], but it is recommended to instead
/// use `dart_style` (dartfmt) where possible. See `test/common.dart` for an
/// example.
static String Function(String) format = (String source) {
try {
return _formatter.format(source);
} on FormatException catch (_) {
return _formatter.formatStatement(source);
}
return collapseWhitespace(source);
};

static String _format(String source) {
Expand Down
56 changes: 0 additions & 56 deletions lib/src/specs/annotation.dart

This file was deleted.

99 changes: 0 additions & 99 deletions lib/src/specs/annotation.g.dart

This file was deleted.

39 changes: 0 additions & 39 deletions lib/src/specs/expression.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import 'package:meta/meta.dart';
import '../base.dart';
import '../emitter.dart';
import '../visitors.dart';
import 'annotation.dart';
import 'code.dart';
import 'method.dart';
import 'reference.dart';
Expand Down Expand Up @@ -244,44 +243,6 @@ abstract class Expression implements Spec {
);
}

/// Returns an annotation as a result of calling this constructor.
@Deprecated('Use "call" instead. Will be removed in 3.0.0.')
Expression annotation([
Iterable<Expression> positionalArguments,
Map<String, Expression> namedArguments = const {},
List<Reference> typeArguments = const [],
]) {
if (positionalArguments == null) {
return new Annotation((b) {
b.code = code;
});
}
return new Annotation((b) {
b.code = new InvokeExpression._(
this,
positionalArguments.toList(),
namedArguments,
typeArguments,
)
.code;
});
}

/// Returns an annotation as a result of calling a named constructor.
@Deprecated('Use a combination of "property" and "call". Removing in 3.0.0.')
Expression annotationNamed(
String name,
Iterable<Expression> positionalArguments, [
Map<String, Expression> namedArguments = const {},
List<Reference> typeArguments = const [],
]) {
// ignore: deprecated_member_use
return new Annotation((b) => b
..code = new InvokeExpression._(this, positionalArguments.toList(),
namedArguments, typeArguments, name)
.code);
}

/// This expression preceded by `return`.
Expression get returned {
return new BinaryExpression._(
Expand Down
Loading

0 comments on commit 5b17b90

Please sign in to comment.