Chromium Code Reviews| Index: pkg/analysis_server/lib/src/services/correction/fix_internal.dart |
| diff --git a/pkg/analysis_server/lib/src/services/correction/fix_internal.dart b/pkg/analysis_server/lib/src/services/correction/fix_internal.dart |
| index d2c1f86b2e3cd8e4a5f8313b503d5848483c7b5a..5a0901fb9966d9163be0b641c549adc0a03d2ae9 100644 |
| --- a/pkg/analysis_server/lib/src/services/correction/fix_internal.dart |
| +++ b/pkg/analysis_server/lib/src/services/correction/fix_internal.dart |
| @@ -4,6 +4,7 @@ |
| library analysis_server.src.services.correction.fix_internal; |
| +import 'dart:async'; |
| import 'dart:collection'; |
| import 'dart:core' hide Resource; |
| @@ -42,13 +43,37 @@ import 'package:path/path.dart'; |
| typedef bool ElementPredicate(Element argument); |
| /** |
| + * The implementation of [DartFixContext]. |
| + * |
| + * Clients may not extend, implement or mix-in this class. |
| + */ |
| +class DartFixContextImpl implements DartFixContext { |
|
Brian Wilkerson
2015/11/20 22:11:59
Why not extend FixContext?
scheglov
2015/11/20 22:56:08
Done.
|
| + final FixContext _context; |
| + |
| + /** |
| + * The [CompilationUnit] to compute fixes in. |
| + */ |
| + final CompilationUnit unit; |
| + |
| + DartFixContextImpl(this._context, this.unit); |
| + |
| + @override |
| + AnalysisContext get analysisContext => _context.analysisContext; |
| + |
| + @override |
| + AnalysisError get error => _context.error; |
| + |
| + @override |
| + ResourceProvider get resourceProvider => _context.resourceProvider; |
| +} |
| + |
| +/** |
| * A [FixContributor] that provides the default set of fixes. |
| */ |
| class DefaultFixContributor extends DartFixContributor { |
| @override |
| - List<Fix> internalComputeFixes(ResourceProvider resourceProvider, |
| - CompilationUnit unit, AnalysisError error) { |
| - FixProcessor processor = new FixProcessor(resourceProvider, unit, error); |
| + Future<List<Fix>> internalComputeFixes(DartFixContext context) { |
| + FixProcessor processor = new FixProcessor(context); |
| return processor.compute(); |
| } |
| } |
| @@ -59,9 +84,9 @@ class DefaultFixContributor extends DartFixContributor { |
| class FixProcessor { |
| static const int MAX_LEVENSHTEIN_DISTANCE = 3; |
| - final ResourceProvider resourceProvider; |
| - final CompilationUnit unit; |
| - final AnalysisError error; |
| + ResourceProvider resourceProvider; |
| + CompilationUnit unit; |
| + AnalysisError error; |
| AnalysisContext context; |
| String file; |
| int fileStamp; |
| @@ -87,17 +112,35 @@ class FixProcessor { |
| AstNode node; |
| AstNode coveredNode; |
| - FixProcessor(this.resourceProvider, this.unit, this.error) { |
| + FixProcessor(DartFixContext dartContext) { |
| + resourceProvider = dartContext.resourceProvider; |
| + context = dartContext.analysisContext; |
| + // unit |
| + unit = dartContext.unit; |
| unitElement = unit.element; |
| - context = unitElement.context; |
| unitSource = unitElement.source; |
| + // file |
| file = unitSource.fullName; |
| fileStamp = context.getModificationStamp(unitSource); |
| + // library |
| unitLibraryElement = unitElement.library; |
| unitLibraryFile = unitLibraryElement.source.fullName; |
| unitLibraryFolder = dirname(unitLibraryFile); |
| - } |
| - |
| + // error |
| + error = dartContext.error; |
| + } |
| + |
| +// FixProcessor(this.resourceProvider, this.unit, this.error) { |
|
Brian Wilkerson
2015/11/20 22:11:59
Did you intend to remove this?
scheglov
2015/11/20 22:56:08
No.
Removed.
|
| +// unitElement = unit.element; |
| +// context = unitElement.context; |
| +// unitSource = unitElement.source; |
| +// file = unitSource.fullName; |
| +// fileStamp = context.getModificationStamp(unitSource); |
| +// unitLibraryElement = unitElement.library; |
| +// unitLibraryFile = unitLibraryElement.source.fullName; |
| +// unitLibraryFolder = dirname(unitLibraryFile); |
| +// } |
| +// |
| DartType get coreTypeBool => _getCoreType('bool'); |
| /** |
| @@ -105,7 +148,7 @@ class FixProcessor { |
| */ |
| String get eol => utils.endOfLine; |
| - List<Fix> compute() { |
| + Future<List<Fix>> compute() async { |
| utils = new CorrectionUtils(unit); |
| errorOffset = error.offset; |
| errorLength = error.length; |