OLD | NEW |
---|---|
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 analysis_server.src.domain_diagnostic; | 5 library analysis_server.src.domain_diagnostic; |
6 | 6 |
7 import 'dart:collection'; | 7 import 'dart:collection'; |
8 import 'dart:core' hide Resource; | 8 import 'dart:core' hide Resource; |
9 | 9 |
10 import 'package:analysis_server/plugin/protocol/protocol.dart'; | 10 import 'package:analysis_server/plugin/protocol/protocol.dart'; |
11 import 'package:analysis_server/src/analysis_server.dart'; | 11 import 'package:analysis_server/src/analysis_server.dart'; |
12 import 'package:analyzer/file_system/file_system.dart'; | |
13 import 'package:analyzer/src/context/cache.dart'; | 12 import 'package:analyzer/src/context/cache.dart'; |
14 import 'package:analyzer/src/context/context.dart'; | 13 import 'package:analyzer/src/context/context.dart'; |
15 import 'package:analyzer/src/generated/engine.dart'; | 14 import 'package:analyzer/src/generated/engine.dart'; |
16 import 'package:analyzer/src/generated/source.dart'; | 15 import 'package:analyzer/src/generated/source.dart'; |
17 import 'package:analyzer/src/generated/utilities_collection.dart'; | 16 import 'package:analyzer/src/generated/utilities_collection.dart'; |
18 import 'package:analyzer/src/task/driver.dart'; | 17 import 'package:analyzer/src/task/driver.dart'; |
19 import 'package:analyzer/task/model.dart'; | 18 import 'package:analyzer/task/model.dart'; |
20 | 19 |
21 int _workItemCount(AnalysisContextImpl context) { | 20 int _workItemCount(AnalysisContextImpl context) { |
22 AnalysisDriver driver = context.driver; | 21 AnalysisDriver driver = context.driver; |
(...skipping 10 matching lines...) Expand all Loading... | |
33 /// The analysis server that is using this handler to process requests. | 32 /// The analysis server that is using this handler to process requests. |
34 final AnalysisServer server; | 33 final AnalysisServer server; |
35 | 34 |
36 /// Initialize a newly created handler to handle requests for the given | 35 /// Initialize a newly created handler to handle requests for the given |
37 /// [server]. | 36 /// [server]. |
38 DiagnosticDomainHandler(this.server); | 37 DiagnosticDomainHandler(this.server); |
39 | 38 |
40 /// Answer the `diagnostic.diagnostics` request. | 39 /// Answer the `diagnostic.diagnostics` request. |
41 Response computeDiagnostics(Request request) { | 40 Response computeDiagnostics(Request request) { |
42 List<ContextData> infos = <ContextData>[]; | 41 List<ContextData> infos = <ContextData>[]; |
43 server.folderMap.forEach((Folder folder, AnalysisContext context) { | 42 for (AnalysisContext context in server.analysisContexts) { |
44 infos.add(extractData(folder, context)); | 43 infos.add(extractData(context)); |
45 }); | 44 } |
45 ; | |
scheglov
2016/02/29 19:03:37
Remove this line.
Brian Wilkerson
2016/02/29 20:45:11
Done
| |
46 | 46 |
47 return new DiagnosticGetDiagnosticsResult(infos).toResponse(request.id); | 47 return new DiagnosticGetDiagnosticsResult(infos).toResponse(request.id); |
48 } | 48 } |
49 | 49 |
50 /// Extract context data from the given [context]. | 50 /// Extract context data from the given [context]. |
51 ContextData extractData(Folder folder, AnalysisContext context) { | 51 ContextData extractData(AnalysisContext context) { |
52 int explicitFiles = 0; | 52 int explicitFiles = 0; |
53 int implicitFiles = 0; | 53 int implicitFiles = 0; |
54 int workItems = 0; | 54 int workItems = 0; |
55 Set<String> exceptions = new HashSet<String>(); | 55 Set<String> exceptions = new HashSet<String>(); |
56 if (context is AnalysisContextImpl) { | 56 if (context is AnalysisContextImpl) { |
57 workItems = _workItemCount(context); | 57 workItems = _workItemCount(context); |
58 var cache = context.analysisCache; | 58 var cache = context.analysisCache; |
59 if (cache is AnalysisCache) { | 59 if (cache is AnalysisCache) { |
60 Set<AnalysisTarget> countedTargets = new HashSet<AnalysisTarget>(); | 60 Set<AnalysisTarget> countedTargets = new HashSet<AnalysisTarget>(); |
61 MapIterator<AnalysisTarget, CacheEntry> iterator = cache.iterator(); | 61 MapIterator<AnalysisTarget, CacheEntry> iterator = cache.iterator(); |
(...skipping 30 matching lines...) Expand all Loading... | |
92 String requestName = request.method; | 92 String requestName = request.method; |
93 if (requestName == DIAGNOSTICS) { | 93 if (requestName == DIAGNOSTICS) { |
94 return computeDiagnostics(request); | 94 return computeDiagnostics(request); |
95 } | 95 } |
96 } on RequestFailure catch (exception) { | 96 } on RequestFailure catch (exception) { |
97 return exception.response; | 97 return exception.response; |
98 } | 98 } |
99 return null; | 99 return null; |
100 } | 100 } |
101 } | 101 } |
OLD | NEW |