Skip to content

Commit

Permalink
Merge branch 'rfw_builder'
Browse files Browse the repository at this point in the history
  • Loading branch information
ebwood committed Mar 14, 2024
2 parents 44db374 + 50e1a02 commit c51b304
Show file tree
Hide file tree
Showing 16 changed files with 1,535 additions and 4 deletions.
1 change: 1 addition & 0 deletions melos.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ packages:
- packages/txt2rfw
- packages/rfw2txt
- packages/widget2rfw
- packages/rfw_builder

scripts:
analyze:
Expand Down
7 changes: 7 additions & 0 deletions packages/rfw2txt/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,13 @@ packages:
url: "https://pub.dev"
source: hosted
version: "0.6.0"
txt2rfw:
dependency: "direct overridden"
description:
path: "../txt2rfw"
relative: true
source: path
version: "0.0.8"
typed_data:
dependency: transitive
description:
Expand Down
3 changes: 3 additions & 0 deletions packages/rfw_builder/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# https://dart.dev/guides/libraries/private-files
# Created by `dart pub`
.dart_tool/
Empty file.
21 changes: 21 additions & 0 deletions packages/rfw_builder/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2024 ebwood

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
1 change: 1 addition & 0 deletions packages/rfw_builder/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# A builder tool to generate RemoteFlutterWidget tree
30 changes: 30 additions & 0 deletions packages/rfw_builder/analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# This file configures the static analysis results for your project (errors,
# warnings, and lints).
#
# This enables the 'recommended' set of lints from `package:lints`.
# This set helps identify many issues that may lead to problems when running
# or consuming Dart code, and enforces writing Dart using a single, idiomatic
# style and format.
#
# If you want a smaller set of lints you can change this to specify
# 'package:lints/core.yaml'. These are just the most critical lints
# (the recommended set includes the core lints).
# The core lints are also what is used by pub.dev for scoring packages.

include: package:lints/recommended.yaml

# Uncomment the following section to specify additional rules.

# linter:
# rules:
# - camel_case_types

# analyzer:
# exclude:
# - path/to/excluded/files/**

# For more information about the core and recommended set of lints, see
# https://dart.dev/go/core-lints

# For additional information about configuring this file, see
# https://dart.dev/guides/language/analysis-options
157 changes: 157 additions & 0 deletions packages/rfw_builder/lib/base.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
import 'package:rfw/formats.dart';

abstract class Builder<T> {
void update(void Function(Builder)? updates) {
updates?.call(this);
}

T build();
}

abstract class Spec {
R accept<R>(SpecVisitor<R> visitor, [R? context]);
}

abstract class SpecVisitor<R> {
R visitDynamicList(DynamicList spec, [R? context]);

R visitDynamicMap(DynamicMap spec, [R? context]);

R visitLibraryName(LibraryName spec, [R? context]);

R visitFullyQualifiedWidgetName(FullyQualifiedWidgetName spec, [R? context]);

R visitMissing(Missing spec, [R? context]);

R visitLoop(Loop spec, [R? context]);

R visitSwitch(Switch spec, [R? context]);

R visitConstructorCall(ConstructorCall spec, [R? context]);

R visitWidgetBuilderDeclaration(WidgetBuilderDeclaration spec, [R? context]);

R visitArgsReference(ArgsReference spec, [R? context]);

R visitBoundArgsReference(BoundArgsReference spec, [R? context]);

R visitDataReference(DataReference spec, [R? context]);

R visitWidgetBuilderArgReference(WidgetBuilderArgReference spec,
[R? context]);

R visitLoopReference(LoopReference spec, [R? context]);

R visitBoundLoopReference(BoundLoopReference spec, [R? context]);

R visitStateReference(StateReference spec, [R? context]);

R visitBoundStateReference(BoundStateReference spec, [R? context]);

R visitEventHandler(EventHandler spec, [R? context]);

R visitSetStateHandler(SetStateHandler spec, [R? context]);

R visitImport(Import spec, [R? context]);

R visitWidgetDeclaration(WidgetDeclaration spec, [R? context]);

R visitRemoteWidgetLibrary(RemoteWidgetLibrary spec, [R? context]);

R visitOtherReference(Reference spec, [R? context]);

R visitOtherAnyEventHandler(AnyEventHandler spec, [R? context]);

R visitOtherBlobNode(BlobNode spec, [R? context]);
}

abstract mixin class DefaultSpecVisitor<R> implements SpecVisitor<R> {
R get defaultValue;

@override
R visitDynamicList(DynamicList spec, [R? context]) => defaultValue;

@override
R visitDynamicMap(DynamicMap spec, [R? context]) => defaultValue;

@override
R visitArgsReference(ArgsReference spec, [R? context]) => defaultValue;

@override
R visitBoundArgsReference(BoundArgsReference spec, [R? context]) =>
defaultValue;

@override
R visitDataReference(DataReference spec, [R? context]) => defaultValue;

@override
R visitWidgetBuilderArgReference(WidgetBuilderArgReference spec,
[R? context]) =>
defaultValue;

@override
R visitLoopReference(LoopReference spec, [R? context]) => defaultValue;

@override
R visitBoundLoopReference(BoundLoopReference spec, [R? context]) =>
defaultValue;

@override
R visitStateReference(StateReference spec, [R? context]) => defaultValue;

@override
R visitBoundStateReference(BoundStateReference spec, [R? context]) =>
defaultValue;

@override
R visitEventHandler(EventHandler spec, [R? context]) => defaultValue;

@override
R visitSetStateHandler(SetStateHandler spec, [R? context]) => defaultValue;

@override
R visitImport(Import spec, [R? context]) => defaultValue;

@override
R visitWidgetDeclaration(WidgetDeclaration spec, [R? context]) =>
defaultValue;

@override
R visitRemoteWidgetLibrary(RemoteWidgetLibrary spec, [R? context]) =>
defaultValue;

@override
R visitOtherReference(Reference spec, [R? context]) => defaultValue;

@override
R visitOtherAnyEventHandler(AnyEventHandler spec, [R? context]) =>
defaultValue;

@override
R visitOtherBlobNode(BlobNode spec, [R? context]) => defaultValue;

@override
R visitLibraryName(LibraryName spec, [R? context]) => defaultValue;

@override
R visitFullyQualifiedWidgetName(FullyQualifiedWidgetName spec,
[R? context]) =>
defaultValue;

@override
R visitMissing(Missing spec, [R? context]) => defaultValue;

@override
R visitLoop(Loop spec, [R? context]) => defaultValue;

@override
R visitSwitch(Switch spec, [R? context]) => defaultValue;

@override
R visitConstructorCall(ConstructorCall spec, [R? context]) => defaultValue;

@override
R visitWidgetBuilderDeclaration(WidgetBuilderDeclaration spec,
[R? context]) =>
defaultValue;
}
139 changes: 139 additions & 0 deletions packages/rfw_builder/lib/json_visitor.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
// import 'package:rfw/src/dart/model.dart';
// import 'package:rfw_builder/base.dart';

// class JsonVisitor extends DefaultSpecVisitor<Map<String, dynamic>> {
// @override
// Map<String, dynamic> visitArgsReference(ArgsReference spec, [Map<String, dynamic>? context]) {
// // TODO: implement visitArgsReference
// throw UnimplementedError();
// }

// @override
// Map<String, dynamic> visitBoundArgsReference(BoundArgsReference spec, [Map<String, dynamic>? context]) {
// // TODO: implement visitBoundArgsReference
// throw UnimplementedError();
// }

// @override
// Map<String, dynamic> visitBoundLoopReference(BoundLoopReference spec, [Map<String, dynamic>? context]) {
// // TODO: implement visitBoundLoopReference
// throw UnimplementedError();
// }

// @override
// Map<String, dynamic> visitBoundStateReference(BoundStateReference spec, [Map<String, dynamic>? context]) {
// // TODO: implement visitBoundStateReference
// throw UnimplementedError();
// }

// @override
// Map<String, dynamic> visitConstructorCall(ConstructorCall spec, [Map<String, dynamic>? context]) {
// // TODO: implement visitConstructorCall
// throw UnimplementedError();
// }

// @override
// Map<String, dynamic> visitDataReference(DataReference spec, [Map<String, dynamic>? context]) {
// // TODO: implement visitDataReference
// throw UnimplementedError();
// }

// @override
// Map<String, dynamic> visitDynamicList(DynamicList spec, [Map<String, dynamic>? context]) {
// // TODO: implement visitDynamicList
// throw UnimplementedError();
// }

// @override
// Map<String, dynamic> visitDynamicMap(DynamicMap spec, [Map<String, dynamic>? context]) {
// // TODO: implement visitDynamicMap
// throw UnimplementedError();
// }

// @override
// Map<String, dynamic> visitEventHandler(EventHandler spec, [Map<String, dynamic>? context]) {
// // TODO: implement visitEventHandler
// throw UnimplementedError();
// }

// @override
// Map<String, dynamic> visitFullyQualifiedWidgetName(FullyQualifiedWidgetName spec, [Map<String, dynamic>? context]) {
// // TODO: implement visitFullyQualifiedWidgetName
// throw UnimplementedError();
// }

// @override
// Map<String, dynamic> visitImport(Import spec, [Map<String, dynamic>? context]) {
// // TODO: implement visitImport
// throw UnimplementedError();
// }

// @override
// Map<String, dynamic> visitLibraryName(LibraryName spec, [Map<String, dynamic>? context]) {
// // TODO: implement visitLibraryName
// throw UnimplementedError();
// }

// @override
// Map<String, dynamic> visitLoop(Loop spec, [Map<String, dynamic>? context]) {
// // TODO: implement visitLoop
// throw UnimplementedError();
// }

// @override
// Map<String, dynamic> visitLoopReference(LoopReference spec, [Map<String, dynamic>? context]) {
// // TODO: implement visitLoopReference
// throw UnimplementedError();
// }

// @override
// Map<String, dynamic> visitMissing(Missing spec, [Map<String, dynamic>? context]) {
// // TODO: implement visitMissing
// throw UnimplementedError();
// }

// @override
// Map<String, dynamic> visitRemoteWidgetLibrary(RemoteWidgetLibrary spec, [Map<String, dynamic>? context]) {
// // TODO: implement visitRemoteWidgetLibrary
// throw UnimplementedError();
// }

// @override
// Map<String, dynamic> visitSetStateHandler(SetStateHandler spec, [Map<String, dynamic>? context]) {
// // TODO: implement visitSetStateHandler
// throw UnimplementedError();
// }

// @override
// Map<String, dynamic> visitStateReference(StateReference spec, [Map<String, dynamic>? context]) {
// // TODO: implement visitStateReference
// throw UnimplementedError();
// }

// @override
// Map<String, dynamic> visitSwitch(Switch spec, [Map<String, dynamic>? context]) {
// // TODO: implement visitSwitch
// throw UnimplementedError();
// }

// @override
// Map<String, dynamic> visitWidgetBuilderArgReference(WidgetBuilderArgReference spec, [Map<String, dynamic>? context]) {
// // TODO: implement visitWidgetBuilderArgReference
// throw UnimplementedError();
// }

// @override
// Map<String, dynamic> visitWidgetBuilderDeclaration(WidgetBuilderDeclaration spec, [Map<String, dynamic>? context]) {
// // TODO: implement visitWidgetBuilderDeclaration
// throw UnimplementedError();
// }

// @override
// Map<String, dynamic> visitWidgetDeclaration(WidgetDeclaration spec, [Map<String, dynamic>? context]) {
// return {
// 'name': spec.name,
// 'type': '${spec.runtimeType}',
// 'root': spec.root.accept(this),
// };
// }
// }
Loading

0 comments on commit c51b304

Please sign in to comment.