| 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 edit.domain; | 5 library edit.domain; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 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 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 } | 90 } |
| 91 // respond | 91 // respond |
| 92 return new EditGetAvailableRefactoringsResult(kinds).toResponse(request.id); | 92 return new EditGetAvailableRefactoringsResult(kinds).toResponse(request.id); |
| 93 } | 93 } |
| 94 | 94 |
| 95 Response getFixes(Request request) { | 95 Response getFixes(Request request) { |
| 96 var params = new EditGetFixesParams.fromRequest(request); | 96 var params = new EditGetFixesParams.fromRequest(request); |
| 97 String file = params.file; | 97 String file = params.file; |
| 98 int offset = params.offset; | 98 int offset = params.offset; |
| 99 // add fixes | 99 // add fixes |
| 100 List<ErrorFixes> errorFixesList = <ErrorFixes>[]; | 100 List<AnalysisErrorFixes> errorFixesList = <AnalysisErrorFixes>[]; |
| 101 List<CompilationUnit> units = server.getResolvedCompilationUnits(file); | 101 List<CompilationUnit> units = server.getResolvedCompilationUnits(file); |
| 102 for (CompilationUnit unit in units) { | 102 for (CompilationUnit unit in units) { |
| 103 engine.AnalysisErrorInfo errorInfo = server.getErrors(file); | 103 engine.AnalysisErrorInfo errorInfo = server.getErrors(file); |
| 104 if (errorInfo != null) { | 104 if (errorInfo != null) { |
| 105 LineInfo lineInfo = errorInfo.lineInfo; | 105 LineInfo lineInfo = errorInfo.lineInfo; |
| 106 int requestLine = lineInfo.getLocation(offset).lineNumber; | 106 int requestLine = lineInfo.getLocation(offset).lineNumber; |
| 107 for (engine.AnalysisError error in errorInfo.errors) { | 107 for (engine.AnalysisError error in errorInfo.errors) { |
| 108 int errorLine = lineInfo.getLocation(error.offset).lineNumber; | 108 int errorLine = lineInfo.getLocation(error.offset).lineNumber; |
| 109 if (errorLine == requestLine) { | 109 if (errorLine == requestLine) { |
| 110 List<Fix> fixes = computeFixes(searchEngine, unit, error); | 110 List<Fix> fixes = computeFixes(searchEngine, unit, error); |
| 111 if (fixes.isNotEmpty) { | 111 if (fixes.isNotEmpty) { |
| 112 AnalysisError serverError = | 112 AnalysisError serverError = |
| 113 new AnalysisError.fromEngine(lineInfo, error); | 113 new AnalysisError.fromEngine(lineInfo, error); |
| 114 ErrorFixes errorFixes = new ErrorFixes(serverError); | 114 AnalysisErrorFixes errorFixes = new AnalysisErrorFixes(serverError
); |
| 115 errorFixesList.add(errorFixes); | 115 errorFixesList.add(errorFixes); |
| 116 fixes.forEach((fix) { | 116 fixes.forEach((fix) { |
| 117 errorFixes.addFix(fix); | 117 errorFixes.addFix(fix); |
| 118 }); | 118 }); |
| 119 } | 119 } |
| 120 } | 120 } |
| 121 } | 121 } |
| 122 } | 122 } |
| 123 } | 123 } |
| 124 // respond | 124 // respond |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 314 if (refactoring is RenameRefactoring) { | 314 if (refactoring is RenameRefactoring) { |
| 315 RenameRefactoring renameRefactoring = refactoring; | 315 RenameRefactoring renameRefactoring = refactoring; |
| 316 RenameOptions renameOptions = | 316 RenameOptions renameOptions = |
| 317 new RenameOptions.fromRefactoringParams(params, request); | 317 new RenameOptions.fromRefactoringParams(params, request); |
| 318 renameRefactoring.newName = renameOptions.newName; | 318 renameRefactoring.newName = renameOptions.newName; |
| 319 return renameRefactoring.checkNewName(); | 319 return renameRefactoring.checkNewName(); |
| 320 } | 320 } |
| 321 return new RefactoringStatus(); | 321 return new RefactoringStatus(); |
| 322 } | 322 } |
| 323 } | 323 } |
| OLD | NEW |