mirror of
https://github.com/pese-git/cherrypick.git
synced 2026-01-23 21:13:35 +00:00
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:
@@ -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)
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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';
|
||||
|
||||
@@ -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');
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import 'package:test/test.dart';
|
||||
import 'package:analyzer/dart/element/type.dart';
|
||||
|
||||
import 'package:analyzer/dart/element/element.dart';
|
||||
import 'package:analyzer/source/source.dart';
|
||||
import 'package:cherrypick_generator/src/type_parser.dart';
|
||||
|
||||
Reference in New Issue
Block a user