| 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 library domain.analysis; | 5 library domain.analysis; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'dart:core'; | 8 import 'dart:core'; |
| 9 | 9 |
| 10 import 'package:analysis_server/plugin/analysis/analysis_domain.dart'; | 10 import 'package:analysis_server/plugin/analysis/analysis_domain.dart'; |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 */ | 88 */ |
| 89 Future<Null> getHover(Request request) async { | 89 Future<Null> getHover(Request request) async { |
| 90 var params = new AnalysisGetHoverParams.fromRequest(request); | 90 var params = new AnalysisGetHoverParams.fromRequest(request); |
| 91 | 91 |
| 92 // Prepare the resolved units. | 92 // Prepare the resolved units. |
| 93 CompilationUnit unit; | 93 CompilationUnit unit; |
| 94 if (server.options.enableNewAnalysisDriver) { | 94 if (server.options.enableNewAnalysisDriver) { |
| 95 AnalysisResult result = await server.getAnalysisResult(params.file); | 95 AnalysisResult result = await server.getAnalysisResult(params.file); |
| 96 unit = result?.unit; | 96 unit = result?.unit; |
| 97 } else { | 97 } else { |
| 98 unit = server.getResolvedCompilationUnit(params.file); | 98 unit = await server.getResolvedCompilationUnit(params.file); |
| 99 } | 99 } |
| 100 | 100 |
| 101 // Prepare the hovers. | 101 // Prepare the hovers. |
| 102 List<HoverInformation> hovers = <HoverInformation>[]; | 102 List<HoverInformation> hovers = <HoverInformation>[]; |
| 103 if (unit != null) { | 103 if (unit != null) { |
| 104 HoverInformation hoverInformation = | 104 HoverInformation hoverInformation = |
| 105 new DartUnitHoverComputer(unit, params.offset).compute(); | 105 new DartUnitHoverComputer(unit, params.offset).compute(); |
| 106 if (hoverInformation != null) { | 106 if (hoverInformation != null) { |
| 107 hovers.add(hoverInformation); | 107 hovers.add(hoverInformation); |
| 108 } | 108 } |
| (...skipping 28 matching lines...) Expand all Loading... |
| 137 // TODO(scheglov) implement for the new analysis driver | 137 // TODO(scheglov) implement for the new analysis driver |
| 138 return new Response.getNavigationInvalidFile(request); | 138 return new Response.getNavigationInvalidFile(request); |
| 139 } | 139 } |
| 140 var params = new AnalysisGetNavigationParams.fromRequest(request); | 140 var params = new AnalysisGetNavigationParams.fromRequest(request); |
| 141 String file = params.file; | 141 String file = params.file; |
| 142 Future<AnalysisDoneReason> analysisFuture = | 142 Future<AnalysisDoneReason> analysisFuture = |
| 143 server.onFileAnalysisComplete(file); | 143 server.onFileAnalysisComplete(file); |
| 144 if (analysisFuture == null) { | 144 if (analysisFuture == null) { |
| 145 return new Response.getNavigationInvalidFile(request); | 145 return new Response.getNavigationInvalidFile(request); |
| 146 } | 146 } |
| 147 analysisFuture.then((AnalysisDoneReason reason) { | 147 analysisFuture.then((AnalysisDoneReason reason) async { |
| 148 switch (reason) { | 148 switch (reason) { |
| 149 case AnalysisDoneReason.COMPLETE: | 149 case AnalysisDoneReason.COMPLETE: |
| 150 CompilationUnit unit = server.getResolvedCompilationUnit(file); | 150 CompilationUnit unit = await server.getResolvedCompilationUnit(file); |
| 151 if (unit == null) { | 151 if (unit == null) { |
| 152 server.sendResponse(new Response.getNavigationInvalidFile(request)); | 152 server.sendResponse(new Response.getNavigationInvalidFile(request)); |
| 153 } else { | 153 } else { |
| 154 CompilationUnitElement unitElement = unit.element; | 154 CompilationUnitElement unitElement = unit.element; |
| 155 NavigationCollectorImpl collector = computeNavigation( | 155 NavigationCollectorImpl collector = computeNavigation( |
| 156 server, | 156 server, |
| 157 unitElement.context, | 157 unitElement.context, |
| 158 unitElement.source, | 158 unitElement.source, |
| 159 params.offset, | 159 params.offset, |
| 160 params.length); | 160 params.length); |
| (...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 413 context.onResultChanged(descriptor).listen((result) { | 413 context.onResultChanged(descriptor).listen((result) { |
| 414 StreamController<engine.ResultChangedEvent> controller = | 414 StreamController<engine.ResultChangedEvent> controller = |
| 415 controllers[result.descriptor]; | 415 controllers[result.descriptor]; |
| 416 if (controller != null) { | 416 if (controller != null) { |
| 417 controller.add(result); | 417 controller.add(result); |
| 418 } | 418 } |
| 419 }); | 419 }); |
| 420 } | 420 } |
| 421 } | 421 } |
| 422 } | 422 } |
| OLD | NEW |