Skip to content

Refer to library by URL. #138

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
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
3 changes: 2 additions & 1 deletion lib/src/builder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ class GeneratorBuilder extends Builder {
var contentBuffer = new StringBuffer();

if (!isStandalone) {
contentBuffer.writeln('part of ${library.name};');
contentBuffer.writeln('// ignore: non_identifier_library_name');
contentBuffer.writeln("part of '${library.definingCompilationUnit.displayName}';");
contentBuffer.writeln();
}

Expand Down
4 changes: 2 additions & 2 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ author: Dart Team <[email protected]>
description: Automatic sourcecode generation for Dart
homepage: https://github.com/dart-lang/source_gen
environment:
sdk: '>=1.12.0 <2.0.0'
sdk: '>=1.23.0-dev.11.0 <2.0.0'
Copy link
Member

Choose a reason for hiding this comment

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

Is this about the SDK min value ... or pkg/analyzer min version?

Copy link
Contributor

Choose a reason for hiding this comment

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

Probably need both? SDK for supporting the output in tools/runtimes, analyzer for supporting parsing this file in later codegen steps etc?

Copy link
Member

Choose a reason for hiding this comment

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

Strictly speaking, this package doesn't need to align w/ the SDK version. Just the analyzer version.

One could generate code with SDK X that doesn't run in SDK X.

...right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, we could generate code that doesn't run. I guess if we do that we would instead need to bump the source_gen major version? Maybe we should do that anyway?

--> no new SDK requirement
--> version bump to 0.6

What do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Friendly ping. Any ideas how we should ship this? Thanks.

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 should bump the min sdk version but not do a major version bump in this package (unless there is a breaking change I am missing).

There isn't much of a point in generating code that can't run in your current sdk imo, it would just lead to confusion.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ack, kept it with just the SDK version bump.

dependencies:
analyzer: ^0.29.2
build: ^0.7.1
dart_style: '>=0.1.7 <2.0.0'
dart_style: ^1.0.0
path: ^1.3.2
dev_dependencies:
build_runner: ^0.3.0
Expand Down
21 changes: 16 additions & 5 deletions test/builder_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -153,14 +153,17 @@ class MyGoodError { }
''';

const _testLibPartContent = r'''
part of test_lib;
// ignore: non_identifier_library_name
part of 'test_lib.dart';
final int bar = 42;
class Customer { }
''';

const _testGenPartContent = r'''// GENERATED CODE - DO NOT MODIFY BY HAND

part of test_lib;
// ignore: non_identifier_library_name
part of 'test_lib.dart';


// **************************************************************************
// Generator: CommentGenerator
Expand All @@ -180,7 +183,9 @@ part of test_lib;
const _testGenPartContentForLibrary =
r'''// GENERATED CODE - DO NOT MODIFY BY HAND

part of test_lib;
// ignore: non_identifier_library_name
part of 'test_lib.dart';


// **************************************************************************
// Generator: CommentGenerator
Expand Down Expand Up @@ -210,7 +215,9 @@ const _testGenStandaloneContent = r'''// GENERATED CODE - DO NOT MODIFY BY HAND
const _testGenPartContentForClassesAndLibrary =
r'''// GENERATED CODE - DO NOT MODIFY BY HAND

part of test_lib;
// ignore: non_identifier_library_name
part of 'test_lib.dart';


// **************************************************************************
// Generator: CommentGenerator
Expand All @@ -236,7 +243,9 @@ part of test_lib;

const _testGenPartContentError = r'''// GENERATED CODE - DO NOT MODIFY BY HAND

part of test_lib;
// ignore: non_identifier_library_name
part of 'test_lib.dart';


// **************************************************************************
// Generator: CommentGenerator
Expand All @@ -246,6 +255,7 @@ part of test_lib;
// Error: Invalid argument (element): We don't support class names with the word 'Error'.
// Try renaming the class.: Instance of 'ClassElementImpl'


// **************************************************************************
// Generator: CommentGenerator
// Target: class MyGoodError
Expand All @@ -254,6 +264,7 @@ part of test_lib;
// Error: Don't use classes with the word 'Error' in the name
// TODO: Rename MyGoodError to something else.


// **************************************************************************
// Generator: CommentGenerator
// Target: class Customer
Expand Down