| 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:analyzer/dart/ast/ast.dart'; | 7 import 'package:analyzer/dart/ast/ast.dart'; |
| 8 import 'package:analyzer/dart/ast/standard_resolution_map.dart'; | 8 import 'package:analyzer/dart/ast/standard_resolution_map.dart'; |
| 9 import 'package:analyzer/dart/element/element.dart'; | 9 import 'package:analyzer/dart/element/element.dart'; |
| 10 import 'package:analyzer/error/error.dart'; | 10 import 'package:analyzer/error/error.dart'; |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 } | 86 } |
| 87 | 87 |
| 88 @override | 88 @override |
| 89 void invalidate(String path) => _resolvedAstGenerator.invalidate(path); | 89 void invalidate(String path) => _resolvedAstGenerator.invalidate(path); |
| 90 | 90 |
| 91 @override | 91 @override |
| 92 void invalidateAll() => _resolvedAstGenerator.invalidateAll(); | 92 void invalidateAll() => _resolvedAstGenerator.invalidateAll(); |
| 93 } | 93 } |
| 94 | 94 |
| 95 class _AnalysisContextProxy implements AnalysisContext { | 95 class _AnalysisContextProxy implements AnalysisContext { |
| 96 final Map<Uri, ResolvedLibrary> _resolvedLibraries; | 96 final Map<Uri, Map<Uri, CompilationUnit>> _resolvedLibraries; |
| 97 | 97 |
| 98 @override | 98 @override |
| 99 final _SourceFactoryProxy sourceFactory = new _SourceFactoryProxy(); | 99 final _SourceFactoryProxy sourceFactory = new _SourceFactoryProxy(); |
| 100 | 100 |
| 101 @override | 101 @override |
| 102 final AnalysisOptions analysisOptions; | 102 final AnalysisOptions analysisOptions; |
| 103 | 103 |
| 104 _AnalysisContextProxy(this._resolvedLibraries, this.analysisOptions); | 104 _AnalysisContextProxy(this._resolvedLibraries, this.analysisOptions); |
| 105 | 105 |
| 106 List<AnalysisError> computeErrors(Source source) { | 106 List<AnalysisError> computeErrors(Source source) { |
| 107 // TODO(paulberry): do we need to return errors sometimes? | 107 // TODO(paulberry): do we need to return errors sometimes? |
| 108 return []; | 108 return []; |
| 109 } | 109 } |
| 110 | 110 |
| 111 LibraryElement computeLibraryElement(Source source) { | 111 LibraryElement computeLibraryElement(Source source) { |
| 112 assert(_resolvedLibraries.containsKey(source.uri)); | 112 assert(_resolvedLibraries.containsKey(source.uri)); |
| 113 return resolutionMap | 113 return resolutionMap |
| 114 .elementDeclaredByCompilationUnit( | 114 .elementDeclaredByCompilationUnit( |
| 115 _resolvedLibraries[source.uri].definingCompilationUnit) | 115 _resolvedLibraries[source.uri][source.uri]) |
| 116 .library; | 116 .library; |
| 117 } | 117 } |
| 118 | 118 |
| 119 noSuchMethod(Invocation invocation) => unimplemented(); | 119 noSuchMethod(Invocation invocation) => unimplemented(); |
| 120 | 120 |
| 121 CompilationUnit resolveCompilationUnit( | 121 CompilationUnit resolveCompilationUnit( |
| 122 Source unitSource, LibraryElement library) { | 122 Source unitSource, LibraryElement library) { |
| 123 assert(_resolvedLibraries.containsKey(library.source.uri)); | 123 var unit = _resolvedLibraries[library.source.uri][unitSource.uri]; |
| 124 var resolvedLibrary = _resolvedLibraries[library.source.uri]; | 124 assert(unit != null); |
| 125 if (unitSource == library.source) { | 125 return unit; |
| 126 return resolvedLibrary.definingCompilationUnit; | |
| 127 } else { | |
| 128 assert(resolvedLibrary.partUnits.containsKey(unitSource.uri)); | |
| 129 return resolvedLibrary.partUnits[unitSource.uri]; | |
| 130 } | |
| 131 } | 126 } |
| 132 } | 127 } |
| 133 | 128 |
| 134 class _AnalysisOptionsProxy implements AnalysisOptions { | 129 class _AnalysisOptionsProxy implements AnalysisOptions { |
| 135 final bool strongMode; | 130 final bool strongMode; |
| 136 | 131 |
| 137 _AnalysisOptionsProxy(this.strongMode); | 132 _AnalysisOptionsProxy(this.strongMode); |
| 138 | 133 |
| 139 noSuchMethod(Invocation invocation) => unimplemented(); | 134 noSuchMethod(Invocation invocation) => unimplemented(); |
| 140 } | 135 } |
| 141 | 136 |
| 142 class _SourceFactoryProxy implements SourceFactory { | 137 class _SourceFactoryProxy implements SourceFactory { |
| 143 Source forUri2(Uri absoluteUri) => new _SourceProxy(absoluteUri); | 138 Source forUri2(Uri absoluteUri) => new _SourceProxy(absoluteUri); |
| 144 | 139 |
| 145 noSuchMethod(Invocation invocation) => unimplemented(); | 140 noSuchMethod(Invocation invocation) => unimplemented(); |
| 146 } | 141 } |
| 147 | 142 |
| 148 class _SourceProxy extends BasicSource { | 143 class _SourceProxy extends BasicSource { |
| 149 _SourceProxy(Uri uri) : super(uri); | 144 _SourceProxy(Uri uri) : super(uri); |
| 150 | 145 |
| 151 noSuchMethod(Invocation invocation) => unimplemented(); | 146 noSuchMethod(Invocation invocation) => unimplemented(); |
| 152 } | 147 } |
| OLD | NEW |