| 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:collection'; | 7 import 'dart:collection'; |
| 8 | 8 |
| 9 import 'package:analysis_server/src/analysis_server.dart'; | 9 import 'package:analysis_server/src/analysis_server.dart'; |
| 10 import 'package:analysis_server/src/constants.dart'; | 10 import 'package:analysis_server/src/constants.dart'; |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 | 31 |
| 32 /** | 32 /** |
| 33 * Implement the `analysis.getHover` request. | 33 * Implement the `analysis.getHover` request. |
| 34 */ | 34 */ |
| 35 Response getAnalysisHover(Request request) { | 35 Response getAnalysisHover(Request request) { |
| 36 // prepare parameters | 36 // prepare parameters |
| 37 String file = request.getRequiredParameter(FILE).asString(); | 37 String file = request.getRequiredParameter(FILE).asString(); |
| 38 int offset = request.getRequiredParameter(OFFSET).asInt(); | 38 int offset = request.getRequiredParameter(OFFSET).asInt(); |
| 39 // prepare hovers | 39 // prepare hovers |
| 40 List<Hover> hovers = <Hover>[]; | 40 List<Hover> hovers = <Hover>[]; |
| 41 { | 41 List<CompilationUnit> units = server.getResolvedCompilationUnits(file); |
| 42 Source source = server.getSource(file); | 42 for (CompilationUnit unit in units) { |
| 43 AnalysisContext context = server.getAnalysisContext(file); | 43 hovers.add(new DartUnitHoverComputer(unit, offset).compute()); |
| 44 if (context != null) { | |
| 45 List<Source> librarySources = context.getLibrariesContaining(source); | |
| 46 for (Source librarySource in librarySources) { | |
| 47 CompilationUnit unit = context.resolveCompilationUnit2(source, | |
| 48 librarySource); | |
| 49 hovers.add(new DartUnitHoverComputer(unit, offset).compute()); | |
| 50 } | |
| 51 } | |
| 52 } | 44 } |
| 53 // send response | 45 // send response |
| 54 Response response = new Response(request.id); | 46 Response response = new Response(request.id); |
| 55 response.setResult(HOVERS, hovers); | 47 response.setResult(HOVERS, hovers); |
| 56 return response; | 48 return response; |
| 57 } | 49 } |
| 58 | 50 |
| 59 @override | 51 @override |
| 60 Response handleRequest(Request request) { | 52 Response handleRequest(Request request) { |
| 61 try { | 53 try { |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 227 | 219 |
| 228 /** | 220 /** |
| 229 * A description of the change to the content of a file. | 221 * A description of the change to the content of a file. |
| 230 */ | 222 */ |
| 231 class ContentChange { | 223 class ContentChange { |
| 232 String content; | 224 String content; |
| 233 int offset; | 225 int offset; |
| 234 int oldLength; | 226 int oldLength; |
| 235 int newLength; | 227 int newLength; |
| 236 } | 228 } |
| OLD | NEW |