| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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'; |
| 6 |
| 5 import 'package:analysis_server/src/analysis_server.dart'; | 7 import 'package:analysis_server/src/analysis_server.dart'; |
| 6 import 'package:analysis_server/src/computer/computer_highlights.dart'; | 8 import 'package:analysis_server/src/computer/computer_highlights.dart'; |
| 7 import 'package:analysis_server/src/computer/computer_highlights2.dart'; | 9 import 'package:analysis_server/src/computer/computer_highlights2.dart'; |
| 8 import 'package:analysis_server/src/computer/computer_outline.dart'; | 10 import 'package:analysis_server/src/computer/computer_outline.dart'; |
| 9 import 'package:analysis_server/src/computer/computer_overrides.dart'; | 11 import 'package:analysis_server/src/computer/computer_overrides.dart'; |
| 10 import 'package:analysis_server/src/domains/analysis/implemented_dart.dart'; | 12 import 'package:analysis_server/src/domains/analysis/implemented_dart.dart'; |
| 11 import 'package:analysis_server/src/domains/analysis/navigation.dart'; | 13 import 'package:analysis_server/src/domains/analysis/navigation.dart'; |
| 12 import 'package:analysis_server/src/domains/analysis/occurrences.dart'; | 14 import 'package:analysis_server/src/domains/analysis/occurrences.dart'; |
| 13 import 'package:analysis_server/src/operation/operation.dart'; | 15 import 'package:analysis_server/src/operation/operation.dart'; |
| 14 import 'package:analysis_server/src/protocol_server.dart' as protocol; | 16 import 'package:analysis_server/src/protocol_server.dart' as protocol; |
| 15 import 'package:analysis_server/src/services/dependencies/library_dependencies.d
art'; | |
| 16 import 'package:analysis_server/src/services/search/search_engine.dart'; | 17 import 'package:analysis_server/src/services/search/search_engine.dart'; |
| 17 import 'package:analyzer/dart/ast/ast.dart'; | 18 import 'package:analyzer/dart/ast/ast.dart'; |
| 18 import 'package:analyzer/dart/ast/standard_resolution_map.dart'; | 19 import 'package:analyzer/dart/ast/standard_resolution_map.dart'; |
| 19 import 'package:analyzer/dart/element/element.dart'; | 20 import 'package:analyzer/dart/element/element.dart'; |
| 20 import 'package:analyzer/error/error.dart'; | 21 import 'package:analyzer/error/error.dart'; |
| 21 import 'package:analyzer/src/generated/engine.dart'; | 22 import 'package:analyzer/src/generated/engine.dart'; |
| 22 import 'package:analyzer/src/generated/source.dart'; | 23 import 'package:analyzer/src/generated/source.dart'; |
| 23 | 24 |
| 24 /** | 25 /** |
| 25 * Run the given function [f] with the given [context] made active. | 26 * Run the given function [f] with the given [context] made active. |
| 26 * Return the result of [f] invocation. | 27 * Return the result of [f] invocation. |
| 27 */ | 28 */ |
| 28 runWithActiveContext(AnalysisContext context, f()) { | 29 runWithActiveContext(AnalysisContext context, f()) { |
| 29 if (context is InternalAnalysisContext && !context.isActive) { | 30 if (context is InternalAnalysisContext && !context.isActive) { |
| 30 context.isActive = true; | 31 context.isActive = true; |
| 31 try { | 32 try { |
| 32 return f(); | 33 return f(); |
| 33 } finally { | 34 } finally { |
| 34 context.isActive = false; | 35 context.isActive = false; |
| 35 } | 36 } |
| 36 } else { | 37 } else { |
| 37 return f(); | 38 return f(); |
| 38 } | 39 } |
| 39 } | 40 } |
| 40 | 41 |
| 41 scheduleImplementedNotification( | 42 Future<Null> scheduleImplementedNotification( |
| 42 AnalysisServer server, Iterable<String> files) async { | 43 AnalysisServer server, Iterable<String> files) async { |
| 43 SearchEngine searchEngine = server.searchEngine; | 44 SearchEngine searchEngine = server.searchEngine; |
| 44 if (searchEngine == null) { | 45 if (searchEngine == null) { |
| 45 return; | 46 return; |
| 46 } | 47 } |
| 47 for (String file in files) { | 48 for (String file in files) { |
| 48 CompilationUnitElement unitElement = server.getCompilationUnitElement(file); | 49 CompilationUnit unit = await server.getResolvedCompilationUnit(file); |
| 50 // This needs to be merged with another CL |
| 51 CompilationUnitElement unitElement = null; //unit?.element; |
| 49 if (unitElement != null) { | 52 if (unitElement != null) { |
| 50 try { | 53 try { |
| 51 ImplementedComputer computer = | 54 ImplementedComputer computer = |
| 52 new ImplementedComputer(searchEngine, unitElement); | 55 new ImplementedComputer(searchEngine, unitElement); |
| 53 await computer.compute(); | 56 await computer.compute(); |
| 54 var params = new protocol.AnalysisImplementedParams( | 57 var params = new protocol.AnalysisImplementedParams( |
| 55 file, computer.classes, computer.members); | 58 file, computer.classes, computer.members); |
| 56 server.sendNotification(params.toNotification()); | 59 server.sendNotification(params.toNotification()); |
| 57 } catch (exception, stackTrace) { | 60 } catch (exception, stackTrace) { |
| 58 server.sendServerErrorNotification( | 61 server.sendServerErrorNotification( |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 } | 129 } |
| 127 // errors | 130 // errors |
| 128 if (server.shouldSendErrorsNotificationFor(file)) { | 131 if (server.shouldSendErrorsNotificationFor(file)) { |
| 129 server.scheduleOperation( | 132 server.scheduleOperation( |
| 130 new _NotificationErrorsOperation(context, file, lineInfo, errors)); | 133 new _NotificationErrorsOperation(context, file, lineInfo, errors)); |
| 131 } | 134 } |
| 132 } | 135 } |
| 133 | 136 |
| 134 void sendAnalysisNotificationAnalyzedFiles(AnalysisServer server) { | 137 void sendAnalysisNotificationAnalyzedFiles(AnalysisServer server) { |
| 135 _sendNotification(server, () { | 138 _sendNotification(server, () { |
| 136 Set<String> analyzedFiles; | 139 Set<String> analyzedFiles = server.driverMap.values |
| 137 if (server.options.enableNewAnalysisDriver) { | 140 .map((driver) => driver.knownFiles) |
| 138 analyzedFiles = server.driverMap.values | 141 .expand((files) => files) |
| 139 .map((driver) => driver.knownFiles) | 142 .toSet(); |
| 140 .expand((files) => files) | |
| 141 .toSet(); | |
| 142 } else { | |
| 143 LibraryDependencyCollector collector = | |
| 144 new LibraryDependencyCollector(server.analysisContexts.toList()); | |
| 145 analyzedFiles = collector.collectLibraryDependencies(); | |
| 146 } | |
| 147 Set<String> prevAnalyzedFiles = server.prevAnalyzedFiles; | 143 Set<String> prevAnalyzedFiles = server.prevAnalyzedFiles; |
| 148 if (prevAnalyzedFiles != null && | 144 if (prevAnalyzedFiles != null && |
| 149 prevAnalyzedFiles.length == analyzedFiles.length && | 145 prevAnalyzedFiles.length == analyzedFiles.length && |
| 150 prevAnalyzedFiles.difference(analyzedFiles).isEmpty) { | 146 prevAnalyzedFiles.difference(analyzedFiles).isEmpty) { |
| 151 // No change to the set of analyzed files. No need to send another | 147 // No change to the set of analyzed files. No need to send another |
| 152 // notification. | 148 // notification. |
| 153 return; | 149 return; |
| 154 } | 150 } |
| 155 server.prevAnalyzedFiles = analyzedFiles; | 151 server.prevAnalyzedFiles = analyzedFiles; |
| 156 protocol.AnalysisAnalyzedFilesParams params = | 152 protocol.AnalysisAnalyzedFilesParams params = |
| (...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 541 abstract class _SingleFileOperation extends SourceSensitiveOperation { | 537 abstract class _SingleFileOperation extends SourceSensitiveOperation { |
| 542 final String file; | 538 final String file; |
| 543 | 539 |
| 544 _SingleFileOperation(AnalysisContext context, this.file) : super(context); | 540 _SingleFileOperation(AnalysisContext context, this.file) : super(context); |
| 545 | 541 |
| 546 @override | 542 @override |
| 547 bool shouldBeDiscardedOnSourceChange(Source source) { | 543 bool shouldBeDiscardedOnSourceChange(Source source) { |
| 548 return source.fullName == file; | 544 return source.fullName == file; |
| 549 } | 545 } |
| 550 } | 546 } |
| OLD | NEW |