| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 analysis_server.edit.assist.assist_dart; | 5 library analysis_server.edit.assist.assist_dart; |
| 6 | 6 |
| 7 import 'package:analysis_server/edit/assist/assist_core.dart'; | 7 import 'package:analysis_server/edit/assist/assist_core.dart'; |
| 8 import 'package:analyzer/src/generated/ast.dart'; | 8 import 'package:analyzer/src/generated/ast.dart'; |
| 9 import 'package:analyzer/src/generated/engine.dart'; | 9 import 'package:analyzer/src/generated/engine.dart'; |
| 10 import 'package:analyzer/src/generated/source.dart'; | 10 import 'package:analyzer/src/generated/source.dart'; |
| 11 | 11 |
| 12 /** | 12 /** |
| 13 * An [AssistContributor] that can be used to contribute assists for Dart | 13 * An [AssistContributor] that can be used to contribute assists for Dart |
| 14 * files. | 14 * files. |
| 15 */ | 15 */ |
| 16 abstract class DartAssistContributor extends AssistContributor { | 16 abstract class DartAssistContributor extends AssistContributor { |
| 17 @override | 17 @override |
| 18 List<Assist> compute( | 18 List<Assist> computeAssists( |
| 19 AnalysisContext context, Source source, int offset, int length) { | 19 AnalysisContext context, Source source, int offset, int length) { |
| 20 if (!AnalysisEngine.isDartFileName(source.fullName)) { | 20 if (!AnalysisEngine.isDartFileName(source.fullName)) { |
| 21 return Assist.EMPTY_LIST; | 21 return Assist.EMPTY_LIST; |
| 22 } | 22 } |
| 23 List<Source> libraries = context.getLibrariesContaining(source); | 23 List<Source> libraries = context.getLibrariesContaining(source); |
| 24 if (libraries.isEmpty) { | 24 if (libraries.isEmpty) { |
| 25 return Assist.EMPTY_LIST; | 25 return Assist.EMPTY_LIST; |
| 26 } | 26 } |
| 27 CompilationUnit unit = | 27 CompilationUnit unit = |
| 28 context.resolveCompilationUnit2(source, libraries[0]); | 28 context.resolveCompilationUnit2(source, libraries[0]); |
| 29 if (unit == null) { | 29 if (unit == null) { |
| 30 return Assist.EMPTY_LIST; | 30 return Assist.EMPTY_LIST; |
| 31 } | 31 } |
| 32 return internalComputeAssists(unit, offset, length); | 32 return internalComputeAssists(unit, offset, length); |
| 33 } | 33 } |
| 34 | 34 |
| 35 /** | 35 /** |
| 36 * Return a list of assists for a location in the given [source]. The location | 36 * Return a list of assists for a location in the given [source]. The location |
| 37 * is specified by the [offset] and [length] of the selected region. The | 37 * is specified by the [offset] and [length] of the selected region. The |
| 38 * [context] can be used to get additional information that is useful for | 38 * [context] can be used to get additional information that is useful for |
| 39 * computing assists. | 39 * computing assists. |
| 40 */ | 40 */ |
| 41 List<Assist> internalComputeAssists( | 41 List<Assist> internalComputeAssists( |
| 42 CompilationUnit unit, int offset, int length); | 42 CompilationUnit unit, int offset, int length); |
| 43 } | 43 } |
| OLD | NEW |