Organize imports

This commit is contained in:
Simon Binder 2021-09-10 11:43:21 +02:00
parent cc7d98d110
commit 40bc3a17bb
No known key found for this signature in database
GPG Key ID: 7891917E4147B8C0
44 changed files with 107 additions and 104 deletions

View File

@ -2,9 +2,9 @@ import 'dart:math';
import 'package:benchmarks/benchmarks.dart';
// ignore: implementation_imports
import 'package:sqlparser/src/reader/tokenizer/token.dart';
// ignore: implementation_imports
import 'package:sqlparser/src/reader/tokenizer/scanner.dart';
// ignore: implementation_imports
import 'package:sqlparser/src/reader/tokenizer/token.dart';
class TokenizerBenchmark extends BenchmarkBase {
late StringBuffer input;
@ -22,7 +22,9 @@ class TokenizerBenchmark extends BenchmarkBase {
final keywordLexemes = keywords.keys.toList();
for (var i = 0; i < size; i++) {
final keyword = keywordLexemes[random.nextInt(keywordLexemes.length)];
input..write(' ')..write(keyword);
input
..write(' ')
..write(keyword);
}
}

View File

@ -6,9 +6,10 @@ library encrypted_moor;
import 'dart:async';
import 'dart:io';
import 'package:path/path.dart';
import 'package:moor/moor.dart';
import 'package:moor/backends.dart';
import 'package:moor/moor.dart';
import 'package:path/path.dart';
import 'package:sqflite_sqlcipher/sqflite.dart' as s;
/// Signature of a function that runs when a database doesn't exist on file.

View File

@ -1,7 +1,6 @@
name: encrypted_moor
description: Encryption support for moor, built with sqflite_sqlcipher
version: 1.0.0
author: Simon Binder <oss@simonbinder.eu>
environment:
sdk: '>=2.12.0-0 <3.0.0'

View File

@ -1,14 +1,14 @@
import 'dart:io';
import 'package:flutter/widgets.dart' show WidgetsFlutterBinding;
import 'package:sqlite3/sqlite3.dart' as raw;
import 'package:moor/ffi.dart';
import 'package:test/test.dart';
import 'package:tests/tests.dart';
import 'package:moor/isolate.dart';
import 'package:moor_flutter/moor_flutter.dart';
import 'package:sqflite/sqflite.dart' show getDatabasesPath;
import 'package:path/path.dart';
import 'package:sqflite/sqflite.dart' show getDatabasesPath;
import 'package:sqlite3/sqlite3.dart' as raw;
import 'package:test/test.dart';
import 'package:tests/tests.dart';
class FfiExecutor extends TestExecutor {
final String dbPath;

View File

@ -1,10 +1,10 @@
import 'dart:io';
import 'package:flutter/widgets.dart' show WidgetsFlutterBinding;
import 'package:tests/tests.dart';
import 'package:encrypted_moor/encrypted_moor.dart';
import 'package:sqflite/sqflite.dart' show getDatabasesPath;
import 'package:flutter/widgets.dart' show WidgetsFlutterBinding;
import 'package:path/path.dart';
import 'package:sqflite/sqflite.dart' show getDatabasesPath;
import 'package:tests/tests.dart';
class EncryptedTestExecutor extends TestExecutor {
@override

View File

@ -2,11 +2,11 @@ import 'dart:io';
import 'package:flutter/services.dart';
import 'package:flutter/widgets.dart' show WidgetsFlutterBinding;
import 'package:tests/tests.dart';
import 'package:test/test.dart';
import 'package:moor_flutter/moor_flutter.dart';
import 'package:sqflite/sqflite.dart' show getDatabasesPath;
import 'package:path/path.dart';
import 'package:sqflite/sqflite.dart' show getDatabasesPath;
import 'package:test/test.dart';
import 'package:tests/tests.dart';
class SqfliteExecutor extends TestExecutor {
@override

View File

@ -1,11 +1,10 @@
import 'dart:io';
import 'package:moor/ffi.dart';
import 'package:path/path.dart' show join;
import 'package:sqlite3/sqlite3.dart';
import 'package:tests/tests.dart';
import 'package:path/path.dart' show join;
class VmExecutor extends TestExecutor {
static String fileName = 'moor-vm-tests-${DateTime.now().toIso8601String()}';
final File file = File(join(Directory.systemTemp.path, fileName));

View File

@ -1,9 +1,9 @@
@TestOn('browser')
import 'dart:html';
import 'package:tests/tests.dart';
import 'package:test/test.dart';
import 'package:moor/moor_web.dart';
import 'package:test/test.dart';
import 'package:tests/tests.dart';
class WebExecutor extends TestExecutor {
final String name = 'db';

View File

@ -1,9 +1,9 @@
import 'package:built_value/built_value.dart';
import 'package:moor/moor.dart';
import 'package:moor/ffi.dart';
import 'package:moor/moor.dart';
part 'database.moor.dart';
part 'database.g.dart';
part 'database.moor.dart';
abstract class Foo implements Built<Foo, FooBuilder> {
User get moorField;

View File

@ -3,21 +3,20 @@ library moor;
// needed for the generated code that generates data classes with an Uint8List
// field.
export 'dart:typed_data' show Uint8List;
// needed for generated code which provides an @required parameter hint where
// appropriate
export 'package:meta/meta.dart' show required;
export 'package:moor/src/dsl/dsl.dart';
export 'package:moor/src/runtime/query_builder/query_builder.dart';
export 'package:moor/src/runtime/api/runtime_api.dart';
export 'package:moor/src/runtime/custom_result_set.dart';
export 'package:moor/src/runtime/data_class.dart';
export 'package:moor/src/runtime/data_verification.dart';
export 'package:moor/src/runtime/exceptions.dart';
export 'package:moor/src/runtime/executor/connection_pool.dart';
export 'package:moor/src/runtime/executor/executor.dart';
export 'package:moor/src/runtime/custom_result_set.dart';
export 'package:moor/src/runtime/data_verification.dart';
export 'package:moor/src/runtime/data_class.dart';
export 'package:moor/src/runtime/api/runtime_api.dart';
export 'package:moor/src/runtime/query_builder/query_builder.dart';
export 'package:moor/src/runtime/types/sql_types.dart';
export 'package:moor/src/runtime/exceptions.dart';
export 'package:moor/src/utils/expand_variables.dart';
export 'package:moor/src/utils/hash.dart';
export 'package:moor/src/utils/lazy_database.dart';

View File

@ -1,5 +1,5 @@
import 'package:test/test.dart';
import 'package:moor/moor.dart';
import 'package:test/test.dart';
import '../data/tables/todos.dart';

View File

@ -4,10 +4,8 @@ import 'dart:io';
import 'package:moor/ffi.dart';
import 'package:moor/isolate.dart';
import 'package:moor/moor.dart';
import 'package:test/test.dart';
import 'package:path/path.dart' show join;
import 'package:test/test.dart';
import '../data/tables/todos.dart';

View File

@ -1,5 +1,5 @@
import 'package:test/test.dart';
import 'package:moor/moor.dart';
import 'package:test/test.dart';
import '../data/tables/todos.dart';
import '../data/utils/expect_generated.dart';

View File

@ -1,7 +1,7 @@
import 'package:mockito/mockito.dart';
import 'package:moor/moor.dart';
import 'package:test/test.dart';
import 'package:moor/moor.dart';
import '../data/tables/custom_tables.dart';
import '../data/tables/todos.dart';
import '../data/utils/expect_generated.dart';

View File

@ -1,5 +1,5 @@
import 'package:test/test.dart';
import 'package:moor/moor.dart';
import 'package:test/test.dart';
import '../data/tables/todos.dart';
import '../data/utils/expect_generated.dart';

View File

@ -1,5 +1,5 @@
import 'package:test/test.dart';
import 'package:moor/moor.dart';
import 'package:test/test.dart';
import '../data/tables/todos.dart';
import '../data/utils/expect_generated.dart';

View File

@ -2,9 +2,9 @@
@TestOn('vm')
import 'dart:convert';
import 'package:moor/extensions/json1.dart';
import 'package:moor/ffi.dart';
import 'package:moor/moor.dart';
import 'package:moor/extensions/json1.dart';
import 'package:test/test.dart';
import '../data/tables/todos.dart';

View File

@ -1,5 +1,5 @@
import 'package:moor/moor.dart';
import 'package:moor/extensions/json1.dart';
import 'package:moor/moor.dart';
import 'package:test/test.dart';
import '../data/utils/expect_generated.dart';

View File

@ -1,7 +1,7 @@
@TestOn('vm')
import 'package:moor/moor.dart';
import 'package:moor/extensions/moor_ffi.dart';
import 'package:moor/ffi.dart';
@TestOn('vm')
import 'package:moor/moor.dart';
import 'package:test/test.dart';
import '../data/tables/todos.dart';

View File

@ -3,8 +3,8 @@ import 'dart:io';
import 'package:moor/ffi.dart';
import 'package:moor/moor.dart';
import 'package:test/test.dart';
import 'package:path/path.dart' as p;
import 'package:test/test.dart';
void main() {
test('can close lost instances', () async {

View File

@ -1,9 +1,9 @@
@TestOn('vm')
import 'dart:async';
import 'package:test/test.dart';
import 'package:moor/ffi.dart';
import 'package:moor/moor.dart';
import 'package:test/test.dart';
class _TestDb extends GeneratedDatabase {
_TestDb() : super(const SqlTypeSystem.withDefaults(), VmDatabase.memory());

View File

@ -2,9 +2,9 @@
import 'dart:async';
import 'dart:isolate';
import 'package:moor/ffi.dart';
import 'package:moor/isolate.dart';
import 'package:moor/moor.dart';
import 'package:moor/ffi.dart';
import 'package:test/test.dart';
import 'data/tables/todos.dart';

View File

@ -1,26 +1,9 @@
import 'dart:async';
@TestOn('!browser') // todo: Figure out why this doesn't run in js
// ignore_for_file: lines_longer_than_80_chars
/*
These tests don't work when compiled to js:
NoSuchMethodError: method not found: 'beginTransaction$0' (executor.beginTransaction$0 is not a function)
package:moor/src/runtime/database.dart 185:45 <fn>
org-dartlang-sdk:///sdk/lib/_internal/js_runtime/lib/async_patch.dart 313:19 _wrapJsFunctionForAsync.closure.$protected
org-dartlang-sdk:///sdk/lib/_internal/js_runtime/lib/async_patch.dart 338:23 _wrapJsFunctionForAsync.<fn>
package:stack_trace StackZoneSpecification._registerBinaryCallback.<fn>
org-dartlang-sdk:///sdk/lib/_internal/js_runtime/lib/async_patch.dart 242:3 Object._asyncStartSync
package:moor/src/runtime/database.dart 185:13 QueryEngine.transaction.<fn>
test/data/utils/mocks.dart 22:20 MockExecutor.<fn>
package:mockito/src/mock.dart 128:22 MockExecutor.noSuchMethod
*/
import 'package:test/test.dart';
import 'package:mockito/mockito.dart';
import 'package:moor/moor.dart';
@TestOn('!browser')
import 'package:test/test.dart';
import 'data/tables/todos.dart';
import 'data/utils/mocks.dart';

View File

@ -6,9 +6,10 @@ library moor_flutter;
import 'dart:async';
import 'dart:io';
import 'package:path/path.dart';
import 'package:moor/moor.dart';
import 'package:moor/backends.dart';
import 'package:moor/moor.dart';
import 'package:path/path.dart';
import 'package:sqflite/sqflite.dart' as s;
export 'package:moor/moor.dart';

View File

@ -1,7 +1,7 @@
import 'package:analyzer/dart/element/nullability_suffix.dart';
import 'package:analyzer/dart/element/type.dart';
import 'package:moor_generator/moor_generator.dart';
import 'package:moor_generator/src/analyzer/errors.dart';
import 'package:analyzer/dart/element/type.dart';
import 'package:moor_generator/src/analyzer/runner/steps.dart';
import 'package:moor_generator/src/analyzer/sql_queries/type_mapping.dart';
import 'package:moor_generator/src/backends/backend.dart';

View File

@ -1,8 +1,8 @@
import 'package:moor_generator/moor_generator.dart';
import 'package:moor_generator/src/analyzer/errors.dart';
import 'package:moor_generator/src/analyzer/runner/steps.dart';
import 'package:moor_generator/src/analyzer/moor/create_table_reader.dart';
import 'package:moor_generator/src/analyzer/runner/results.dart';
import 'package:moor_generator/src/analyzer/runner/steps.dart';
import 'package:moor_generator/src/model/sql_query.dart';
import 'package:sqlparser/sqlparser.dart';

View File

@ -6,18 +6,17 @@ import 'package:moor_generator/moor_generator.dart';
import 'package:moor_generator/src/analyzer/dart/parser.dart';
import 'package:moor_generator/src/analyzer/errors.dart';
import 'package:moor_generator/src/analyzer/moor/entity_handler.dart';
import 'package:moor_generator/src/analyzer/moor/parser.dart';
import 'package:moor_generator/src/analyzer/runner/file_graph.dart';
import 'package:moor_generator/src/analyzer/runner/results.dart';
import 'package:moor_generator/src/analyzer/moor/parser.dart';
import 'package:moor_generator/src/analyzer/runner/task.dart';
import 'package:moor_generator/src/analyzer/sql_queries/custom_result_class.dart';
import 'package:moor_generator/src/analyzer/sql_queries/query_analyzer.dart';
import 'package:moor_generator/src/analyzer/sql_queries/type_mapping.dart';
import 'package:moor_generator/src/analyzer/runner/task.dart';
import 'package:moor_generator/src/analyzer/view/view_analyzer.dart';
import 'package:moor_generator/src/model/sql_query.dart';
import 'package:moor_generator/src/model/view.dart';
import 'package:moor_generator/src/utils/entity_reference_sorter.dart';
import 'package:source_gen/source_gen.dart';
part 'steps/analyze_dart.dart';

View File

@ -5,9 +5,9 @@ import 'package:moor_generator/src/analyzer/errors.dart';
import 'package:moor_generator/src/analyzer/runner/file_graph.dart';
import 'package:moor_generator/src/analyzer/runner/steps.dart';
import 'package:moor_generator/src/analyzer/sql_queries/lints/linter.dart';
import 'package:moor_generator/src/model/sql_query.dart';
import 'package:moor_generator/src/analyzer/sql_queries/query_handler.dart';
import 'package:moor_generator/src/analyzer/sql_queries/type_mapping.dart';
import 'package:moor_generator/src/model/sql_query.dart';
import 'package:moor_generator/src/model/view.dart';
import 'package:sqlparser/sqlparser.dart' hide ResultColumn;
import 'package:sqlparser/utils/find_referenced_tables.dart';
@ -171,7 +171,7 @@ class SqlAnalyzer extends BaseAnalyzer {
final handled =
QueryHandler(query, context, mapper, requiredVariables: variables)
.handle()
..declaredInMoorFile = query is DeclaredMoorQuery;
..declaredInMoorFile = query is DeclaredMoorQuery;
foundQueries.add(handled);
} catch (e, s) {
// todo remove dependency on build package here

View File

@ -1,7 +1,7 @@
import 'package:moor_generator/moor_generator.dart';
import 'package:moor_generator/src/analyzer/sql_queries/type_mapping.dart';
import 'package:moor_generator/src/model/sql_query.dart';
import 'package:moor_generator/src/model/used_type_converter.dart';
import 'package:moor_generator/src/analyzer/sql_queries/type_mapping.dart';
import 'package:moor_generator/src/utils/type_converter_hint.dart';
import 'package:sqlparser/sqlparser.dart' hide ResultColumn;
import 'package:sqlparser/utils/find_referenced_tables.dart';

View File

@ -1,7 +1,7 @@
import 'package:analyzer/dart/analysis/analysis_context.dart';
import 'package:analyzer/dart/analysis/results.dart';
import 'package:analyzer/dart/element/type.dart';
import 'package:analyzer/dart/element/element.dart';
import 'package:analyzer/dart/element/type.dart';
import 'package:analyzer/file_system/overlay_file_system.dart';
import 'package:logging/logging.dart';

View File

@ -211,7 +211,9 @@ class QueryWriter {
'Future<List<${_select.resultTypeCode(scope.generationOptions)}>>';
_buffer.write('$returnType ${query.name}(');
_writeParameters();
_buffer..write(') {\n')..write('return ${_nameOfCreationMethod()}(');
_buffer
..write(') {\n')
..write('return ${_nameOfCreationMethod()}(');
_writeUseParameters();
_buffer.write(').get();\n}\n');
}
@ -232,7 +234,9 @@ class QueryWriter {
'Stream<List<${_select.resultTypeCode(scope.generationOptions)}>>';
_buffer.write('$returnType $methodName(');
_writeParameters();
_buffer..write(') {\n')..write('return ${_nameOfCreationMethod()}(');
_buffer
..write(') {\n')
..write('return ${_nameOfCreationMethod()}(');
_writeUseParameters();
_buffer.write(').watch();\n}\n');
}
@ -359,10 +363,16 @@ class QueryWriter {
for (final arg in optional.availableResultSets) {
if (i != 0) buffer.write(', ');
buffer..write(arg.argumentType)..write(' ')..write('_' * (i + 1));
buffer
..write(arg.argumentType)
..write(' ')
..write('_' * (i + 1));
i++;
}
buffer..write(') => ')..write(defaultCode)..write(';');
buffer
..write(') => ')
..write(defaultCode)
..write(';');
// With the function being written, the default code is just a tear-
// off of that function
@ -383,12 +393,16 @@ class QueryWriter {
(!isNullable || isMarkedAsRequired) && defaultCode == null ||
options.namedParametersAlwaysRequired;
if (isRequired) {
_buffer..write(scope.required)..write(' ');
_buffer
..write(scope.required)
..write(' ');
}
_buffer.write('$type ${optional.dartParameterName}');
if (defaultCode != null && !isRequired) {
_buffer..write(' = ')..write(defaultCode);
_buffer
..write(' = ')
..write(defaultCode);
}
}
@ -451,7 +465,10 @@ class QueryWriter {
void _increaseIndexCounter(String by) {
if (needsIndexCounter) {
_buffer..write('$highestAssignedIndexVar += ')..write(by)..write(';\n');
_buffer
..write('$highestAssignedIndexVar += ')
..write(by)
..write(';\n');
}
}
@ -516,7 +533,9 @@ class QueryWriter {
..write(useExpression())
..write(');\n');
} else {
_buffer..write(r'$write(')..write(useExpression());
_buffer
..write(r'$write(')
..write(useExpression());
if (query.hasMultipleTables) {
_buffer.write(', hasMultipleTables: true');
}
@ -609,7 +628,7 @@ class QueryWriter {
node is DartPlaceholder ||
node is NestedStarResultColumn)
.toList()
..sort(_compareNodes);
..sort(_compareNodes);
final buffer = StringBuffer("'");
@ -701,7 +720,10 @@ class QueryWriter {
void _writeUpdates() {
final from = _update.updates.map((t) => t.table.dbGetterName).join(', ');
_buffer..write('updates: {')..write(from)..write('}');
_buffer
..write('updates: {')
..write(from)
..write('}');
}
void _writeUpdateKind() {

View File

@ -1,9 +1,9 @@
//@dart=2.9
import 'package:build/build.dart';
import 'package:moor_generator/src/model/types.dart';
import 'package:moor_generator/src/analyzer/runner/results.dart';
import 'package:moor_generator/src/analyzer/runner/steps.dart';
import 'package:moor_generator/src/analyzer/session.dart';
import 'package:moor_generator/src/model/types.dart';
import 'package:test/test.dart';
import '../../utils/test_backend.dart';

View File

@ -6,8 +6,8 @@ import 'package:analyzer/file_system/memory_file_system.dart';
import 'package:build/build.dart';
import 'package:build_test/build_test.dart';
import 'package:moor_generator/src/backends/build/moor_builder.dart';
import 'package:test/test.dart';
import 'package:pub_semver/pub_semver.dart';
import 'package:test/test.dart';
const _testInput = r'''
import 'package:moor/moor.dart';

View File

@ -1,6 +1,6 @@
import 'package:sqlparser/sqlparser.dart';
import 'package:sqlparser/src/utils/ast_equality.dart';
import 'package:test/test.dart';
import 'package:sqlparser/sqlparser.dart';
import '../parser/utils.dart';
import 'data.dart';

View File

@ -1,5 +1,5 @@
import 'package:test/test.dart';
import 'package:sqlparser/sqlparser.dart';
import 'package:test/test.dart';
import 'data.dart';

View File

@ -1,6 +1,6 @@
import 'package:sqlparser/sqlparser.dart';
import 'package:sqlparser/src/reader/tokenizer/token.dart';
import 'package:test/test.dart';
import 'package:sqlparser/sqlparser.dart';
import 'utils.dart';

View File

@ -1,5 +1,5 @@
import 'package:test/test.dart';
import 'package:sqlparser/sqlparser.dart';
import 'package:test/test.dart';
import 'utils.dart';

View File

@ -1,7 +1,7 @@
import 'package:sqlparser/src/reader/tokenizer/token.dart';
import 'package:test/test.dart';
import 'package:sqlparser/sqlparser.dart';
import 'package:sqlparser/src/reader/tokenizer/token.dart';
import 'package:sqlparser/src/utils/ast_equality.dart';
import 'package:test/test.dart';
import '../utils.dart';

View File

@ -1,7 +1,7 @@
import 'package:sqlparser/src/reader/tokenizer/token.dart';
import 'package:test/test.dart';
import 'package:sqlparser/sqlparser.dart';
import 'package:sqlparser/src/reader/tokenizer/token.dart';
import 'package:sqlparser/src/utils/ast_equality.dart';
import 'package:test/test.dart';
import '../utils.dart';

View File

@ -1,7 +1,7 @@
import 'package:sqlparser/src/reader/tokenizer/token.dart';
import 'package:test/test.dart';
import 'package:sqlparser/sqlparser.dart';
import 'package:sqlparser/src/reader/tokenizer/token.dart';
import 'package:sqlparser/src/utils/ast_equality.dart';
import 'package:test/test.dart';
import '../utils.dart';

View File

@ -1,7 +1,7 @@
import 'package:sqlparser/src/reader/tokenizer/token.dart';
import 'package:test/test.dart';
import 'package:sqlparser/sqlparser.dart';
import 'package:sqlparser/src/reader/tokenizer/token.dart';
import 'package:sqlparser/src/utils/ast_equality.dart';
import 'package:test/test.dart';
import '../utils.dart';

View File

@ -1,6 +1,7 @@
import 'package:sqlparser/sqlparser.dart';
import 'package:sqlparser/src/ast/ast.dart';
import 'package:test/test.dart';
import 'package:sqlparser/sqlparser.dart';
import 'utils.dart';
final Map<String, AstNode> testCases = {

View File

@ -1,6 +1,6 @@
import 'package:test/test.dart';
import 'package:sqlparser/src/reader/tokenizer/scanner.dart';
import 'package:sqlparser/src/reader/tokenizer/token.dart';
import 'package:test/test.dart';
void main() {
test('parses moor specific tokens', () {

View File

@ -2,11 +2,10 @@
import 'dart:convert';
import 'dart:ffi';
import 'package:test/test.dart';
import 'package:sqlite3/open.dart';
import 'package:ffi/ffi.dart';
import 'package:sqlite3/open.dart';
import 'package:sqlparser/src/reader/tokenizer/token.dart';
import 'package:test/test.dart';
typedef SqliteKeywordCountNative = Int32 Function();
typedef SqliteKeywordCount = int Function();