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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 | 69 |
70 /** | 70 /** |
71 * Initialize a newly created handler to handle requests for the given [server
]. | 71 * Initialize a newly created handler to handle requests for the given [server
]. |
72 */ | 72 */ |
73 EditDomainHandler(AnalysisServer server) : super(server) { | 73 EditDomainHandler(AnalysisServer server) : super(server) { |
74 searchEngine = server.searchEngine; | 74 searchEngine = server.searchEngine; |
75 _newRefactoringManager(); | 75 _newRefactoringManager(); |
76 } | 76 } |
77 | 77 |
78 Response format(Request request) { | 78 Response format(Request request) { |
| 79 server.options.analytics?.sendEvent('edit', 'format'); |
| 80 |
79 EditFormatParams params = new EditFormatParams.fromRequest(request); | 81 EditFormatParams params = new EditFormatParams.fromRequest(request); |
80 String file = params.file; | 82 String file = params.file; |
81 | 83 |
82 String unformattedSource; | 84 String unformattedSource; |
83 try { | 85 try { |
84 Source source = server.resourceProvider.getFile(file).createSource(); | 86 Source source = server.resourceProvider.getFile(file).createSource(); |
85 unformattedSource = | 87 unformattedSource = |
86 server.fileContentOverlay[file] ?? source.contents.data; | 88 server.fileContentOverlay[file] ?? source.contents.data; |
87 } catch (e) { | 89 } catch (e) { |
88 return new Response.formatInvalidFile(request); | 90 return new Response.formatInvalidFile(request); |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
262 .addAll(result.fixes.map(converter.convertAnalysisErrorFixes)); | 264 .addAll(result.fixes.map(converter.convertAnalysisErrorFixes)); |
263 } | 265 } |
264 // | 266 // |
265 // Send the response. | 267 // Send the response. |
266 // | 268 // |
267 server.sendResponse( | 269 server.sendResponse( |
268 new EditGetFixesResult(errorFixesList).toResponse(request.id)); | 270 new EditGetFixesResult(errorFixesList).toResponse(request.id)); |
269 } | 271 } |
270 | 272 |
271 Future getPostfixCompletion(Request request) async { | 273 Future getPostfixCompletion(Request request) async { |
| 274 server.options.analytics?.sendEvent('edit', 'getPostfixCompletion'); |
| 275 |
272 var params = new EditGetPostfixCompletionParams.fromRequest(request); | 276 var params = new EditGetPostfixCompletionParams.fromRequest(request); |
273 SourceChange change; | 277 SourceChange change; |
274 | 278 |
275 AnalysisResult result = await server.getAnalysisResult(params.file); | 279 AnalysisResult result = await server.getAnalysisResult(params.file); |
276 if (result != null) { | 280 if (result != null) { |
277 CompilationUnit unit = result.unit; | 281 CompilationUnit unit = result.unit; |
278 CompilationUnitElement unitElement = | 282 CompilationUnitElement unitElement = |
279 resolutionMap.elementDeclaredByCompilationUnit(unit); | 283 resolutionMap.elementDeclaredByCompilationUnit(unit); |
280 if (unitElement.context != null) { | 284 if (unitElement.context != null) { |
281 PostfixCompletionContext context = new PostfixCompletionContext( | 285 PostfixCompletionContext context = new PostfixCompletionContext( |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
411 .map((pfc) => | 415 .map((pfc) => |
412 new PostfixTemplateDescriptor(pfc.name, pfc.key, pfc.example)) | 416 new PostfixTemplateDescriptor(pfc.name, pfc.key, pfc.example)) |
413 .toList(); | 417 .toList(); |
414 | 418 |
415 Response response = new EditListPostfixCompletionTemplatesResult(templates) | 419 Response response = new EditListPostfixCompletionTemplatesResult(templates) |
416 .toResponse(request.id); | 420 .toResponse(request.id); |
417 server.sendResponse(response); | 421 server.sendResponse(response); |
418 } | 422 } |
419 | 423 |
420 Future<Null> organizeDirectives(Request request) async { | 424 Future<Null> organizeDirectives(Request request) async { |
| 425 server.options.analytics?.sendEvent('edit', 'organizeDirectives'); |
| 426 |
421 var params = new EditOrganizeDirectivesParams.fromRequest(request); | 427 var params = new EditOrganizeDirectivesParams.fromRequest(request); |
422 // prepare file | 428 // prepare file |
423 String file = params.file; | 429 String file = params.file; |
424 if (!engine.AnalysisEngine.isDartFileName(file)) { | 430 if (!engine.AnalysisEngine.isDartFileName(file)) { |
425 server.sendResponse(new Response.fileNotAnalyzed(request, file)); | 431 server.sendResponse(new Response.fileNotAnalyzed(request, file)); |
426 return; | 432 return; |
427 } | 433 } |
428 // Prepare the file information. | 434 // Prepare the file information. |
429 AnalysisResult result = await server.getAnalysisResult(file); | 435 AnalysisResult result = await server.getAnalysisResult(file); |
430 if (result == null) { | 436 if (result == null) { |
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
680 _reset(); | 686 _reset(); |
681 } | 687 } |
682 | 688 |
683 void getRefactoring(Request _request) { | 689 void getRefactoring(Request _request) { |
684 // prepare for processing the request | 690 // prepare for processing the request |
685 request = _request; | 691 request = _request; |
686 result = new EditGetRefactoringResult( | 692 result = new EditGetRefactoringResult( |
687 EMPTY_PROBLEM_LIST, EMPTY_PROBLEM_LIST, EMPTY_PROBLEM_LIST); | 693 EMPTY_PROBLEM_LIST, EMPTY_PROBLEM_LIST, EMPTY_PROBLEM_LIST); |
688 // process the request | 694 // process the request |
689 var params = new EditGetRefactoringParams.fromRequest(_request); | 695 var params = new EditGetRefactoringParams.fromRequest(_request); |
| 696 |
| 697 if (params.kind != null) { |
| 698 server.options.analytics |
| 699 ?.sendEvent('refactor', params.kind.name.toLowerCase()); |
| 700 } |
| 701 |
690 runZoned(() async { | 702 runZoned(() async { |
691 await _init(params.kind, params.file, params.offset, params.length); | 703 await _init(params.kind, params.file, params.offset, params.length); |
692 if (initStatus.hasFatalError) { | 704 if (initStatus.hasFatalError) { |
693 feedback = null; | 705 feedback = null; |
694 _sendResultResponse(); | 706 _sendResultResponse(); |
695 return; | 707 return; |
696 } | 708 } |
697 // set options | 709 // set options |
698 if (_requiresOptions) { | 710 if (_requiresOptions) { |
699 if (params.options == null) { | 711 if (params.options == null) { |
(...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1023 } | 1035 } |
1024 return new RefactoringStatus(); | 1036 return new RefactoringStatus(); |
1025 } | 1037 } |
1026 } | 1038 } |
1027 | 1039 |
1028 /** | 1040 /** |
1029 * [_RefactoringManager] throws instances of this class internally to stop | 1041 * [_RefactoringManager] throws instances of this class internally to stop |
1030 * processing in a manager that was reset. | 1042 * processing in a manager that was reset. |
1031 */ | 1043 */ |
1032 class _ResetError {} | 1044 class _ResetError {} |
OLD | NEW |