Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(167)

Unified Diff: pkg/analysis_server/lib/src/services/dependencies/library_dependencies.dart

Issue 3003173002: Remove more references to AnalysisContext (Closed)
Patch Set: Created 3 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: pkg/analysis_server/lib/src/services/dependencies/library_dependencies.dart
diff --git a/pkg/analysis_server/lib/src/services/dependencies/library_dependencies.dart b/pkg/analysis_server/lib/src/services/dependencies/library_dependencies.dart
deleted file mode 100644
index 6865b69d2f87d655fb6e381134e962cc71b83cbd..0000000000000000000000000000000000000000
--- a/pkg/analysis_server/lib/src/services/dependencies/library_dependencies.dart
+++ /dev/null
@@ -1,67 +0,0 @@
-// Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-
-import 'package:analyzer/dart/element/element.dart';
-import 'package:analyzer/file_system/file_system.dart';
-import 'package:analyzer/src/generated/engine.dart';
-import 'package:analyzer/src/generated/source.dart';
-import 'package:analyzer/src/generated/source_io.dart';
-
-class LibraryDependencyCollector {
- final Set<LibraryElement> _visitedLibraries = new Set<LibraryElement>();
- final Set<String> _dependencies = new Set<String>();
-
- final Iterable<AnalysisContext> _contexts;
-
- LibraryDependencyCollector(this._contexts);
-
- Map<String, Map<String, List<String>>> calculatePackageMap(
- Map<Folder, AnalysisContext> folderMap) {
- Map<AnalysisContext, Folder> contextMap = _reverse(folderMap);
- Map<String, Map<String, List<String>>> result =
- new Map<String, Map<String, List<String>>>();
- for (AnalysisContext context in _contexts) {
- Map<String, List<Folder>> packageMap = context.sourceFactory.packageMap;
- if (packageMap != null) {
- Map<String, List<String>> map = new Map<String, List<String>>();
- packageMap.forEach((String name, List<Folder> folders) =>
- map[name] = new List.from(folders.map((Folder f) => f.path)));
- result[contextMap[context].path] = map;
- }
- }
- return result;
- }
-
- Set<String> collectLibraryDependencies() {
- _contexts.forEach((AnalysisContext context) => context.librarySources
- .forEach((Source source) =>
- _addDependencies(context.getLibraryElement(source))));
- return _dependencies;
- }
-
- void _addDependencies(LibraryElement libraryElement) {
- if (libraryElement == null) {
- return;
- }
- if (_visitedLibraries.add(libraryElement)) {
- for (CompilationUnitElement cu in libraryElement.units) {
- String path = cu.source.fullName;
- if (path != null) {
- _dependencies.add(path);
- }
- }
- libraryElement.imports.forEach(
- (ImportElement import) => _addDependencies(import.importedLibrary));
- libraryElement.exports.forEach(
- (ExportElement export) => _addDependencies(export.exportedLibrary));
- }
- }
-
- Map<AnalysisContext, Folder> _reverse(Map<Folder, AnalysisContext> map) {
- Map<AnalysisContext, Folder> reverseMap =
- new Map<AnalysisContext, Folder>();
- map.forEach((Folder f, AnalysisContext c) => reverseMap[c] = f);
- return reverseMap;
- }
-}

Powered by Google App Engine
This is Rietveld 408576698