| 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'; | 5 import 'dart:async'; |
| 6 | 6 |
| 7 import 'package:analysis_server/plugin/edit/assist/assist_core.dart'; | 7 import 'package:analysis_server/plugin/edit/assist/assist_core.dart'; |
| 8 import 'package:analysis_server/plugin/edit/assist/assist_dart.dart'; | 8 import 'package:analysis_server/plugin/edit/assist/assist_dart.dart'; |
| 9 import 'package:analysis_server/plugin/edit/fix/fix_core.dart'; | 9 import 'package:analysis_server/plugin/edit/fix/fix_core.dart'; |
| 10 import 'package:analysis_server/plugin/edit/fix/fix_dart.dart'; | 10 import 'package:analysis_server/plugin/edit/fix/fix_dart.dart'; |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 145 EditGetAssistsParams params = new EditGetAssistsParams.fromRequest(request); | 145 EditGetAssistsParams params = new EditGetAssistsParams.fromRequest(request); |
| 146 String file = params.file; | 146 String file = params.file; |
| 147 int offset = params.offset; | 147 int offset = params.offset; |
| 148 int length = params.length; | 148 int length = params.length; |
| 149 | 149 |
| 150 List<SourceChange> changes = <SourceChange>[]; | 150 List<SourceChange> changes = <SourceChange>[]; |
| 151 if (server.options.enableNewAnalysisDriver) { | 151 if (server.options.enableNewAnalysisDriver) { |
| 152 // | 152 // |
| 153 // Allow plugins to start computing assists. | 153 // Allow plugins to start computing assists. |
| 154 // | 154 // |
| 155 AnalysisDriver driver = server.getAnalysisDriver(file); | 155 Map<PluginInfo, Future<plugin.Response>> pluginFutures; |
| 156 plugin.EditGetAssistsParams requestParams = | 156 plugin.EditGetAssistsParams requestParams = |
| 157 new plugin.EditGetAssistsParams(file, offset, length); | 157 new plugin.EditGetAssistsParams(file, offset, length); |
| 158 Map<PluginInfo, Future<plugin.Response>> pluginFutures = server | 158 AnalysisDriver driver = server.getAnalysisDriver(file); |
| 159 .pluginManager | 159 if (driver == null) { |
| 160 .broadcastRequest(requestParams, contextRoot: driver.contextRoot); | 160 pluginFutures = <PluginInfo, Future<plugin.Response>>{}; |
| 161 } else { |
| 162 pluginFutures = server.pluginManager |
| 163 .broadcastRequest(requestParams, contextRoot: driver.contextRoot); |
| 164 } |
| 161 // | 165 // |
| 162 // Compute fixes associated with server-generated errors. | 166 // Compute fixes associated with server-generated errors. |
| 163 // | 167 // |
| 164 AnalysisResult result = await server.getAnalysisResult(file); | 168 AnalysisResult result = await server.getAnalysisResult(file); |
| 165 if (result != null) { | 169 if (result != null) { |
| 166 CompilationUnit unit = result.unit; | 170 CompilationUnit unit = result.unit; |
| 167 CompilationUnitElement compilationUnitElement = | 171 CompilationUnitElement compilationUnitElement = |
| 168 resolutionMap.elementDeclaredByCompilationUnit(unit); | 172 resolutionMap.elementDeclaredByCompilationUnit(unit); |
| 169 DartAssistContext dartAssistContext = new _DartAssistContextForValues( | 173 DartAssistContext dartAssistContext = new _DartAssistContextForValues( |
| 170 compilationUnitElement.source, | 174 compilationUnitElement.source, |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 219 Future getFixes(Request request) async { | 223 Future getFixes(Request request) async { |
| 220 var params = new EditGetFixesParams.fromRequest(request); | 224 var params = new EditGetFixesParams.fromRequest(request); |
| 221 String file = params.file; | 225 String file = params.file; |
| 222 int offset = params.offset; | 226 int offset = params.offset; |
| 223 | 227 |
| 224 List<AnalysisErrorFixes> errorFixesList = <AnalysisErrorFixes>[]; | 228 List<AnalysisErrorFixes> errorFixesList = <AnalysisErrorFixes>[]; |
| 225 if (server.options.enableNewAnalysisDriver) { | 229 if (server.options.enableNewAnalysisDriver) { |
| 226 // | 230 // |
| 227 // Allow plugins to start computing fixes. | 231 // Allow plugins to start computing fixes. |
| 228 // | 232 // |
| 229 AnalysisDriver driver = server.getAnalysisDriver(file); | 233 Map<PluginInfo, Future<plugin.Response>> pluginFutures; |
| 230 plugin.EditGetFixesParams requestParams = | 234 plugin.EditGetFixesParams requestParams = |
| 231 new plugin.EditGetFixesParams(file, offset); | 235 new plugin.EditGetFixesParams(file, offset); |
| 232 Map<PluginInfo, Future<plugin.Response>> pluginFutures = server | 236 AnalysisDriver driver = server.getAnalysisDriver(file); |
| 233 .pluginManager | 237 if (driver == null) { |
| 234 .broadcastRequest(requestParams, contextRoot: driver.contextRoot); | 238 pluginFutures = <PluginInfo, Future<plugin.Response>>{}; |
| 239 } else { |
| 240 pluginFutures = server.pluginManager |
| 241 .broadcastRequest(requestParams, contextRoot: driver.contextRoot); |
| 242 } |
| 235 // | 243 // |
| 236 // Compute fixes associated with server-generated errors. | 244 // Compute fixes associated with server-generated errors. |
| 237 // | 245 // |
| 238 AnalysisResult result = await server.getAnalysisResult(file); | 246 AnalysisResult result = await server.getAnalysisResult(file); |
| 239 if (result != null) { | 247 if (result != null) { |
| 240 CompilationUnit unit = result.unit; | 248 CompilationUnit unit = result.unit; |
| 241 LineInfo lineInfo = result.lineInfo; | 249 LineInfo lineInfo = result.lineInfo; |
| 242 int requestLine = lineInfo.getLocation(offset).lineNumber; | 250 int requestLine = lineInfo.getLocation(offset).lineNumber; |
| 243 for (engine.AnalysisError error in result.errors) { | 251 for (engine.AnalysisError error in result.errors) { |
| 244 int errorLine = lineInfo.getLocation(error.offset).lineNumber; | 252 int errorLine = lineInfo.getLocation(error.offset).lineNumber; |
| (...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 440 server.sendResponse(new Response.sortMembersInvalidFile(request)); | 448 server.sendResponse(new Response.sortMembersInvalidFile(request)); |
| 441 return; | 449 return; |
| 442 } | 450 } |
| 443 // Prepare the file information. | 451 // Prepare the file information. |
| 444 int fileStamp; | 452 int fileStamp; |
| 445 String code; | 453 String code; |
| 446 CompilationUnit unit; | 454 CompilationUnit unit; |
| 447 List<engine.AnalysisError> errors; | 455 List<engine.AnalysisError> errors; |
| 448 if (server.options.enableNewAnalysisDriver) { | 456 if (server.options.enableNewAnalysisDriver) { |
| 449 AnalysisDriver driver = server.getAnalysisDriver(file); | 457 AnalysisDriver driver = server.getAnalysisDriver(file); |
| 450 ParseResult result = await driver.parseFile(file); | 458 ParseResult result = await driver?.parseFile(file); |
| 451 if (result == null) { | 459 if (result == null) { |
| 452 server.sendResponse(new Response.fileNotAnalyzed(request, file)); | 460 server.sendResponse(new Response.fileNotAnalyzed(request, file)); |
| 453 return; | 461 return; |
| 454 } | 462 } |
| 455 fileStamp = -1; | 463 fileStamp = -1; |
| 456 code = result.content; | 464 code = result.content; |
| 457 unit = result.unit; | 465 unit = result.unit; |
| 458 errors = result.errors; | 466 errors = result.errors; |
| 459 } else { | 467 } else { |
| 460 // prepare location | 468 // prepare location |
| (...skipping 609 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1070 } | 1078 } |
| 1071 return new RefactoringStatus(); | 1079 return new RefactoringStatus(); |
| 1072 } | 1080 } |
| 1073 } | 1081 } |
| 1074 | 1082 |
| 1075 /** | 1083 /** |
| 1076 * [_RefactoringManager] throws instances of this class internally to stop | 1084 * [_RefactoringManager] throws instances of this class internally to stop |
| 1077 * processing in a manager that was reset. | 1085 * processing in a manager that was reset. |
| 1078 */ | 1086 */ |
| 1079 class _ResetError {} | 1087 class _ResetError {} |
| OLD | NEW |