Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(180)

Side by Side Diff: pkg/analysis_server/lib/src/domain_analysis.dart

Issue 362893004: Implementation for 'analysis.getHover'. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fixes for review comments Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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:analyzer/src/generated/engine.dart';
10 import 'package:analysis_server/src/analysis_server.dart'; 9 import 'package:analysis_server/src/analysis_server.dart';
11 import 'package:analysis_server/src/constants.dart'; 10 import 'package:analysis_server/src/constants.dart';
12 import 'package:analysis_server/src/protocol.dart'; 11 import 'package:analysis_server/src/protocol.dart';
12 import 'package:analyzer/src/generated/engine.dart';
13 import 'package:analyzer/src/generated/source.dart';
14 import 'package:analyzer/src/generated/ast.dart';
15 import 'package:analysis_server/src/computer/computer_hover.dart';
13 16
14 /** 17 /**
15 * Instances of the class [AnalysisDomainHandler] implement a [RequestHandler] 18 * Instances of the class [AnalysisDomainHandler] implement a [RequestHandler]
16 * that handles requests in the `analysis` domain. 19 * that handles requests in the `analysis` domain.
17 */ 20 */
18 class AnalysisDomainHandler implements RequestHandler { 21 class AnalysisDomainHandler implements RequestHandler {
19 /** 22 /**
20 * The analysis server that is using this handler to process requests. 23 * The analysis server that is using this handler to process requests.
21 */ 24 */
22 final AnalysisServer server; 25 final AnalysisServer server;
23 26
24 /** 27 /**
25 * Initialize a newly created handler to handle requests for the given [server ]. 28 * Initialize a newly created handler to handle requests for the given [server ].
26 */ 29 */
27 AnalysisDomainHandler(this.server); 30 AnalysisDomainHandler(this.server);
28 31
32 /**
33 * Implement the `analysis.getHover` request.
34 */
35 Response getAnalysisHover(Request request) {
36 // prepare parameters
37 String file = request.getRequiredParameter(FILE).asString();
38 int offset = request.getRequiredParameter(OFFSET).asInt();
39 // prepare hovers
40 List<Map<String, Object>> hovers = <Map<String, Object>>[];
41 {
42 Source source = server.getSource(file);
43 AnalysisContext context = server.getAnalysisContext(file);
44 List<Source> librarySources = context.getLibrariesContaining(source);
45 for (Source librarySource in librarySources) {
46 CompilationUnit unit = context.resolveCompilationUnit2(source,
47 librarySource);
48 hovers.add(new DartUnitHoverComputer(unit, offset).compute());
49 }
50 }
51 // send response
52 Response response = new Response(request.id);
53 response.setResult(HOVERS, hovers);
54 return response;
55 }
56
29 @override 57 @override
30 Response handleRequest(Request request) { 58 Response handleRequest(Request request) {
31 try { 59 try {
32 String requestName = request.method; 60 String requestName = request.method;
33 if (requestName == ANALYSIS_SET_ANALYSIS_ROOTS) { 61 if (requestName == ANALYSIS_GET_HOVER) {
62 return getAnalysisHover(request);
63 } else if (requestName == ANALYSIS_SET_ANALYSIS_ROOTS) {
34 return setAnalysisRoots(request); 64 return setAnalysisRoots(request);
35 } else if (requestName == ANALYSIS_SET_PRIORITY_FILES) { 65 } else if (requestName == ANALYSIS_SET_PRIORITY_FILES) {
36 return setPriorityFiles(request); 66 return setPriorityFiles(request);
37 } else if (requestName == ANALYSIS_SET_SUBSCRIPTIONS) { 67 } else if (requestName == ANALYSIS_SET_SUBSCRIPTIONS) {
38 return setSubscriptions(request); 68 return setSubscriptions(request);
39 } else if (requestName == ANALYSIS_UPDATE_CONTENT) { 69 } else if (requestName == ANALYSIS_UPDATE_CONTENT) {
40 return updateContent(request); 70 return updateContent(request);
41 } else if (requestName == ANALYSIS_UPDATE_OPTIONS) { 71 } else if (requestName == ANALYSIS_UPDATE_OPTIONS) {
42 return updateOptions(request); 72 return updateOptions(request);
43 } else if (requestName == ANALYSIS_UPDATE_SDKS) { 73 } else if (requestName == ANALYSIS_UPDATE_SDKS) {
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 225
196 /** 226 /**
197 * A description of the change to the content of a file. 227 * A description of the change to the content of a file.
198 */ 228 */
199 class ContentChange { 229 class ContentChange {
200 String content; 230 String content;
201 int offset; 231 int offset;
202 int oldLength; 232 int oldLength;
203 int newLength; 233 int newLength;
204 } 234 }
OLDNEW
« no previous file with comments | « pkg/analysis_server/lib/src/constants.dart ('k') | pkg/analysis_server/test/analysis_abstract.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698