-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
• Refractor code • Provide more documentation
- Loading branch information
1 parent
885a35c
commit b796127
Showing
10 changed files
with
205 additions
and
180 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
## 0.0.1 | ||
|
||
Initial release : | ||
- Creation of a `toJsonSupabase` which exclude the primary key from the `Map` | ||
- Creation of a `toJsonSupabase` which exclude the `primaryKey` from the `Map` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
part of '../../flutter_supabase_macro.dart'; | ||
|
||
extension on Code { | ||
/// Used for error messages. | ||
String get debugString { | ||
final buffer = StringBuffer(); | ||
_writeDebugString(buffer); | ||
return buffer.toString(); | ||
} | ||
|
||
void _writeDebugString(StringBuffer buffer) { | ||
for (final part in parts) { | ||
switch (part) { | ||
case Code(): | ||
part._writeDebugString(buffer); | ||
case Identifier(): | ||
buffer.write(part.name); | ||
case OmittedTypeAnnotation(): | ||
buffer.write('<omitted>'); | ||
default: | ||
buffer.write(part); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
part of '../../flutter_supabase_macro.dart'; | ||
|
||
extension _IterableExtension<T> on Iterable<T> { | ||
T? firstWhereOrNull(bool Function(T) compare) { | ||
for (final item in this) { | ||
if (compare(item)) return item; | ||
} | ||
return null; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
part of '../../flutter_supabase_macro.dart'; | ||
|
||
extension on NamedTypeAnnotation { | ||
/// Follows the declaration of this type through any type aliases, until it | ||
/// reaches a [ClassDeclaration], or returns null if it does not bottom out on | ||
/// a class. | ||
Future<ClassDeclaration?> classDeclaration(DefinitionBuilder builder) async { | ||
var typeDeclaration = await builder.typeDeclarationOf(identifier); | ||
while (typeDeclaration is TypeAliasDeclaration) { | ||
final aliasedType = typeDeclaration.aliasedType; | ||
if (aliasedType is! NamedTypeAnnotation) { | ||
builder.report( | ||
Diagnostic( | ||
DiagnosticMessage( | ||
'Only fields with named types are allowed on serializable ' | ||
'classes', | ||
target: asDiagnosticTarget, | ||
), | ||
Severity.error, | ||
), | ||
); | ||
return null; | ||
} | ||
typeDeclaration = await builder.typeDeclarationOf(aliasedType.identifier); | ||
} | ||
if (typeDeclaration is! ClassDeclaration) { | ||
builder.report( | ||
Diagnostic( | ||
DiagnosticMessage( | ||
'Only classes are supported as field types for serializable ' | ||
'classes', | ||
target: asDiagnosticTarget, | ||
), | ||
Severity.error, | ||
), | ||
); | ||
return null; | ||
} | ||
return typeDeclaration; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
part of '../../flutter_supabase_macro.dart'; | ||
|
||
extension _IsExactly on TypeDeclaration { | ||
/// Cheaper than checking types using a [StaticType]. | ||
bool isExactly(String name, Uri library) => | ||
identifier.name == name && this.library.uri == library; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.