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

Side by Side Diff: pkg/analysis_server/lib/src/edit/edit_domain.dart

Issue 1080653003: Create a public API for contributing fixes and make fixes pluggable (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Missed clean-up Created 5 years, 8 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 edit.domain; 5 library edit.domain;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 8
9 import 'package:analysis_server/edit/fix/fix_core.dart';
9 import 'package:analysis_server/src/analysis_server.dart'; 10 import 'package:analysis_server/src/analysis_server.dart';
10 import 'package:analysis_server/src/collections.dart'; 11 import 'package:analysis_server/src/collections.dart';
11 import 'package:analysis_server/src/constants.dart'; 12 import 'package:analysis_server/src/constants.dart';
13 import 'package:analysis_server/src/plugin/server_plugin.dart';
12 import 'package:analysis_server/src/protocol_server.dart' hide Element; 14 import 'package:analysis_server/src/protocol_server.dart' hide Element;
13 import 'package:analysis_server/src/services/correction/assist.dart'; 15 import 'package:analysis_server/src/services/correction/assist.dart';
14 import 'package:analysis_server/src/services/correction/fix.dart'; 16 import 'package:analysis_server/src/services/correction/fix.dart';
15 import 'package:analysis_server/src/services/correction/sort_members.dart'; 17 import 'package:analysis_server/src/services/correction/sort_members.dart';
16 import 'package:analysis_server/src/services/correction/status.dart'; 18 import 'package:analysis_server/src/services/correction/status.dart';
17 import 'package:analysis_server/src/services/refactoring/refactoring.dart'; 19 import 'package:analysis_server/src/services/refactoring/refactoring.dart';
18 import 'package:analysis_server/src/services/search/search_engine.dart'; 20 import 'package:analysis_server/src/services/search/search_engine.dart';
19 import 'package:analyzer/src/generated/ast.dart'; 21 import 'package:analyzer/src/generated/ast.dart';
20 import 'package:analyzer/src/generated/element.dart'; 22 import 'package:analyzer/src/generated/element.dart';
21 import 'package:analyzer/src/generated/engine.dart' as engine; 23 import 'package:analyzer/src/generated/engine.dart' as engine;
(...skipping 11 matching lines...) Expand all
33 * Instances of the class [EditDomainHandler] implement a [RequestHandler] 35 * Instances of the class [EditDomainHandler] implement a [RequestHandler]
34 * that handles requests in the edit domain. 36 * that handles requests in the edit domain.
35 */ 37 */
36 class EditDomainHandler implements RequestHandler { 38 class EditDomainHandler implements RequestHandler {
37 /** 39 /**
38 * The analysis server that is using this handler to process requests. 40 * The analysis server that is using this handler to process requests.
39 */ 41 */
40 final AnalysisServer server; 42 final AnalysisServer server;
41 43
42 /** 44 /**
45 * The server plugin that defines the extension points used by this handler.
46 */
47 final ServerPlugin plugin;
48
49 /**
43 * The [SearchEngine] for this server. 50 * The [SearchEngine] for this server.
44 */ 51 */
45 SearchEngine searchEngine; 52 SearchEngine searchEngine;
46 53
47 _RefactoringManager refactoringManager; 54 _RefactoringManager refactoringManager;
48 55
49 /** 56 /**
50 * Initialize a newly created handler to handle requests for the given [server ]. 57 * Initialize a newly created handler to handle requests for the given [server ].
51 */ 58 */
52 EditDomainHandler(this.server) { 59 EditDomainHandler(this.server, this.plugin) {
53 searchEngine = server.searchEngine; 60 searchEngine = server.searchEngine;
54 _newRefactoringManager(); 61 _newRefactoringManager();
55 } 62 }
56 63
57 Response format(Request request) { 64 Response format(Request request) {
58 EditFormatParams params = new EditFormatParams.fromRequest(request); 65 EditFormatParams params = new EditFormatParams.fromRequest(request);
59 String file = params.file; 66 String file = params.file;
60 67
61 ContextSourcePair contextSource = server.getContextSourcePair(file); 68 ContextSourcePair contextSource = server.getContextSourcePair(file);
62 69
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 List<AnalysisErrorFixes> errorFixesList = <AnalysisErrorFixes>[]; 137 List<AnalysisErrorFixes> errorFixesList = <AnalysisErrorFixes>[];
131 List<CompilationUnit> units = server.getResolvedCompilationUnits(file); 138 List<CompilationUnit> units = server.getResolvedCompilationUnits(file);
132 for (CompilationUnit unit in units) { 139 for (CompilationUnit unit in units) {
133 engine.AnalysisErrorInfo errorInfo = server.getErrors(file); 140 engine.AnalysisErrorInfo errorInfo = server.getErrors(file);
134 if (errorInfo != null) { 141 if (errorInfo != null) {
135 LineInfo lineInfo = errorInfo.lineInfo; 142 LineInfo lineInfo = errorInfo.lineInfo;
136 int requestLine = lineInfo.getLocation(offset).lineNumber; 143 int requestLine = lineInfo.getLocation(offset).lineNumber;
137 for (engine.AnalysisError error in errorInfo.errors) { 144 for (engine.AnalysisError error in errorInfo.errors) {
138 int errorLine = lineInfo.getLocation(error.offset).lineNumber; 145 int errorLine = lineInfo.getLocation(error.offset).lineNumber;
139 if (errorLine == requestLine) { 146 if (errorLine == requestLine) {
140 List<Fix> fixes = computeFixes(unit, error); 147 List<Fix> fixes = computeFixes(plugin, unit.element.context, error);
141 if (fixes.isNotEmpty) { 148 if (fixes.isNotEmpty) {
142 AnalysisError serverError = 149 AnalysisError serverError =
143 newAnalysisError_fromEngine(lineInfo, error); 150 newAnalysisError_fromEngine(lineInfo, error);
144 AnalysisErrorFixes errorFixes = 151 AnalysisErrorFixes errorFixes =
145 new AnalysisErrorFixes(serverError); 152 new AnalysisErrorFixes(serverError);
146 errorFixesList.add(errorFixes); 153 errorFixesList.add(errorFixes);
147 fixes.forEach((fix) { 154 fixes.forEach((fix) {
148 errorFixes.fixes.add(fix.change); 155 errorFixes.fixes.add(fix.change);
149 }); 156 });
150 } 157 }
(...skipping 474 matching lines...) Expand 10 before | Expand all | Expand 10 after
625 } 632 }
626 if (refactoring is RenameRefactoring) { 633 if (refactoring is RenameRefactoring) {
627 RenameRefactoring renameRefactoring = refactoring; 634 RenameRefactoring renameRefactoring = refactoring;
628 RenameOptions renameOptions = params.options; 635 RenameOptions renameOptions = params.options;
629 renameRefactoring.newName = renameOptions.newName; 636 renameRefactoring.newName = renameOptions.newName;
630 return renameRefactoring.checkNewName(); 637 return renameRefactoring.checkNewName();
631 } 638 }
632 return new RefactoringStatus(); 639 return new RefactoringStatus();
633 } 640 }
634 } 641 }
OLDNEW
« no previous file with comments | « pkg/analysis_server/lib/plugin/fix.dart ('k') | pkg/analysis_server/lib/src/plugin/server_plugin.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698