Skip to content

Commit

Permalink
Parts. Remove GatherUsedImportedElementsVisitor.
Browse files Browse the repository at this point in the history
Change-Id: Ice56db3284631bf7cd3fe6e9c519f577c3486303
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/384120
Commit-Queue: Konstantin Shcheglov <[email protected]>
Reviewed-by: Brian Wilkerson <[email protected]>
  • Loading branch information
scheglov authored and Commit Queue committed Sep 7, 2024
1 parent 319bdf4 commit b775d29
Show file tree
Hide file tree
Showing 4 changed files with 79 additions and 500 deletions.
12 changes: 1 addition & 11 deletions pkg/analyzer/lib/src/dart/analysis/library_analyzer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -313,25 +313,18 @@ class LibraryAnalyzer {
_libraryVerificationContext.constructorFieldsVerifier.report();

if (_analysisOptions.warning) {
var usedImportedElements = <UsedImportedElements>[];
var usedLocalElements = <UsedLocalElements>[];
for (var fileAnalysis in _libraryFiles.values) {
{
var visitor = GatherUsedLocalElementsVisitor(_libraryElement);
fileAnalysis.unit.accept(visitor);
usedLocalElements.add(visitor.usedElements);
}
{
var visitor = GatherUsedImportedElementsVisitor(_libraryElement);
fileAnalysis.unit.accept(visitor);
usedImportedElements.add(visitor.usedElements);
}
}
var usedElements = UsedLocalElements.merge(usedLocalElements);
for (var fileAnalysis in _libraryFiles.values) {
_computeWarnings(
fileAnalysis,
usedImportedElements: usedImportedElements,
usedElements: usedElements,
);
}
Expand Down Expand Up @@ -465,7 +458,6 @@ class LibraryAnalyzer {

void _computeWarnings(
FileAnalysis fileAnalysis, {
required List<UsedImportedElements> usedImportedElements,
required UsedLocalElements usedElements,
}) {
var errorReporter = fileAnalysis.errorReporter;
Expand Down Expand Up @@ -509,14 +501,12 @@ class LibraryAnalyzer {
fileAnalysis: fileAnalysis,
);
verifier.addImports(unit);
usedImportedElements.forEach(verifier.removeUsedElements);
verifier.generateDuplicateExportWarnings(errorReporter);
verifier.generateDuplicateImportWarnings(errorReporter);
verifier.generateDuplicateShownHiddenNameWarnings(errorReporter);
verifier.generateUnusedImportHints(errorReporter);
verifier.generateUnusedShownNameHints(errorReporter);
verifier.generateUnnecessaryImportHints(
errorReporter, usedImportedElements);
verifier.generateUnnecessaryImportHints(errorReporter);
}

// Unused local elements.
Expand Down
Loading

0 comments on commit b775d29

Please sign in to comment.