mirror of https://github.com/AMT-Cheif/drift.git
[drift_dev] Update analyzer and deprecated methods (#2084)
This commit is contained in:
parent
ccea98e4a2
commit
b2796fc77e
|
@ -1,10 +1,9 @@
|
|||
## 2.3.0-dev
|
||||
|
||||
- Serialize `uniqueKeys` overrides into a database schema.
|
||||
|
||||
## 2.2.0-dev
|
||||
|
||||
- Fix the nullability of columns generated for Dart-defined views.
|
||||
- __Potentially breaking bug-fix__: Fix the nullability of columns generated for
|
||||
Dart-defined views.
|
||||
- Serialize `uniqueKeys` overrides into a database schema.
|
||||
- Support latest version of the `analyzer` package.
|
||||
|
||||
## 2.1.0
|
||||
|
||||
|
|
|
@ -67,7 +67,7 @@ class ColumnParser {
|
|||
|
||||
if (expr is! FunctionExpressionInvocation) {
|
||||
base.step.reportError(ErrorInDartCode(
|
||||
affectedElement: getter.declaredElement2,
|
||||
affectedElement: getter.declaredElement,
|
||||
message: _errorMessage,
|
||||
severity: Severity.criticalError,
|
||||
));
|
||||
|
@ -106,7 +106,7 @@ class ColumnParser {
|
|||
base.step.reportError(
|
||||
ErrorInDartCode(
|
||||
severity: Severity.warning,
|
||||
affectedElement: getter.declaredElement2,
|
||||
affectedElement: getter.declaredElement,
|
||||
message:
|
||||
"You're setting more than one name here, the first will "
|
||||
'be used',
|
||||
|
@ -119,7 +119,7 @@ class ColumnParser {
|
|||
base.step.reportError(
|
||||
ErrorInDartCode(
|
||||
severity: Severity.error,
|
||||
affectedElement: getter.declaredElement2,
|
||||
affectedElement: getter.declaredElement,
|
||||
message:
|
||||
'This table name is cannot be resolved! Please only use '
|
||||
'a constant string as parameter for .named().',
|
||||
|
@ -134,7 +134,7 @@ class ColumnParser {
|
|||
if (first is! Identifier) {
|
||||
base.step.reportError(ErrorInDartCode(
|
||||
message: 'This parameter should be a simple class name',
|
||||
affectedElement: getter.declaredElement2,
|
||||
affectedElement: getter.declaredElement,
|
||||
affectedNode: first,
|
||||
));
|
||||
break;
|
||||
|
@ -144,7 +144,7 @@ class ColumnParser {
|
|||
if (staticElement is! ClassElement) {
|
||||
base.step.reportError(ErrorInDartCode(
|
||||
message: '${first.name} is not a class!',
|
||||
affectedElement: getter.declaredElement2,
|
||||
affectedElement: getter.declaredElement,
|
||||
affectedNode: first,
|
||||
));
|
||||
break;
|
||||
|
@ -154,7 +154,7 @@ class ColumnParser {
|
|||
if (columnNameNode is! SymbolLiteral) {
|
||||
base.step.reportError(ErrorInDartCode(
|
||||
message: 'This should be a symbol literal (`#columnName`)',
|
||||
affectedElement: getter.declaredElement2,
|
||||
affectedElement: getter.declaredElement,
|
||||
affectedNode: columnNameNode,
|
||||
));
|
||||
break;
|
||||
|
@ -170,7 +170,7 @@ class ColumnParser {
|
|||
base.step.reportError(ErrorInDartCode(
|
||||
message:
|
||||
'Should be a direct enum reference (`KeyAction.cascade`)',
|
||||
affectedElement: getter.declaredElement2,
|
||||
affectedElement: getter.declaredElement,
|
||||
affectedNode: expr,
|
||||
));
|
||||
return null;
|
||||
|
@ -209,7 +209,7 @@ class ColumnParser {
|
|||
columnName,
|
||||
onUpdate,
|
||||
onDelete,
|
||||
getter.declaredElement2,
|
||||
getter.declaredElement,
|
||||
first,
|
||||
columnNameNode,
|
||||
));
|
||||
|
@ -242,7 +242,7 @@ class ColumnParser {
|
|||
base.step.reportError(
|
||||
ErrorInDartCode(
|
||||
severity: Severity.warning,
|
||||
affectedElement: getter.declaredElement2,
|
||||
affectedElement: getter.declaredElement,
|
||||
affectedNode: remainingExpr.methodName,
|
||||
message:
|
||||
"You've already set custom constraints on this column, "
|
||||
|
@ -256,7 +256,7 @@ class ColumnParser {
|
|||
base.step.reportError(
|
||||
ErrorInDartCode(
|
||||
severity: Severity.warning,
|
||||
affectedElement: getter.declaredElement2,
|
||||
affectedElement: getter.declaredElement,
|
||||
message:
|
||||
'This constraint is cannot be resolved! Please only use '
|
||||
'a constant string as parameter for .customConstraint().',
|
||||
|
@ -339,7 +339,7 @@ class ColumnParser {
|
|||
if (foundExplicitName != null) {
|
||||
name = ColumnName.explicitly(foundExplicitName);
|
||||
} else {
|
||||
name = ColumnName.implicitly(ReCase(getter.name2.lexeme).snakeCase);
|
||||
name = ColumnName.implicitly(ReCase(getter.name.lexeme).snakeCase);
|
||||
}
|
||||
|
||||
final columnType = _startMethodToColumnType(foundStartMethod);
|
||||
|
@ -368,7 +368,7 @@ class ColumnParser {
|
|||
base.step.reportError(ErrorInDartCode(
|
||||
message: 'Using $startEnum will apply a custom converter by default, '
|
||||
"so you can't add an additional converter",
|
||||
affectedElement: getter.declaredElement2,
|
||||
affectedElement: getter.declaredElement,
|
||||
severity: Severity.warning,
|
||||
));
|
||||
}
|
||||
|
@ -380,7 +380,7 @@ class ColumnParser {
|
|||
} on InvalidTypeForEnumConverterException catch (e) {
|
||||
base.step.errors.report(ErrorInDartCode(
|
||||
message: e.errorDescription,
|
||||
affectedElement: getter.declaredElement2,
|
||||
affectedElement: getter.declaredElement,
|
||||
severity: Severity.error,
|
||||
));
|
||||
}
|
||||
|
@ -390,7 +390,7 @@ class ColumnParser {
|
|||
base.step.reportError(
|
||||
ErrorInDartCode(
|
||||
severity: Severity.warning,
|
||||
affectedElement: getter.declaredElement2,
|
||||
affectedElement: getter.declaredElement,
|
||||
message: 'clientDefault() and withDefault() are mutually exclusive, '
|
||||
"they can't both be used. Use clientDefault() for values that "
|
||||
'are different for each row and withDefault() otherwise.',
|
||||
|
@ -403,7 +403,7 @@ class ColumnParser {
|
|||
base.step.reportError(
|
||||
ErrorInDartCode(
|
||||
severity: Severity.error,
|
||||
affectedElement: getter.declaredElement2,
|
||||
affectedElement: getter.declaredElement,
|
||||
message: 'Primary key column cannot have UNIQUE constraint',
|
||||
),
|
||||
);
|
||||
|
@ -413,7 +413,7 @@ class ColumnParser {
|
|||
base.step.reportError(
|
||||
ErrorInDartCode(
|
||||
severity: Severity.warning,
|
||||
affectedElement: getter.declaredElement2,
|
||||
affectedElement: getter.declaredElement,
|
||||
message: 'This column definition is using both drift-defined '
|
||||
'constraints (like references, autoIncrement, ...) and a '
|
||||
'customConstraint(). Only the custom constraint will be added '
|
||||
|
@ -426,7 +426,7 @@ class ColumnParser {
|
|||
getter.documentationComment?.tokens.map((t) => t.toString()).join('\n');
|
||||
return DriftColumn(
|
||||
type: columnType,
|
||||
dartGetterName: getter.name2.lexeme,
|
||||
dartGetterName: getter.name.lexeme,
|
||||
name: name,
|
||||
overriddenJsonName: _readJsonKey(element),
|
||||
customConstraints: foundCustomConstraint,
|
||||
|
|
|
@ -62,7 +62,7 @@ class DriftDartParser {
|
|||
if (body is! ExpressionFunctionBody) {
|
||||
if (reportErrorOnFailure) {
|
||||
step.reportError(ErrorInDartCode(
|
||||
affectedElement: method.declaredElement2,
|
||||
affectedElement: method.declaredElement,
|
||||
severity: Severity.criticalError,
|
||||
message: 'This method must have an expression body '
|
||||
'(use => instead of {return ...})',
|
||||
|
|
|
@ -235,7 +235,7 @@ class ViewParser {
|
|||
final type = tables.firstWhereOrNull(
|
||||
(tbl) => tbl.fromClass!.name == node.returnType.toString());
|
||||
if (type != null) {
|
||||
final name = node.name2.lexeme;
|
||||
final name = node.name.lexeme;
|
||||
return TableReferenceInDartView(type, name);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
name: drift_dev
|
||||
description: Dev-dependency for users of drift. Contains a the generator and development tools.
|
||||
version: 2.1.0
|
||||
version: 2.2.0-dev
|
||||
repository: https://github.com/simolus3/drift
|
||||
homepage: https://drift.simonbinder.eu/
|
||||
issue_tracker: https://github.com/simolus3/drift/issues
|
||||
|
||||
environment:
|
||||
sdk: '>=2.14.0 <3.0.0'
|
||||
sdk: '>=2.17.0 <3.0.0'
|
||||
|
||||
dependencies:
|
||||
charcode: ^1.2.0
|
||||
|
@ -30,7 +30,7 @@ dependencies:
|
|||
sqlparser: ^0.23.2
|
||||
|
||||
# Dart analysis
|
||||
analyzer: "^4.5.0"
|
||||
analyzer: ^5.0.0
|
||||
analyzer_plugin: ^0.11.0
|
||||
source_span: ^1.5.5
|
||||
package_config: ^2.0.0
|
||||
|
|
|
@ -132,18 +132,17 @@ class _GeneratesConstDataClasses extends Matcher {
|
|||
|
||||
final definedClasses = parsed.declarations.whereType<ClassDeclaration>();
|
||||
for (final definedClass in definedClasses) {
|
||||
if (expectedWithConstConstructor.contains(definedClass.name2.lexeme)) {
|
||||
if (expectedWithConstConstructor.contains(definedClass.name.lexeme)) {
|
||||
final constructor = definedClass.members
|
||||
.whereType<ConstructorDeclaration>()
|
||||
.firstWhereOrNull((e) => e.name2 == null);
|
||||
.firstWhereOrNull((e) => e.name == null);
|
||||
if (constructor?.constKeyword == null) {
|
||||
matchState['desc'] =
|
||||
'Constructor ${definedClass.name2.lexeme} is not '
|
||||
matchState['desc'] = 'Constructor ${definedClass.name.lexeme} is not '
|
||||
'const.';
|
||||
return false;
|
||||
}
|
||||
|
||||
remaining.remove(definedClass.name2.lexeme);
|
||||
remaining.remove(definedClass.name.lexeme);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -80,19 +80,19 @@ class _GeneratesWithoutFinalFields extends Matcher {
|
|||
|
||||
final definedClasses = parsed.declarations.whereType<ClassDeclaration>();
|
||||
for (final definedClass in definedClasses) {
|
||||
final definedClassName = definedClass.name2.lexeme;
|
||||
final definedClassName = definedClass.name.lexeme;
|
||||
if (expectedWithoutFinals.contains(definedClassName)) {
|
||||
for (final member in definedClass.members) {
|
||||
if (member is FieldDeclaration) {
|
||||
if (member.fields.isFinal) {
|
||||
matchState['desc'] =
|
||||
'Field ${member.fields.variables.first.name2.lexeme} in '
|
||||
'Field ${member.fields.variables.first.name.lexeme} in '
|
||||
'$definedClassName is final.';
|
||||
return false;
|
||||
}
|
||||
} else if (member is ConstructorDeclaration) {
|
||||
if (member.constKeyword != null) {
|
||||
matchState['desc'] = 'Constructor ${member.name2?.lexeme ?? ''} '
|
||||
matchState['desc'] = 'Constructor ${member.name?.lexeme ?? ''} '
|
||||
'in $definedClassName is constant.';
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@ publish_to: none
|
|||
version: 1.0.0
|
||||
|
||||
environment:
|
||||
sdk: '>=2.12.0 <3.0.0'
|
||||
sdk: '>=2.14.0 <3.0.0'
|
||||
|
||||
dependencies:
|
||||
drift: ^2.0.0-dev
|
||||
|
@ -11,5 +11,10 @@ dependencies:
|
|||
|
||||
dev_dependencies:
|
||||
drift_dev: ^2.0.0-dev
|
||||
built_value_generator: ^8.1.1
|
||||
built_value_generator: ^8.1.3
|
||||
build_runner: ^2.0.0
|
||||
|
||||
# built_value_generator does not yet support the latest version of the analyzer
|
||||
# but there will be no problems after updating the analyzer to 5 version
|
||||
dependency_overrides:
|
||||
analyzer: ^5.0.0
|
||||
|
|
Loading…
Reference in New Issue