From 38e38c4a849fd8b311c5a5db2b8addf77710bcb6 Mon Sep 17 00:00:00 2001 From: thomashii Date: Tue, 18 May 2021 20:12:47 +0800 Subject: [PATCH] Updated jael_preprocessor --- packages/jael/jael_preprocessor/CHANGELOG.md | 3 ++ packages/jael/jael_preprocessor/README.md | 2 +- .../jael_preprocessor/analysis_options.yaml | 1 + .../jael/jael_preprocessor/example/main.dart | 2 +- .../lib/jael3_preprocessor.dart | 42 ++++++++++--------- packages/jael/jael_preprocessor/pubspec.yaml | 5 ++- 6 files changed, 31 insertions(+), 24 deletions(-) diff --git a/packages/jael/jael_preprocessor/CHANGELOG.md b/packages/jael/jael_preprocessor/CHANGELOG.md index 9868a28b..80ad9d29 100644 --- a/packages/jael/jael_preprocessor/CHANGELOG.md +++ b/packages/jael/jael_preprocessor/CHANGELOG.md @@ -1,3 +1,6 @@ +# 4.0.1 +* Resolved static analysis warnings + # 4.0.0 * Migrated to support Dart SDK 2.12.x NNBD diff --git a/packages/jael/jael_preprocessor/README.md b/packages/jael/jael_preprocessor/README.md index dbd095db..494b31d6 100644 --- a/packages/jael/jael_preprocessor/README.md +++ b/packages/jael/jael_preprocessor/README.md @@ -1,5 +1,5 @@ # jael3_preprocessor -[![version](https://img.shields.io/badge/pub-v4.0.0-brightgreen)](https://pub.dartlang.org/packages/jael3_preprocessor) +[![version](https://img.shields.io/badge/pub-v4.0.1-brightgreen)](https://pub.dartlang.org/packages/jael3_preprocessor) [![Null Safety](https://img.shields.io/badge/null-safety-brightgreen)](https://dart.dev/null-safety) [![Gitter](https://img.shields.io/gitter/room/angel_dart/discussion)](https://gitter.im/angel_dart/discussion) diff --git a/packages/jael/jael_preprocessor/analysis_options.yaml b/packages/jael/jael_preprocessor/analysis_options.yaml index eae1e42a..c230cee7 100644 --- a/packages/jael/jael_preprocessor/analysis_options.yaml +++ b/packages/jael/jael_preprocessor/analysis_options.yaml @@ -1,3 +1,4 @@ +include: package:pedantic/analysis_options.yaml analyzer: strong-mode: implicit-casts: false \ No newline at end of file diff --git a/packages/jael/jael_preprocessor/example/main.dart b/packages/jael/jael_preprocessor/example/main.dart index 14ff3f9c..84edc0ed 100644 --- a/packages/jael/jael_preprocessor/example/main.dart +++ b/packages/jael/jael_preprocessor/example/main.dart @@ -5,7 +5,7 @@ import 'package:jael3/jael3.dart' as jael; import 'package:jael3_preprocessor/jael3_preprocessor.dart' as jael; Future process( - jael.Document doc, Directory dir, errorHandler(jael.JaelError e)) { + jael.Document doc, Directory dir, Function(jael.JaelError e) errorHandler) { return jael.resolve(doc, dir, onError: errorHandler, patch: [ (doc, dir, onError) { print(doc!.root.children.length); diff --git a/packages/jael/jael_preprocessor/lib/jael3_preprocessor.dart b/packages/jael/jael_preprocessor/lib/jael3_preprocessor.dart index c4ed9adc..88e08441 100644 --- a/packages/jael/jael_preprocessor/lib/jael3_preprocessor.dart +++ b/packages/jael/jael_preprocessor/lib/jael3_preprocessor.dart @@ -6,15 +6,15 @@ import 'package:jael3/jael3.dart'; import 'package:angel3_symbol_table/angel3_symbol_table.dart'; /// Modifies a Jael document. -typedef FutureOr? Patcher(Document? document, - Directory currentDirectory, void onError(JaelError error)?); +typedef Patcher = FutureOr? Function(Document? document, + Directory currentDirectory, void Function(JaelError error)? onError); /// Expands all `block[name]` tags within the template, replacing them with the correct content. /// /// To apply additional patches to resolved documents, provide a set of [patch] /// functions. Future resolve(Document document, Directory currentDirectory, - {void onError(JaelError error)?, Iterable? patch}) async { + {void Function(JaelError error)? onError, Iterable? patch}) async { onError ?? (e) => throw e; // Resolve all includes... @@ -24,7 +24,9 @@ Future resolve(Document document, Directory currentDirectory, var patched = await applyInheritance( includesResolved, currentDirectory, onError, patch); - if (patch?.isNotEmpty != true) return patched; + if (patch?.isNotEmpty != true) { + return patched; + } for (var p in patch!) { patched = await p(patched, currentDirectory, onError); @@ -37,7 +39,7 @@ Future resolve(Document document, Directory currentDirectory, Future applyInheritance( Document? document, Directory currentDirectory, - void onError(JaelError error)?, + void Function(JaelError error)? onError, Iterable? patch) async { if (document == null) { return null; @@ -102,7 +104,7 @@ Future applyInheritance( while (hierarchy!.extendsTemplates.isNotEmpty) { var tmpl = hierarchy.extendsTemplates.removeFirst(); var definedOverrides = findBlockOverrides(tmpl, onError); - if (definedOverrides == null) break; + //if (definedOverrides == null) break; out = setOut(out!, definedOverrides, hierarchy.extendsTemplates.isNotEmpty); } @@ -117,7 +119,7 @@ Future applyInheritance( } Map findBlockOverrides( - Element tmpl, void onError(JaelError e)?) { + Element tmpl, void Function(JaelError e)? onError) { var out = {}; for (var child in tmpl.children) { @@ -137,7 +139,7 @@ Map findBlockOverrides( /// Resolves the document hierarchy at a given node in the tree. Future resolveHierarchy(Document document, - Directory currentDirectory, void onError(JaelError e)?) async { + Directory currentDirectory, void Function(JaelError e)? onError) async { var extendsTemplates = Queue(); String? parent; @@ -175,7 +177,7 @@ class DocumentHierarchy { Iterable replaceBlocks( Element element, Map definedOverrides, - void onError(JaelError e)?, + void Function(JaelError e)? onError, bool replaceWithDefault, bool anyTemplatesRemain) { if (element.tagName.name == 'block') { @@ -234,7 +236,7 @@ Iterable replaceBlocks( Element replaceChildrenOfElement( Element el, Map definedOverrides, - void onError(JaelError e)?, + void Function(JaelError e)? onError, bool replaceWithDefault, bool anyTemplatesRemain) { if (el is RegularElement) { @@ -248,7 +250,7 @@ Element replaceChildrenOfElement( RegularElement replaceChildrenOfRegularElement( RegularElement el, Map definedOverrides, - void onError(JaelError e)?, + void Function(JaelError e)? onError, bool replaceWithDefault, bool anyTemplatesRemain) { var children = allChildrenOfRegularElement( @@ -260,7 +262,7 @@ RegularElement replaceChildrenOfRegularElement( List allChildrenOfRegularElement( RegularElement el, Map definedOverrides, - void onError(JaelError e)?, + void Function(JaelError e)? onError, bool replaceWithDefault, bool anyTemplatesRemain) { var children = []; @@ -278,7 +280,7 @@ List allChildrenOfRegularElement( } /// Finds the name of the parent template. -String? getParent(Document document, void onError(JaelError error)?) { +String? getParent(Document document, void Function(JaelError error)? onError) { var element = document.root; if (element.tagName.name != 'extend') return null; @@ -300,11 +302,11 @@ String? getParent(Document document, void onError(JaelError error)?) { /// Expands all `include[src]` tags within the template, and fills in the content of referenced files. Future resolveIncludes(Document? document, - Directory currentDirectory, void onError(JaelError error)?) async { + Directory currentDirectory, void Function(JaelError error)? onError) async { if (document == null) { return null; } - Element? rootElement = + var rootElement = await _expandIncludes(document.root, currentDirectory, onError); if (rootElement != null) { return Document(document.doctype, rootElement); @@ -314,16 +316,16 @@ Future resolveIncludes(Document? document, } Future _expandIncludes(Element element, Directory currentDirectory, - void onError(JaelError error)?) async { + void Function(JaelError error)? onError) async { if (element.tagName.name != 'include') { - if (element is SelfClosingElement) + if (element is SelfClosingElement) { return element; - else if (element is RegularElement) { - List expanded = []; + } else if (element is RegularElement) { + var expanded = []; for (var child in element.children) { if (child is Element) { - Element? includeElement = + var includeElement = await _expandIncludes(child, currentDirectory, onError); if (includeElement != null) { expanded.add(includeElement); diff --git a/packages/jael/jael_preprocessor/pubspec.yaml b/packages/jael/jael_preprocessor/pubspec.yaml index 5b6d8434..81eec730 100644 --- a/packages/jael/jael_preprocessor/pubspec.yaml +++ b/packages/jael/jael_preprocessor/pubspec.yaml @@ -1,5 +1,5 @@ name: jael3_preprocessor -version: 4.0.0 +version: 4.0.1 description: A pre-processor for resolving blocks and includes within Jael templates. homepage: https://github.com/dukefirehawk/angel/tree/angel3/packages/jael/jael_preprocessor environment: @@ -11,4 +11,5 @@ dependencies: collection: ^1.15.0 dev_dependencies: angel3_code_buffer: ^2.0.0 - test: ^1.17.4 \ No newline at end of file + test: ^1.17.4 + pedantic: ^1.11.0