Skip to content
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

refactor: generator #81

Merged
merged 3 commits into from
Dec 27, 2023
Merged
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
64 changes: 32 additions & 32 deletions examples/envied_example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,18 @@ packages:
dependency: transitive
description:
name: _fe_analyzer_shared
sha256: ae92f5d747aee634b87f89d9946000c2de774be1d6ac3e58268224348cd0101a
sha256: "36a321c3d2cbe01cbcb3540a87b8843846e0206df3e691fa7b23e19e78de6d49"
url: "https://pub.dev"
source: hosted
version: "61.0.0"
version: "65.0.0"
analyzer:
dependency: transitive
description:
name: analyzer
sha256: ea3d8652bda62982addfd92fdc2d0214e5f82e43325104990d4f4c4a2a313562
sha256: dfe03b90ec022450e22513b5e5ca1f01c0c01de9c3fba2f7fd233cb57a6b9a07
url: "https://pub.dev"
source: hosted
version: "5.13.0"
version: "6.3.0"
args:
dependency: transitive
description:
Expand Down Expand Up @@ -61,18 +61,18 @@ packages:
dependency: transitive
description:
name: build_daemon
sha256: "5f02d73eb2ba16483e693f80bee4f088563a820e47d1027d4cdfe62b5bb43e65"
sha256: "0343061a33da9c5810b2d6cee51945127d8f4c060b7fbdd9d54917f0a3feaaa1"
url: "https://pub.dev"
source: hosted
version: "4.0.0"
version: "4.0.1"
build_resolvers:
dependency: transitive
description:
name: build_resolvers
sha256: "6c4dd11d05d056e76320b828a1db0fc01ccd376922526f8e9d6c796a5adbac20"
sha256: "64e12b0521812d1684b1917bc80945625391cb9bdd4312536b1d69dcb6133ed8"
url: "https://pub.dev"
source: hosted
version: "2.2.1"
version: "2.4.1"
build_runner:
dependency: "direct dev"
description:
Expand All @@ -85,10 +85,10 @@ packages:
dependency: transitive
description:
name: build_runner_core
sha256: "6d6ee4276b1c5f34f21fdf39425202712d2be82019983d52f351c94aafbc2c41"
sha256: c9e32d21dd6626b5c163d48b037ce906bbe428bc23ab77bcd77bb21e593b6185
url: "https://pub.dev"
source: hosted
version: "7.2.10"
version: "7.2.11"
built_collection:
dependency: transitive
description:
Expand All @@ -101,10 +101,10 @@ packages:
dependency: transitive
description:
name: built_value
sha256: "598a2a682e2a7a90f08ba39c0aaa9374c5112340f0a2e275f61b59389543d166"
sha256: "723b4021e903217dfc445ec4cf5b42e27975aece1fc4ebbc1ca6329c2d9fb54e"
url: "https://pub.dev"
source: hosted
version: "8.6.1"
version: "8.7.0"
checked_yaml:
dependency: transitive
description:
Expand All @@ -117,10 +117,10 @@ packages:
dependency: transitive
description:
name: code_builder
sha256: "315a598c7fbe77f22de1c9da7cfd6fd21816312f16ffa124453b4fc679e540f1"
sha256: b2151ce26a06171005b379ecff6e08d34c470180ffe16b8e14b6d52be292b55f
url: "https://pub.dev"
source: hosted
version: "4.6.0"
version: "4.8.0"
collection:
dependency: transitive
description:
Expand All @@ -141,10 +141,10 @@ packages:
dependency: transitive
description:
name: coverage
sha256: "2fb815080e44a09b85e0f2ca8a820b15053982b2e714b59267719e8a9ff17097"
sha256: ac86d3abab0f165e4b8f561280ff4e066bceaac83c424dd19f1ae2c2fcd12ca9
url: "https://pub.dev"
source: hosted
version: "1.6.3"
version: "1.7.1"
crypto:
dependency: transitive
description:
Expand All @@ -157,24 +157,24 @@ packages:
dependency: transitive
description:
name: dart_style
sha256: "1efa911ca7086affd35f463ca2fc1799584fb6aa89883cf0af8e3664d6a02d55"
sha256: "40ae61a5d43feea6d24bd22c0537a6629db858963b99b4bc1c3db80676f32368"
url: "https://pub.dev"
source: hosted
version: "2.3.2"
version: "2.3.4"
envied:
dependency: "direct main"
description:
path: "../../packages/envied"
relative: true
source: path
version: "0.5.1"
version: "0.5.2"
envied_generator:
dependency: "direct dev"
description:
path: "../../packages/envied_generator"
relative: true
source: path
version: "0.5.1"
version: "0.5.2"
file:
dependency: transitive
description:
Expand Down Expand Up @@ -259,10 +259,10 @@ packages:
dependency: "direct dev"
description:
name: lints
sha256: "0a217c6c989d21039f1498c3ed9f3ed71b354e69873f13a8dfc3c9fe76f1b452"
sha256: cbf8d4b858bb0134ef3ef87841abdf8d63bfc255c266b7bf6b39daa1085c4290
url: "https://pub.dev"
source: hosted
version: "2.1.1"
version: "3.0.0"
logging:
dependency: transitive
description:
Expand All @@ -283,10 +283,10 @@ packages:
dependency: transitive
description:
name: meta
sha256: "3c74dbf8763d36539f114c799d8a2d87343b5067e9d796ca22b5eb8437090ee3"
sha256: d584fa6707a52763a52446f02cc621b077888fb63b93bbcb1143a7be5a0c0c04
url: "https://pub.dev"
source: hosted
version: "1.9.1"
version: "1.11.0"
mime:
dependency: transitive
description:
Expand Down Expand Up @@ -459,10 +459,10 @@ packages:
dependency: "direct dev"
description:
name: test
sha256: "9b0dd8e36af4a5b1569029949d50a52cb2a2a2fdaa20cebb96e6603b9ae241f9"
sha256: a1f7595805820fcc05e5c52e3a231aedd0b72972cb333e8c738a8b1239448b6f
url: "https://pub.dev"
source: hosted
version: "1.24.6"
version: "1.24.9"
test_api:
dependency: transitive
description:
Expand All @@ -475,10 +475,10 @@ packages:
dependency: transitive
description:
name: test_core
sha256: "4bef837e56375537055fdbbbf6dd458b1859881f4c7e6da936158f77d61ab265"
sha256: a757b14fc47507060a162cc2530d9a4a2f92f5100a952c7443b5cad5ef5b106a
url: "https://pub.dev"
source: hosted
version: "0.5.6"
version: "0.5.9"
timing:
dependency: transitive
description:
Expand All @@ -499,10 +499,10 @@ packages:
dependency: transitive
description:
name: vm_service
sha256: "0fae432c85c4ea880b33b497d32824b97795b04cdaa74d270219572a1f50268d"
sha256: b3d56ff4341b8f182b96aceb2fa20e3dcb336b9f867bc0eafc0de10f1048e957
url: "https://pub.dev"
source: hosted
version: "11.9.0"
version: "13.0.0"
watcher:
dependency: transitive
description:
Expand All @@ -523,10 +523,10 @@ packages:
dependency: transitive
description:
name: webkit_inspection_protocol
sha256: "67d3a8b6c79e1987d19d848b0892e582dbb0c66c57cc1fef58a177dd2aa2823d"
sha256: "87d3f2333bb240704cd3f1c6b5b7acd8a10e7f0bc28c28dcf14e782014f4a572"
url: "https://pub.dev"
source: hosted
version: "1.2.0"
version: "1.2.1"
yaml:
dependency: transitive
description:
Expand Down
10 changes: 5 additions & 5 deletions examples/envied_example/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
name: example
description: A sample command-line application.
version: 2.0.0
version: 2.0.1
publish_to: none

environment:
sdk: ">=3.0.0 <4.0.0"

dev_dependencies:
build_runner: ^2.4.6
envied_generator: ^0.5.0
lints: ^2.1.1
test: ^1.24.6
envied_generator: ^0.5.2
lints: ^3.0.0
test: ^1.24.9
dependencies:
envied: ^0.5.0
envied: ^0.5.2
44 changes: 23 additions & 21 deletions packages/envied_generator/lib/src/generate_field_encrypted.dart
Original file line number Diff line number Diff line change
Expand Up @@ -97,12 +97,8 @@ Iterable<Field> generateFieldsEncrypted(
..isNullable = isNullable,
)
..name = field.name
// TODO(@techouse): replace with `Expression.operatorBitwiseXor` once https://github.com/dart-lang/code_builder/pull/427 gets merged
..assignment = Block.of([
refer(keyName).code,
Code('^'),
literalNum(encValue).code,
]),
..assignment =
refer(keyName).operatorBitwiseXor(literalNum(encValue)).code,
),
];
}
Expand Down Expand Up @@ -139,12 +135,8 @@ Iterable<Field> generateFieldsEncrypted(
..isNullable = isNullable,
)
..name = field.name
// TODO(@techouse): replace with `Expression.operatorBitwiseXor` once https://github.com/dart-lang/code_builder/pull/427 gets merged
..assignment = Block.of([
refer(keyName).code,
Code('^'),
literalBool(encValue).code,
]),
..assignment =
refer(keyName).operatorBitwiseXor(literalBool(encValue)).code,
),
];
}
Expand Down Expand Up @@ -191,7 +183,11 @@ Iterable<Field> generateFieldsEncrypted(
final Expression stringExpression = refer('String').type.newInstanceNamed(
'fromCharCodes',
[
refer('List<int>')
TypeReference(
(TypeReferenceBuilder typeBuilder) => typeBuilder
..symbol = 'List'
..types.add(refer('int')),
)
.type
.newInstanceNamed(
'generate',
Expand Down Expand Up @@ -224,12 +220,10 @@ Iterable<Field> generateFieldsEncrypted(
..type = refer('int'),
),
)
// TODO(@techouse): replace with `Expression.operatorBitwiseXor` once https://github.com/dart-lang/code_builder/pull/427 gets merged
..body = Block.of([
refer(encName).index(refer('i')).code,
Code('^'),
refer(keyName).index(refer('i')).code,
]),
..body = refer(encName)
.index(refer('i'))
.operatorBitwiseXor(refer(keyName).index(refer('i')))
.code,
).closure,
]),
],
Expand Down Expand Up @@ -260,15 +254,23 @@ Iterable<Field> generateFieldsEncrypted(
(FieldBuilder fieldBuilder) => fieldBuilder
..static = true
..modifier = FieldModifier.constant
..type = refer('List<int>')
..type = TypeReference(
(TypeReferenceBuilder typeBuilder) => typeBuilder
..symbol = 'List'
..types.add(refer('int')),
)
..name = keyName
..assignment = literalList(key, refer('int')).code,
),
Field(
(FieldBuilder fieldBuilder) => fieldBuilder
..static = true
..modifier = FieldModifier.constant
..type = refer('List<int>')
..type = TypeReference(
(TypeReferenceBuilder typeBuilder) => typeBuilder
..symbol = 'List'
..types.add(refer('int')),
)
..name = encName
..assignment = literalList(encValue, refer('int')).code,
),
Expand Down
2 changes: 1 addition & 1 deletion packages/envied_generator/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ environment:
dependencies:
envied: ^0.5.0
build: ^2.4.1
code_builder: ^4.6.0
code_builder: ^4.8.0
dart_style: ^2.3.2
source_gen: ^1.4.0
analyzer: ">=5.1.0 <7.0.0"
Expand Down