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
8 changes: 8 additions & 0 deletions packages/catalyst_builder/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
## 6.0.0-dev.2

**BREAKING CHANGE**: Upgraded the versions of this packages:
```yaml
build: ^4.0.0
analyzer: ^8.0.0
```

## 6.0.0-dev.1

To support the latest version of `build` and `analyzer` we
Expand Down
2 changes: 1 addition & 1 deletion packages/catalyst_builder/example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ dependencies:
path: ../

dev_dependencies:
lints: ^5.1.1
lints: ^6.0.0
build_runner: any

dependency_overrides:
Expand Down
4 changes: 2 additions & 2 deletions packages/catalyst_builder/lib/src/builder/helpers.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import 'constants.dart';
extension ElementAnnotationExtension on ElementAnnotation {
/// Checks if the annotation is part of the catalyst_builder package.
bool isLibraryAnnotation(String name) {
if (element2?.enclosingElement2?.displayName != name) {
if (element?.enclosingElement?.displayName != name) {
return false;
}
var packageUri = element2!.library2?.uri.toString();
var packageUri = element!.library?.uri.toString();
if (packageUri == null) {
return false;
}
Expand Down
40 changes: 20 additions & 20 deletions packages/catalyst_builder/lib/src/builder/preflight_builder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import 'dart:async';
import 'dart:convert';

import 'package:analyzer/dart/constant/value.dart';
import 'package:analyzer/dart/element/element2.dart';
import 'package:analyzer/dart/element/element.dart';
import 'package:analyzer/dart/element/type.dart';
import 'package:build/build.dart';
import 'package:catalyst_builder_contracts/catalyst_builder_contracts.dart';
Expand All @@ -26,7 +26,7 @@ class PreflightBuilder implements Builder {
return;
}

LibraryElement2 libraryElement;
LibraryElement libraryElement;
try {
libraryElement = await buildStep.inputLibrary;
} catch (e) {
Expand All @@ -45,29 +45,29 @@ class PreflightBuilder implements Builder {
);
}

PreflightPart _extractAnnotations(LibraryElement2 entryLib) {
PreflightPart _extractAnnotations(LibraryElement entryLib) {
var services = <ExtractedService>[];

for (var lib in entryLib.children2.whereType<Annotatable>()) {
for (var lib in entryLib.children.whereType<Element>()) {
services.addAll(_extractFromTopLevelElement(lib));
}

return PreflightPart(services: services);
}

List<ExtractedService> _extractFromTopLevelElement(Annotatable el) {
List<ExtractedService> _extractFromTopLevelElement(Element el) {
var services = <ExtractedService>[];
var isPreloaded = el.metadata2.annotations.any(
var isPreloaded = el.metadata.annotations.any(
(a) => a.isLibraryAnnotation('Preload'),
);

for (var annotation in el.metadata2.annotations) {
for (var annotation in el.metadata.annotations) {
if (annotation.isLibraryAnnotation('ServiceMap')) {
services.addAll(
_extractServicesFromServiceMap(annotation, isPreloaded),
);
}
if (annotation.isLibraryAnnotation('Service') && el is ClassElement2) {
if (annotation.isLibraryAnnotation('Service') && el is ClassElement) {
var serviceAnnotation = annotation.computeConstantValue();
services.add(
_mapToExtractedService(el, serviceAnnotation, isPreloaded),
Expand All @@ -91,8 +91,8 @@ class PreflightBuilder implements Builder {
continue;
}

var keyElement = typed.element3;
if (keyElement is! ClassElement2) {
var keyElement = typed.element;
if (keyElement is! ClassElement) {
continue;
}

Expand All @@ -104,7 +104,7 @@ class PreflightBuilder implements Builder {
}

ExtractedService _mapToExtractedService(
ClassElement2 serviceClass,
ClassElement serviceClass,
DartObject? serviceAnnotation,
bool isPreloaded,
) {
Expand All @@ -114,7 +114,7 @@ class PreflightBuilder implements Builder {
lifetime: lifetime.toString(),
service: SymbolReference(
symbolName: serviceClass.displayName,
library: serviceClass.library2.uri.toString(),
library: serviceClass.library.uri.toString(),
),
constructorArgs: _extractConstructorArgs(serviceClass),
exposeAs: _getExposeAs(serviceAnnotation),
Expand All @@ -129,11 +129,11 @@ class PreflightBuilder implements Builder {
return null;
}

var exposeAsElement = typed.element3;
var exposeAsElement = typed.element;

return SymbolReference(
symbolName: exposeAsElement.displayName,
library: exposeAsElement.library2.uri.toString(),
library: exposeAsElement.library.uri.toString(),
);
}

Expand All @@ -145,14 +145,14 @@ class PreflightBuilder implements Builder {
return ServiceLifetime.values[lifetimeIndex ?? 1];
}

List<ConstructorArg> _extractConstructorArgs(ClassElement2 el) {
var constructors = el.children2
.whereType<ConstructorElement2>()
List<ConstructorArg> _extractConstructorArgs(ClassElement el) {
var constructors = el.children
.whereType<ConstructorElement>()
.where(
(ctor) =>
!ctor.isFactory &&
(ctor.firstFragment.name2 == '' ||
ctor.firstFragment.name2 == 'new'),
(ctor.firstFragment.name == '' ||
ctor.firstFragment.name == 'new'),
)
.toList();
return constructors.firstOrNull?.formalParameters
Expand All @@ -162,7 +162,7 @@ class PreflightBuilder implements Builder {
}

ConstructorArg _buildConstructorArg(FormalParameterElement param) {
var annotations = param.metadata2.annotations;
var annotations = param.metadata.annotations;

return ConstructorArg(
name: param.displayName,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import 'dart:async';
import 'dart:convert';

import 'package:analyzer/dart/element/element2.dart';
import 'package:analyzer/dart/element/element.dart';
import 'package:build/build.dart';
import 'package:code_builder/code_builder.dart';
import 'package:dart_style/dart_style.dart';
Expand All @@ -20,17 +20,17 @@ class ServiceContainerPluginBuilder implements Builder {
if (!await buildStep.resolver.isLibrary(buildStep.inputId)) {
return;
}
LibraryElement2 libraryElement;
LibraryElement libraryElement;
try {
libraryElement = (await buildStep.inputLibrary);
} catch (e) {
log.warning('Error while processing input library. Skip for now.', e);
return;
}

var annotation = libraryElement.children2
.whereType<Annotatable>()
.map((el) => el.metadata2.annotations.where(
var annotation = libraryElement.children
.whereType<Element>()
.map((el) => el.metadata.annotations.where(
(m) => m.isLibraryAnnotation('GenerateServiceContainerPlugin')))
.fold(<ElementAnnotation>[], (prev, e) => [...prev, ...e]).firstOrNull;

Expand Down
8 changes: 4 additions & 4 deletions packages/catalyst_builder/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: catalyst_builder
description: A lightweight and easy to use dependency injection container builder for dart.
version: 6.0.0-dev.1
version: 6.0.0-dev.2
homepage: 'https://github.com/mintware-de/catalyst_builder'
repository: 'https://github.com/mintware-de/catalyst_builder/tree/main/packages/catalyst_builder'
documentation: 'https://github.com/mintware-de/catalyst_builder/wiki'
Expand All @@ -24,15 +24,15 @@ topics:
- service-provider

environment:
sdk: ">=3.5.0 <4.0.0"
sdk: ^3.5.0

dependencies:
code_builder: ^4.2.0
dart_style: ^3.0.1
build: ^3.0.0
build: ^4.0.0
glob: ^2.1.0
path: ^1.8.0
analyzer: '>=7.4.0 <9.0.0'
analyzer: ^8.0.0
yaml: ^3.0.0
catalyst_builder_contracts: ^2.0.0

Expand Down