Skip to content

Commit c5a0db0

Browse files
committed
style: fix
1 parent 13b9e41 commit c5a0db0

19 files changed

+51
-48
lines changed

slang/bin/slang.dart

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ Future<void> _generateTranslationsFromWatch({
245245
required String fileName,
246246
}) async {
247247
final stopwatch = Stopwatch()..start();
248-
_printDynamicLastLine('\r[$currentTime] $_YELLOW#$counter Generating...');
248+
_printDynamicLastLine('\r[$currentTime] $_yellow#$counter Generating...');
249249

250250
final newFiles = inputDirectory
251251
.listSync(recursive: true)
@@ -270,17 +270,17 @@ Future<void> _generateTranslationsFromWatch({
270270
success = false;
271271
log.error('\n${e.toString()}');
272272
_printDynamicLastLine(
273-
'\r[$currentTime] $_RED#$counter Error ${stopwatch.elapsedSeconds}',
273+
'\r[$currentTime] $_red#$counter Error ${stopwatch.elapsedSeconds}',
274274
);
275275
}
276276

277277
if (success) {
278278
if (counter == 1) {
279279
_printDynamicLastLine(
280-
'\r[$currentTime] $_GREEN#1 Init ${stopwatch.elapsedSeconds}');
280+
'\r[$currentTime] $_green#1 Init ${stopwatch.elapsedSeconds}');
281281
} else {
282282
_printDynamicLastLine(
283-
'\r[$currentTime] $_GREEN#$counter Update $fileName ${stopwatch.elapsedSeconds}',
283+
'\r[$currentTime] $_green#$counter Update $fileName ${stopwatch.elapsedSeconds}',
284284
);
285285
}
286286
}
@@ -390,7 +390,7 @@ Future<void> generateTranslations({
390390
log.verbose('');
391391
}
392392
log.info(
393-
'${_GREEN}Translations generated successfully. ${stopwatch.elapsedSeconds}$_RESET');
393+
'${_green}Translations generated successfully. ${stopwatch.elapsedSeconds}$_reset');
394394
}
395395
}
396396

@@ -411,17 +411,17 @@ String? _lastPrint;
411411

412412
void _printDynamicLastLine(String output) {
413413
if (_lastPrint == null) {
414-
stdout.write('\r$output$_RESET');
414+
stdout.write('\r$output$_reset');
415415
} else {
416-
stdout.write('\r${output.padRight(_lastPrint!.length, ' ')}$_RESET');
416+
stdout.write('\r${output.padRight(_lastPrint!.length, ' ')}$_reset');
417417
}
418418
_lastPrint = output;
419419
}
420420

421-
const _GREEN = '\x1B[32m';
422-
const _YELLOW = '\x1B[33m';
423-
const _RED = '\x1B[31m';
424-
const _RESET = '\x1B[0m';
421+
const _green = '\x1B[32m';
422+
const _yellow = '\x1B[33m';
423+
const _red = '\x1B[31m';
424+
const _reset = '\x1B[0m';
425425

426426
extension on Stopwatch {
427427
String get elapsedSeconds {

slang/lib/src/builder/builder/raw_config_builder.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ extension on Map<String, dynamic> {
153153
return ContextType(
154154
enumName: enumName,
155155
defaultParameter:
156-
config['default_parameter'] ?? ContextType.DEFAULT_PARAMETER,
156+
config['default_parameter'] ?? ContextType.defaultParameterSlang,
157157
generateEnum: config['generate_enum'] ?? defaultGenerateEnum,
158158
);
159159
}).toList();

slang/lib/src/builder/builder/slang_file_collection_builder.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ class SlangFileCollectionBuilder {
113113
return TranslationFile(
114114
path: f.path,
115115
locale: locale,
116-
namespace: RegexUtils.DEFAULT_NAMESPACE,
116+
namespace: RegexUtils.defaultNamespace,
117117
read: f.read,
118118
);
119119
}
@@ -158,7 +158,7 @@ class SlangFileCollectionBuilder {
158158
locale: directoryLocale ?? config.baseLocale,
159159
namespace: config.namespaces
160160
? fileNameNoExtension
161-
: RegexUtils.DEFAULT_NAMESPACE,
161+
: RegexUtils.defaultNamespace,
162162
read: f.read,
163163
);
164164
}
@@ -187,7 +187,7 @@ class SlangFileCollectionBuilder {
187187
locale: locale,
188188
namespace: config.namespaces
189189
? namespace
190-
: RegexUtils.DEFAULT_NAMESPACE,
190+
: RegexUtils.defaultNamespace,
191191
read: f.read,
192192
);
193193
}

slang/lib/src/builder/builder/translation_map_builder.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ class TranslationMapBuilder {
9090
}
9191
}
9292

93-
const _BASE_STR_LENGTH = 7; // "(base) "
93+
const _baseStrLength = 7; // "(base) "
9494

9595
/// Determines the longest debug string used for PadLeft
9696
int _getPadLeft({
@@ -108,7 +108,7 @@ int _getPadLeft({
108108
}
109109

110110
if (file.locale.languageTag == baseLocale) {
111-
currLength += _BASE_STR_LENGTH;
111+
currLength += _baseStrLength;
112112
}
113113

114114
if (currLength > longest) {

slang/lib/src/builder/builder/translation_model_builder.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -443,7 +443,7 @@ Map<String, Node> _parseMapNode({
443443
Map<String, TextNode> digestedMap = <String, StringTextNode>{};
444444
final entries = children.entries.toList();
445445
for (final entry in entries) {
446-
final split = entry.key.split(Node.KEY_DELIMITER);
446+
final split = entry.key.split(Node.keyDelimiter);
447447
if (split.length == 1) {
448448
// keep as is
449449
digestedMap[entry.key] = entry.value as StringTextNode;
@@ -486,7 +486,7 @@ Map<String, Node> _parseMapNode({
486486
if (context == null) {
487487
context = PendingContextType(
488488
enumName: enumName,
489-
defaultParameter: ContextType.DEFAULT_PARAMETER,
489+
defaultParameter: ContextType.defaultParameterSlang,
490490
generateEnum: config.generateEnum,
491491
);
492492
contextCollection[context.enumName] = context;
@@ -625,7 +625,7 @@ _DetectionResult _determineNodeType(
625625
);
626626
} else {
627627
final childrenSplitByComma =
628-
children.keys.expand((key) => key.split(Node.KEY_DELIMITER)).toList();
628+
children.keys.expand((key) => key.split(Node.keyDelimiter)).toList();
629629

630630
if (childrenSplitByComma.isEmpty) {
631631
// fallback: empty node is a class by default

slang/lib/src/builder/builder/translation_model_list_builder.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,12 +71,12 @@ class TranslationModelListBuilder {
7171

7272
extension on Map<String, Map<String, dynamic>> {
7373
Map<String, dynamic> digest() {
74-
if (length > 1 && containsKey(RegexUtils.DEFAULT_NAMESPACE)) {
74+
if (length > 1 && containsKey(RegexUtils.defaultNamespace)) {
7575
return {
76-
...this[RegexUtils.DEFAULT_NAMESPACE]!,
76+
...this[RegexUtils.defaultNamespace]!,
7777
...{
7878
for (final entry in entries)
79-
if (entry.key != RegexUtils.DEFAULT_NAMESPACE)
79+
if (entry.key != RegexUtils.defaultNamespace)
8080
entry.key: entry.value,
8181
},
8282
};

slang/lib/src/builder/generator/helper.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ String getClassName({
5252
return parentName + childName.toCase(CaseStyle.pascal) + languageTag;
5353
}
5454

55-
const _NULL_FLAG = '\u0000';
55+
const _nullFlag = '\u0000';
5656

5757
/// Either returns the plain string or the obfuscated one.
5858
/// Whenever translation strings gets rendered, this method must be called.
@@ -81,13 +81,13 @@ String getStringLiteral(String value, int linkCount, ObfuscationConfig config) {
8181

8282
interpolations.add(actualMatch);
8383
links.add(actualMatch.startsWith(characteristicLinkPrefix));
84-
return _NULL_FLAG; // replace interpolation with a null flag
84+
return _nullFlag; // replace interpolation with a null flag
8585
},
8686
);
8787

8888
// join the string with the interpolation in between
8989
final buffer = StringBuffer();
90-
final parts = digestedString.split(_NULL_FLAG);
90+
final parts = digestedString.split(_nullFlag);
9191
bool needPlus = false;
9292
for (int i = 0; i < parts.length; i++) {
9393
// add the string part

slang/lib/src/builder/model/context_type.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/// Parsed from build config.
22
/// Enum values may be null. In this case, they will be inferred during model build step.
33
class ContextType {
4-
static const String DEFAULT_PARAMETER = 'context';
4+
static const String defaultParameterSlang = 'context';
55

66
final String enumName;
77
final String defaultParameter;

slang/lib/src/builder/model/i18n_locale.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import 'package:slang/src/builder/utils/string_extensions.dart';
44

55
/// own Locale type to decouple from dart:ui package
66
class I18nLocale {
7-
static const String UNDEFINED_LANGUAGE = 'und';
7+
static const String undefinedLanguage = 'und';
88

99
final String language;
1010
final String? script;

slang/lib/src/builder/model/node.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ class NodeModifiers {
5353

5454
/// the super class of every node
5555
abstract class Node {
56-
static const KEY_DELIMITER = ','; // used by plural or context
56+
static const keyDelimiter = ','; // used by plural or context
5757

5858
final String path;
5959
final String rawPath; // including modifiers

0 commit comments

Comments
 (0)