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

Conversation

@matanlurey
Copy link
Contributor

Added:

  • Allocator (prefixing)
  • Directive and File

@matanlurey matanlurey requested a review from alorenzen July 8, 2017 01:15
@matanlurey
Copy link
Contributor Author

Ping @alorenzen since you're back - this is probably enough to roll I imagine.

///
/// For example, a no-op implementation:
/// ```dart
/// allocate(const Reference('List', 'dart:core')); // Outputs 'List'.
Copy link
Contributor

Choose a reason for hiding this comment

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

Minor nit: I'd consider replacing Outputs 'List' with Returns 'List'.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

///
/// Where-as an implementation that prefixes imports might output:
/// ```dart
/// allocate(const Reference('Foo', 'package:foo')); // Outputs '_i1.Foo'.
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here, consider replacing Outputs with Returns.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

class DartEmitter extends GeneralizingSpecVisitor<StringSink> {
const DartEmitter();
class DartEmitter implements SpecVisitor<StringSink> {
final Allocator _allocator;
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think _allocator.imports is ever called. So how would you actually print out the imports in a file?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, good catch. Added to visitFile and updated file_test.

test('should emit a source file', () {
expect(
new File((b) => b
..directives.add(new Directive.import('dart:collection'))
Copy link
Contributor

Choose a reason for hiding this comment

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

Is the assumption that you always have to add the imports manually? Can you add a test which uses allocator.imports instead?

Also, maybe a test case for prefixing imports?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed. Added test cases.

Copy link
Contributor Author

@matanlurey matanlurey left a comment

Choose a reason for hiding this comment

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

PTAL.

///
/// For example, a no-op implementation:
/// ```dart
/// allocate(const Reference('List', 'dart:core')); // Outputs 'List'.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

///
/// Where-as an implementation that prefixes imports might output:
/// ```dart
/// allocate(const Reference('Foo', 'package:foo')); // Outputs '_i1.Foo'.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

class DartEmitter extends GeneralizingSpecVisitor<StringSink> {
const DartEmitter();
class DartEmitter implements SpecVisitor<StringSink> {
final Allocator _allocator;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, good catch. Added to visitFile and updated file_test.

test('should emit a source file', () {
expect(
new File((b) => b
..directives.add(new Directive.import('dart:collection'))
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed. Added test cases.

@matanlurey matanlurey merged commit 56f812b into dart-archive:v2 Jul 12, 2017
@matanlurey matanlurey deleted the more branch July 12, 2017 17:59
matanlurey added a commit that referenced this pull request Jul 14, 2017
* WIP.

* Finish up feature parity.

* Dartfmt.

* Address feedback.

* Format with dart_style:format for now.

* Fix tests.
mosuem pushed a commit to dart-lang/tools that referenced this pull request Oct 25, 2024
* WIP.

* Finish up feature parity.

* Dartfmt.

* Address feedback.

* Format with dart_style:format for now.

* Fix tests.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants