Skip to content
This repository was archived by the owner on Apr 8, 2025. It is now read-only.

Commit 5b17b90

Browse files
authored
Remove deprecated code and classes. (#182)
1 parent d977a99 commit 5b17b90

19 files changed

+49
-361
lines changed

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
## 3.0.0-alpha
2+
3+
* Using `equalsDart` no longer formats automatically with `dartfmt`.
4+
5+
* Removed deprecated `Annotation` and `File` classes.
6+
7+
* `Method.lambda` is inferred based on `Method.body` where possible and now
8+
defaults to `null`.
9+
110
## 2.4.0
211

312
* Add `equalTo`, `notEqualTo`, `greaterThan`, `lessThan`, `greateOrEqualTo`, and

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ void main() {
2525
..extend = refer('Organism')
2626
..methods.add(new Method.returnsVoid((b) => b
2727
..name = 'eat'
28-
..lambda = true
2928
..body = const Code('print(\'Yum\')'))));
3029
final emitter = new DartEmitter();
3130
print(new DartFormatter().format('${animal.accept(emitter)}'));

example/example.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ String animalClass() {
2525
..extend = refer('Organism')
2626
..methods.add(new Method.returnsVoid((b) => b
2727
..name = 'eat'
28-
..lambda = null
2928
..body = refer('print').call([literalString('Yum!')]).code)));
3029
return _dartfmt.format('${animal.accept(new DartEmitter())}');
3130
}

lib/code_builder.dart

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ export 'src/base.dart' show lazySpec, Spec;
77
export 'src/emitter.dart' show DartEmitter;
88
export 'src/matchers.dart' show equalsDart, EqualsDart;
99
export 'src/matchers.dart' show equalsDart;
10-
// ignore: deprecated_member_use
11-
export 'src/specs/annotation.dart' show Annotation, AnnotationBuilder;
1210
export 'src/specs/class.dart' show Class, ClassBuilder;
1311
export 'src/specs/code.dart'
1412
show lazyCode, Block, BlockBuilder, Code, StaticCode, ScopedCode;
@@ -38,9 +36,7 @@ export 'src/specs/expression.dart'
3836
literalTrue,
3937
literalFalse;
4038
export 'src/specs/field.dart' show Field, FieldBuilder, FieldModifier;
41-
// TODO: Remove File, FileBuilder in 3.0.0.
42-
// ignore: deprecated_member_use
43-
export 'src/specs/library.dart' show File, FileBuilder, Library, LibraryBuilder;
39+
export 'src/specs/library.dart' show Library, LibraryBuilder;
4440
export 'src/specs/method.dart'
4541
show
4642
Method,

lib/src/emitter.dart

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import 'package:meta/meta.dart';
66

77
import 'allocator.dart';
88
import 'base.dart';
9-
import 'specs/annotation.dart';
109
import 'specs/class.dart';
1110
import 'specs/code.dart';
1211
import 'specs/constructor.dart';
@@ -79,11 +78,7 @@ class DartEmitter extends Object
7978
@override
8079
visitAnnotation(Expression spec, [StringSink output]) {
8180
(output ??= new StringBuffer()).write('@');
82-
if (spec is Annotation) {
83-
spec.code.accept(this, output);
84-
} else {
85-
spec.accept(this, output);
86-
}
81+
spec.accept(this, output);
8782
output.write(' ');
8883
return output;
8984
}
@@ -281,12 +276,7 @@ class DartEmitter extends Object
281276
}
282277

283278
@override
284-
visitLibrary(Library spec, [StringSink output]) => visitFile(spec, output);
285-
286-
@override
287-
// TODO: Remove File in 3.0.0.
288-
// ignore: deprecated_member_use
289-
visitFile(File spec, [StringSink output]) {
279+
visitLibrary(Library spec, [StringSink output]) {
290280
output ??= new StringBuffer();
291281
// Process the body first in order to prime the allocators.
292282
final body = new StringBuffer();

lib/src/matchers.dart

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
// for details. All rights reserved. Use of this source code is governed by a
33
// BSD-style license that can be found in the LICENSE file.
44

5-
import 'package:dart_style/dart_style.dart';
65
import 'package:matcher/matcher.dart';
76

87
import 'base.dart';
@@ -23,23 +22,13 @@ Matcher equalsDart(
2322
///
2423
/// See [EqualsDart.format] to specify the default source code formatter.
2524
class EqualsDart extends Matcher {
26-
// TODO: Remove in 3.0.0.
27-
static final _formatter = new DartFormatter();
28-
2925
/// May override to provide a function to format Dart on [equalsDart].
3026
///
31-
/// As of `2.x.x`, this defaults to using `dartfmt`, but in an upcoming
32-
/// release (`3.x.x`) it will default to [collapseWhitespace]. This is in
33-
/// order to avoid a dependency on specific versions of `dartfmt` and the
34-
/// `analyzer` package.
35-
///
36-
/// To future proof, see an example in code_builder's `test/common.dart`.
27+
/// By default, uses [collapseWhitespace], but it is recommended to instead
28+
/// use `dart_style` (dartfmt) where possible. See `test/common.dart` for an
29+
/// example.
3730
static String Function(String) format = (String source) {
38-
try {
39-
return _formatter.format(source);
40-
} on FormatException catch (_) {
41-
return _formatter.formatStatement(source);
42-
}
31+
return collapseWhitespace(source);
4332
};
4433

4534
static String _format(String source) {

lib/src/specs/annotation.dart

Lines changed: 0 additions & 56 deletions
This file was deleted.

lib/src/specs/annotation.g.dart

Lines changed: 0 additions & 99 deletions
This file was deleted.

lib/src/specs/expression.dart

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import 'package:meta/meta.dart';
99
import '../base.dart';
1010
import '../emitter.dart';
1111
import '../visitors.dart';
12-
import 'annotation.dart';
1312
import 'code.dart';
1413
import 'method.dart';
1514
import 'reference.dart';
@@ -244,44 +243,6 @@ abstract class Expression implements Spec {
244243
);
245244
}
246245

247-
/// Returns an annotation as a result of calling this constructor.
248-
@Deprecated('Use "call" instead. Will be removed in 3.0.0.')
249-
Expression annotation([
250-
Iterable<Expression> positionalArguments,
251-
Map<String, Expression> namedArguments = const {},
252-
List<Reference> typeArguments = const [],
253-
]) {
254-
if (positionalArguments == null) {
255-
return new Annotation((b) {
256-
b.code = code;
257-
});
258-
}
259-
return new Annotation((b) {
260-
b.code = new InvokeExpression._(
261-
this,
262-
positionalArguments.toList(),
263-
namedArguments,
264-
typeArguments,
265-
)
266-
.code;
267-
});
268-
}
269-
270-
/// Returns an annotation as a result of calling a named constructor.
271-
@Deprecated('Use a combination of "property" and "call". Removing in 3.0.0.')
272-
Expression annotationNamed(
273-
String name,
274-
Iterable<Expression> positionalArguments, [
275-
Map<String, Expression> namedArguments = const {},
276-
List<Reference> typeArguments = const [],
277-
]) {
278-
// ignore: deprecated_member_use
279-
return new Annotation((b) => b
280-
..code = new InvokeExpression._(this, positionalArguments.toList(),
281-
namedArguments, typeArguments, name)
282-
.code);
283-
}
284-
285246
/// This expression preceded by `return`.
286247
Expression get returned {
287248
return new BinaryExpression._(

0 commit comments

Comments
 (0)