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 import 'dart:async'; | 5 import 'dart:async'; |
6 import 'dart:collection'; | 6 import 'dart:collection'; |
7 import 'dart:core'; | 7 import 'dart:core'; |
8 | 8 |
9 import 'package:analysis_server/protocol/protocol.dart'; | 9 import 'package:analysis_server/protocol/protocol.dart'; |
10 import 'package:analysis_server/protocol/protocol_generated.dart'; | 10 import 'package:analysis_server/protocol/protocol_generated.dart'; |
(...skipping 19 matching lines...) Expand all Loading... |
30 class DiagnosticDomainHandler implements RequestHandler { | 30 class DiagnosticDomainHandler implements RequestHandler { |
31 /// The analysis server that is using this handler to process requests. | 31 /// The analysis server that is using this handler to process requests. |
32 final AnalysisServer server; | 32 final AnalysisServer server; |
33 | 33 |
34 /// Initialize a newly created handler to handle requests for the given | 34 /// Initialize a newly created handler to handle requests for the given |
35 /// [server]. | 35 /// [server]. |
36 DiagnosticDomainHandler(this.server); | 36 DiagnosticDomainHandler(this.server); |
37 | 37 |
38 /// Answer the `diagnostic.getDiagnostics` request. | 38 /// Answer the `diagnostic.getDiagnostics` request. |
39 Response computeDiagnostics(Request request) { | 39 Response computeDiagnostics(Request request) { |
40 List<ContextData> contexts = <ContextData>[]; | 40 List<ContextData> contexts = |
41 if (server.options.enableNewAnalysisDriver) { | 41 server.driverMap.values.map(extractDataFromDriver).toList(); |
42 contexts = server.driverMap.values.map(extractDataFromDriver).toList(); | |
43 } else { | |
44 for (AnalysisContext context in server.analysisContexts) { | |
45 contexts.add(extractDataFromContext(context)); | |
46 } | |
47 } | |
48 return new DiagnosticGetDiagnosticsResult(contexts).toResponse(request.id); | 42 return new DiagnosticGetDiagnosticsResult(contexts).toResponse(request.id); |
49 } | 43 } |
50 | 44 |
51 /// Extract context data from the given [context]. | 45 /// Extract context data from the given [context]. |
52 ContextData extractDataFromContext(AnalysisContext context) { | 46 ContextData extractDataFromContext(AnalysisContext context) { |
53 int explicitFiles = 0; | 47 int explicitFiles = 0; |
54 int implicitFiles = 0; | 48 int implicitFiles = 0; |
55 int workItems = 0; | 49 int workItems = 0; |
56 Set<String> exceptions = new HashSet<String>(); | 50 Set<String> exceptions = new HashSet<String>(); |
57 if (context is AnalysisContextImpl) { | 51 if (context is AnalysisContextImpl) { |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 } | 119 } |
126 } | 120 } |
127 | 121 |
128 class MemoryCpuSample { | 122 class MemoryCpuSample { |
129 final DateTime time; | 123 final DateTime time; |
130 final double cpuPercentage; | 124 final double cpuPercentage; |
131 final int memoryKB; | 125 final int memoryKB; |
132 | 126 |
133 MemoryCpuSample(this.time, this.cpuPercentage, this.memoryKB); | 127 MemoryCpuSample(this.time, this.cpuPercentage, this.memoryKB); |
134 } | 128 } |
OLD | NEW |