Skip to content

Commit

Permalink
fix: Fixed a bug where class names could not be defined.
Browse files Browse the repository at this point in the history
  • Loading branch information
mathrunet committed Jan 19, 2023
1 parent 6b9f0af commit 552c5ba
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 35 deletions.
26 changes: 13 additions & 13 deletions packages/katana_prefs/example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -297,17 +297,17 @@ packages:
source: hosted
version: "4.7.0"
katana:
dependency: "direct overridden"
dependency: transitive
description:
path: "../../katana"
relative: true
source: path
name: katana
url: "https://pub.dartlang.org"
source: hosted
version: "0.15.10+2"
katana_listenables_annotation:
dependency: "direct overridden"
description:
path: "/Users/mathru/Documents/github/flutter_masamune/packages/katana_prefs/example/../../katana_listenables_annotation"
relative: false
path: "../../katana_listenables_annotation"
relative: true
source: path
version: "1.2.9"
katana_prefs:
Expand All @@ -316,21 +316,21 @@ packages:
path: ".."
relative: true
source: path
version: "1.0.0"
version: "1.1.0"
katana_prefs_annotation:
dependency: "direct overridden"
dependency: transitive
description:
path: "../../katana_prefs_annotation"
relative: true
source: path
version: "1.0.0"
name: katana_prefs_annotation
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.0"
katana_prefs_builder:
dependency: "direct dev"
description:
path: "../../katana_prefs_builder"
relative: true
source: path
version: "1.0.0"
version: "1.1.0"
lints:
dependency: transitive
description:
Expand Down
14 changes: 7 additions & 7 deletions packages/katana_prefs/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -152,17 +152,17 @@ packages:
katana:
dependency: "direct main"
description:
path: "../katana"
relative: true
source: path
name: katana
url: "https://pub.dartlang.org"
source: hosted
version: "0.15.10+2"
katana_prefs_annotation:
dependency: "direct main"
description:
path: "../katana_prefs_annotation"
relative: true
source: path
version: "1.0.0"
name: katana_prefs_annotation
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.0"
matcher:
dependency: transitive
description:
Expand Down
6 changes: 3 additions & 3 deletions packages/katana_prefs_annotation/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -165,9 +165,9 @@ packages:
katana:
dependency: "direct main"
description:
path: "../katana"
relative: true
source: path
name: katana
url: "https://pub.dartlang.org"
source: hosted
version: "0.15.10+2"
logging:
dependency: transitive
Expand Down
6 changes: 3 additions & 3 deletions packages/katana_prefs_builder/lib/common/base_class.dart
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ List<Spec> baseClass(
..type = MethodType.getter
..lambda = true
..returns = Reference(
"_\$_PrefsValue<${param.type.toString()}>",
"_\$_${model.name}<${param.type.toString()}>",
)
..body = const Code("throw UnimplementedError()"),
);
Expand Down Expand Up @@ -230,7 +230,7 @@ List<Spec> baseClass(
(m) => m
..name = param.name
..returns = Reference(
"_\$_PrefsValue<${param.type.toString()}>",
"_\$_${model.name}<${param.type.toString()}>",
)
..lambda = true
..type = MethodType.getter
Expand Down Expand Up @@ -301,7 +301,7 @@ List<Spec> baseClass(
(m) => m
..name = param.name
..returns = Reference(
"_\$_PrefsValue<${param.type.toString()}>",
"_\$_${model.name}<${param.type.toString()}>",
)
..lambda = true
..type = MethodType.getter
Expand Down
8 changes: 6 additions & 2 deletions packages/katana_prefs_builder/lib/value/parameter_value.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ part of katana_prefs_builder;

final _regexp = RegExp(r"@Default\(([^\)]+)\)");
final _classRegExp = RegExp(r"[a-zA-Z0-9_$-]+\(([^\)]+)\)");
final _listRegExp = RegExp(r"(<[^>]+>)?\[([^\]]*)\]");
final _mapRegExp = RegExp(r"(<[^>]+>)?\{([^\}]*)\}");

/// Parameter Value.
///
Expand Down Expand Up @@ -34,8 +36,10 @@ class ParamaterValue {
continue;
}
exists = true;
final code = match.group(1);
if (_classRegExp.hasMatch(code ?? "")) {
final code = match.group(1)?.trim();
if (_classRegExp.hasMatch(code ?? "") ||
_listRegExp.hasMatch(code ?? "") ||
_mapRegExp.hasMatch(code ?? "")) {
defaultValueCode = "const $code";
} else {
defaultValueCode = code;
Expand Down
14 changes: 7 additions & 7 deletions packages/katana_prefs_builder/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -207,17 +207,17 @@ packages:
katana:
dependency: "direct main"
description:
path: "../katana"
relative: true
source: path
name: katana
url: "https://pub.dartlang.org"
source: hosted
version: "0.15.10+2"
katana_prefs_annotation:
dependency: "direct main"
description:
path: "../katana_prefs_annotation"
relative: true
source: path
version: "1.0.0"
name: katana_prefs_annotation
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.0"
logging:
dependency: transitive
description:
Expand Down

0 comments on commit 552c5ba

Please sign in to comment.