Fixed jael_web analysis warnings

This commit is contained in:
thomashii@dukefirehawk.com 2022-08-27 15:37:20 +08:00
parent 2c52e4a5d5
commit 6a34b51f04
3 changed files with 31 additions and 21 deletions

View file

@ -11,8 +11,8 @@ import 'package:path/src/context.dart';
/// Converts a [DartType] to a [TypeReference]. /// Converts a [DartType] to a [TypeReference].
TypeReference convertTypeReference(DartType? t) { TypeReference convertTypeReference(DartType? t) {
return new TypeReference((b) { return TypeReference((b) {
b..symbol = t?.getDisplayString(withNullability: false); b.symbol = t?.getDisplayString(withNullability: false);
if (t is InterfaceType) { if (t is InterfaceType) {
b.types.addAll(t.typeArguments.map(convertTypeReference)); b.types.addAll(t.typeArguments.map(convertTypeReference));
@ -49,6 +49,7 @@ class BuildFileSystem extends FileSystem {
BuildFileSystem(this.reader, this.package); BuildFileSystem(this.reader, this.package);
@override
Context get path => _path; Context get path => _path;
@override @override
@ -56,6 +57,7 @@ class BuildFileSystem extends FileSystem {
return BuildSystemDirectory(this, reader, package, _path.current); return BuildSystemDirectory(this, reader, package, _path.current);
} }
@override
set currentDirectory(value) { set currentDirectory(value) {
if (value is Directory) { if (value is Directory) {
_path = Context(current: value.path); _path = Context(current: value.path);
@ -69,28 +71,30 @@ class BuildFileSystem extends FileSystem {
@override @override
Directory directory(path) { Directory directory(path) {
late String p; late String p;
if (path is String) if (path is String) {
p = path; p = path;
else if (path is Uri) } else if (path is Uri) {
p = path.toString(); //p.toString(); p = path.toString();
else if (path is FileSystemEntity) } else if (path is FileSystemEntity) {
p = path.path; p = path.path;
else } else {
throw ArgumentError(); throw ArgumentError();
}
return BuildSystemDirectory(this, reader, package, p); return BuildSystemDirectory(this, reader, package, p);
} }
@override @override
File file(path) { File file(path) {
late String p; late String p;
if (path is String) if (path is String) {
p = path; p = path;
else if (path is Uri) } else if (path is Uri) {
p = path.toString(); // p.toString(); p = path.toString();
else if (path is FileSystemEntity) } else if (path is FileSystemEntity) {
p = path.path; p = path.path;
else } else {
throw ArgumentError(); throw ArgumentError();
}
return BuildSystemFile(this, reader, package, p); return BuildSystemFile(this, reader, package, p);
} }
@ -125,13 +129,16 @@ class BuildFileSystem extends FileSystem {
} }
class BuildSystemFile extends File { class BuildSystemFile extends File {
@override
final BuildFileSystem fileSystem; final BuildFileSystem fileSystem;
final AssetReader reader; final AssetReader reader;
final String package; final String package;
@override
final String path; final String path;
BuildSystemFile(this.fileSystem, this.reader, this.package, this.path); BuildSystemFile(this.fileSystem, this.reader, this.package, this.path);
@override
Uri get uri => fileSystem.path.toUri(path); Uri get uri => fileSystem.path.toUri(path);
@override @override
@ -147,7 +154,8 @@ class BuildSystemFile extends File {
File copySync(String newPath) => throw _unsupported(); File copySync(String newPath) => throw _unsupported();
@override @override
Future<File> create({bool recursive = false}) => throw _unsupported(); Future<File> create({bool exclusive = false, bool recursive = false}) =>
throw _unsupported();
@override @override
void createSync({bool recursive = false}) => throw _unsupported(); void createSync({bool recursive = false}) => throw _unsupported();
@ -312,9 +320,11 @@ class BuildSystemFile extends File {
} }
class BuildSystemDirectory extends Directory { class BuildSystemDirectory extends Directory {
@override
final BuildFileSystem fileSystem; final BuildFileSystem fileSystem;
final AssetReader reader; final AssetReader reader;
final String package; final String package;
@override
final String path; final String path;
BuildSystemDirectory(this.fileSystem, this.reader, this.package, this.path); BuildSystemDirectory(this.fileSystem, this.reader, this.package, this.path);

View file

@ -1,5 +1,5 @@
name: jael3_web name: jael3_web
version: 6.0.0 version: 7.0.0
description: Experimental virtual DOM/SPA engine built on Jael3. Supports SSR. description: Experimental virtual DOM/SPA engine built on Jael3. Supports SSR.
publish_to: none publish_to: none
environment: environment:
@ -8,15 +8,15 @@ dependencies:
build: ^2.0.2 build: ^2.0.2
build_config: ^1.0.0 build_config: ^1.0.0
code_builder: ^4.0.0 code_builder: ^4.0.0
jael3: ^6.0.0 jael3: ^7.0.0
jael3_preprocessor: ^6.0.0 jael3_preprocessor: ^7.0.0
source_gen: ^1.0.2 source_gen: ^1.0.2
dev_dependencies: dev_dependencies:
build_runner: ^2.0.4 build_runner: ^2.0.4
build_web_compilers: ^3.0.0 build_web_compilers: ^3.0.0
lints: ^2.0.0 lints: ^2.0.0
# dependency_overrides: dependency_overrides:
# jael3: jael3:
# path: ../jael path: ../jael
# jael3_preprocessor: jael3_preprocessor:
# path: ../jael_preprocessor path: ../jael_preprocessor