| 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 services.correction.assist; | 5 library services.correction.assist; |
| 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:analysis_server/src/plugin/server_plugin.dart'; | 8 import 'package:analysis_server/src/plugin/server_plugin.dart'; |
| 9 import 'package:analyzer/src/generated/engine.dart'; | 9 import 'package:analyzer/src/generated/engine.dart'; |
| 10 import 'package:analyzer/src/generated/java_engine.dart'; | 10 import 'package:analyzer/src/generated/java_engine.dart'; |
| 11 import 'package:analyzer/src/generated/source.dart'; | 11 import 'package:analyzer/src/generated/source.dart'; |
| 12 | 12 |
| 13 /** | 13 /** |
| 14 * Compute and return the assists available at the given selection (described by | 14 * Compute and return the assists available at the given selection (described by |
| 15 * the [offset] and [length]) in the given [source]. The source was analyzed in | 15 * the [offset] and [length]) in the given [source]. The source was analyzed in |
| 16 * the given [context]. The [plugin] is used to get the list of assist | 16 * the given [context]. The [plugin] is used to get the list of assist |
| 17 * contributors. | 17 * contributors. |
| 18 */ | 18 */ |
| 19 List<Assist> computeAssists(ServerPlugin plugin, AnalysisContext context, | 19 List<Assist> computeAssists(ServerPlugin plugin, AnalysisContext context, |
| 20 Source source, int offset, int length) { | 20 Source source, int offset, int length) { |
| 21 List<Assist> assists = <Assist>[]; | 21 List<Assist> assists = <Assist>[]; |
| 22 List<AssistContributor> contributors = plugin.assistContributors(); | 22 List<AssistContributor> contributors = plugin.assistContributors; |
| 23 for (AssistContributor contributor in contributors) { | 23 for (AssistContributor contributor in contributors) { |
| 24 try { | 24 try { |
| 25 List<Assist> contributedAssists = | 25 List<Assist> contributedAssists = |
| 26 contributor.computeAssists(context, source, offset, length); | 26 contributor.computeAssists(context, source, offset, length); |
| 27 if (contributedAssists != null) { | 27 if (contributedAssists != null) { |
| 28 assists.addAll(contributedAssists); | 28 assists.addAll(contributedAssists); |
| 29 } | 29 } |
| 30 } catch (exception, stackTrace) { | 30 } catch (exception, stackTrace) { |
| 31 AnalysisEngine.instance.logger.logError( | 31 AnalysisEngine.instance.logger.logError( |
| 32 'Exception from assist contributor: ${contributor.runtimeType}', | 32 'Exception from assist contributor: ${contributor.runtimeType}', |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 const AssistKind('SURROUND_WITH_FOR_IN', 30, "Surround with 'for-in'"); | 97 const AssistKind('SURROUND_WITH_FOR_IN', 30, "Surround with 'for-in'"); |
| 98 static const SURROUND_WITH_IF = | 98 static const SURROUND_WITH_IF = |
| 99 const AssistKind('SURROUND_WITH_IF', 30, "Surround with 'if'"); | 99 const AssistKind('SURROUND_WITH_IF', 30, "Surround with 'if'"); |
| 100 static const SURROUND_WITH_TRY_CATCH = const AssistKind( | 100 static const SURROUND_WITH_TRY_CATCH = const AssistKind( |
| 101 'SURROUND_WITH_TRY_CATCH', 30, "Surround with 'try-catch'"); | 101 'SURROUND_WITH_TRY_CATCH', 30, "Surround with 'try-catch'"); |
| 102 static const SURROUND_WITH_TRY_FINALLY = const AssistKind( | 102 static const SURROUND_WITH_TRY_FINALLY = const AssistKind( |
| 103 'SURROUND_WITH_TRY_FINALLY', 30, "Surround with 'try-finally'"); | 103 'SURROUND_WITH_TRY_FINALLY', 30, "Surround with 'try-finally'"); |
| 104 static const SURROUND_WITH_WHILE = | 104 static const SURROUND_WITH_WHILE = |
| 105 const AssistKind('SURROUND_WITH_WHILE', 30, "Surround with 'while'"); | 105 const AssistKind('SURROUND_WITH_WHILE', 30, "Surround with 'while'"); |
| 106 } | 106 } |
| OLD | NEW |