Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ packages/
The repo uses [Dart pub workspaces](https://dart.dev/tools/pub/workspaces): a single `pubspec.lock` and shared resolution at the root. Run `dart pub get` at the repo root to resolve all workspace packages.

- **In the workspace:** mix, mix_annotations, mix_generator, mix_winds, mix_winds/example.
- **Excluded:** `mix_lint` (an analyzer plugin; it uses the analyzer version its `analysis_server_plugin` requires, currently 14.x, while `mix_generator` uses analyzer >=9 <11). Run `dart pub get` inside `packages/mix_lint` when working on the linter.
- **Excluded:** `mix_lint` (an analyzer plugin; it uses the analyzer version its `analysis_server_plugin` requires, currently 14.x, while `mix_generator` supports analyzer >=10 <15). Run `dart pub get` inside `packages/mix_lint` when working on the linter.

## Commands

Expand Down
2 changes: 1 addition & 1 deletion packages/mix_chart_protocol/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ dependencies:
path: ../mix_protocol

dev_dependencies:
analyzer: '>=9.0.0 <11.0.0'
analyzer: '>=13.0.0 <15.0.0'
dart_code_metrics_presets: ^2.24.0
flutter_lints: ^6.0.0
flutter_test:
Expand Down
5 changes: 5 additions & 0 deletions packages/mix_generator/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## Unreleased

- **FIX**: Support analyzer `>=10.0.0 <15.0.0`, including analyzer 14,
by replacing the removed synthetic-field API with field-origin checks.

## 2.2.0

Stable release of the 2.2.0 line. Cumulative since 2.1.3:
Expand Down
2 changes: 1 addition & 1 deletion packages/mix_generator/lib/src/modifier_generator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class ModifierGenerator extends GeneratorForAnnotation<MixableModifier> {
}

final instanceFields = classElement.fields
.where((field) => !field.isStatic && !field.isSynthetic)
.where((field) => !field.isStatic && !field.isOriginGetterSetter)
.toList();

for (final field in instanceFields) {
Expand Down
2 changes: 1 addition & 1 deletion packages/mix_generator/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ dependencies:
mix_annotations: ^2.2.0
dart_style: ^3.0.0
source_gen: ">=3.0.0 <5.0.0"
analyzer: '>=9.0.0 <11.0.0'
analyzer: '>=10.0.0 <15.0.0'
build: ">=3.0.0 <5.0.0"

dev_dependencies:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,44 @@ class OpacityModifierMix extends ModifierMix<OpacityModifier>

void main() {
group('ModifierGenerator', () {
test('ignores static fields and fields induced by accessors', () async {
const body = r'''
@MixableModifier()
final class OpacityModifier with _$OpacityModifier {
static const double defaultOpacity = 1.0;

@override
final double opacity;

const OpacityModifier([double? opacity])
: opacity = opacity ?? defaultOpacity;

double get doubledOpacity => opacity * 2;

set ignoredOpacity(double value) {}

@override
Widget build(Widget child) => child;
}
''';

await expectGeneratorOutputResolves(
builder: partBuilder(const ModifierGenerator()),
sources: {
..._modifierSupportSources,
'mix_generator|lib/modifier_case.dart': _modifierSource(body),
},
inputAsset: 'mix_generator|lib/modifier_case.dart',
outputAsset: 'mix_generator|lib/modifier_case.g.dart',
outputMatcher: allOf([
contains('List<Object?> get props => [opacity];'),
isNot(contains('doubledOpacity')),
isNot(contains('ignoredOpacity')),
isNot(contains('defaultOpacity')),
]),
);
});

test('emits resolving spec-style modifier output', () async {
const body = r'''
@MixableModifier()
Expand Down
2 changes: 1 addition & 1 deletion packages/mix_protocol/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ dependencies:
mix: ^2.2.0

dev_dependencies:
analyzer: '>=9.0.0 <11.0.0'
analyzer: '>=13.0.0 <15.0.0'
flutter_test:
sdk: flutter
flutter_lints: ^6.0.0
6 changes: 3 additions & 3 deletions packages/mix_protocol/tool/inventory_check.dart
Original file line number Diff line number Diff line change
Expand Up @@ -653,8 +653,8 @@ ArgumentList? _argumentList(Expression? expression) {

Expression? _namedArgument(ArgumentList argumentList, String name) {
for (final argument in argumentList.arguments) {
if (argument is NamedExpression && argument.name.label.name == name) {
return argument.expression;
if (argument is NamedArgument && argument.name.lexeme == name) {
return argument.argumentExpression;
}
}

Expand All @@ -669,7 +669,7 @@ String? _namedStringArgument(ArgumentList argumentList, String name) {

String? _firstPositionalStringArgument(ArgumentList argumentList) {
for (final argument in argumentList.arguments) {
if (argument is NamedExpression) continue;
if (argument is NamedArgument) continue;

return argument is StringLiteral ? argument.stringValue : null;
}
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ environment:

dependencies:
melos: 6.3.3
analyzer: '>=9.0.0 <11.0.0'
analyzer: '>=13.0.0 <15.0.0'

dev_dependencies:
flutter_lints: ^6.0.0
144 changes: 30 additions & 114 deletions scripts/generate_widget_docs.dart
Original file line number Diff line number Diff line change
Expand Up @@ -438,85 +438,28 @@ class WidgetVisitor extends RecursiveAstVisitor<void> {

void _extractConstructorParams(ConstructorDeclaration constructor) {
for (final param in constructor.parameters.parameters) {
if (param is DefaultFormalParameter) {
final normalParam = param.parameter;
String paramName = '';
String paramType = 'dynamic';

if (normalParam is SimpleFormalParameter) {
paramName = normalParam.name?.lexeme ?? '';
paramType = normalParam.type?.toSource() ?? 'dynamic';
} else if (normalParam is SuperFormalParameter) {
paramName = normalParam.name.lexeme;
paramType = _resolveSuperParamType(
paramName,
normalParam.type?.toSource(),
);
} else if (normalParam is FieldFormalParameter) {
paramName = normalParam.name.lexeme;
paramType =
normalParam.type?.toSource() ??
fieldTypes[paramName] ??
'dynamic';
}

// Skip 'key' parameter
if (paramName == 'key') continue;

final defaultValue = param.defaultValue?.toSource();
final isRequired = param.isRequired;

constructorParams.add(
ConstructorParam(
name: paramName,
type: paramType,
isRequired: isRequired,
defaultValue: defaultValue,
),
);
} else if (param is SimpleFormalParameter) {
final paramName = param.name?.lexeme ?? '';
final paramType = param.type?.toSource() ?? 'dynamic';

// Skip 'key' parameter
if (paramName == 'key') continue;
final paramName = param.name?.lexeme ?? '';
if (paramName == 'key') continue;

constructorParams.add(
ConstructorParam(name: paramName, type: paramType, isRequired: true),
);
} else if (param is SuperFormalParameter) {
final paramName = param.name.lexeme;
final paramType = _resolveSuperParamType(
final declaredType = param.type?.toSource();
final paramType = switch (param) {
SuperFormalParameter() => _resolveSuperParamType(
paramName,
param.type?.toSource(),
);

// Skip super parameters that we don't want to document
if (paramName == 'key') continue;

constructorParams.add(
ConstructorParam(
name: paramName,
type: paramType,
isRequired: param.isRequired,
),
);
} else if (param is FieldFormalParameter) {
final paramName = param.name.lexeme;
final paramType =
param.type?.toSource() ?? fieldTypes[paramName] ?? 'dynamic';

// Skip 'key' parameter
if (paramName == 'key') continue;

constructorParams.add(
ConstructorParam(
name: paramName,
type: paramType,
isRequired: param.isRequired,
),
);
}
declaredType,
),
FieldFormalParameter() =>
declaredType ?? fieldTypes[paramName] ?? 'dynamic',
_ => declaredType ?? 'dynamic',
};

constructorParams.add(
ConstructorParam(
name: paramName,
type: paramType,
isRequired: param.isRequired,
defaultValue: param.defaultClause?.value.toSource(),
),
);
}
}

Expand Down Expand Up @@ -596,7 +539,7 @@ class StylerVisitor extends RecursiveAstVisitor<void> {
_currentSource = node.name.lexeme;

// Extract public methods from mixin
for (final member in node.body.members) {
for (final member in (node.body as BlockClassBody).members) {
if (member is MethodDeclaration) {
if (!member.isStatic &&
!member.isGetter &&
Expand Down Expand Up @@ -632,42 +575,15 @@ class StylerVisitor extends RecursiveAstVisitor<void> {
final parameters = <MethodParam>[];
if (method.parameters != null) {
for (final param in method.parameters!.parameters) {
if (param is DefaultFormalParameter) {
final normalParam = param.parameter;
String paramName = '';
String paramType = 'dynamic';

if (normalParam is SimpleFormalParameter) {
paramName = normalParam.name?.lexeme ?? '';
paramType = normalParam.type?.toSource() ?? 'dynamic';
}

final defaultValue = param.defaultValue?.toSource();
final isRequired = param.isRequired;
final isNamed = param.isNamed;

parameters.add(
MethodParam(
name: paramName,
type: paramType,
isRequired: isRequired,
isNamed: isNamed,
defaultValue: defaultValue,
),
);
} else if (param is SimpleFormalParameter) {
final paramName = param.name?.lexeme ?? '';
final paramType = param.type?.toSource() ?? 'dynamic';

parameters.add(
MethodParam(
name: paramName,
type: paramType,
isRequired: true,
isNamed: false,
),
);
}
parameters.add(
MethodParam(
name: param.name?.lexeme ?? '',
type: param.type?.toSource() ?? 'dynamic',
isRequired: param.isRequired,
isNamed: param.isNamed,
defaultValue: param.defaultClause?.value.toSource(),
),
);
}
}

Expand Down
Loading