refactor: clean up unused code and fix all analyzer warnings

- Removed all unused imports and variables across generator sources and tests
- Applied Dart 3 super parameters to all custom exceptions
- Project now passes 'dart analyze' with zero warnings or infos
- All tests (164/164) are green

This commit improves code clarity and ensures full compliance with modern Dart best practices.
This commit is contained in:
Sergey Penkovsky
2025-07-15 16:28:05 +03:00
parent 71d3ef77a9
commit edc2a14ad7
5 changed files with 24 additions and 52 deletions

View File

@@ -13,8 +13,8 @@
import 'dart:async';
import 'package:analyzer/dart/constant/value.dart';
import 'package:analyzer/dart/element/nullability_suffix.dart';
import 'package:analyzer/dart/element/type.dart';
import 'package:build/build.dart';
import 'package:source_gen/source_gen.dart';
import 'package:analyzer/dart/element/element.dart';
@@ -85,9 +85,6 @@ class InjectGenerator extends GeneratorForAnnotation<ann.injectable> {
final className = classElement.name;
final mixinName = '_\$$className';
// Get the source file name for the part directive
final sourceFile = classElement.source.shortName;
// Collect and process all @inject fields.
final injectFields = classElement.fields
.where(_isInjectField)

View File

@@ -217,7 +217,6 @@ class AnnotationValidator {
final obj = meta.computeConstantValue();
final type = obj?.type?.getDisplayString();
if (type == 'scope') {
final scopeName = obj?.getField('name')?.toStringValue();
// Empty scope name is treated as no scope (uses root scope)
// This is allowed for backward compatibility and convenience
}

View File

@@ -12,7 +12,7 @@
//
import 'package:analyzer/dart/element/element.dart';
import 'package:source_gen/source_gen.dart';
import 'bind_parameters_spec.dart';
import 'metadata_utils.dart';

View File

@@ -82,60 +82,36 @@ class CherryPickGeneratorException extends InvalidGenerationSourceError {
/// Specific exception types for different error categories
class AnnotationValidationException extends CherryPickGeneratorException {
AnnotationValidationException(
String message, {
required Element element,
String? suggestion,
Map<String, dynamic>? context,
}) : super(
message,
element: element,
category: 'ANNOTATION_VALIDATION',
suggestion: suggestion,
context: context,
);
super.message, {
required super.element,
super.suggestion,
super.context,
}) : super(category: 'ANNOTATION_VALIDATION');
}
class TypeParsingException extends CherryPickGeneratorException {
TypeParsingException(
String message, {
required Element element,
String? suggestion,
Map<String, dynamic>? context,
}) : super(
message,
element: element,
category: 'TYPE_PARSING',
suggestion: suggestion,
context: context,
);
super.message, {
required super.element,
super.suggestion,
super.context,
}) : super(category: 'TYPE_PARSING');
}
class CodeGenerationException extends CherryPickGeneratorException {
CodeGenerationException(
String message, {
required Element element,
String? suggestion,
Map<String, dynamic>? context,
}) : super(
message,
element: element,
category: 'CODE_GENERATION',
suggestion: suggestion,
context: context,
);
super.message, {
required super.element,
super.suggestion,
super.context,
}) : super(category: 'CODE_GENERATION');
}
class DependencyResolutionException extends CherryPickGeneratorException {
DependencyResolutionException(
String message, {
required Element element,
String? suggestion,
Map<String, dynamic>? context,
}) : super(
message,
element: element,
category: 'DEPENDENCY_RESOLUTION',
suggestion: suggestion,
context: context,
);
super.message, {
required super.element,
super.suggestion,
super.context,
}) : super(category: 'DEPENDENCY_RESOLUTION');
}