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

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

Issue 1527793003: Clean up imports in analysis_server and analyzer_cli (and one missed in analyzer) (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 5 years 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library services.dependencies.library; 5 library services.dependencies.library;
6 6
7 import 'package:analyzer/dart/element/element.dart';
7 import 'package:analyzer/file_system/file_system.dart'; 8 import 'package:analyzer/file_system/file_system.dart';
8 import 'package:analyzer/src/generated/element.dart';
9 import 'package:analyzer/src/generated/engine.dart'; 9 import 'package:analyzer/src/generated/engine.dart';
10 import 'package:analyzer/src/generated/source.dart'; 10 import 'package:analyzer/src/generated/source.dart';
11 import 'package:analyzer/src/generated/source_io.dart'; 11 import 'package:analyzer/src/generated/source_io.dart';
12 12
13 class LibraryDependencyCollector { 13 class LibraryDependencyCollector {
14 final Set<LibraryElement> _visitedLibraries = new Set<LibraryElement>(); 14 final Set<LibraryElement> _visitedLibraries = new Set<LibraryElement>();
15 final Set<String> _dependencies = new Set<String>(); 15 final Set<String> _dependencies = new Set<String>();
16 16
17 final List<AnalysisContext> _contexts; 17 final List<AnalysisContext> _contexts;
18 18
(...skipping 16 matching lines...) Expand all
35 return result; 35 return result;
36 } 36 }
37 37
38 Set<String> collectLibraryDependencies() { 38 Set<String> collectLibraryDependencies() {
39 _contexts.forEach((AnalysisContext context) => context.librarySources 39 _contexts.forEach((AnalysisContext context) => context.librarySources
40 .forEach((Source source) => 40 .forEach((Source source) =>
41 _addDependencies(context.getLibraryElement(source)))); 41 _addDependencies(context.getLibraryElement(source))));
42 return _dependencies; 42 return _dependencies;
43 } 43 }
44 44
45 Map<AnalysisContext, Folder> _reverse(Map<Folder, AnalysisContext> map) {
46 Map<AnalysisContext, Folder> reverseMap =
47 new Map<AnalysisContext, Folder>();
48 map.forEach((Folder f, AnalysisContext c) => reverseMap[c] = f);
49 return reverseMap;
50 }
51
52 void _addDependencies(LibraryElement libraryElement) { 45 void _addDependencies(LibraryElement libraryElement) {
53 if (libraryElement == null) { 46 if (libraryElement == null) {
54 return; 47 return;
55 } 48 }
56 if (_visitedLibraries.add(libraryElement)) { 49 if (_visitedLibraries.add(libraryElement)) {
57 for (CompilationUnitElement cu in libraryElement.units) { 50 for (CompilationUnitElement cu in libraryElement.units) {
58 String path = cu.source.fullName; 51 String path = cu.source.fullName;
59 if (path != null) { 52 if (path != null) {
60 _dependencies.add(path); 53 _dependencies.add(path);
61 } 54 }
62 } 55 }
63 libraryElement.imports.forEach( 56 libraryElement.imports.forEach(
64 (ImportElement import) => _addDependencies(import.importedLibrary)); 57 (ImportElement import) => _addDependencies(import.importedLibrary));
65 libraryElement.exports.forEach( 58 libraryElement.exports.forEach(
66 (ExportElement export) => _addDependencies(export.exportedLibrary)); 59 (ExportElement export) => _addDependencies(export.exportedLibrary));
67 } 60 }
68 } 61 }
62
63 Map<AnalysisContext, Folder> _reverse(Map<Folder, AnalysisContext> map) {
64 Map<AnalysisContext, Folder> reverseMap =
65 new Map<AnalysisContext, Folder>();
66 map.forEach((Folder f, AnalysisContext c) => reverseMap[c] = f);
67 return reverseMap;
68 }
69 } 69 }
OLDNEW
« no previous file with comments | « pkg/analysis_server/lib/src/services/correction/util.dart ('k') | pkg/analysis_server/lib/src/services/index/index.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698