| OLD | NEW |
| 1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2017, 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/src/protocol_server.dart' hide Element; | 7 import 'package:analysis_server/src/protocol_server.dart' hide Element; |
| 8 import 'package:analysis_server/src/services/correction/util.dart'; | 8 import 'package:analysis_server/src/services/correction/util.dart'; |
| 9 import 'package:analyzer/dart/analysis/session.dart'; | 9 import 'package:analyzer/dart/analysis/session.dart'; |
| 10 import 'package:analyzer/dart/ast/ast.dart'; | 10 import 'package:analyzer/dart/ast/ast.dart'; |
| 11 import 'package:analyzer/dart/element/element.dart'; | 11 import 'package:analyzer/dart/element/element.dart'; |
| 12 import 'package:analyzer/dart/element/type.dart'; | 12 import 'package:analyzer/dart/element/type.dart'; |
| 13 import 'package:analyzer/error/error.dart' as engine; | 13 import 'package:analyzer/error/error.dart' as engine; |
| 14 import 'package:analyzer/src/dart/analysis/driver.dart'; | 14 import 'package:analyzer/src/dart/analysis/driver.dart'; |
| 15 import 'package:analyzer/src/dart/ast/utilities.dart'; | 15 import 'package:analyzer/src/dart/ast/utilities.dart'; |
| 16 import 'package:analyzer/src/generated/engine.dart'; | |
| 17 import 'package:analyzer/src/generated/java_core.dart'; | 16 import 'package:analyzer/src/generated/java_core.dart'; |
| 18 import 'package:analyzer/src/generated/resolver.dart'; | 17 import 'package:analyzer/src/generated/resolver.dart'; |
| 19 import 'package:analyzer/src/generated/source.dart'; | 18 import 'package:analyzer/src/generated/source.dart'; |
| 20 import 'package:analyzer_plugin/utilities/change_builder/change_builder_dart.dar
t'; | 19 import 'package:analyzer_plugin/utilities/change_builder/change_builder_dart.dar
t'; |
| 21 import 'package:analyzer_plugin/utilities/range_factory.dart'; | 20 import 'package:analyzer_plugin/utilities/range_factory.dart'; |
| 22 | 21 |
| 23 /** | 22 /** |
| 24 * An enumeration of possible postfix completion kinds. | 23 * An enumeration of possible postfix completion kinds. |
| 25 */ | 24 */ |
| 26 class DartPostfixCompletion { | 25 class DartPostfixCompletion { |
| (...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 272 } | 271 } |
| 273 | 272 |
| 274 /** | 273 /** |
| 275 * The computer for Dart postfix completions. | 274 * The computer for Dart postfix completions. |
| 276 */ | 275 */ |
| 277 class PostfixCompletionProcessor { | 276 class PostfixCompletionProcessor { |
| 278 static final NO_COMPLETION = new PostfixCompletion( | 277 static final NO_COMPLETION = new PostfixCompletion( |
| 279 DartPostfixCompletion.NO_TEMPLATE, new SourceChange("", edits: [])); | 278 DartPostfixCompletion.NO_TEMPLATE, new SourceChange("", edits: [])); |
| 280 | 279 |
| 281 final PostfixCompletionContext completionContext; | 280 final PostfixCompletionContext completionContext; |
| 282 final AnalysisContext analysisContext; | |
| 283 final CorrectionUtils utils; | 281 final CorrectionUtils utils; |
| 284 AstNode node; | 282 AstNode node; |
| 285 PostfixCompletion completion; | 283 PostfixCompletion completion; |
| 286 SourceChange change = new SourceChange('postfix-completion'); | 284 SourceChange change = new SourceChange('postfix-completion'); |
| 287 final Map<String, LinkedEditGroup> linkedPositionGroups = | 285 final Map<String, LinkedEditGroup> linkedPositionGroups = |
| 288 <String, LinkedEditGroup>{}; | 286 <String, LinkedEditGroup>{}; |
| 289 Position exitPosition = null; | 287 Position exitPosition = null; |
| 290 TypeProvider _typeProvider; | 288 TypeProvider _typeProvider; |
| 291 | 289 |
| 292 PostfixCompletionProcessor(this.completionContext) | 290 PostfixCompletionProcessor(this.completionContext) |
| 293 : analysisContext = completionContext.unitElement.context, | 291 : utils = new CorrectionUtils(completionContext.unit); |
| 294 utils = new CorrectionUtils(completionContext.unit); | |
| 295 | 292 |
| 296 AnalysisDriver get driver => completionContext.driver; | 293 AnalysisDriver get driver => completionContext.driver; |
| 297 | 294 |
| 298 String get eol => utils.endOfLine; | 295 String get eol => utils.endOfLine; |
| 299 | 296 |
| 300 String get file => completionContext.file; | 297 String get file => completionContext.file; |
| 301 | 298 |
| 302 String get key => completionContext.key; | 299 String get key => completionContext.key; |
| 303 | 300 |
| 304 LineInfo get lineInfo => completionContext.lineInfo; | 301 LineInfo get lineInfo => completionContext.lineInfo; |
| (...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 561 [List args]) { | 558 [List args]) { |
| 562 SourceChange change = builder.sourceChange; | 559 SourceChange change = builder.sourceChange; |
| 563 if (change.edits.isEmpty) { | 560 if (change.edits.isEmpty) { |
| 564 completion = null; | 561 completion = null; |
| 565 return; | 562 return; |
| 566 } | 563 } |
| 567 change.message = formatList(kind.message, args); | 564 change.message = formatList(kind.message, args); |
| 568 completion = new PostfixCompletion(kind, change); | 565 completion = new PostfixCompletion(kind, change); |
| 569 } | 566 } |
| 570 } | 567 } |
| OLD | NEW |