Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(420)

Unified Diff: pkg/analysis_server/lib/src/services/completion/dart/completion_manager.dart

Issue 1692273003: rework LocalLibraryContributor to resolve referenced units (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: merge Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: pkg/analysis_server/lib/src/services/completion/dart/completion_manager.dart
diff --git a/pkg/analysis_server/lib/src/services/completion/dart/completion_manager.dart b/pkg/analysis_server/lib/src/services/completion/dart/completion_manager.dart
index 5cfdacef0120bf9de9db13431207ad612a3c9b19..52ae065b3296e2f1c5735888ae2fcf967ad72827 100644
--- a/pkg/analysis_server/lib/src/services/completion/dart/completion_manager.dart
+++ b/pkg/analysis_server/lib/src/services/completion/dart/completion_manager.dart
@@ -139,6 +139,12 @@ class DartCompletionRequestImpl implements DartCompletionRequest {
*/
InterfaceType _objectType;
+ /**
+ * The resolved [CompilationUnitElement]s comprising the library
+ * or `null` if not computed.
+ */
+ List<CompilationUnitElement> _resolvedUnits;
+
OpType _opType;
final CompletionRequest _originalRequest;
@@ -267,6 +273,33 @@ class DartCompletionRequestImpl implements DartCompletionRequest {
_updateTargets(resolvedUnit);
}
+ @override
+ Future<List<CompilationUnitElement>> resolveUnits() async {
+ checkAborted();
+ if (_resolvedUnits != null) {
+ return _resolvedUnits;
+ }
+ LibraryElement libElem = libraryElement;
+ if (libElem == null) {
+ return null;
+ }
+ _resolvedUnits = <CompilationUnitElement>[];
+ for (CompilationUnitElement unresolvedUnit in libElem.units) {
+ CompilationUnit unit = await _computeAsync(
+ this,
+ new LibrarySpecificUnit(libElem.source, unresolvedUnit.source),
+ RESOLVED_UNIT3,
+ performance,
+ 'resolve library unit');
+ checkAborted();
+ CompilationUnitElement resolvedUnit = unit?.element;
+ if (resolvedUnit != null) {
+ _resolvedUnits.add(resolvedUnit);
+ }
+ }
+ return _resolvedUnits;
+ }
+
/**
* Update the completion [target] and [dotTarget] based on the given [unit].
*/
@@ -365,8 +398,12 @@ class DartCompletionRequestImpl implements DartCompletionRequest {
return dartRequest;
}
- static Future _computeAsync(CompletionRequest request, AnalysisTarget target,
- ResultDescriptor descriptor, CompletionPerformance performance, String perfTag) async {
+ static Future _computeAsync(
+ CompletionRequest request,
+ AnalysisTarget target,
+ ResultDescriptor descriptor,
+ CompletionPerformance performance,
+ String perfTag) async {
request.checkAborted();
performance.logStartTime(perfTag);
var result;

Powered by Google App Engine
This is Rietveld 408576698