Skip to content

Commit

Permalink
refactor: enhance import handling in analyzing_builder.dart
Browse files Browse the repository at this point in the history
- Update import retrieval to use the library's compilation unit for better accuracy
- Replace direct access to libraryImports and libraryExports with compilationUnit properties
- Improve compatibility with the analyzer package by ensuring correct import processing
- Remove lint warnings by properly handling nullable types and type casting
  • Loading branch information
gonft committed Jan 3, 2025
1 parent c759ba4 commit fb53533
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions packages/jaspr_builder/lib/src/imports/analyzing_builder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,11 @@ class ImportsModuleBuilder implements Builder {
var outputId = buildStep.inputId.changeExtension('.imports.json');
var partId = buildStep.inputId.changeExtension('.imports.dart');

var import = lib.libraryImports
// Get the library's compilation unit and use its imports instead
var compilationUnit = lib.definingCompilationUnit;
var import = compilationUnit.libraryImports
.cast<Element>()
.followedBy(lib.libraryExports)
.followedBy(compilationUnit.libraryExports)
.where((Element e) => importChecker.hasAnnotationOf(e))
.where((Element e) {
var uri = switch (e) {
Expand Down

0 comments on commit fb53533

Please sign in to comment.