Skip to content

Commit

Permalink
feat(writer): added refer to manifest param
Browse files Browse the repository at this point in the history
  • Loading branch information
FatulM committed Oct 18, 2021
1 parent 1027b7f commit 4ac480c
Show file tree
Hide file tree
Showing 12 changed files with 45 additions and 16 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
@@ -1,3 +1,7 @@
## 1.13.0

- Added referToManifest to source writer

## 1.12.0

- Added hierarchy feature to use sealed classes directly in sealed hierarchies
Expand Down
4 changes: 4 additions & 0 deletions example/CHANGELOG.md
@@ -1,3 +1,7 @@
## 1.13.0

- Added referToManifest to source writer

## 1.12.0

- Added hierarchy feature to use sealed classes directly in sealed hierarchies
Expand Down
6 changes: 3 additions & 3 deletions example/pubspec.yaml
Expand Up @@ -3,7 +3,7 @@ description: Dart and Flutter sealed or union class generator and annotations, w
repository: https://github.com/6thsolution/dart_sealed/tree/master/example
homepage: https://github.com/6thsolution/dart_sealed

version: 1.12.0
version: 1.13.0

# example package should not be published
publish_to: 'none'
Expand All @@ -13,11 +13,11 @@ environment:

dependencies:
# use fixed version dependency
sealed_annotations: '1.12.0'
sealed_annotations: '1.13.0'

dev_dependencies:
# use fixed version dependency
sealed_generators: '1.12.0'
sealed_generators: '1.13.0'
lints: any
test: any
build_runner: any
Expand Down
4 changes: 4 additions & 0 deletions sealed_annotations/CHANGELOG.md
@@ -1,3 +1,7 @@
## 1.13.0

- Added referToManifest to source writer

## 1.12.0

- Added hierarchy feature to use sealed classes directly in sealed hierarchies
Expand Down
2 changes: 1 addition & 1 deletion sealed_annotations/pubspec.yaml
Expand Up @@ -3,7 +3,7 @@ description: Dart and Flutter sealed or union class generator and annotations, w
repository: https://github.com/6thsolution/dart_sealed/tree/master/sealed_annotations
homepage: https://github.com/6thsolution/dart_sealed

version: 1.12.0
version: 1.13.0

environment:
sdk: '>=2.12.0 <3.0.0'
Expand Down
4 changes: 4 additions & 0 deletions sealed_generators/CHANGELOG.md
@@ -1,3 +1,7 @@
## 1.13.0

- Added referToManifest to source writer

## 1.12.0

- Added hierarchy feature to use sealed classes directly in sealed hierarchies
Expand Down
6 changes: 3 additions & 3 deletions sealed_generators/pubspec.yaml
Expand Up @@ -3,16 +3,16 @@ description: Dart and Flutter sealed or union class generator and annotations, w
repository: https://github.com/6thsolution/dart_sealed/tree/master/sealed_generators
homepage: https://github.com/6thsolution/dart_sealed

version: 1.12.0
version: 1.13.0

environment:
sdk: '>=2.12.0 <3.0.0'

dependencies:
# use fixed version dependency
sealed_annotations: '1.12.0'
sealed_annotations: '1.13.0'
# use fixed version dependency
sealed_writer: '1.12.0'
sealed_writer: '1.13.0'
build: any
source_gen: any
analyzer: any
Expand Down
4 changes: 4 additions & 0 deletions sealed_writer/CHANGELOG.md
@@ -1,3 +1,7 @@
## 1.13.0

- Added referToManifest to source writer

## 1.12.0

- Added hierarchy feature to use sealed classes directly in sealed hierarchies
Expand Down
2 changes: 1 addition & 1 deletion sealed_writer/example/example.dart
Expand Up @@ -33,7 +33,7 @@ void main() {
print('FORWARD WRITER');
print('==============');

final forward = SourceWriter(source);
final forward = SourceWriter(source, referToManifest: false);
print(forward.write());

print('===============');
Expand Down
11 changes: 8 additions & 3 deletions sealed_writer/lib/src/writer/source_writer.dart
Expand Up @@ -8,10 +8,15 @@ import 'package:sealed_writer/src/writer/top/top_writer.dart';
///
/// NOTE: writer phase is completely disjoint from reader phase.
class SourceWriter extends BaseWriter {
/// [referenceManifest] dictates weather to reference
/// [referToManifest] dictates weather to reference
/// manifest with @SealedManifest or not, it is true by default
SourceWriter(Manifest manifest)
: topWriter = TopWriter(manifest),
SourceWriter(
Manifest manifest, {
bool referToManifest = true,
}) : topWriter = TopWriter(
manifest,
referToManifest: referToManifest,
),
subWriter = SubWriter(manifest),
super(manifest);

Expand Down
12 changes: 8 additions & 4 deletions sealed_writer/lib/src/writer/top/top_writer.dart
Expand Up @@ -9,16 +9,20 @@ import 'package:sealed_writer/src/writer/top/top_doc_writer.dart';

/// source writer
class TopWriter extends BaseUtilsWriter {
/// [referenceManifest] dictates weather to reference
/// [referToManifest] dictates weather to reference
/// manifest with @SealedManifest or not, it is true by default
TopWriter(Manifest manifest)
: topBuilderWriter = TopBuilderWriter(manifest),
TopWriter(
Manifest manifest, {
this.referToManifest = true,
}) : topBuilderWriter = TopBuilderWriter(manifest),
topCastWriter = TopCastWriter(manifest),
topMatchWriter = TopMatchWriter(manifest),
topDocWriter = TopDocWriter(manifest),
topCommonWriter = TopCommonWriter(manifest),
super(manifest);

final bool referToManifest;

final TopBuilderWriter topBuilderWriter;

final TopCastWriter topCastWriter;
Expand All @@ -43,7 +47,7 @@ class TopWriter extends BaseUtilsWriter {

String topClassStart() => [
topDocWriter.write(),
topManifest(),
if (referToManifest) topManifest(),
'abstract class $topDec',
].joinLines();

Expand Down
2 changes: 1 addition & 1 deletion sealed_writer/pubspec.yaml
Expand Up @@ -3,7 +3,7 @@ description: Dart and Flutter sealed or union class generator and annotations, w
repository: https://github.com/6thsolution/dart_sealed/tree/master/sealed_writer
homepage: https://github.com/6thsolution/dart_sealed

version: 1.12.0
version: 1.13.0

environment:
sdk: '>=2.12.0 <3.0.0'
Expand Down

0 comments on commit 4ac480c

Please sign in to comment.